[DEV] change the parameter object system (NOT work)
This commit is contained in:
parent
0eb9d5c322
commit
91091b7ccb
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
||||
Subproject commit ab78695585a3c94d2583f8a1d4bf6e180f2cc8ca
|
||||
Subproject commit e56a7466c6ad272194ba645875402e871c2fa0dd
|
@ -622,3 +622,21 @@ const etk::Color<float>& ewol::compositing::Shaper::getColor(int32_t _id) {
|
||||
}
|
||||
return m_colorProperty->get(_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string std::to_string(const ewol::compositing::Shaper& _obj) {
|
||||
return _obj.getSource();
|
||||
}
|
||||
|
||||
std::u32string std::to_u32string(const ewol::compositing::Shaper& _obj) {
|
||||
return std::to_u32string(std::to_string(_obj));
|
||||
}
|
||||
|
||||
bool std::from_string(ewol::compositing::Shaper& _variableRet, const std::string& _value) {
|
||||
_variableRet.setSource(_value);
|
||||
return true;
|
||||
}
|
||||
bool std::from_string(ewol::compositing::Shaper& _variableRet, const std::u32string& _value) {
|
||||
return from_string(_variableRet, std::to_string(_value));
|
||||
}
|
@ -295,5 +295,12 @@ namespace ewol {
|
||||
};
|
||||
};
|
||||
|
||||
namespace std {
|
||||
std::string to_string(const ewol::compositing::Shaper& _obj);
|
||||
std::u32string to_u32string(const ewol::compositing::Shaper& _obj);
|
||||
bool from_string(ewol::compositing::Shaper& _variableRet, const std::string& _value);
|
||||
bool from_string(ewol::compositing::Shaper& _variableRet, const std::u32string& _value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,448 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/object/Param.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// int16_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<int16_t>::getType() const {
|
||||
return "int16_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<int16_t>::getValueSpecific(const int16_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<int16_t>::set(const int16_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<int16_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoi(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<int16_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uint16_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uint16_t>::getType() const {
|
||||
return "uint16_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint16_t>::getValueSpecific(const uint16_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uint16_t>::set(const uint16_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uint16_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoi(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint16_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uint32_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uint32_t>::getType() const {
|
||||
return "uint32_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint32_t>::getValueSpecific(const uint32_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uint32_t>::set(const uint32_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uint32_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoul(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint32_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// int32_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<int32_t>::getType() const {
|
||||
return "int32_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<int32_t>::getValueSpecific(const int32_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<int32_t>::set(const int32_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<int32_t>::setString(const std::string& _newVal) {
|
||||
set(std::stol(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<int32_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uint64_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uint64_t>::getType() const {
|
||||
return "uint64_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint64_t>::getValueSpecific(const uint64_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uint64_t>::set(const uint64_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uint64_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoull(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint64_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Int64_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<int64_t>::getType() const {
|
||||
return "int64_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<int64_t>::getValueSpecific(const int64_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<int64_t>::set(const int64_t& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<int64_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoll(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<int64_t>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Float
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<float>::getType() const {
|
||||
return "float";
|
||||
}
|
||||
template<> std::string ewol::object::Param<float>::getValueSpecific(const float& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<float>::set(const float& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<float>::setString(const std::string& _newVal) {
|
||||
set(std::stof(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<float>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Double
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<double>::getType() const {
|
||||
return "double";
|
||||
}
|
||||
template<> std::string ewol::object::Param<double>::getValueSpecific(const double& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<double>::set(const double& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<double>::setString(const std::string& _newVal) {
|
||||
set(std::stod(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<double>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Boolean
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<bool>::getType() const {
|
||||
return "bool";
|
||||
}
|
||||
template<> std::string ewol::object::Param<bool>::getValueSpecific(const bool& _valueRequested) const {
|
||||
if (_valueRequested == true) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
template<> void ewol::object::Param<bool>::set(const bool& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<bool>::setString(const std::string& _newVal) {
|
||||
if( std::tolower(_newVal) == "true"
|
||||
|| std::tolower(_newVal) == "enable"
|
||||
|| _newVal == "1") {
|
||||
set(true);
|
||||
} else {
|
||||
set(false);
|
||||
}
|
||||
}
|
||||
template<> std::string ewol::object::Param<bool>::getInfo() const {
|
||||
return getType() + " default=" + (m_default?"true":"false");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<std::string>::getType() const {
|
||||
return "string";
|
||||
}
|
||||
template<> std::string ewol::object::Param<std::string>::getValueSpecific(const std::string& _valueRequested) const {
|
||||
return _valueRequested;
|
||||
}
|
||||
template<> void ewol::object::Param<std::string>::set(const std::string& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<std::string>::setString(const std::string& _newVal) {
|
||||
set(_newVal);
|
||||
}
|
||||
template<> std::string ewol::object::Param<std::string>::getInfo() const {
|
||||
return getType() + " default=" + m_default;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// vec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<vec2>::getType() const {
|
||||
return "vec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec2>::getValueSpecific(const vec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<vec2>::set(const vec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<vec2>::setString(const std::string& _newVal) {
|
||||
set(vec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec2>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// ivec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<ivec2>::getType() const {
|
||||
return "ivec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec2>::getValueSpecific(const ivec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<ivec2>::set(const ivec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<ivec2>::setString(const std::string& _newVal) {
|
||||
set(ivec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec2>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uivec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uivec2>::getType() const {
|
||||
return "uivec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec2>::getValueSpecific(const uivec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uivec2>::set(const uivec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uivec2>::setString(const std::string& _newVal) {
|
||||
set(uivec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec2>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// bvec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<bvec2>::getType() const {
|
||||
return "bvec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec2>::getValueSpecific(const bvec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<bvec2>::set(const bvec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<bvec2>::setString(const std::string& _newVal) {
|
||||
set(bvec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec2>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
/*
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// vec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<vec3>::getType() const {
|
||||
return "vec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec3>::getValueSpecific(const vec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<vec3>::set(const vec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<vec3>::setString(const std::string& _newVal) {
|
||||
set(vec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec3>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// ivec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<ivec3>::getType() const {
|
||||
return "ivec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec3>::getValueSpecific(const ivec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<ivec3>::set(const ivec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<ivec3>::setString(const std::string& _newVal) {
|
||||
set(ivec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec3>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uivec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uivec3>::getType() const {
|
||||
return "uivec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec3>::getValueSpecific(const uivec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uivec3>::set(const uivec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uivec3>::setString(const std::string& _newVal) {
|
||||
set(uivec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec3>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// bvec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<bvec3>::getType() const {
|
||||
return "bvec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec3>::getValueSpecific(const bvec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<bvec3>::set(const bvec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<bvec3>::setString(const std::string& _newVal) {
|
||||
set(bvec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec3>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
*/
|
@ -32,31 +32,46 @@ namespace ewol {
|
||||
*/
|
||||
Param(ewol::object::ParameterList& _objectLink,
|
||||
const std::string& _name,
|
||||
const TYPE& _defaultValue,
|
||||
const MY_TYPE& _defaultValue,
|
||||
const std::string& _description = "") :
|
||||
Parameter(_objectLink, _name),
|
||||
m_value(_defaultValue),
|
||||
m_default(_defaultValue) {
|
||||
|
||||
};
|
||||
Param(ewol::object::ParameterList& _objectLink,
|
||||
const std::string& _name,
|
||||
const std::string& _description = "") :
|
||||
Parameter(_objectLink, _name),
|
||||
m_value(),
|
||||
m_default() {
|
||||
|
||||
};
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~Param() { };
|
||||
// herited methode
|
||||
virtual std::string getType() const;
|
||||
virtual std::string getType() const {
|
||||
return typeid(MY_TYPE).name();
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getString() const {
|
||||
return getValueSpecific(m_value);
|
||||
};
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getDefault() const {
|
||||
return getValueSpecific(m_default);
|
||||
};
|
||||
}
|
||||
// herited methode
|
||||
virtual void setString(const std::string& _newVal);
|
||||
virtual void setString(const std::string& _newVal) {
|
||||
// when you want to set an element in parameter you will implement the function template std::from_string
|
||||
std::from_string(m_value, _newVal);
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getInfo() const;
|
||||
virtual std::string getInfo() const {
|
||||
return getType() + " default=" + getDefault();
|
||||
}
|
||||
// herited methode
|
||||
virtual bool isDefault() const {
|
||||
return m_value == m_default;
|
||||
@ -81,13 +96,17 @@ namespace ewol {
|
||||
* @brief Set a new value for this parameter
|
||||
* @param[in] newVal New value to set (set the nearest value if range is set)
|
||||
*/
|
||||
void set(const MY_TYPE& _newVal);
|
||||
void set(const MY_TYPE& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief Get the string of the specify value.
|
||||
* @return convetion of the velue in string.
|
||||
*/
|
||||
std::string getValueSpecific(const MY_TYPE& _valueRequested) const;
|
||||
std::string getValueSpecific(const MY_TYPE& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief assignement operator.
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <ewol/object/ParameterList.h>
|
||||
#include <ewol/object/Parameter.h>
|
||||
#include <map>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace ewol {
|
||||
namespace object {
|
||||
@ -52,8 +53,8 @@ namespace ewol {
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getType() const {
|
||||
return "list...";
|
||||
};
|
||||
return typeid(MY_TYPE).name();
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getString() const {
|
||||
return getElement(m_value);
|
||||
|
@ -1,469 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/object/Param.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// int16_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<int16_t>::getType() const {
|
||||
return "int16_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<int16_t>::getValueSpecific(const int16_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<int16_t>::set(const int16_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<int16_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoi(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<int16_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uint16_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uint16_t>::getType() const {
|
||||
return "uint16_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint16_t>::getValueSpecific(const uint16_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uint16_t>::set(const uint16_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uint16_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoi(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint16_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uint32_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uint32_t>::getType() const {
|
||||
return "uint32_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint32_t>::getValueSpecific(const uint32_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uint32_t>::set(const uint32_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uint32_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoul(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint32_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// int32_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<int32_t>::getType() const {
|
||||
return "int32_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<int32_t>::getValueSpecific(const int32_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<int32_t>::set(const int32_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<int32_t>::setString(const std::string& _newVal) {
|
||||
set(std::stol(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<int32_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uint64_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uint64_t>::getType() const {
|
||||
return "uint64_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint64_t>::getValueSpecific(const uint64_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uint64_t>::set(const uint64_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uint64_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoull(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uint64_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Int64_t
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<int64_t>::getType() const {
|
||||
return "int64_t";
|
||||
}
|
||||
template<> std::string ewol::object::Param<int64_t>::getValueSpecific(const int64_t& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<int64_t>::set(const int64_t& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<int64_t>::setString(const std::string& _newVal) {
|
||||
set(std::stoll(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<int64_t>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Float
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<float>::getType() const {
|
||||
return "float";
|
||||
}
|
||||
template<> std::string ewol::object::Param<float>::getValueSpecific(const float& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<float>::set(const float& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<float>::setString(const std::string& _newVal) {
|
||||
set(std::stof(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<float>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Double
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<double>::getType() const {
|
||||
return "double";
|
||||
}
|
||||
template<> std::string ewol::object::Param<double>::getValueSpecific(const double& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<double>::set(const double& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<double>::setString(const std::string& _newVal) {
|
||||
set(std::stod(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<double>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " [" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Boolean
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<bool>::getType() const {
|
||||
return "bool";
|
||||
}
|
||||
template<> std::string ewol::object::Param<bool>::getValueSpecific(const bool& _valueRequested) const {
|
||||
if (_valueRequested == true) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
template<> void ewol::object::Param<bool>::set(const bool& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<bool>::setString(const std::string& _newVal) {
|
||||
if( std::tolower(_newVal) == "true"
|
||||
|| std::tolower(_newVal) == "enable"
|
||||
|| _newVal == "1") {
|
||||
set(true);
|
||||
} else {
|
||||
set(false);
|
||||
}
|
||||
}
|
||||
template<> std::string ewol::object::Param<bool>::getInfo() const {
|
||||
return getType() + " default=" + (m_default?"true":"false");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<std::string>::getType() const {
|
||||
return "string";
|
||||
}
|
||||
template<> std::string ewol::object::Param<std::string>::getValueSpecific(const std::string& _valueRequested) const {
|
||||
return _valueRequested;
|
||||
}
|
||||
template<> void ewol::object::Param<std::string>::set(const std::string& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<std::string>::setString(const std::string& _newVal) {
|
||||
set(_newVal);
|
||||
}
|
||||
template<> std::string ewol::object::Param<std::string>::getInfo() const {
|
||||
return getType() + " default=" + m_default;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// vec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<vec2>::getType() const {
|
||||
return "vec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec2>::getValueSpecific(const vec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<vec2>::set(const vec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<vec2>::setString(const std::string& _newVal) {
|
||||
set(vec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec2>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// ivec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<ivec2>::getType() const {
|
||||
return "ivec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec2>::getValueSpecific(const ivec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<ivec2>::set(const ivec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<ivec2>::setString(const std::string& _newVal) {
|
||||
set(ivec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec2>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uivec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uivec2>::getType() const {
|
||||
return "uivec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec2>::getValueSpecific(const uivec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uivec2>::set(const uivec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uivec2>::setString(const std::string& _newVal) {
|
||||
set(uivec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec2>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// bvec2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<bvec2>::getType() const {
|
||||
return "bvec2";
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec2>::getValueSpecific(const bvec2& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<bvec2>::set(const bvec2& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<bvec2>::setString(const std::string& _newVal) {
|
||||
set(bvec2(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec2>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
/*
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// vec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<vec3>::getType() const {
|
||||
return "vec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec3>::getValueSpecific(const vec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<vec3>::set(const vec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<vec3>::setString(const std::string& _newVal) {
|
||||
set(vec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<vec3>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// ivec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<ivec3>::getType() const {
|
||||
return "ivec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec3>::getValueSpecific(const ivec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<ivec3>::set(const ivec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<ivec3>::setString(const std::string& _newVal) {
|
||||
set(ivec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<ivec3>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// uivec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<uivec3>::getType() const {
|
||||
return "uivec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec3>::getValueSpecific(const uivec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<uivec3>::set(const uivec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
if (m_min != m_max) {
|
||||
m_value.setMin(m_min);
|
||||
m_value.setMin(m_max);
|
||||
}
|
||||
}
|
||||
template<> void ewol::object::Param<uivec3>::setString(const std::string& _newVal) {
|
||||
set(uivec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<uivec3>::getInfo() const {
|
||||
if (m_min == m_max) {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
return getType() + " x[" + std::to_string(m_min) + ".." + std::to_string(m_max) + "] "
|
||||
+ " default=" + std::to_string(m_default);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// bvec3
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
template<> std::string ewol::object::Param<bvec3>::getType() const {
|
||||
return "bvec3";
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec3>::getValueSpecific(const bvec3& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
template<> void ewol::object::Param<bvec3>::set(const bvec3& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
template<> void ewol::object::Param<bvec3>::setString(const std::string& _newVal) {
|
||||
set(bvec3(_newVal));
|
||||
}
|
||||
template<> std::string ewol::object::Param<bvec3>::getInfo() const {
|
||||
return getType() + " default=" + std::to_string(m_default);
|
||||
}
|
||||
*/
|
@ -12,7 +12,7 @@
|
||||
#include <ewol/object/ParameterList.h>
|
||||
#include <ewol/object/Parameter.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
namespace ewol {
|
||||
namespace object {
|
||||
@ -34,9 +34,9 @@ namespace ewol {
|
||||
*/
|
||||
ParamRange(ewol::object::ParameterList& _objectLink,
|
||||
const std::string& _name,
|
||||
const TYPE& _defaultValue,
|
||||
const TYPE& _min,
|
||||
const TYPE& _max,
|
||||
const MY_TYPE& _defaultValue,
|
||||
const MY_TYPE& _min,
|
||||
const MY_TYPE& _max,
|
||||
const std::string& _description = "") :
|
||||
Parameter(_objectLink, _name),
|
||||
m_value(_defaultValue),
|
||||
@ -50,7 +50,9 @@ namespace ewol {
|
||||
*/
|
||||
virtual ~ParamRange() { };
|
||||
// herited methode
|
||||
virtual std::string getType() const;
|
||||
virtual std::string getType() const {
|
||||
return typeid(MY_TYPE).name();
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getString() const {
|
||||
return getValueSpecific(m_value);
|
||||
@ -60,9 +62,16 @@ namespace ewol {
|
||||
return getValueSpecific(m_default);
|
||||
};
|
||||
// herited methode
|
||||
virtual void setString(const std::string& _newVal);
|
||||
virtual void setString(const std::string& _newVal) {
|
||||
MY_TYPE val;
|
||||
// when you want to set an element in parameter you will implement the function template std::from_string
|
||||
std::from_string(val, _newVal);
|
||||
set(val);
|
||||
}
|
||||
// herited methode
|
||||
virtual std::string getInfo() const;
|
||||
virtual std::string getInfo() const {
|
||||
return getType() + " default=" + getDefault();
|
||||
}
|
||||
// herited methode
|
||||
virtual bool isDefault() const {
|
||||
return m_value == m_default;
|
||||
@ -87,13 +96,21 @@ namespace ewol {
|
||||
* @brief Set a new value for this parameter
|
||||
* @param[in] newVal New value to set (set the nearest value if range is set)
|
||||
*/
|
||||
void set(const MY_TYPE& _newVal);
|
||||
void set(const MY_TYPE& _newVal) {
|
||||
if (m_min == m_max) {
|
||||
m_value = _newVal;
|
||||
} else {
|
||||
m_value = std::avg(m_min, _newVal, m_max);
|
||||
}
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief Get the string of the specify value.
|
||||
* @return convetion of the velue in string.
|
||||
*/
|
||||
std::string getValueSpecific(const MY_TYPE& _valueRequested) const;
|
||||
std::string getValueSpecific(const MY_TYPE& _valueRequested) const {
|
||||
return std::to_string(_valueRequested);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief assignement operator.
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define __EWOL_PARAMETER_H__
|
||||
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace ewol {
|
||||
namespace object {
|
||||
|
@ -29,7 +29,7 @@ const char* const ewol::widget::Button::eventValue = "value";
|
||||
#define STATUS_DOWN (3)
|
||||
|
||||
ewol::widget::Button::Button() :
|
||||
m_shaper(*this, "shaper", "", "The display name for config file"),
|
||||
m_shaper(*this, "shaper", "The display name for config file"),
|
||||
m_value(*this, "value", false, "Value of the Button"),
|
||||
m_lock(*this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder"),
|
||||
m_toggleMode(*this, "toggle", false, "The Button can toogle"),
|
||||
|
@ -12,10 +12,10 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/widget/Container2.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <ewol/compositing/Image.h>
|
||||
#include <ewol/compositing/Shaper.h>
|
||||
#include <ewol/widget/Container2.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
|
||||
|
||||
@ -34,12 +34,6 @@ namespace ewol {
|
||||
static const char* const eventEnter;
|
||||
static const char* const eventLeave;
|
||||
static const char* const eventValue;
|
||||
// Config list of properties
|
||||
static const char* const configToggle;
|
||||
static const char* const configLock;
|
||||
static const char* const configEnableSingle;
|
||||
static const char* const configValue;
|
||||
static const char* const configShaper;
|
||||
enum buttonLock{
|
||||
lockNone, //!< normal status of the button
|
||||
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
||||
|
@ -98,7 +98,8 @@ def create(target):
|
||||
'ewol/object/Parameter.cpp',
|
||||
'ewol/object/ParameterList.cpp',
|
||||
'ewol/object/ParamList.cpp',
|
||||
'ewol/object/Param.cpp'
|
||||
'ewol/object/Param.cpp',
|
||||
'ewol/object/ParamRange.cpp'
|
||||
])
|
||||
|
||||
# OpenGL interface :
|
||||
|
Loading…
x
Reference in New Issue
Block a user