mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Add the ability to limit-rate the dashboard updating (#3527)
Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/intproperty.h>
|
||||
#include <openspace/properties/vector/ivec2property.h>
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
#include <ghoul/glm.h>
|
||||
@@ -43,6 +44,14 @@ public:
|
||||
Dashboard();
|
||||
virtual ~Dashboard() override = default;
|
||||
|
||||
/**
|
||||
* Renders all of the items of this Dashboard at the provided \p penPosition. The
|
||||
* position is provided in pixels with the top-left corner being located at (0,0). The
|
||||
* rendering of the DashboardItems will update the \p penPosition according to where
|
||||
* the next item should be placed.
|
||||
*
|
||||
* \param penPosition The location at which we want to render the dashboard items
|
||||
*/
|
||||
void render(glm::vec2& penPosition);
|
||||
|
||||
void addDashboardItem(std::unique_ptr<DashboardItem> item);
|
||||
@@ -63,8 +72,10 @@ public:
|
||||
private:
|
||||
properties::BoolProperty _isEnabled;
|
||||
properties::IVec2Property _startPositionOffset;
|
||||
properties::IntProperty _refreshRate;
|
||||
|
||||
std::vector<std::unique_ptr<DashboardItem>> _items;
|
||||
std::chrono::steady_clock::time_point _lastRefresh;
|
||||
};
|
||||
|
||||
} // openspace
|
||||
|
||||
@@ -45,6 +45,18 @@ public:
|
||||
explicit DashboardItem(const ghoul::Dictionary& dictionary);
|
||||
|
||||
bool isEnabled() const;
|
||||
virtual void update() = 0;
|
||||
|
||||
/**
|
||||
* Renders this DashboardItem at the provided \p penPosition. The position indicates
|
||||
* where this DashboardItem should render itself and is provided in pixel-coordinates
|
||||
* with the top-left corner of the screen being at (0,0). Each derived subclass shall
|
||||
* update the \p penPosition according to the items that it should render. If, for
|
||||
* example, a single line of text is rendered, the \p penPosition shall be updated by
|
||||
* one line's worth of vertical separation.
|
||||
*
|
||||
* \p penPosition The position at which this DashboardItem should be rendered
|
||||
*/
|
||||
virtual void render(glm::vec2& penPosition) = 0;
|
||||
|
||||
virtual glm::vec2 size() const = 0;
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
explicit DashboardTextItem(const ghoul::Dictionary& dictionary, float fontSize = 10.f,
|
||||
const std::string& fontName = "Mono");
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
protected:
|
||||
@@ -49,6 +51,7 @@ protected:
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
std::string _buffer;
|
||||
};
|
||||
|
||||
} // openspace
|
||||
|
||||
Reference in New Issue
Block a user