diff --git a/external/etk b/external/etk index ab786955..e56a7466 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit ab78695585a3c94d2583f8a1d4bf6e180f2cc8ca +Subproject commit e56a7466c6ad272194ba645875402e871c2fa0dd diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index ab215ac1..fa23faee 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -622,3 +622,21 @@ const etk::Color& 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)); +} \ No newline at end of file diff --git a/sources/ewol/compositing/Shaper.h b/sources/ewol/compositing/Shaper.h index 7cf0caf4..bc1a5b6b 100644 --- a/sources/ewol/compositing/Shaper.h +++ b/sources/ewol/compositing/Shaper.h @@ -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 diff --git a/sources/ewol/object/Param.cpp b/sources/ewol/object/Param.cpp index da180c05..e69de29b 100644 --- a/sources/ewol/object/Param.cpp +++ b/sources/ewol/object/Param.cpp @@ -1,448 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include - -////////////////////////////////////////////////////////////////////////////////// -// int16_t -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "int16_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const int16_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoi(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uint16_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uint16_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoi(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uint32_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uint32_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoul(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "int32_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const int32_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stol(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uint64_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uint64_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoull(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "int64_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const int64_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const int64_t& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(std::stoll(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} - - -////////////////////////////////////////////////////////////////////////////////// -// Float -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "float"; -} -template<> std::string ewol::object::Param::getValueSpecific(const float& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const float& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(std::stof(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} - - -////////////////////////////////////////////////////////////////////////////////// -// Double -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "double"; -} -template<> std::string ewol::object::Param::getValueSpecific(const double& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const double& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(std::stod(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} - -////////////////////////////////////////////////////////////////////////////////// -// Boolean -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "bool"; -} -template<> std::string ewol::object::Param::getValueSpecific(const bool& _valueRequested) const { - if (_valueRequested == true) { - return "true"; - } - return "false"; -} -template<> void ewol::object::Param::set(const bool& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::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::getInfo() const { - return getType() + " default=" + (m_default?"true":"false"); -} - -////////////////////////////////////////////////////////////////////////////////// -// string -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "string"; -} -template<> std::string ewol::object::Param::getValueSpecific(const std::string& _valueRequested) const { - return _valueRequested; -} -template<> void ewol::object::Param::set(const std::string& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(_newVal); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + m_default; -} - -////////////////////////////////////////////////////////////////////////////////// -// vec2 -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "vec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const vec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(vec2(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "ivec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const ivec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(ivec2(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uivec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uivec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(uivec2(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "bvec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const bvec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const bvec2& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(bvec2(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} -/* -////////////////////////////////////////////////////////////////////////////////// -// vec3 -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "vec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const vec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(vec3(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "ivec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const ivec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(ivec3(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uivec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uivec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(uivec3(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "bvec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const bvec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const bvec3& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(bvec3(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} -*/ diff --git a/sources/ewol/object/Param.h b/sources/ewol/object/Param.h index caf8effa..2c3f5219 100644 --- a/sources/ewol/object/Param.h +++ b/sources/ewol/object/Param.h @@ -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. diff --git a/sources/ewol/object/ParamList.h b/sources/ewol/object/ParamList.h index ed1db5cf..3ca93165 100644 --- a/sources/ewol/object/ParamList.h +++ b/sources/ewol/object/ParamList.h @@ -12,6 +12,7 @@ #include #include #include +#include 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); diff --git a/sources/ewol/object/ParamRange.cpp b/sources/ewol/object/ParamRange.cpp index 6b50e5de..e69de29b 100644 --- a/sources/ewol/object/ParamRange.cpp +++ b/sources/ewol/object/ParamRange.cpp @@ -1,469 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include - -////////////////////////////////////////////////////////////////////////////////// -// int16_t -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "int16_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const int16_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoi(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uint16_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uint16_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoi(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uint32_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uint32_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoul(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "int32_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const int32_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stol(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uint64_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uint64_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoull(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "int64_t"; -} -template<> std::string ewol::object::Param::getValueSpecific(const int64_t& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stoll(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "float"; -} -template<> std::string ewol::object::Param::getValueSpecific(const float& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stof(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "double"; -} -template<> std::string ewol::object::Param::getValueSpecific(const double& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(std::stod(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "bool"; -} -template<> std::string ewol::object::Param::getValueSpecific(const bool& _valueRequested) const { - if (_valueRequested == true) { - return "true"; - } - return "false"; -} -template<> void ewol::object::Param::set(const bool& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::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::getInfo() const { - return getType() + " default=" + (m_default?"true":"false"); -} - -////////////////////////////////////////////////////////////////////////////////// -// string -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "string"; -} -template<> std::string ewol::object::Param::getValueSpecific(const std::string& _valueRequested) const { - return _valueRequested; -} -template<> void ewol::object::Param::set(const std::string& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(_newVal); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + m_default; -} - -////////////////////////////////////////////////////////////////////////////////// -// vec2 -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "vec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const vec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(vec2(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "ivec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const ivec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(ivec2(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uivec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uivec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(uivec2(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "bvec2"; -} -template<> std::string ewol::object::Param::getValueSpecific(const bvec2& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const bvec2& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(bvec2(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} -/* -////////////////////////////////////////////////////////////////////////////////// -// vec3 -////////////////////////////////////////////////////////////////////////////////// -template<> std::string ewol::object::Param::getType() const { - return "vec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const vec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(vec3(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "ivec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const ivec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(ivec3(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "uivec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const uivec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::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::setString(const std::string& _newVal) { - set(uivec3(_newVal)); -} -template<> std::string ewol::object::Param::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::getType() const { - return "bvec3"; -} -template<> std::string ewol::object::Param::getValueSpecific(const bvec3& _valueRequested) const { - return std::to_string(_valueRequested); -} -template<> void ewol::object::Param::set(const bvec3& _newVal) { - m_value = _newVal; -} -template<> void ewol::object::Param::setString(const std::string& _newVal) { - set(bvec3(_newVal)); -} -template<> std::string ewol::object::Param::getInfo() const { - return getType() + " default=" + std::to_string(m_default); -} -*/ diff --git a/sources/ewol/object/ParamRange.h b/sources/ewol/object/ParamRange.h index 7e6c2cd2..3e1832db 100644 --- a/sources/ewol/object/ParamRange.h +++ b/sources/ewol/object/ParamRange.h @@ -12,7 +12,7 @@ #include #include #include - +#include 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. diff --git a/sources/ewol/object/Parameter.h b/sources/ewol/object/Parameter.h index 4d87e4b5..4c058b40 100644 --- a/sources/ewol/object/Parameter.h +++ b/sources/ewol/object/Parameter.h @@ -12,6 +12,7 @@ #define __EWOL_PARAMETER_H__ #include +#include namespace ewol { namespace object { diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index ea1dc754..829f2dc6 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -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"), diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index f099e5dd..e3263013 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -12,10 +12,10 @@ #include #include -#include #include #include #include +#include #include @@ -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 diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index d666a718..c16d7c04 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -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 :