Restructure DashboardItems

- Add a new class DashboardTextItem that is a DashboardItem that can render text with font
This commit is contained in:
Alexander Bock
2020-12-09 00:44:25 +01:00
parent 9c0aecba80
commit eb69d2219a
23 changed files with 107 additions and 640 deletions

View File

@@ -35,22 +35,6 @@
#include <ghoul/misc/profiling.h>
namespace {
constexpr const char* KeyFontMono = "Mono";
constexpr const float DefaultFontSize = 10.f;
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
constexpr openspace::properties::Property::PropertyInfo PropertyUriInfo = {
"URI",
"Property URI",
@@ -79,18 +63,6 @@ documentation::Documentation DashboardItemPropertyValue::Documentation() {
new StringEqualVerifier("DashboardItemPropertyValue"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
},
{
PropertyUriInfo.identifier,
new StringVerifier,
@@ -109,9 +81,7 @@ documentation::Documentation DashboardItemPropertyValue::Documentation() {
DashboardItemPropertyValue::DashboardItemPropertyValue(
const ghoul::Dictionary& dictionary)
: DashboardItem(dictionary)
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
: DashboardTextItem(dictionary)
, _propertyUri(PropertyUriInfo)
, _displayString(DisplayStringInfo)
{
@@ -121,22 +91,6 @@ DashboardItemPropertyValue::DashboardItemPropertyValue(
"DashboardItemPropertyValue"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = global::fontManager->font(_fontName, _fontSize);
});
addProperty(_fontName);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
}
_fontSize.onChange([this](){
_font = global::fontManager->font(_fontName, _fontSize);
});
addProperty(_fontSize);
if (dictionary.hasKey(PropertyUriInfo.identifier)) {
_propertyUri = dictionary.value<std::string>(PropertyUriInfo.identifier);
}
@@ -147,8 +101,6 @@ DashboardItemPropertyValue::DashboardItemPropertyValue(
_displayString = dictionary.value<std::string>(DisplayStringInfo.identifier);
}
addProperty(_displayString);
_font = global::fontManager->font(_fontName, _fontSize);
}
void DashboardItemPropertyValue::render(glm::vec2& penPosition) {