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
@@ -36,83 +36,12 @@
#include <ghoul/font/fontrenderer.h>
#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."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemParallelConnection::Documentation() {
using namespace documentation;
return {
"DashboardItem Parallel Connection",
"base_dashboarditem_parallelconnection",
{
{
"Type",
new StringEqualVerifier("DashboardItemParallelConnection"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
}
}
};
}
DashboardItemParallelConnection::DashboardItemParallelConnection(
const ghoul::Dictionary& dictionary)
: DashboardItem(dictionary)
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemParallelConnection"
);
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);
_font = global::fontManager->font(_fontName, _fontSize);
}
: DashboardTextItem(dictionary)
{}
void DashboardItemParallelConnection::render(glm::vec2& penPosition) {
ZoneScoped