mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 17:30:04 -05:00
Make DashboardItemGlobeLocation derive from DashboardTextItem instead
This commit is contained in:
@@ -42,19 +42,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
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 DisplayFormatInfo = {
|
||||
"DisplayFormat",
|
||||
"Display Format",
|
||||
@@ -68,12 +55,6 @@ namespace {
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(DashboardItemGlobeLocation)]] Parameters {
|
||||
// [[codegen::verbatim(FontNameInfo.description)]]
|
||||
std::optional<std::string> fontName;
|
||||
|
||||
// [[codegen::verbatim(FontSizeInfo.description)]]
|
||||
std::optional<float> fontSize;
|
||||
|
||||
enum class DisplayFormat {
|
||||
DecimalDegrees,
|
||||
DegreeMinuteSeconds
|
||||
@@ -91,32 +72,20 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation DashboardItemGlobeLocation::Documentation() {
|
||||
return codegen::doc<Parameters>("globebrowsing_dashboarditem_globelocation");
|
||||
return codegen::doc<Parameters>(
|
||||
"globebrowsing_dashboarditem_globelocation",
|
||||
DashboardTextItem::Documentation()
|
||||
);
|
||||
}
|
||||
|
||||
DashboardItemGlobeLocation::DashboardItemGlobeLocation(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, "Mono")
|
||||
, _fontSize(FontSizeInfo, 10.f, 10.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _displayFormat(DisplayFormatInfo)
|
||||
, _significantDigits(SignificantDigitsInfo, 4, 1, 12)
|
||||
, _font(global::fontManager->font("Mono", 10))
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_fontName = p.fontName.value_or(_fontName);
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
_fontSize = p.fontSize.value_or(_fontSize);
|
||||
_fontSize.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
auto updateFormatString = [this]() {
|
||||
switch (_displayFormat.value()) {
|
||||
case static_cast<int>(DisplayFormat::DecimalDegrees):
|
||||
|
||||
@@ -25,20 +25,18 @@
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___DASHBOARDITEMGLOBELOCATION___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___DASHBOARDITEMGLOBELOCATION___H__
|
||||
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
#include <openspace/rendering/dashboardtextitem.h>
|
||||
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/scalar/intproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemGlobeLocation : public DashboardItem {
|
||||
class DashboardItemGlobeLocation : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemGlobeLocation(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemGlobeLocation() override = default;
|
||||
@@ -55,13 +53,9 @@ private:
|
||||
DegreeMinuteSeconds
|
||||
};
|
||||
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
properties::OptionProperty _displayFormat;
|
||||
properties::IntProperty _significantDigits;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
std::string _formatString;
|
||||
std::vector<char> _buffer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user