mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-20 20:09:08 -06:00
Add stepping value into Property description
This commit is contained in:
Submodule ext/ghoul updated: dd5ad1d055...fd9674595b
@@ -35,8 +35,10 @@ 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, T value,
|
||||
T minimumValue, T maximumValue);
|
||||
NumericalProperty(std::string identifier, std::string guiName, T value,
|
||||
T minimumValue, T maximumValue);
|
||||
T minimumValue, T maximumValue, T steppingValue);
|
||||
|
||||
bool getLua(lua_State* state) const override;
|
||||
bool setLua(lua_State* state) override;
|
||||
@@ -52,11 +54,13 @@ public:
|
||||
protected:
|
||||
static const std::string MinimumValueKey;
|
||||
static const std::string MaximumValueKey;
|
||||
static const std::string SteppingValueKey;
|
||||
|
||||
std::string generateAdditionalDescription() const;
|
||||
|
||||
T _minimumValue;
|
||||
T _maximumValue;
|
||||
T _stepping;
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -42,6 +42,9 @@ namespace properties {
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
|
||||
@@ -71,43 +74,43 @@ namespace properties {
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return #CLASS_NAME; \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_VALUE; \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_MIN_VALUE; \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_MAX_VALUE; \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_STEPPING; \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State * state, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue<TYPE>( \
|
||||
@@ -115,8 +118,7 @@ namespace properties {
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(state, \
|
||||
success); \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
@@ -147,7 +149,10 @@ template <typename T>
|
||||
const std::string NumericalProperty<T>::MinimumValueKey = "MinimumValue";
|
||||
|
||||
template <typename T>
|
||||
const std::string NumericalProperty<T>::MaximumValueKey = "MaximumValueKey";
|
||||
const std::string NumericalProperty<T>::MaximumValueKey = "MaximumValue";
|
||||
|
||||
template <typename T>
|
||||
const std::string NumericalProperty<T>::SteppingValueKey = "SteppingValue";
|
||||
|
||||
// Delegating constructors are necessary; automatic template deduction cannot
|
||||
// deduce template argument for 'U' if 'default' methods are used as default values in
|
||||
@@ -155,30 +160,46 @@ const std::string NumericalProperty<T>::MaximumValueKey = "MaximumValueKey";
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName)
|
||||
: 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>())
|
||||
: 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>())
|
||||
: 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>()
|
||||
)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(std::string identifier,
|
||||
std::string guiName, T value,
|
||||
T minimumValue, T maximumValue)
|
||||
T minimumValue, T maximumValue, T steppingValue)
|
||||
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value))
|
||||
, _minimumValue(std::move(minimumValue))
|
||||
, _maximumValue(std::move(maximumValue))
|
||||
, _stepping(std::move(steppingValue))
|
||||
{}
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::string NumericalProperty<T>::className() const {
|
||||
return PropertyDelegate<NumericalProperty<T>>::className();
|
||||
@@ -219,8 +240,9 @@ T NumericalProperty<T>::maxValue() const {
|
||||
template <typename T>
|
||||
std::string NumericalProperty<T>::generateAdditionalDescription() const {
|
||||
std::string result;
|
||||
result += MinimumValueKey + " = " + std::to_string(_minimumValue) + ",";
|
||||
result += MaximumValueKey + " = " + std::to_string(_maximumValue);
|
||||
result += MinimumValueKey + " = " + std::to_string(_minimumValue) + ",";
|
||||
result += MaximumValueKey + " = " + std::to_string(_maximumValue) + ",";
|
||||
result += SteppingValueKey + " = " + std::to_string(_stepping);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,19 @@ public:
|
||||
template <typename U>
|
||||
static U defaultMaximumValue();
|
||||
|
||||
/**
|
||||
* The method returns the default stepping value for the class <code>T</code> used in
|
||||
* GUI elements. The default implementation will lead to a compile-time error if the
|
||||
* class method is not specialized. This method is not used in TemplateProperty, but
|
||||
* only NumericalProperty, so the TemplateProperty does not require this method to be
|
||||
* specialized.
|
||||
* \return The default stepping that the class <code>T</code> should use
|
||||
* \tparam U The type by which the class T is specialized. If
|
||||
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
|
||||
*/
|
||||
template <typename U>
|
||||
static U defaultSteppingValue();
|
||||
|
||||
/**
|
||||
* This method converts the top value from the Lua stack into a value of type
|
||||
* <code>U</code> and reports the <code>success</code> back to the caller. The default
|
||||
|
||||
@@ -54,6 +54,13 @@ U PropertyDelegate<T>::defaultMaximumValue() {
|
||||
"Unimplemented PropertyDelegate::defaultMaximumValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultSteppingValue() {
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::fromLuaValue(lua_State* state, bool& success) {
|
||||
|
||||
@@ -81,10 +81,8 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0),
|
||||
numeric_limits<float>::max()
|
||||
),
|
||||
glm::mat2x2(
|
||||
0.01f,
|
||||
0.01f,
|
||||
0.01f,
|
||||
0.01f,
|
||||
0.01f, 0.01f,
|
||||
0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x2), LUA_TTABLE);
|
||||
|
||||
Reference in New Issue
Block a user