Add visibility toggle to Property base class

Restructure GuiPropertyComponent to take a source function that returns a list of PropertyOwner%s instead of registering individual properties
Apply restructuring
This commit is contained in:
Alexander Bock
2016-06-28 14:50:53 +02:00
parent 90d9f09909
commit 9fb7814145
26 changed files with 311 additions and 658 deletions

View File

@@ -28,6 +28,8 @@
#include <modules/onscreengui/include/guicomponent.h>
#include <modules/onscreengui/include/guipropertycomponent.h>
#include <map>
namespace openspace {
namespace gui {
@@ -40,7 +42,7 @@ struct RadioOption {
class GuiIswaComponent : public GuiPropertyComponent {
public:
GuiIswaComponent();
virtual void render() override;
void render() override;
private:
bool _gmdata;

View File

@@ -27,70 +27,32 @@
#include <modules/onscreengui/include/guicomponent.h>
#include <ghoul/misc/dictionary.h>
#include <string>
#include <functional>
#include <vector>
#include <set>
namespace openspace {
namespace properties {
class Property;
class PropertyOwner;
}
namespace gui {
class GuiPropertyComponent : public GuiComponent {
public:
void registerProperty(properties::Property* prop, properties::Property* sibling = nullptr);
void unregisterProperty(properties::Property* prop);
void unregisterProperties(std::string owner);
using SourceFunction = std::function<std::vector<properties::PropertyOwner*>()>;
// This is the function that evaluates to the list of Propertyowners that this
// component should render
void setSource(SourceFunction func);
void render();
protected:
enum class PropertyType {
BoolProperty = 0,
IntProperty,
FloatProperty,
Vec2Property,
Vec3Property,
StringProperty,
OptionProperty,
SelectionProperty,
TriggerProperty,
InvalidPropertyType
};
void renderProperty(properties::Property* prop, properties::PropertyOwner* owner);
struct PropertyInfo {
PropertyType type;
std::string identifier;
std::string name;
std::string group;
};
typedef std::string PropertyOwner;
struct Property {
PropertyOwner owner;
std::vector<PropertyInfo> properties;
};
PropertyType toPropertyType(const std::string& name) const;
void renderProperty(const PropertyInfo& info) const;
std::set<properties::Property*> _boolProperties;
std::set<properties::Property*> _intProperties;
std::set<properties::Property*> _floatProperties;
std::set<properties::Property*> _vec2Properties;
std::set<properties::Property*> _vec3Properties;
std::set<properties::Property*> _vec4Properties;
std::set<properties::Property*> _stringProperties;
std::set<properties::Property*> _optionProperties;
std::set<properties::Property*> _selectionProperties;
std::set<properties::Property*> _triggerProperties;
std::map<std::string, std::vector<properties::Property*>> _propertiesByOwner;
//std::vector<Property> _properties;
SourceFunction _function;
};
} // namespace gui

View File

@@ -25,22 +25,26 @@
#ifndef __RENDERPROPERTIES_H__
#define __RENDERPROPERTIES_H__
#include <openspace/engine/openspaceengine.h>
#include <openspace/properties/property.h>
#include <string>
namespace openspace {
using namespace openspace::properties;
namespace properties {
class Property;
}
void executeScript(const std::string& id, const std::string& value);
void renderBoolProperty(Property* prop, const std::string& ownerName);
void renderOptionProperty(Property* prop, const std::string& ownerName);
void renderSelectionProperty(Property* prop, const std::string& ownerName);
void renderStringProperty(Property* prop, const std::string& ownerName);
void renderIntProperty(Property* prop, const std::string& ownerName);
void renderFloatProperty(Property* prop, const std::string& ownerName);
void renderVec2Property(Property* prop, const std::string& ownerName);
void renderVec3Property(Property* prop, const std::string& ownerName);
void renderVec4Property(Property* prop, const std::string& ownerName);
void renderTriggerProperty(Property* prop, const std::string& ownerName);
void renderBoolProperty(properties::Property* prop, const std::string& ownerName);
void renderOptionProperty(properties::Property* prop, const std::string& ownerName);
void renderSelectionProperty(properties::Property* prop, const std::string& ownerName);
void renderStringProperty(properties::Property* prop, const std::string& ownerName);
void renderIntProperty(properties::Property* prop, const std::string& ownerName);
void renderFloatProperty(properties::Property* prop, const std::string& ownerName);
void renderVec2Property(properties::Property* prop, const std::string& ownerName);
void renderVec3Property(properties::Property* prop, const std::string& ownerName);
void renderVec4Property(properties::Property* prop, const std::string& ownerName);
void renderTriggerProperty(properties::Property* prop, const std::string& ownerName);
#endif __RENDERPROPERTIES_H__
} // namespace
#endif __RENDERPROPERTIES_H__