[DEV] start rework for parameters

This commit is contained in:
Edouard DUPIN 2014-08-11 22:43:05 +02:00
parent 70487330ce
commit 0eb9d5c322
20 changed files with 1176 additions and 440 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 2198a20dcc94593f57081c99d3d5f18a17ed28fa
Subproject commit ab78695585a3c94d2583f8a1d4bf6e180f2cc8ca

2
external/ewolsa vendored

@ -1 +1 @@
Subproject commit c25640d80e675d25660a78dc2dc0a4f20831d4e2
Subproject commit a657e619550fe0135e42075b97076343fcf0c902

2
external/exml vendored

@ -1 +1 @@
Subproject commit 3ae5e16d48318ebbd158a6a7f7936000ff64b83f
Subproject commit ce3c68cc5b1d995c47886488b4ab56d2c973f913

2
monk

@ -1 +1 @@
Subproject commit 85ebc5ec327c3920264de479c8b1049c1b81596c
Subproject commit 895e18786ce732e8cc1c282863677c21e1806062

View File

@ -15,8 +15,6 @@
#undef __class__
#define __class__ "Object"
const char* const ewol::Object::configName = "name";
size_t ewol::Object::m_valUID = 0;
void ewol::Object::autoDestroy() {
@ -50,12 +48,11 @@ void ewol::Object::removeParent() {
ewol::Object::Object() :
m_objectHasBeenInit(false),
m_static(false),
m_name(*this, "name", ""),
m_name(*this, "name", "", "Object name, might be a unique reference in all the program"),
m_isResource(false) {
// note this is nearly atomic ... (but it is enough)
m_uniqueId = m_valUID++;
EWOL_DEBUG("new Object : [" << m_uniqueId << "]");
registerConfig(configName, "string", nullptr, "Object name, might be a unique reference in all the program");
}
ewol::Object::~Object() {
@ -285,42 +282,19 @@ void ewol::Object::onObjectRemove(const std::shared_ptr<ewol::Object>& _object)
}
}
void ewol::Object::registerConfig(const char* _config,
const char* _type,
const char* _control,
const char* _description,
const char* _default) {
if (nullptr == _config) {
EWOL_ERROR("Try to add nullptr config");
return;
}
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (nullptr != m_listConfig[iii].getConfig()) {
if (0 == strcmp(m_listConfig[iii].getConfig(), _config) ) {
EWOL_ERROR("Try to add config already added : " << _config << " at pos=" << iii);
}
}
}
m_listConfig.push_back(ewol::object::ConfigElement(_config, _type, _control, _description, _default));
}
bool ewol::Object::loadXML(exml::Element* _node) {
if (nullptr == _node) {
return false;
}
bool errorOccured = true;
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (m_listConfig[iii].getConfig() == nullptr) {
bool errorOccured = false;
for(size_t iii=0 ; iii<_node->sizeAttribute() ; iii++) {
auto pair = _node->getAttrPair(iii);
if (pair.first == "") {
continue;
}
if (_node->existAttribute(m_listConfig[iii].getConfig()) == false) {
continue;
}
std::string value = _node->getAttribute(m_listConfig[iii].getConfig());
if (false == setConfig(ewol::object::Config(m_listConfig[iii].getConfig(), value) ) ) {
errorOccured = false;
if (parameterSet(pair.first, pair.second) == false) {
errorOccured = true;
}
}
return errorOccured;
@ -331,82 +305,16 @@ bool ewol::Object::storeXML(exml::Element* _node) const {
return false;
}
bool errorOccured = true;
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (m_listConfig[iii].getConfig() == nullptr) {
continue;
}
std::string value = getConfig(m_listConfig[iii].getConfig());
if (nullptr != m_listConfig[iii].getDefault() ) {
if (value == m_listConfig[iii].getDefault() ) {
// nothing to add on the XML :
continue;
}
}
// add attribute ... == > note : add special element when '"' element detected ...
_node->setAttribute(m_listConfig[iii].getConfig(), value);
for (auto &it : parameterGetAll(true)) {
_node->setAttribute(it.first, it.second);
}
return errorOccured;
}
bool ewol::Object::onSetConfig(const ewol::object::Config& _conf) {
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config : " << _conf);
if (_conf.getConfig() == configName) {
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config name : \"" << _conf.getData() << "\"");
setName(_conf.getData());
return true;
void ewol::Object::onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer) {
if (_paramPointer == m_name) {
EWOL_CRITICAL("[" << getId() << "] Parameter name change : " << m_name);
}
return false;
}
bool ewol::Object::onGetConfig(const char* _config, std::string& _result) const {
if (_config == configName) {
_result = getName();
return true;
}
return false;
}
bool ewol::Object::setConfig(const std::string& _config, const std::string& _value) {
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (nullptr != m_listConfig[iii].getConfig()) {
if (_config == m_listConfig[iii].getConfig() ) {
// call config with standard parameter
return setConfig(ewol::object::Config(m_listConfig[iii].getConfig(), _value));
}
}
}
EWOL_ERROR(" parameter is not in the list : \"" << _config << "\"" );
return false;
}
std::string ewol::Object::getConfig(const char* _config) const {
std::string res="";
if (nullptr != _config) {
onGetConfig(_config, res);
}
return res;
}
std::string ewol::Object::getConfig(const std::string& _config) const {
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (nullptr != m_listConfig[iii].getConfig()) {
if (_config == m_listConfig[iii].getConfig() ) {
// call config with standard parameter
return getConfig(m_listConfig[iii].getConfig());
}
}
}
EWOL_ERROR(" parameter is not in the list : \"" << _config << "\"" );
return "";
}
bool ewol::Object::setConfigNamed(const std::string& _objectName, const ewol::object::Config& _conf) {
std::shared_ptr<ewol::Object> object = getObjectManager().get(_objectName);
if (object == nullptr) {
return false;
}
return object->setConfig(_conf);
}
bool ewol::Object::setConfigNamed(const std::string& _objectName, const std::string& _config, const std::string& _value) {

View File

@ -67,10 +67,7 @@ namespace ewol {
*/
class Object : public std::enable_shared_from_this<Object>, public ewol::object::ParameterList {
private:
static size_t m_valUID; //!< stic used for the unique ID definition
public:
// Config list of properties
static const char* const configName;
static size_t m_valUID; //!< Static used for the unique ID definition
private:
bool m_objectHasBeenInit; //!< Know if the init function has bben called
protected:
@ -209,62 +206,29 @@ namespace ewol {
virtual void onReceiveMessage(const ewol::object::Message& _msg) {
};
private:
std::vector<ewol::object::ConfigElement> m_listConfig;
protected:
/**
* @brief the Object add a configuration capabilities
* @param[in] _config Configuration name.
* @param[in] _type Type of the config.
* @param[in] _control control of the current type.
* @param[in] _description Descritpion on the current type.
* @param[in] _default Default value of this parameter.
*/
void registerConfig(const char* _config,
const char* _type = nullptr,
const char* _control = nullptr,
const char* _description = nullptr,
const char* _default = nullptr);
/**
* @brief Configuration requested to the curent Object
* @param[in] _conf Configuration handle.
* @return true if the parametere has been used
*/
virtual bool onSetConfig(const ewol::object::Config& _conf);
/**
* @brief Receive a configuration message from an other element system or from the curent Object
* @param[in] _config Configuration name.
* @param[out] _result Result of the request.
* @return true if the config is set
*/
virtual bool onGetConfig(const char* _config, std::string& _result) const ;
public:
/**
* @brief get all the configuration list
* @return The list of all parameter availlable in the widget
*/
virtual const std::vector<ewol::object::ConfigElement>& getConfigList() {
return m_listConfig;
};
/**
* @brief Configuration requested to the curent Object (systrem mode)
* @param[in] _conf Configuration handle.
* @return true if config set correctly...
*/
bool setConfig(const ewol::object::Config& _conf) {
return onSetConfig(_conf);
};
bool setConfig(const std::string& _config, const std::string& _value); // need a search ...
// TODO : Distingish global search and sub search ...
bool setConfigNamed(const std::string& _objectName, const std::string& _config, const std::string& _value); // need a search ...
bool setConfigNamed(const std::string& _objectName, const ewol::object::Config& _conf);
// TODO : Remove this function .... ==> parameterSet(_config, _value);
bool setConfig(const std::string& _config, const std::string& _value) {
return parameterSet(_config, _value);
}
// TODO : Rework the position on this function ...
bool setConfigNamed(const std::string& _objectName, const std::string& _config, const std::string& _value);
/**
* @brief Configuration get from the curent Object (systrem mode)
* @param[in] _config Configuration name.
* @return the config properties
*/
std::string getConfig(const char* _config) const;
std::string getConfig(const std::string& _config) const; // need search
// TODO : Remove this :
std::string getConfig(const std::string& _config) const {
return parameterGet(_config);
}
// herited function :
virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer);
protected:
ewol::object::Param<std::string> m_name; //!< name of the element ...
public:

View File

@ -12,121 +12,207 @@
//////////////////////////////////////////////////////////////////////////////////
// int16_t
//////////////////////////////////////////////////////////////////////////////////
template<> std::string ewol::object::Param<int16_t>::getType() {
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) {
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));
}
//////////////////////////////////////////////////////////////////////////////////
// uint32_t
//////////////////////////////////////////////////////////////////////////////////
template<> std::string ewol::object::Param<uint32_t>::getType() {
return "uint32_t";
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);
}
template<> std::string ewol::object::Param<uint32_t>::getValueSpecific(const uint32_t& _valueRequested) {
//////////////////////////////////////////////////////////////////////////////////
// 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() {
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) {
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() {
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) {
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() {
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) {
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() {
template<> std::string ewol::object::Param<float>::getType() const {
return "float";
}
template<> std::string ewol::object::Param<float>::getValueSpecific(const float& _valueRequested) {
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() {
template<> std::string ewol::object::Param<double>::getType() const {
return "double";
}
template<> std::string ewol::object::Param<double>::getValueSpecific(const double& _valueRequested) {
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>::getValueSpecific(const bool& _valueRequested) {
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"
@ -136,19 +222,227 @@ template<> void ewol::object::Param<bool>::setString(const std::string& _newVal)
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>::getValueSpecific(const std::string& _valueRequested) {
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);
}
*/

View File

@ -6,8 +6,8 @@
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_PARAM_TYPE_H__
#define __EWOL_PARAM_TYPE_H__
#ifndef __EWOL_PARAM_H__
#define __EWOL_PARAM_H__
#include <ewol/object/ParameterList.h>
#include <ewol/object/Parameter.h>
@ -19,47 +19,23 @@ namespace ewol {
template<typename MY_TYPE> class Param : public Parameter {
private:
MY_TYPE m_value; //!< Current value.
MY_TYPE m_min; //!< Minimum value.
MY_TYPE m_max; //!< Maximum value.
MY_TYPE m_default; //!< Default value.
public:
/**
* @brief Create a parameter with a specific type.
* @param[in] blockLink Pointer on the reference block (must be define for upper class.
* @param[in] name Static name of the parameter.
* @param[in] defaultValue Default value of the parameter.
* @param[in] min Minumum value.
* @param[in] max Maximum value
* @param[in] _objectLink reference on the parameter lister.
* @param[in] _name Static name of the parameter.
* @param[in] _defaultValue Default value of the parameter.
* @param[in] _min Minumum value.
* @param[in] _max Maximum value.
* @param[in] _description description of the parameter.
*/
template<typename TYPE, typename = typename
std::enable_if< std::is_same<std::string, TYPE>::value
|| std::is_same<char[1], TYPE>::value
|| std::is_same<bvec2, TYPE>::value
|| std::is_same<bvec3, TYPE>::value
|| std::is_same<vec2, TYPE>::value
|| std::is_same<vec3, TYPE>::value
|| std::is_same<ivec2, TYPE>::value
|| std::is_same<ivec3, TYPE>::value
|| std::is_same<uivec2, TYPE>::value
|| std::is_same<uivec3, TYPE>::value>::type>
Param(ewol::object::ParameterList& _objectLink,
const std::string& _name,
const TYPE& _defaultValue) :
Parameter(_objectLink, _name),
m_value(_defaultValue),
m_default(_defaultValue) {
};
template<typename TYPE, typename = typename std::enable_if<!std::is_same<std::string, TYPE>::value>::type>
Param(ewol::object::ParameterList& _objectLink,
const std::string& _name,
const TYPE& _defaultValue,
const TYPE& _min,
const TYPE& _max) :
const std::string& _description = "") :
Parameter(_objectLink, _name),
m_value(_defaultValue),
m_min(_min),
m_max(_max),
m_default(_defaultValue) {
};
@ -68,21 +44,21 @@ namespace ewol {
*/
virtual ~Param() { };
// herited methode
virtual std::string getType();
virtual std::string getType() const;
// herited methode
virtual std::string getString() {
virtual std::string getString() const {
return getValueSpecific(m_value);
};
// herited methode
virtual std::string getDefault() {
virtual std::string getDefault() const {
return getValueSpecific(m_default);
};
// herited methode
virtual void setString(const std::string& _newVal);
// herited methode
virtual std::string getInfo();
virtual std::string getInfo() const;
// herited methode
virtual bool isDefault() {
virtual bool isDefault() const {
return m_value == m_default;
}
// herited methode
@ -95,6 +71,9 @@ namespace ewol {
* @note For performence, this function must be inline
* @return the Reference value
*/
inline MY_TYPE& get() {
return m_value;
};
const inline MY_TYPE& get() const {
return m_value;
};
@ -108,7 +87,7 @@ namespace ewol {
* @brief Get the string of the specify value.
* @return convetion of the velue in string.
*/
std::string getValueSpecific(const MY_TYPE& _valueRequested);
std::string getValueSpecific(const MY_TYPE& _valueRequested) const;
public:
/**
* @brief assignement operator.
@ -118,47 +97,10 @@ namespace ewol {
set(_newVal);
return *this;
};
operator MY_TYPE() {
operator MY_TYPE() const {
return m_value;
}
};
template<> std::string Param<bool>::getType() {
return "bool";
}
template<> std::string Param<std::string>::getType() {
return "string";
}
template<>
std::string Param<bool>::getInfo() {
return getType() + " default=" + (m_default?"true":"false");
}
template<>
std::string Param<std::string>::getInfo() {
return getType() + " default=" + m_default;
}
template<typename MY_TYPE>
std::string Param<MY_TYPE>::getInfo() {
return getType() + " default= (heterogen type)";
/*
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);
*/
}
template<>
void Param<std::string>::set(const std::string& _newVal) {
m_value = _newVal;
};
template<typename MY_TYPE>
void Param<MY_TYPE>::set(const MY_TYPE& _newVal) {
if (m_min == m_max) {
m_value = _newVal;
} else {
m_value = std::avg(m_min, _newVal, m_max);
}
};
template<typename MY_TYPE> std::ostream& operator <<(std::ostream& _os, const ewol::object::Param<MY_TYPE>& _obj) {
_os << _obj.get();

View File

@ -8,63 +8,3 @@
#include <ewol/debug.h>
#include <ewol/object/ParamList.h>
void ewol::object::ParamList::add(int64_t _value, const std::string& _name, const std::string& _description) {
auto it = m_list.find(_name);
if (it != m_list.end()) {
it->second = _value;
return;
}
m_list.insert(std::make_pair(_name, _value));
}
std::string ewol::object::ParamList::getElement(int64_t _intValue) {
for (auto &it : m_list) {
if (it.second == _intValue) {
return it.first;
}
}
return "???";
}
std::string ewol::object::ParamList::getString() {
return getElement(m_value);
}
std::string ewol::object::ParamList::getDefault() {
return getElement(m_default);
}
std::string ewol::object::ParamList::getInfo() {
return "List default=" + getElement(m_default);
}
void ewol::object::ParamList::setString(const std::string& _newVal) {
auto it = m_list.find(_newVal);
if (it != m_list.end()) {
m_value = it->second;
return;
}
EWOL_WARNING("paramList value='" << _newVal << "' is not un the list ... ==> no change");
for (auto &it : m_list) {
EWOL_DEBUG(" element : " << it.first);
}
}
void ewol::object::ParamList::set(int64_t _newVal) {
for (auto &it : m_list) {
if (it.second == _newVal) {
m_value = it.second;
return;
}
}
EWOL_WARNING("paramList value=" << _newVal << " is not un the list ... ==> no change");
}
std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::ParamList& _obj) {
_os << _obj.get();
return _os;
}

View File

@ -15,22 +15,25 @@
namespace ewol {
namespace object {
class ParamList : public Parameter {
template<typename MY_TYPE> class ParamList : public Parameter {
private:
int64_t m_value; //!< Element value ==> can be directly used.
int64_t m_default; //!< Default value.
std::map<std::string, int64_t> m_list; //!< pointer on the list of all elements.
MY_TYPE m_value; //!< Element value ==> can be directly used.
MY_TYPE m_default; //!< Default value.
std::map<std::string, MY_TYPE> m_list; //!< pointer on the list of all elements.
public:
/**
* @brief Create a parameter with List of element parameter.
* @param[in] blockLink Pointer on the reference block (must be define for upper class).
* @param[in] name Static name of the parameter.
* @param[in] _objectLink reference on the parameter lister.
* @param[in] _name Static name of the parameter.
* @param[in] _description description of the parameter.
*/
ParamList(ewol::object::ParameterList& _objectLink,
const std::string& _name) :
const std::string& _name,
const MY_TYPE& _defaultValue,
const std::string& _description="") :
Parameter(_objectLink, _name),
m_value(0),
m_default(0) {
m_value(_defaultValue),
m_default(_defaultValue) {
};
/**
@ -39,60 +42,111 @@ namespace ewol {
virtual ~ParamList() {
};
void add(int64_t _value, const std::string& _name, const std::string& _description = "");
void add(const MY_TYPE& _value, const std::string& _name, const std::string& _description = "") {
auto it = m_list.find(_name);
if (it != m_list.end()) {
it->second = _value;
return;
}
m_list.insert(std::make_pair(_name, _value));
}
// herited methode
virtual std::string getType() {
return "list";
virtual std::string getType() const {
return "list...";
};
// herited methode
virtual std::string getString();
virtual std::string getString() const {
return getElement(m_value);
}
// herited methode
virtual std::string getDefault();
virtual std::string getDefault() const {
return getElement(m_default);
}
// herited methode
virtual void setString(const std::string& _newVal);
virtual void setString(const std::string& _newVal) {
auto it = m_list.find(_newVal);
if (it != m_list.end()) {
m_value = it->second;
return;
}
EWOL_WARNING("paramList value='" << _newVal << "' is not un the list ... ==> no change");
for (auto &it : m_list) {
EWOL_VERBOSE(" element : " << it.first);
}
}
// herited methode
virtual std::string getInfo();
virtual std::string getInfo() const {
std::string list = "List default=" + getElement(m_default) + " in : [";
for (auto &it : m_list) {
list += it.first + "/";
}
return list + "]";
}
// herited methode
virtual bool isDefault() {
virtual bool isDefault() const {
return m_value == m_default;
}
// herited methode
virtual void setDefault() {
m_value = m_default;
}
void setDefaultValue(const MY_TYPE& _value) {
m_default = _value;
}
/**
* @brief Get the value of the current parameter.
* @return the Reference value
*/
const inline int64_t& get() const {
inline MY_TYPE& get() {
return m_value;
};
const inline MY_TYPE& get() const {
return m_value;
};
/**
* @brief Set the value of the current parameter.
* @param[in] _newVal New value of the parameter. (not set if out of range)
*/
void set(int64_t _newVal);
void set(MY_TYPE _newVal) {
for (auto &it : m_list) {
if (it.second == _newVal) {
m_value = it.second;
return;
}
}
EWOL_WARNING("paramList value=??? is not un the list ... ==> no change");
}
private:
/**
* @brief Get the element description from real Value.
* @param[in] _intValue value that might be converted in string.
* @return the description string coresponding to this ID.
*/
std::string getElement(int64_t _intValue);
std::string getElement(MY_TYPE _intValue) const {
for (auto &it : m_list) {
if (it.second == _intValue) {
return it.first;
}
}
return "???";
}
public:
/**
* @brief assignement operator.
* @param[in] newVal The new value of the parameter.
*/
const ParamList& operator= (int64_t _newVal) {
const ParamList& operator= (MY_TYPE _newVal) {
set(_newVal);
return *this;
}
operator int64_t() {
operator MY_TYPE() const {
return m_value;
}
};
std::ostream& operator <<(std::ostream& _os, const ewol::object::ParamList& _obj);
template<typename MY_TYPE> std::ostream& operator <<(std::ostream& _os, const ewol::object::ParamList<MY_TYPE>& _obj) {
_os << _obj.get();
return _os;
}
};
};
#endif

View File

@ -0,0 +1,469 @@
/**
* @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);
}
*/

View File

@ -0,0 +1,117 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_PARAM_RANGE_H__
#define __EWOL_PARAM_RANGE_H__
#include <ewol/object/ParameterList.h>
#include <ewol/object/Parameter.h>
#include <etk/math/Vector2D.h>
namespace ewol {
namespace object {
template<typename MY_TYPE> class ParamRange : public Parameter {
private:
MY_TYPE m_value; //!< Current value.
MY_TYPE m_min; //!< Minimum value.
MY_TYPE m_max; //!< Maximum value.
MY_TYPE m_default; //!< Default value.
public:
/**
* @brief Create a parameter with a specific type.
* @param[in] _objectLink reference on the parameter lister.
* @param[in] _name Static name of the parameter.
* @param[in] _defaultValue Default value of the parameter.
* @param[in] _min Minumum value.
* @param[in] _max Maximum value.
* @param[in] _description description of the parameter.
*/
ParamRange(ewol::object::ParameterList& _objectLink,
const std::string& _name,
const TYPE& _defaultValue,
const TYPE& _min,
const TYPE& _max,
const std::string& _description = "") :
Parameter(_objectLink, _name),
m_value(_defaultValue),
m_min(_min),
m_max(_max),
m_default(_defaultValue) {
};
/**
* @brief Destructor.
*/
virtual ~ParamRange() { };
// herited methode
virtual std::string getType() const;
// 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);
// herited methode
virtual std::string getInfo() const;
// herited methode
virtual bool isDefault() const {
return m_value == m_default;
}
// herited methode
virtual void setDefault() {
m_value = m_default;
}
public:
/**
* @brief Get the value of the current parameter.
* @note For performence, this function must be inline
* @return the Reference value
*/
inline MY_TYPE& get() {
return m_value;
};
const inline MY_TYPE& get() const {
return m_value;
};
/**
* @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);
private:
/**
* @brief Get the string of the specify value.
* @return convetion of the velue in string.
*/
std::string getValueSpecific(const MY_TYPE& _valueRequested) const;
public:
/**
* @brief assignement operator.
* @param[in] newVal The new value of the parameter.
*/
const Param<MY_TYPE>& operator= (const MY_TYPE& _newVal) {
set(_newVal);
return *this;
};
operator MY_TYPE() const {
return m_value;
}
};
template<typename MY_TYPE> std::ostream& operator <<(std::ostream& _os, const ewol::object::Param<MY_TYPE>& _obj) {
_os << _obj.get();
return _os;
}
};
};
#endif

View File

@ -12,8 +12,12 @@
ewol::object::Parameter::Parameter(ewol::object::ParameterList& _objectLink, const std::string& _name) :
m_objectLink(_objectLink),
m_name(_name) {
// add a reference on the current parameter ...
_objectLink.parameterAdd(this);
}
void ewol::object::Parameter::notifyChange() const {
m_objectLink.onParameterChangeValue(ewol::object::ParameterRef(this));
}

View File

@ -15,34 +15,40 @@
namespace ewol {
namespace object {
class ParameterRef;
class Parameter {
private:
ewol::object::ParameterList& m_objectLink;
std::string m_name;
public:
Parameter(ewol::object::ParameterList& _objectLink, const std::string& _name);
virtual ~Parameter() { };
/**
* @brief call main class that parameterChange
*/
void notifyChange() const;
/**
* @brief Get the name of the parameter.
* @return The name of the parameter
*/
virtual std::string getName() {
virtual std::string getName() const {
return m_name;
};
/**
* @brief Get the type of the parameter in string mode.
* @return The string type of the parameter.
*/
virtual std::string getType() = 0;
virtual std::string getType() const = 0;
/**
* @brief Get the string of the current value of the parameter.
* @return The string description of the value.
*/
virtual std::string getString() = 0;
virtual std::string getString() const = 0;
/**
* @brief Get the string of the default value of the parameter.
* @return the string decription of the default value.
*/
virtual std::string getDefault() = 0;
virtual std::string getDefault() const = 0;
/**
* @brief Set a new value of the parameter (with string interface).
* @param[in] _newVal New value of the parameters.
@ -52,17 +58,31 @@ namespace ewol {
* @brief Description of the parameters.
* @return Descriptive information of the parameter (for remote UI).
*/
virtual std::string getInfo() = 0;
virtual std::string getInfo() const = 0;
/**
* @brief Check if the value is the default
* @return true : the vakue is the default one, false otherwise.
*/
virtual bool isDefault() = 0;
virtual bool isDefault() const = 0;
/**
* @brief Reset the value to the default value.
*/
virtual void setDefault() = 0;
};
class ParameterRef {
public:
const Parameter* m_ref;
ParameterRef(const Parameter* _ref) :
m_ref(_ref) {
// nothing to do ...
}
};
bool operator==(const ParameterRef& _obj, const Parameter& _obj2) noexcept {
return &_obj2 == _obj.m_ref;
}
bool operator==(const Parameter& _obj2, const ParameterRef& _obj) noexcept {
return &_obj2 == _obj.m_ref;
}
};
};

View File

@ -46,7 +46,7 @@ bool ewol::object::ParameterList::parameterSet(const std::string& _parameter, co
return false;
}
std::string ewol::object::ParameterList::parameterGet(const std::string& _parameter) {
std::string ewol::object::ParameterList::parameterGet(const std::string& _parameter) const {
for (auto &it : m_list) {
if( it != nullptr
&& it->getName() == _parameter) {
@ -56,7 +56,7 @@ std::string ewol::object::ParameterList::parameterGet(const std::string& _parame
return "???";
}
void ewol::object::ParameterList::parameterDisplay(bool _changeOnly) {
void ewol::object::ParameterList::parameterDisplay(bool _changeOnly) const {
EWOL_INFO(" Object parameters:");
for (auto &it : m_list) {
if(it != nullptr) {
@ -73,3 +73,17 @@ void ewol::object::ParameterList::parameterDisplay(bool _changeOnly) {
}
}
std::map<std::string, std::string> ewol::object::ParameterList::parameterGetAll(bool _notIfDefault) const {
std::map<std::string, std::string> out;
for (auto &it : m_list) {
if(it != nullptr) {
std::string paramName = it->getName();
std::string paramVal = it->getString();
if ( _notIfDefault == false
|| it->isDefault() == false) {
out.insert(std::make_pair(paramName, paramVal));
}
}
}
return out;
}

View File

@ -11,10 +11,12 @@
#define __EWOL_PARAMETER_LIST_H__
#include <vector>
#include <map>
namespace ewol {
namespace object {
class Parameter;
class ParameterRef;
class ParameterList {
friend class ewol::object::Parameter; // to register parameter in the list.
private:
@ -27,7 +29,7 @@ namespace ewol {
/**
* @brief Destructor.
*/
~ParameterList();
virtual ~ParameterList();
/**
* @brief Register a parameter class pointer in the List of parameters
* @note This class does not destroy the parameter pointer!!!
@ -52,12 +54,22 @@ namespace ewol {
* @param[in] parameter The parameter string name.
* @return The value of the parameter (string).
*/
std::string parameterGet(const std::string& _parameter);
std::string parameterGet(const std::string& _parameter) const;
/**
* @brief Display all the parameter value with there name.
* @param[in] changeOnly check at true if the user want to display only parameter that are not at default value.
*/
void parameterDisplay(bool _changeOnly = false);
void parameterDisplay(bool _changeOnly = false) const;
/**
* @brief Called when a parameter change value.
* @param[in] _paramPointer Pointer on the parameter (to know which parameter have change);
*/
virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer) { };
/**
* @brief Get All the parameter configuration:
* @return map on the parameters
*/
std::map<std::string, std::string> parameterGetAll(bool _notIfDefault=true) const;
};
};
};

View File

@ -21,12 +21,6 @@ const char* const ewol::widget::Button::eventEnter = "enter";
const char* const ewol::widget::Button::eventLeave = "leave";
const char* const ewol::widget::Button::eventValue = "value";
const char* const ewol::widget::Button::configToggle = "toggle";
const char* const ewol::widget::Button::configLock = "lock";
const char* const ewol::widget::Button::configEnableSingle = "enable-single";
const char* const ewol::widget::Button::configValue = "value";
const char* const ewol::widget::Button::configShaper = "shaper";
// DEFINE for the shader display system :
#define STATUS_UP (0)
@ -35,10 +29,11 @@ const char* const ewol::widget::Button::configShaper = "shaper";
#define STATUS_DOWN (3)
ewol::widget::Button::Button() :
m_value(false),
m_lock(ewol::widget::Button::lockNone),
m_toggleMode(false),
m_enableSingle(false),
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"),
m_enableSingle(*this, "enable-single", false, "If one element set in the Button ==> display only set"),
m_mouseHover(false),
m_buttonPressed(false),
m_selectableAreaPos(0,0),
@ -51,12 +46,12 @@ ewol::widget::Button::Button() :
addEventId(eventEnter);
addEventId(eventLeave);
addEventId(eventValue);
// add configuration
registerConfig(configToggle, "bool", nullptr, "The Button can toogle");
registerConfig(configValue, "bool", nullptr, "Basic value of the widget");
registerConfig(configEnableSingle, "bool", nullptr, "If one element set in the Button ==> display only set");
registerConfig(configLock, "list", "none;true;released;pressed", "Lock the button in a special state to permit changing state only by the coder");
registerConfig(configShaper, "string", nullptr, "the display name for config file");
// set property list:
m_lock.add(lockNone, "none");
m_lock.add(lockWhenPressed, "pressed");
m_lock.add(lockWhenReleased, "released");
m_lock.add(lockAccess, "access");
// shaper satatus update:
CheckStatus();
@ -68,7 +63,7 @@ ewol::widget::Button::Button() :
void ewol::widget::Button::init(const std::string& _shaperName) {
ewol::widget::Container2::init();
m_shaper.setSource(_shaperName);
m_shaper.get().setSource(_shaperName);
}
@ -79,12 +74,12 @@ ewol::widget::Button::~Button() {
void ewol::widget::Button::setShaperName(const std::string& _shaperName) {
EWOL_WARNING("set shaper name : '" << _shaperName << "'");
m_shaper.setSource(_shaperName);
m_shaper.get().setSource(_shaperName);
markToRedraw();
}
void ewol::widget::Button::calculateSize(const vec2& _availlable) {
ewol::Padding padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.get().getPadding();
ewol::Padding ret = calculateSizePadded(_availlable, padding);
//EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << "");
m_selectableAreaPos = vec2(ret.xLeft(), ret.yButtom());
@ -93,13 +88,13 @@ void ewol::widget::Button::calculateSize(const vec2& _availlable) {
void ewol::widget::Button::calculateMinMaxSize() {
ewol::Padding padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.get().getPadding();
calculateMinMaxSizePadded(padding);
}
void ewol::widget::Button::onDraw() {
// draw the shaaper (if needed indeed)
m_shaper.draw();
m_shaper.get().draw();
}
void ewol::widget::Button::onRegenerateDisplay() {
@ -107,8 +102,8 @@ void ewol::widget::Button::onRegenerateDisplay() {
if (needRedraw() == false) {
return;
}
ewol::Padding padding = m_shaper.getPadding();
m_shaper.setShape(vec2(0,0),
ewol::Padding padding = m_shaper.get().getPadding();
m_shaper.get().setShape(vec2(0,0),
m_size,
vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(),padding.yButtom()) ),
vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) ) );
@ -309,7 +304,7 @@ void ewol::widget::Button::CheckStatus() {
}
void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper.changeStatusIn(_newStatusId) ) {
if (true == m_shaper.get().changeStatusIn(_newStatusId) ) {
periodicCallEnable();
markToRedraw();
}
@ -317,7 +312,7 @@ void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) {
void ewol::widget::Button::periodicCall(const ewol::event::Time& _event) {
if (false == m_shaper.periodicCall(_event) ) {
if (false == m_shaper.get().periodicCall(_event) ) {
periodicCallDisable();
}
markToRedraw();
@ -393,7 +388,7 @@ bool ewol::widget::Button::onGetConfig(const char* _config, std::string& _result
return true;
}
if (_config == configShaper) {
_result = m_shaper.getSource();
_result = m_shaper.get().getSource();
return true;
}
if (_config == configEnableSingle) {

View File

@ -47,7 +47,7 @@ namespace ewol {
lockAccess, //!< all event are trashed == > acctivity of the button is disable
};
private:
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
ewol::object::Param<ewol::compositing::Shaper> m_shaper; //!< Compositing theme.
protected:
/**
* @brief Constructor
@ -67,7 +67,7 @@ namespace ewol {
*/
void setShaperName(const std::string& _shaperName);
protected:
bool m_value; //!< Current state of the button.
ewol::object::Param<bool> m_value; //!< Current state of the button.
public:
/**
* @brief set the currentValue of the Button (pressed or not)
@ -84,7 +84,7 @@ namespace ewol {
return m_value;
};
protected:
enum buttonLock m_lock; //!< Current lock state of the button.
ewol::object::ParamList<enum buttonLock> m_lock; //!< Current lock state of the button.
public:
/**
* @brief set the button lock state.
@ -99,7 +99,7 @@ namespace ewol {
return m_lock;
};
protected:
bool m_toggleMode; //!< The button is able to toggle.
ewol::object::Param<bool> m_toggleMode; //!< The button is able to toggle.
public:
/**
* @brief change the toggle mode.
@ -114,7 +114,7 @@ namespace ewol {
return m_toggleMode;
};
protected:
bool m_enableSingle; //!< When a single subwidget is set display all time it.
ewol::object::Param<bool> m_enableSingle; //!< When a single subwidget is set display all time it.
public:
/**
* @brief Chane the display single widget mode availlable.

View File

@ -86,13 +86,8 @@ std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::gravity _obj
#undef __class__
#define __class__ "Widget"
const char* const ewol::Widget::configFill = "fill";
const char* const ewol::Widget::configExpand = "expand";
const char* const ewol::Widget::configHide = "hide";
// TODO : Event config :
const char* const ewol::Widget::configFocus = "focus";
const char* const ewol::Widget::configMinSize = "min-size";
const char* const ewol::Widget::configMaxSize = "max-size";
const char* const ewol::Widget::configGravity = "gravity";
// configuration :
const char* const ewol::Widget::configAnnimationAddType = "annimation-start-type";
@ -111,12 +106,12 @@ ewol::Widget::Widget() :
m_offset(0,0),
m_zoom(1.0f),
m_origin(0,0),
m_userMinSize(vec2(0,0),ewol::Dimension::Pixel),
m_userMaxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),ewol::Dimension::Pixel),
m_userExpand(false,false),
m_userFill(*this, "fill", bvec2(false,false)),
m_hide(false),
m_gravity(ewol::gravityButtomLeft),
m_userMinSize(*this, "min-size", ewol::Dimension(vec2(0,0),ewol::Dimension::Pixel), "User minimum size"),
m_userMaxSize(*this, "max-size", ewol::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),ewol::Dimension::Pixel), "User maximum size"),
m_userExpand(*this, "expand", bvec2(false,false), "Request the widget Expand size wile space is available"),
m_userFill(*this, "fill", bvec2(false,false), "Fill the widget available size"),
m_hide(*this, "hide", false, "The widget start hided"),
m_gravity(*this, "gravity", ewol::gravityButtomLeft, "Gravity orientation"),
m_hasFocus(false),
m_canFocus(false),
m_limitMouseEvent(3),
@ -127,24 +122,37 @@ ewol::Widget::Widget() :
m_grabCursor(false),
m_cursorDisplay(ewol::context::cursorArrow),
m_annimationMode(annimationModeDisable),
m_annimationratio(0.0f) {
m_annimationratio(0.0f),
m_annimationTypeStart(*this, "annimation-start-type", "Annimation type, when adding/show a widget"),
m_annimationTimeStart(*this, "annimation-start-time", "Annimation time in second, when adding/show a widget", 0.2f, 0.0f, 200.0f),
m_annimationTypeStop(*this, "annimation-stop-type", "Annimation type, when removing/hide a widget"),
m_annimationTimeStop(*this, "annimation-stop-time", "Annimation time in second, when removing/hide a widget", 0.2f, 0.0f, 200.0f){
m_annimationType[0] = nullptr;
m_annimationType[1] = nullptr;
m_annimationTime[0] = 0.1f; // annimation will be 100ms at the first state
m_annimationTime[1] = 0.1f; // annimation will be 100ms at the first state
addObjectType("ewol::Widget");
// set all the config in the list :
registerConfig(ewol::Widget::configFill, "bvec2", nullptr, "Fill the widget available size");
registerConfig(ewol::Widget::configExpand, "bvec2", nullptr, "Request the widget Expand size wile space is available");
registerConfig(ewol::Widget::configHide, "bool", nullptr, "The widget start hided");
registerConfig(ewol::Widget::configFocus, "bool", nullptr, "The widget request focus");
registerConfig(ewol::Widget::configMinSize, "dimension", nullptr, "User minimum size");
registerConfig(ewol::Widget::configMaxSize, "dimension", nullptr, "User maximum size");
registerConfig(ewol::Widget::configGravity, "list", "center;top-left;top;top-right;right;buttom-right;buttom;buttom-left;left", "User maximum size");
registerConfig(ewol::Widget::configAnnimationAddType, "list", nullptr /* no control */, "Annimation type, when adding/show a widget");
registerConfig(ewol::Widget::configAnnimationAddTime, "float", nullptr /* no control */, "Annimation time in second, when adding/show a widget");
registerConfig(ewol::Widget::configAnnimationRemoveType, "list", nullptr /* no control */, "Annimation type, when removing/hide a widget");
registerConfig(ewol::Widget::configAnnimationRemoveTime, "float", nullptr /* no control */, "Annimation time in second, when removing/hide a widget");
// TODO : Set a static interface for list ==> this methode create a multiple allocation
m_gravity.add(ewol::gravityCenter, "center");
m_gravity.add(ewol::gravityTopLeft, "top-left");
m_gravity.add(ewol::gravityTop, "top");
m_gravity.add(ewol::gravityTopRight, "top-right");
m_gravity.add(ewol::gravityRight, "right");
m_gravity.add(ewol::gravityButtomRight, "buttom-right");
m_gravity.add(ewol::gravityButtom, "buttom");
m_gravity.add(ewol::gravityButtomLeft, "buttom-left");
m_gravity.add(ewol::gravityLeft, "left");
m_annimationTypeStart.add(0, "none");
m_annimationTypeStart.setDefault(0);
m_annimationTypeStop.add(0, "none");
m_annimationTypeStop.setDefault(0);
addEventId(eventAnnimationStart);
addEventId(eventAnnimationRatio);
addEventId(eventAnnimationStop);

View File

@ -240,7 +240,7 @@ namespace ewol {
*/
virtual vec2 getOrigin();
protected:
ewol::Dimension m_userMinSize; //!< user define the minimum size of the widget
ewol::object::Param<ewol::Dimension> m_userMinSize; //!< user define the minimum size of the widget
public:
/**
* @brief User set the minimum size he want to set the display
@ -256,7 +256,7 @@ namespace ewol {
* @return the size requested
*/
const ewol::Dimension& getMinSize() {
return m_userMinSize;
return m_userMinSize.get();
};
/**
* @brief Check if the current min size is compatible with the user minimum size
@ -265,7 +265,7 @@ namespace ewol {
*/
virtual void checkMinSize();
protected:
ewol::Dimension m_userMaxSize; //!< user define the maximum size of the widget
ewol::object::Param<ewol::Dimension> m_userMaxSize; //!< user define the maximum size of the widget
public:
/**
* @brief User set the maximum size he want to set the display
@ -281,7 +281,7 @@ namespace ewol {
* @return the size requested
*/
const ewol::Dimension& getMaxSize() {
return m_userMaxSize;
return m_userMaxSize.get();
};
/**
* @brief Check if the current max size is compatible with the user maximum size
@ -290,7 +290,7 @@ namespace ewol {
*/
virtual void checkMaxSize();
protected:
bvec2 m_userExpand;
ewol::object::Param<bvec2> m_userExpand;
public:
/**
* @brief set the expend capabilities (x&y)
@ -332,7 +332,7 @@ namespace ewol {
*/
const bvec2& canFill();
protected:
bool m_hide; //!< hide a widget on the display
ewol::object::Param<bool> m_hide; //!< hide a widget on the display
public:
/**
* @brief set the widget hidden
@ -351,7 +351,7 @@ namespace ewol {
};
protected:
enum ewol::gravity m_gravity; //!< Gravity of the widget
ewol::object::Param<enum ewol::gravity> m_gravity; //!< Gravity of the widget
public:
/**
* @brief set the widget gravity
@ -370,7 +370,7 @@ namespace ewol {
// ----------------------------------------------------------------------------------------------------------------
private:
bool m_hasFocus; //!< set the focus on this widget
bool m_canFocus; //!< the focus can be done on this widget
ewol::object::Param<bool> m_canFocus; //!< the focus can be done on this widget
public:
/**
* @brief get the focus state of the widget
@ -707,11 +707,6 @@ namespace ewol {
* Annimation section :
*/
public:
// configuration :
static const char* const configAnnimationAddType;
static const char* const configAnnimationAddTime;
static const char* const configAnnimationRemoveType;
static const char* const configAnnimationRemoveTime;
// event generated :
static const char* const eventAnnimationStart; //!< event when start annimation
static const char* const eventAnnimationRatio; //!< event when % of annimation change (integer)
@ -724,11 +719,11 @@ namespace ewol {
};
enum annimationMode m_annimationMode; //!< true when the annimation is started
float m_annimationratio; //!< Ratio of the annimation [0..1]
private:
std::vector<const char*> m_annimationList[2]; //!< List of all annimation type ADD
protected:
const char* m_annimationType[2]; //!< type of start annimation (default nullptr ==> no annimation)
float m_annimationTime[2]; //!< time to produce start annimation
ewol::object::ParamList<int32_t> m_annimationTypeStart; //!< type of start annimation
ewol::object::Param<float> m_annimationTimeStart; //!< time to produce start annimation
ewol::object::ParamList<int32_t> m_annimationTypeStop; //!< type of start annimation
ewol::object::Param<float> m_annimationTimeStop; //!< time to produce start annimation
protected:
/**
* @brief Add a annimation type capabilities of this widget.