mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-01 08:19:51 -05:00
Started work to produce descriptive output for Properties in preparation for GUI generation
This commit is contained in:
@@ -200,6 +200,20 @@ public:
|
||||
*/
|
||||
std::string guiName() const;
|
||||
|
||||
/**
|
||||
* Returns the description for this Property that contains all necessary information
|
||||
* required for creating a GUI representation. The format of the description is a
|
||||
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
|
||||
* <code>}</code> with key,value pairs between. Each value can either be a number, a
|
||||
* string, a bool, or another table. The general values that every Property must set
|
||||
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
|
||||
* values are specific to the type. If a Property does not override this method, an
|
||||
* empty string is returned.
|
||||
* \return The descriptive text for the Property that can be used for constructing a
|
||||
* GUI representation
|
||||
*/
|
||||
virtual std::string description() const;
|
||||
|
||||
/**
|
||||
* Sets the identifier of the group that this Property belongs to. Property groups can
|
||||
* be used, for example, by GUI application to visually group different properties,
|
||||
@@ -274,6 +288,20 @@ public:
|
||||
const ghoul::Dictionary& metaData() const;
|
||||
|
||||
protected:
|
||||
static const std::string IdentifierKey;
|
||||
static const std::string NameKey;
|
||||
static const std::string TypeKey;
|
||||
static const std::string MetaDataKey;
|
||||
|
||||
/**
|
||||
* Creates the information for the <code>MetaData</code> key-part of the Lua
|
||||
* description for the Property. The result can be included as one key-value pair in
|
||||
* the description text generated by subclasses. Only the metadata curated by the
|
||||
* Property class is used in this method.
|
||||
* \return The metadata information text for the property
|
||||
*/
|
||||
std::string generateMetaDataDescription() const;
|
||||
|
||||
/**
|
||||
* This method must be called by all subclasses whenever the encapsulated value has
|
||||
* changed and a potential listener has to be informed.
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace properties {
|
||||
namespace {
|
||||
const std::string _loggerCat = "Property";
|
||||
const std::string _metaDataKeyGuiName = "guiName";
|
||||
const std::string _metaDataKeyGroup = "group";
|
||||
const std::string _metaDataKeyGroup = "Group";
|
||||
const std::string _metaDataKeyVisible = "isVisible";
|
||||
const std::string _metaDataKeyReadOnly = "isReadOnly";
|
||||
|
||||
@@ -45,7 +45,11 @@ const std::string Property::ViewOptions::Color = "color";
|
||||
const std::string Property::ViewOptions::LightPosition = "lightPosition";
|
||||
const std::string Property::ViewOptions::PowerScaledCoordinate = "powerScaledCoordinate";
|
||||
const std::string Property::ViewOptions::PowerScaledScalar = "powerScaledScalar";
|
||||
|
||||
|
||||
const std::string Property::IdentifierKey = "Identifier";
|
||||
const std::string Property::NameKey = "Name";
|
||||
const std::string Property::TypeKey = "Type";
|
||||
const std::string Property::MetaDataKey = "MetaData";
|
||||
|
||||
Property::Property(std::string identifier, std::string guiName)
|
||||
: _identifier(std::move(identifier))
|
||||
@@ -105,6 +109,10 @@ std::string Property::guiName() const {
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
std::string Property::description() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
void Property::setGroupIdentifier(std::string groupId) {
|
||||
_metaData.setValue(_metaDataKeyGroup, std::move(groupId));
|
||||
}
|
||||
@@ -133,7 +141,6 @@ const ghoul::Dictionary& Property::metaData() const {
|
||||
|
||||
void Property::onChange(std::function<void()> callback) {
|
||||
_onChangeCallback = std::move(callback);
|
||||
|
||||
}
|
||||
|
||||
PropertyOwner* Property::owner() const
|
||||
@@ -151,5 +158,18 @@ void Property::notifyListener() {
|
||||
_onChangeCallback();
|
||||
}
|
||||
|
||||
std::string Property::generateMetaDataDescription() const {
|
||||
bool isVisible, isReadOnly;
|
||||
_metaData.getValue(_metaDataKeyVisible, isVisible);
|
||||
_metaData.getValue(_metaDataKeyReadOnly, isReadOnly);
|
||||
|
||||
return
|
||||
MetaDataKey + " = {" +
|
||||
_metaDataKeyGroup + " = '" + groupIdentifier() + "',\n" +
|
||||
_metaDataKeyVisible + " = '" + (isVisible ? "true" : "false") + "',\n" +
|
||||
_metaDataKeyReadOnly +" = ;" + (isReadOnly ? "true" : "false") + "'\n" +
|
||||
"},";
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user