Introduce property to toggle dashboard globally (closes #545)

This commit is contained in:
Alexander Bock
2018-03-08 03:04:57 -05:00
parent cc292dd330
commit c5c95a5640
2 changed files with 20 additions and 3 deletions
+3 -2
View File
@@ -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;
};
+17 -1
View File
@@ -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);