Add visibility setting to the property classes (closing #166)

This commit is contained in:
Alexander Bock
2016-11-23 23:24:07 +01:00
parent 357a447435
commit 7ffcf81235
17 changed files with 200 additions and 84 deletions
@@ -33,12 +33,15 @@ namespace properties {
template <typename T>
class NumericalProperty : public TemplateProperty<T> {
public:
NumericalProperty(std::string identifier, std::string guiName);
NumericalProperty(std::string identifier, std::string guiName, T value);
NumericalProperty(std::string identifier, std::string guiName,
Visibility visibility = Visibility::User);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue);
Visibility visibility = Visibility::User);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue, T steppingValue);
T minimumValue, T maximumValue, Visibility visibility = Visibility::User);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue, T steppingValue,
Visibility visibility = Visibility::User);
bool getLuaValue(lua_State* state) const override;
bool setLuaValue(lua_State* state) override;
@@ -233,42 +233,50 @@ const std::string NumericalProperty<T>::SteppingValueKey = "SteppingValue";
// a single constructor
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName)
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName,
Visibility visibility)
: NumericalProperty<T>(
std::move(identifier), std::move(guiName),
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier,
std::string guiName, T value)
: NumericalProperty<T>(
std::move(identifier), std::move(guiName), std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName,
T value, T minimumValue, T maximumValue)
: NumericalProperty<T>(
std::move(identifier) , std::move(guiName), std::move(value),
std::move(minimumValue), std::move(maximumValue),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>(),
visibility
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier,
std::string guiName, T value,
T minimumValue, T maximumValue, T steppingValue)
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value))
Visibility visibility)
: NumericalProperty<T>(
std::move(identifier), std::move(guiName), std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>(),
visibility
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName,
T value, T minimumValue, T maximumValue,
Visibility visibility)
: NumericalProperty<T>(
std::move(identifier) , std::move(guiName), std::move(value),
std::move(minimumValue), std::move(maximumValue),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>(),
visibility
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier,
std::string guiName, T value,
T minimumValue, T maximumValue, T steppingValue,
Visibility visibility)
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value),
visibility)
, _minimumValue(std::move(minimumValue))
, _maximumValue(std::move(maximumValue))
, _stepping(std::move(steppingValue))
@@ -61,7 +61,8 @@ public:
* \param identifier A unique identifier for this property
* \param guiName The GUI name that should be used to represent this property
*/
OptionProperty(std::string identifier, std::string guiName);
OptionProperty(std::string identifier, std::string guiName,
Visibility visibility = Visibility::User);
/**
* The constructor delegating the <code>identifier</code> and the <code>guiName</code>
@@ -70,7 +71,8 @@ public:
* \param guiName The GUI name that should be used to represent this property
* \param displayType Optional DisplayType for GUI (default RADIO)
*/
OptionProperty(std::string identifier, std::string guiName, DisplayType displayType);
OptionProperty(std::string identifier, std::string guiName, DisplayType displayType,
Visibility visibility = Visibility::User);
/**
* Returns the name of the class for reflection purposes.
+21 -11
View File
@@ -62,6 +62,17 @@ class PropertyOwner;
*/
class Property {
public:
/**
* The visibility classes for Property%s. The classes are strictly ordered as
* All > Developer > User > None
*/
enum class Visibility {
All = 3, ///< Visible for all types, no matter what
Developer = 2, ///< Visible in Developer mode
User = 1, ///< Visible in User mode
None = 0 ///< Never visible
};
/**
* The constructor for the property. The <code>identifier</code> needs to be unique
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
@@ -74,7 +85,8 @@ public:
* \pre \p identifier must not be empty
* \pre \p guiName must not be empty
*/
Property(std::string identifier, std::string guiName);
Property(std::string identifier, std::string guiName,
Visibility visibility = Visibility::All);
/**
* The destructor taking care of deallocating all unused memory. This method will not
@@ -255,20 +267,18 @@ public:
std::string groupIdentifier() const;
/**
* Determines a hint if this Property should be visible, or hidden. Each application
* accessing the properties is free to ignore this hint. It is stored in the metaData
* Dictionary with the key: <code>isVisible</code>. The default value is
* <code>true</code>.
* \param state <code>true</code> if the Property should be visible,
* <code>false</code> otherwise.
* Sets a hint about the visibility of the Property. Each application accessing the
* properties is free to ignore this hint. It is stored in the metaData Dictionary
* with the key: <code>Visibility</code>.
* \param visibility The new visibility of the Property
*/
void setVisible(bool state);
void setVisibility(Visibility visibility);
/**
* Returns whether this Property is visible or not.
* \return Whether this Property is visible or hidden
* Returns this Property%'s visibility setting
* \return This Property%'s visibility setting
*/
bool isVisible() const;
Visibility visibility() const;
/**
* This method determines if this Property should be read-only in external
@@ -39,7 +39,8 @@ public:
std::string description;
};
SelectionProperty(std::string identifier, std::string guiName);
SelectionProperty(std::string identifier, std::string guiName,
Visibility visibility = Visibility::User);
void addOption(Option option);
void removeOptions();
@@ -63,14 +63,16 @@ public:
* \param identifier The identifier that is used for this TemplateProperty
* \param guiName The human-readable GUI name for this TemplateProperty
*/
TemplateProperty(std::string identifier, std::string guiName);
TemplateProperty(std::string identifier, std::string guiName,
Visibility visibility = Visibility::User);
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code>, human-readable <code>guiName</code> and provided
* <code>value</code>.
*/
TemplateProperty(std::string identifier, std::string guiName, T value);
TemplateProperty(std::string identifier, std::string guiName, T value,
Visibility visibility = Visibility::User);
/**
* Returns the class name for this TemplateProperty. The default implementation makes
@@ -149,17 +149,20 @@ namespace properties {
// a single constructor
template <typename T>
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName)
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName,
Visibility visibility)
: TemplateProperty<T>(
std::move(identifier), std::move(guiName),
PropertyDelegate<TemplateProperty<T>>::template defaultValue<T>())
PropertyDelegate<TemplateProperty<T>>::template defaultValue<T>(),
visibility)
{
}
template <typename T>
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName,
T value)
: Property(std::move(identifier), std::move(guiName))
T value, Visibility visibility)
: Property(std::move(identifier), std::move(guiName), visibility)
, _value(std::move(value)) {
}
@@ -42,7 +42,8 @@ public:
* \param identifier The unique identifier used for this Property
* \param guiName The human-readable name of this Property
*/
TriggerProperty(std::string identifier, std::string guiName);
TriggerProperty(std::string identifier, std::string guiName,
Visibility visibility = Visibility::User);
/**
* Returns the class name <code>TriggerProperty</code>.