mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 02:48:25 -05:00
Introduce property to toggle dashboard globally (closes #545)
This commit is contained in:
@@ -27,10 +27,9 @@
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -59,6 +58,8 @@ public:
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
properties::BoolProperty _isEnabled;
|
||||
|
||||
std::vector<std::unique_ptr<DashboardItem>> _items;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,11 +30,23 @@
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include "dashboard_lua.inl"
|
||||
|
||||
namespace {
|
||||
static const openspace::properties::Property::PropertyInfo EnabledInfo = {
|
||||
"IsEnabled",
|
||||
"Enabled",
|
||||
"If this value is 'false', this dashboard will be invisible, regardless of the "
|
||||
"state of the individual components"
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Dashboard::Dashboard()
|
||||
: properties::PropertyOwner({ "Dashboard" })
|
||||
{}
|
||||
, _isEnabled(EnabledInfo, true)
|
||||
{
|
||||
addProperty(_isEnabled);
|
||||
}
|
||||
|
||||
void Dashboard::addDashboardItem(std::unique_ptr<DashboardItem> item) {
|
||||
std::string originalName = item->name();
|
||||
@@ -85,6 +97,10 @@ void Dashboard::removeDashboardItems() {
|
||||
}
|
||||
|
||||
void Dashboard::render(glm::vec2& penPosition) {
|
||||
if (!_isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const std::unique_ptr<DashboardItem>& item : _items) {
|
||||
if (item->isEnabled()) {
|
||||
item->render(penPosition);
|
||||
|
||||
Reference in New Issue
Block a user