From e1a0b972cdb44f0a11ae8cda890e9c757b889356 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 19 Aug 2014 23:57:31 +0200 Subject: [PATCH 01/22] Update version tag : 0.9.2-dev --- sources/tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tag b/sources/tag index 899f24fc..c50fb225 100644 --- a/sources/tag +++ b/sources/tag @@ -1 +1 @@ -0.9.0 \ No newline at end of file +0.9.2-dev \ No newline at end of file From 749b7a09c09d659415831464ab9503f620aeff3c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 19 Aug 2014 23:26:51 +0200 Subject: [PATCH 02/22] [DEV] Start dev of the signal system (nearly compatible with old system) --- sources/ewol/object/Object.cpp | 12 +-- sources/ewol/object/Object.h | 77 +++--------------- sources/ewol/object/Param.h | 2 +- sources/ewol/object/Signal.cpp | 0 sources/ewol/object/Signal.h | 125 +++++++++++++++++++++++++++++ sources/ewol/object/SignalBase.cpp | 23 ++++++ sources/ewol/object/SignalBase.h | 48 +++++++++++ sources/ewol/object/SignalList.cpp | 88 ++++++++++++++++++++ sources/ewol/object/SignalList.h | 113 ++++++++++++++++++++++++++ sources/ewol/widget/Button.cpp | 1 + sources/ewol/widget/Button.h | 2 + sources/lutin_ewol.py | 5 +- 12 files changed, 422 insertions(+), 74 deletions(-) create mode 100644 sources/ewol/object/Signal.cpp create mode 100644 sources/ewol/object/Signal.h create mode 100644 sources/ewol/object/SignalBase.cpp create mode 100644 sources/ewol/object/SignalBase.h create mode 100644 sources/ewol/object/SignalList.cpp create mode 100644 sources/ewol/object/SignalList.h diff --git a/sources/ewol/object/Object.cpp b/sources/ewol/object/Object.cpp index 66f5754a..60c77947 100644 --- a/sources/ewol/object/Object.cpp +++ b/sources/ewol/object/Object.cpp @@ -57,8 +57,6 @@ ewol::Object::Object() : ewol::Object::~Object() { EWOL_DEBUG("delete Object : [" << m_uniqueId << "] : " << getTypeDescription()); - m_externEvent.clear(); - m_availlableEventId.clear(); m_uniqueId = -1; } @@ -109,6 +107,8 @@ bool ewol::Object::isTypeCompatible(const std::string& _type) { return false; } +/* + void ewol::Object::addEventId(const char * _generateEventId) { for (auto &it : m_availlableEventId) { if (std::string(it) == _generateEventId) { @@ -155,6 +155,7 @@ void ewol::Object::generateEventId(const char * _generateEventId, const std::str EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->removObject() which is asynchronous"); } } +*/ void ewol::Object::sendMultiCast(const char* const _messageId, const std::string& _data) { if (m_objectHasBeenInit == false) { @@ -175,7 +176,7 @@ void ewol::Object::registerMultiCast(const char* const _messageId) { } getMultiCast().add(shared_from_this(), _messageId); } - +/* void ewol::Object::registerOnEvent(const std::shared_ptr& _destinationObject, const char * _eventId, const char * _eventIdgenerated, @@ -263,6 +264,7 @@ void ewol::Object::unRegisterOnEvent(const std::shared_ptr& _desti } } } +*/ bool ewol::Object::loadXML(exml::Element* _node) { if (nullptr == _node) { @@ -313,7 +315,7 @@ ewol::object::MultiCast& ewol::Object::getMultiCast() const { ewol::Context& ewol::Object::getContext() const { return ewol::getContext(); } - +/* void ewol::Object::registerOnObjectEvent(const std::shared_ptr& _destinationObject, const std::string& _objectName, const char * _eventId, @@ -327,7 +329,7 @@ void ewol::Object::registerOnObjectEvent(const std::shared_ptr& _d EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Can not register event : \"" << _eventId << "\" the object named=\"" << _objectName << "\" does not exist"); } } - +*/ std::shared_ptr ewol::Object::getObjectNamed(const std::string& _objectName) const { return getObjectManager().getObjectNamed(_objectName); } diff --git a/sources/ewol/object/Object.h b/sources/ewol/object/Object.h index 0ee75c03..1e7d4407 100644 --- a/sources/ewol/object/Object.h +++ b/sources/ewol/object/Object.h @@ -31,6 +31,7 @@ namespace ewol { #include #include #include +#include #define DECLARE_FACTORY(className) \ template static std::shared_ptr create( T&& ... all ) { \ @@ -47,24 +48,13 @@ namespace ewol { } namespace ewol { - namespace object { - /** - * local class for event generation - * @not-in-doc - */ - class EventExtGen { - public: - const char* localEventId; //!< local event Id generation - std::weak_ptr destObject; //!< destination widget that might be call - const char* destEventId; //!< generated event ID on the distant widget - std::string overloadData; //!< sometimes the user prefer to receive some specific data on an event (instead of the one sed by the widget) - }; - } /** * @brief Basic message classes for ewol system * this class mermit at every Object to communicate between them. */ - class Object : public std::enable_shared_from_this, public ewol::object::ParameterList { + class Object : public std::enable_shared_from_this, + public ewol::object::ParameterList, + public ewol::object::SignalList { private: static size_t m_valUID; //!< Static used for the unique ID definition private: @@ -148,58 +138,23 @@ namespace ewol { int32_t getId(){ return m_uniqueId; }; - private: - std::vector m_externEvent; //!< Generic list of event generation for output link - std::vector m_availlableEventId; //!< List of all event availlable for this widget + // TODO : Remove this section : protected: - /** - * @brief add a specific event Id in the list to prevent wrong link on a Object - * @param[in] _generateEventId event Id to add - */ - void addEventId(const char * _generateEventId); - /** - * @brief generate event on all registered Object - * @param[in] _generateEventId event Id that is curetly generated - * @param[in] _data data associated with the event - */ - void generateEventId(const char * _generateEventId, const std::string& _data = ""); /** * @brief generate Multicast event on all Object requested the event * @param[in] _messageId Event Id that is generated * @param[in] _data String that is send at all the destinations */ + // TODO : Remove this ... Not really needed : user can simply create an object and send event with it ... void sendMultiCast(const char* const _messageId, const std::string& _data = ""); /** * @brief Register of the arrival of a Multicast message * @param[in] _messageId Event Id waiting for... */ + // TODO : Remove this ... void registerMultiCast(const char* const _messageId); public: - /** - * @brief Register an Object over an other to get event on the second... - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _eventId Event generate inside the object (note : "*" event register on all event generated ) - * @param[in] _eventIdgenerated event generated when call the distant Object.onReceiveMessage(...) - * @param[in] _overloadData When the user prever to receive a data specificly for this event ... - */ - void registerOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId, - const char * _eventIdgenerated = nullptr, - const std::string& _overloadData = ""); - /** - * @brief Un-Register an Object over an other. - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object) - */ - void unRegisterOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId = nullptr); - /** - * @brief Receive a message from an other Object with a specific eventId and data - * @param[in] _msg Message handle - */ - virtual void onReceiveMessage(const ewol::object::Message& _msg) { }; - public: - // TODO : Rework the position on this function ... + // TODO : Rework the position on this function ... This is a convignet function ... bool parameterSetOnWidgetNamed(const std::string& _objectName, const std::string& _config, const std::string& _value); protected: ewol::object::Param m_name; //!< name of the element ... @@ -267,20 +222,6 @@ namespace ewol { bool getStatusResource() const { return m_isResource; } - /** - * @brief Register an Event an named widget. @see registerOnEvent - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _objectName Name of the object. - * @param[in] _eventId Event generate inside the object. - * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) - * @param[in] _overloadData When the user prever to receive a data specificly for this event ... - * @note : To used when NOT herited from this object. - */ - void registerOnObjectEvent(const std::shared_ptr& _destinationObject, - const std::string& _objectName, - const char * _eventId, - const char * _eventIdgenerated = nullptr, - const std::string& _overloadData=""); /** * @brief Retrive an object with his name (in the global list) * @param[in] _name Name of the object @@ -291,6 +232,8 @@ namespace ewol { }; +//#include + #endif diff --git a/sources/ewol/object/Param.h b/sources/ewol/object/Param.h index f2da9ff4..77bcee18 100644 --- a/sources/ewol/object/Param.h +++ b/sources/ewol/object/Param.h @@ -135,7 +135,7 @@ namespace ewol { } }; - template std::ostream& operator <<(std::ostream& _os, const ewol::object::Param& _obj) { + template std::ostream& operator <<(std::ostream& _os, const ewol::object::Param& _obj) { _os << _obj.get(); return _os; } diff --git a/sources/ewol/object/Signal.cpp b/sources/ewol/object/Signal.cpp new file mode 100644 index 00000000..e69de29b diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h new file mode 100644 index 00000000..11c1d4f0 --- /dev/null +++ b/sources/ewol/object/Signal.h @@ -0,0 +1,125 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include + +#ifndef __EWOL_SIGNAL_H__ +#define __EWOL_SIGNAL_H__ + +#include +#include +#include + + +namespace ewol { + namespace object { + template class Signal : public SignalBase { + private: + //std::vector> m_callerList; + std::vector, const char*, std::string>> m_serializedCallerList; + 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. + */ + Signal(ewol::object::SignalList& _objectLink, + const std::string& _name, + const std::string& _description = "") : + SignalBase(_objectLink, _name, _description) { + + }; + /** + * @brief Destructor. + */ + virtual ~Signal() { }; + + const std::string& getName() { + return m_name; + } + const std::string& getDescription() { + return m_description; + } + + bool connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { + m_serializedCallerList.push_back(std::make_tuple(_obj, _destId, _data)); + } + bool release(std::shared_ptr _obj) { + for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { + if (std::get<0>(it) == _obj) { + m_serializedCallerList.erase(it); + it = m_serializedCallerList.begin(); + } + } + } + /* + bool emitString(const std::shared_ptr& _source, const std::string& _data) { + // note : this can not emit on function .... + for (auto &it : m_serializedCallerList) { + std::shared_ptr destObject = std::get<0>(it).lock(); + if (destObject == nullptr) { + // TODO : Remove instance ... + EWOL_VERBOSE(" nullptr dest"); + continue; + } + const char* eventId = m_name.c_str(); + if (std::get<1>(it) != nullptr) { + eventId = std::get<1>(it); + } + if (std::get<2>(it).size() <= 0){ + ewol::object::Message tmpMsg(_source, eventId, _data); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } else { + // set the user requested data ... + ewol::object::Message tmpMsg(_source, eventId, std::get<2>(it)); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } + } + } + */ + + bool emit(const std::shared_ptr& _source, const T& _data) { + // note : this can not emit on function .... + std::string stringData; + if (m_serializedCallerList.size()>0 ) { + stringData = etk::to_string(_data); + } + for (auto &it : m_serializedCallerList) { + std::shared_ptr destObject = std::get<0>(it).lock(); + if (destObject == nullptr) { + // TODO : Remove instance ... + EWOL_VERBOSE(" nullptr dest"); + continue; + } + const char* eventId = m_name.c_str(); + if (std::get<1>(it) != nullptr) { + eventId = std::get<1>(it); + } + if (std::get<2>(it).size() <= 0){ + ewol::object::Message tmpMsg(_source, eventId, stringData); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } else { + // set the user requested data ... + ewol::object::Message tmpMsg(_source, eventId, std::get<2>(it)); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } + } + } + }; + + }; +}; +#endif diff --git a/sources/ewol/object/SignalBase.cpp b/sources/ewol/object/SignalBase.cpp new file mode 100644 index 00000000..66cd59a9 --- /dev/null +++ b/sources/ewol/object/SignalBase.cpp @@ -0,0 +1,23 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#include +#include + +ewol::object::SignalBase::SignalBase(ewol::object::SignalList& _objectLink, + const std::string& _name, + const std::string& _description) : + m_objectLink(_objectLink), + m_name(_name), + m_description(_description) { + // add a reference on the current signal ... + m_objectLink.signalAdd(this); +} diff --git a/sources/ewol/object/SignalBase.h b/sources/ewol/object/SignalBase.h new file mode 100644 index 00000000..535ed751 --- /dev/null +++ b/sources/ewol/object/SignalBase.h @@ -0,0 +1,48 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#ifndef __EWOL_SIGNAL_BASE_H__ +#define __EWOL_SIGNAL_BASE_H__ + +#include +#include +#include + + +namespace ewol { + namespace object { + class SignalBase { + protected: + ewol::object::SignalList& m_objectLink; + std::string m_name; + std::string m_description; + 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] _description description of the parameter. + */ + SignalBase(ewol::object::SignalList& _objectLink, + const std::string& _name, + const std::string& _description = ""); + /** + * @brief Destructor. + */ + virtual ~SignalBase() { }; + + const std::string& getName() { + return m_name; + } + const std::string& getDescription() { + return m_description; + } + }; + }; +}; +#endif diff --git a/sources/ewol/object/SignalList.cpp b/sources/ewol/object/SignalList.cpp new file mode 100644 index 00000000..ce1c8498 --- /dev/null +++ b/sources/ewol/object/SignalList.cpp @@ -0,0 +1,88 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#include +#include + +ewol::object::SignalList::SignalList() { + +} + +ewol::object::SignalList::~SignalList() { + m_list.clear(); +} + +// note this pointer is not allocated and not free at the end of the class +void ewol::object::SignalList::signalAdd(SignalBase* _pointerOnSignal) { + if (_pointerOnSignal == nullptr) { + EWOL_ERROR("Try to link a nullptr parameters"); + return; + } + m_list.push_back(_pointerOnSignal); +} + +#if 0 +// Note no lock is needed at this level, because the lock is done is the upper elements ... +// the parameter set might be done with a pool of parameter, allone, the overhed is bigger ... +bool ewol::object::SignalList::parameterSet(const std::string& _parameter, const std::string& _value) { + for (auto &it : m_list) { + if( it != nullptr + && it->getName() == _parameter) { + it->setString(_value); + return true; + } + } + // can not find the parameters : + return false; +} + +std::string ewol::object::SignalList::parameterGet(const std::string& _parameter) const { + for (auto &it : m_list) { + if( it != nullptr + && it->getName() == _parameter) { + return it->getString(); + } + } + return "???"; +} + +void ewol::object::SignalList::parameterDisplay(bool _changeOnly) const { + EWOL_INFO(" Object parameters:"); + for (auto &it : m_list) { + if(it != nullptr) { + std::string paramName = it->getName(); + std::string paramVal = it->getString(); + std::string paramInfo = it->getInfo(); + if ( _changeOnly == false + || it->isDefault() == false) { + EWOL_INFO(" | param='" << paramName << "' value=" << paramVal << " (" << paramInfo << ")"); + } + } else { + EWOL_INFO(" | param=nullptr"); + } + } +} + +std::map ewol::object::SignalList::parameterGetAll(bool _notIfDefault) const { + std::map 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; +} +#endif diff --git a/sources/ewol/object/SignalList.h b/sources/ewol/object/SignalList.h new file mode 100644 index 00000000..38924010 --- /dev/null +++ b/sources/ewol/object/SignalList.h @@ -0,0 +1,113 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + + +#ifndef __EWOL_SIGNAL_LIST_H__ +#define __EWOL_SIGNAL_LIST_H__ + +#include +#include + +namespace ewol { + namespace object { + class SignalBase; + class SignalList { + friend class ewol::object::SignalBase; // to register parameter in the list. + private: + std::vector m_list; //!< list of availlable Parameters + public: + /** + * @brief Constructor. + */ + SignalList(); + /** + * @brief Destructor. + */ + virtual ~SignalList(); + /** + * @brief Register a parameter class pointer in the List of parameters + * @note This class does not destroy the parameter pointer!!! + * @param[in] pointerOnParameter Pointer on the parameter that might be added. + */ + void signalAdd(SignalBase* _pointerOnParameter); + #if 0 + /** + * @brief Set a specific value to the parameter reference name. + * @param[in] parameter The parameter string name. + * @param[in] value The new value of the parameter (string). + * @return true Parameter update. + * @return false Parameter not update. + */ + bool parameterSet(const std::string& _parameter, const std::string& _value); + /** + * @brief Get a specific value of the parameter reference name. + * @param[in] parameter The parameter string name. + * @return The value of the parameter (string). + */ + 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) 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 parameterGetAll(bool _notIfDefault=true) const; + #endif + /** + * @brief Register an Event an named widget. @see registerOnEvent + * @param[in] _destinationObject pointer on the object that might be call when an event is generated + * @param[in] _objectName Name of the object. + * @param[in] _eventId Event generate inside the object. + * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) + * @param[in] _overloadData When the user prever to receive a data specificly for this event ... + * @note : To used when NOT herited from this object. + */ + // TODO : Change name : registerOnSignal + void registerOnObjectEvent(const std::shared_ptr& _destinationObject, + const std::string& _objectName, + const char * _eventId, + const char * _eventIdgenerated = nullptr, + const std::string& _overloadData=""); + + public: + /** + * @brief Register an Object over an other to get event on the second... + * @param[in] _destinationObject pointer on the object that might be call when an event is generated + * @param[in] _eventId Event generate inside the object (note : "*" event register on all event generated ) + * @param[in] _eventIdgenerated event generated when call the distant Object.onReceiveMessage(...) + * @param[in] _overloadData When the user prever to receive a data specificly for this event ... + */ + void registerOnEvent(const std::shared_ptr& _destinationObject, + const char * _eventId, + const char * _eventIdgenerated = nullptr, + const std::string& _overloadData = ""); + /** + * @brief Un-Register an Object over an other. + * @param[in] _destinationObject pointer on the object that might be call when an event is generated + * @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object) + */ + void unRegisterOnEvent(const std::shared_ptr& _destinationObject, + const char * _eventId = nullptr); + /** + * @brief Receive a message from an other Object with a specific eventId and data + * @param[in] _msg Message handle + */ + virtual void onReceiveMessage(const ewol::object::Message& _msg) { }; + }; + }; +}; + +#endif diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index 13b59cab..86197e9e 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -29,6 +29,7 @@ const char* const ewol::widget::Button::eventValue = "value"; #define STATUS_DOWN (3) ewol::widget::Button::Button() : + signalPressed(*this, "pressed", "Button is pressed"), 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"), diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index 3a8498e5..ed6a8cbe 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -17,6 +17,7 @@ #include #include #include +#include @@ -29,6 +30,7 @@ namespace ewol { class Button : public ewol::widget::Container2 { public: // Event list of properties + ewol::object::Signal signalPressed; static const char* const eventPressed; static const char* const eventDown; static const char* const eventUp; diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index 3044e27d..aed548ef 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -97,7 +97,10 @@ def create(target): 'ewol/object/ParameterList.cpp', 'ewol/object/ParamList.cpp', 'ewol/object/Param.cpp', - 'ewol/object/ParamRange.cpp' + 'ewol/object/ParamRange.cpp', + 'ewol/object/SignalList.cpp', + 'ewol/object/SignalBase.cpp', + 'ewol/object/Signal.cpp' ]) # OpenGL interface : From 006ed42f3803f6a472075a92ba21bdeb7de698ad Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 19 Aug 2014 22:57:39 +0200 Subject: [PATCH 03/22] [DEV] signal is better --- sources/ewol/object/Signal.h | 74 +++++++++++++++++++++++++++++++++++- sources/ewol/widget/Button.h | 11 +++--- 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index 11c1d4f0..61553b18 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -52,6 +52,7 @@ namespace ewol { bool connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { m_serializedCallerList.push_back(std::make_tuple(_obj, _destId, _data)); + return true; } bool release(std::shared_ptr _obj) { for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { @@ -88,7 +89,6 @@ namespace ewol { } } */ - bool emit(const std::shared_ptr& _source, const T& _data) { // note : this can not emit on function .... std::string stringData; @@ -120,6 +120,78 @@ namespace ewol { } }; + template<> class Signal : public SignalBase { + private: + //std::vector> m_callerList; + std::vector, const char*, std::string>> m_serializedCallerList; + 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. + */ + Signal(ewol::object::SignalList& _objectLink, + const std::string& _name, + const std::string& _description = "") : + SignalBase(_objectLink, _name, _description) { + + }; + /** + * @brief Destructor. + */ + virtual ~Signal() { }; + + const std::string& getName() { + return m_name; + } + const std::string& getDescription() { + return m_description; + } + + bool connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { + m_serializedCallerList.push_back(std::make_tuple(_obj, _destId, _data)); + return true; + } + bool release(std::shared_ptr _obj) { + for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { + if (std::get<0>(it) == _obj) { + m_serializedCallerList.erase(it); + it = m_serializedCallerList.begin(); + } + } + } + bool emit(const std::shared_ptr& _source) { + // note : this can not emit on function .... + std::string stringData; + for (auto &it : m_serializedCallerList) { + std::shared_ptr destObject = std::get<0>(it).lock(); + if (destObject == nullptr) { + // TODO : Remove instance ... + EWOL_VERBOSE(" nullptr dest"); + continue; + } + const char* eventId = m_name.c_str(); + if (std::get<1>(it) != nullptr) { + eventId = std::get<1>(it); + } + if (std::get<2>(it).size() <= 0){ + ewol::object::Message tmpMsg(_source, eventId, stringData); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } else { + // set the user requested data ... + ewol::object::Message tmpMsg(_source, eventId, std::get<2>(it)); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } + } + } + }; + }; }; #endif diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index ed6a8cbe..6f5c60db 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -31,12 +31,11 @@ namespace ewol { public: // Event list of properties ewol::object::Signal signalPressed; - static const char* const eventPressed; - static const char* const eventDown; - static const char* const eventUp; - static const char* const eventEnter; - static const char* const eventLeave; - static const char* const eventValue; + ewol::object::Signal signalDown; + ewol::object::Signal signalUp; + ewol::object::Signal signalEnter; + ewol::object::Signal signalLeave; + ewol::object::Signal signalValue; enum buttonLock{ lockNone, //!< normal status of the button lockWhenPressed, //!< When the state is set in pressed, the status stay in this one From 3175657fed772932fcfd3463b2bbe01613a798fe Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 20 Aug 2014 22:34:31 +0200 Subject: [PATCH 04/22] [DEV] rework signal interface (step 1 normalisation) --- external/ege | 2 +- sources/ewol/object/Object.cpp | 104 ----------------- sources/ewol/object/Signal.h | 73 ++++++------ sources/ewol/object/SignalBase.cpp | 6 + sources/ewol/object/SignalBase.h | 7 +- sources/ewol/object/SignalList.cpp | 128 +++++++++++++-------- sources/ewol/object/SignalList.h | 32 +----- sources/ewol/widget/Button.cpp | 42 +++---- sources/ewol/widget/Button.h | 4 +- sources/ewol/widget/ButtonColor.cpp | 9 +- sources/ewol/widget/ButtonColor.h | 3 +- sources/ewol/widget/CheckBox.cpp | 36 +++--- sources/ewol/widget/CheckBox.h | 11 +- sources/ewol/widget/ColorBar.cpp | 10 +- sources/ewol/widget/ColorBar.h | 3 +- sources/ewol/widget/Entry.cpp | 22 ++-- sources/ewol/widget/Entry.h | 8 +- sources/ewol/widget/Image.cpp | 6 +- sources/ewol/widget/Image.h | 3 +- sources/ewol/widget/Joystick.cpp | 18 ++- sources/ewol/widget/Joystick.h | 9 +- sources/ewol/widget/Label.cpp | 6 +- sources/ewol/widget/Label.h | 3 +- sources/ewol/widget/ListFileSystem.cpp | 34 +++--- sources/ewol/widget/ListFileSystem.h | 9 +- sources/ewol/widget/Menu.cpp | 8 +- sources/ewol/widget/Slider.cpp | 8 +- sources/ewol/widget/Slider.h | 3 +- sources/ewol/widget/WSlider.cpp | 12 +- sources/ewol/widget/WSlider.h | 5 +- sources/ewol/widget/Widget.cpp | 12 +- sources/ewol/widget/Widget.h | 7 +- sources/ewol/widget/meta/ColorChooser.cpp | 12 +- sources/ewol/widget/meta/ColorChooser.h | 3 +- sources/ewol/widget/meta/FileChooser.cpp | 25 ++-- sources/ewol/widget/meta/FileChooser.h | 5 +- sources/ewol/widget/meta/Parameter.cpp | 12 +- sources/ewol/widget/meta/Parameter.h | 2 +- sources/ewol/widget/meta/ParameterList.cpp | 8 +- sources/ewol/widget/meta/ParameterList.h | 2 +- sources/ewol/widget/meta/StdPopUp.cpp | 2 +- 41 files changed, 281 insertions(+), 433 deletions(-) diff --git a/external/ege b/external/ege index d22d7ade..87b68c40 160000 --- a/external/ege +++ b/external/ege @@ -1 +1 @@ -Subproject commit d22d7ade7310428a294cc8b057d9ab2563afc9b6 +Subproject commit 87b68c408e3bceff1923e84d2e08fcee9d868561 diff --git a/sources/ewol/object/Object.cpp b/sources/ewol/object/Object.cpp index 60c77947..3c3033f9 100644 --- a/sources/ewol/object/Object.cpp +++ b/sources/ewol/object/Object.cpp @@ -176,95 +176,6 @@ void ewol::Object::registerMultiCast(const char* const _messageId) { } getMultiCast().add(shared_from_this(), _messageId); } -/* -void ewol::Object::registerOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId, - const char * _eventIdgenerated, - const std::string& _overloadData) { - if (nullptr == _destinationObject) { - EWOL_ERROR("Input ERROR nullptr pointer Object ..."); - return; - } - if (nullptr == _eventId) { - EWOL_ERROR("Input ERROR nullptr pointer Event Id..."); - return; - } - if ( _eventId[0] == '*' - && _eventId[1] == '\0') { - EWOL_VERBOSE("Register on all event ..."); - for(auto &it : m_availlableEventId) { - ewol::object::EventExtGen tmpEvent; - tmpEvent.localEventId = it; - tmpEvent.destObject = _destinationObject; - tmpEvent.overloadData = _overloadData; - if (nullptr != _eventIdgenerated) { - tmpEvent.destEventId = _eventIdgenerated; - } else { - tmpEvent.destEventId = it; - } - m_externEvent.push_back(tmpEvent); - } - return; - } - // check if event existed : - bool findIt = false; - for(auto &it : m_availlableEventId) { - if (it == _eventId) { - findIt = true; - break; - } - } - if (false == findIt) { - EWOL_VERBOSE("Try to register with a NON direct string name"); - for(auto &it : m_availlableEventId) { - if (0 == strncmp(it, _eventId, 1024)) { - findIt = true; - _eventId = it; - EWOL_VERBOSE("find event ID : '" << _eventId << "' ==> '" << _eventIdgenerated << "'"); - break; - } - } - } - if (false == findIt) { - EWOL_ERROR("Can not register event on this Type=" << getObjectType() << " event=\"" << _eventId << "\" == > unknow event"); - return; - } - ewol::object::EventExtGen tmpEvent; - tmpEvent.localEventId = _eventId; - tmpEvent.destObject = _destinationObject; - tmpEvent.overloadData = _overloadData; - if (nullptr != _eventIdgenerated) { - tmpEvent.destEventId = _eventIdgenerated; - } else { - tmpEvent.destEventId = _eventId; - } - m_externEvent.push_back(tmpEvent); -} - -void ewol::Object::unRegisterOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId) { - if (_destinationObject == nullptr) { - EWOL_ERROR("Input ERROR nullptr pointer Object ..."); - return; - } - // check if event existed : - auto it(m_externEvent.begin()); - while(it != m_externEvent.end()) { - std::shared_ptr obj = it->destObject.lock(); - if (obj == nullptr) { - m_externEvent.erase(it); - it = m_externEvent.begin(); - } else if ( obj == _destinationObject - && it->localEventId == _eventId) { - m_externEvent.erase(it); - it = m_externEvent.begin(); - EWOL_INFO("[" << getId() << "] Remove extern event : to object id=" << _destinationObject->getId() << " event=" << _eventId); - } else { - ++it; - } - } -} -*/ bool ewol::Object::loadXML(exml::Element* _node) { if (nullptr == _node) { @@ -315,21 +226,6 @@ ewol::object::MultiCast& ewol::Object::getMultiCast() const { ewol::Context& ewol::Object::getContext() const { return ewol::getContext(); } -/* -void ewol::Object::registerOnObjectEvent(const std::shared_ptr& _destinationObject, - const std::string& _objectName, - const char * _eventId, - const char * _eventIdgenerated, - const std::string& _overloadData) { - std::shared_ptr tmpObject = getObjectManager().getObjectNamed(_objectName); - if (nullptr != tmpObject) { - EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'"); - tmpObject->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData); - } else { - EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Can not register event : \"" << _eventId << "\" the object named=\"" << _objectName << "\" does not exist"); - } -} -*/ std::shared_ptr ewol::Object::getObjectNamed(const std::string& _objectName) const { return getObjectManager().getObjectNamed(_objectName); } diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index 61553b18..fc6b517c 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -18,10 +18,22 @@ namespace ewol { namespace object { + class SignalCallerIdentifier { + public: + std::weak_ptr m_object; + const char* m_enevntId; + std::string m_data; + SignalCallerIdentifier(std::shared_ptr _object, const char* _enevntId, const std::string& _data) : + m_object(_object), + m_enevntId(_enevntId), + m_data(_data) { + // nothing to do ... + } + }; template class Signal : public SignalBase { private: //std::vector> m_callerList; - std::vector, const char*, std::string>> m_serializedCallerList; + std::vector m_serializedCallerList; public: /** * @brief Create a parameter with a specific type. @@ -42,21 +54,12 @@ namespace ewol { * @brief Destructor. */ virtual ~Signal() { }; - - const std::string& getName() { - return m_name; + void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { + m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data)); } - const std::string& getDescription() { - return m_description; - } - - bool connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { - m_serializedCallerList.push_back(std::make_tuple(_obj, _destId, _data)); - return true; - } - bool release(std::shared_ptr _obj) { + void release(std::shared_ptr _obj) { for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { - if (std::get<0>(it) == _obj) { + if (it->m_object.lock() == _obj) { m_serializedCallerList.erase(it); it = m_serializedCallerList.begin(); } @@ -89,30 +92,30 @@ namespace ewol { } } */ - bool emit(const std::shared_ptr& _source, const T& _data) { + void emit(const std::shared_ptr& _source, const T& _data) { // note : this can not emit on function .... std::string stringData; if (m_serializedCallerList.size()>0 ) { stringData = etk::to_string(_data); } for (auto &it : m_serializedCallerList) { - std::shared_ptr destObject = std::get<0>(it).lock(); + std::shared_ptr destObject = it.m_object.lock(); if (destObject == nullptr) { // TODO : Remove instance ... EWOL_VERBOSE(" nullptr dest"); continue; } const char* eventId = m_name.c_str(); - if (std::get<1>(it) != nullptr) { - eventId = std::get<1>(it); + if (it.m_enevntId != nullptr) { + eventId = it.m_enevntId; } - if (std::get<2>(it).size() <= 0){ + if (it.m_data.size() <= 0){ ewol::object::Message tmpMsg(_source, eventId, stringData); EWOL_VERBOSE("send message " << tmpMsg); destObject->onReceiveMessage(tmpMsg); } else { // set the user requested data ... - ewol::object::Message tmpMsg(_source, eventId, std::get<2>(it)); + ewol::object::Message tmpMsg(_source, eventId, it.m_data); EWOL_VERBOSE("send message " << tmpMsg); destObject->onReceiveMessage(tmpMsg); } @@ -123,7 +126,7 @@ namespace ewol { template<> class Signal : public SignalBase { private: //std::vector> m_callerList; - std::vector, const char*, std::string>> m_serializedCallerList; + std::vector m_serializedCallerList; public: /** * @brief Create a parameter with a specific type. @@ -145,46 +148,38 @@ namespace ewol { */ virtual ~Signal() { }; - const std::string& getName() { - return m_name; + void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { + m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data)); } - const std::string& getDescription() { - return m_description; - } - - bool connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { - m_serializedCallerList.push_back(std::make_tuple(_obj, _destId, _data)); - return true; - } - bool release(std::shared_ptr _obj) { + void release(std::shared_ptr _obj) { for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { - if (std::get<0>(it) == _obj) { + if (it->m_object.lock() == _obj) { m_serializedCallerList.erase(it); it = m_serializedCallerList.begin(); } } } - bool emit(const std::shared_ptr& _source) { + void emit(const std::shared_ptr& _source) { // note : this can not emit on function .... std::string stringData; for (auto &it : m_serializedCallerList) { - std::shared_ptr destObject = std::get<0>(it).lock(); + std::shared_ptr destObject = it.m_object.lock(); if (destObject == nullptr) { // TODO : Remove instance ... EWOL_VERBOSE(" nullptr dest"); continue; } const char* eventId = m_name.c_str(); - if (std::get<1>(it) != nullptr) { - eventId = std::get<1>(it); + if (it.m_enevntId != nullptr) { + eventId = it.m_enevntId; } - if (std::get<2>(it).size() <= 0){ + if (it.m_data.size() <= 0){ ewol::object::Message tmpMsg(_source, eventId, stringData); EWOL_VERBOSE("send message " << tmpMsg); destObject->onReceiveMessage(tmpMsg); } else { // set the user requested data ... - ewol::object::Message tmpMsg(_source, eventId, std::get<2>(it)); + ewol::object::Message tmpMsg(_source, eventId, it.m_data); EWOL_VERBOSE("send message " << tmpMsg); destObject->onReceiveMessage(tmpMsg); } diff --git a/sources/ewol/object/SignalBase.cpp b/sources/ewol/object/SignalBase.cpp index 66cd59a9..11d2aac6 100644 --- a/sources/ewol/object/SignalBase.cpp +++ b/sources/ewol/object/SignalBase.cpp @@ -21,3 +21,9 @@ ewol::object::SignalBase::SignalBase(ewol::object::SignalList& _objectLink, // add a reference on the current signal ... m_objectLink.signalAdd(this); } + +std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::SignalBase& _obj) { + _os << _obj.getName(); + return _os; +} + diff --git a/sources/ewol/object/SignalBase.h b/sources/ewol/object/SignalBase.h index 535ed751..f6951795 100644 --- a/sources/ewol/object/SignalBase.h +++ b/sources/ewol/object/SignalBase.h @@ -36,13 +36,16 @@ namespace ewol { */ virtual ~SignalBase() { }; - const std::string& getName() { + const std::string& getName() const { return m_name; } - const std::string& getDescription() { + const std::string& getDescription() const { return m_description; } + virtual void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) = 0; + virtual void release(std::shared_ptr _obj) = 0; }; + std::ostream& operator <<(std::ostream& _os, const SignalBase& _obj); }; }; #endif diff --git a/sources/ewol/object/SignalList.cpp b/sources/ewol/object/SignalList.cpp index ce1c8498..92e9b5a3 100644 --- a/sources/ewol/object/SignalList.cpp +++ b/sources/ewol/object/SignalList.cpp @@ -11,6 +11,7 @@ #include #include #include +#include ewol::object::SignalList::SignalList() { @@ -29,60 +30,85 @@ void ewol::object::SignalList::signalAdd(SignalBase* _pointerOnSignal) { m_list.push_back(_pointerOnSignal); } -#if 0 -// Note no lock is needed at this level, because the lock is done is the upper elements ... -// the parameter set might be done with a pool of parameter, allone, the overhed is bigger ... -bool ewol::object::SignalList::parameterSet(const std::string& _parameter, const std::string& _value) { - for (auto &it : m_list) { - if( it != nullptr - && it->getName() == _parameter) { - it->setString(_value); - return true; - } - } - // can not find the parameters : - return false; -} - -std::string ewol::object::SignalList::parameterGet(const std::string& _parameter) const { - for (auto &it : m_list) { - if( it != nullptr - && it->getName() == _parameter) { - return it->getString(); - } - } - return "???"; -} - -void ewol::object::SignalList::parameterDisplay(bool _changeOnly) const { - EWOL_INFO(" Object parameters:"); +std::vector ewol::object::SignalList::signalGetAll() const { + std::vector out; for (auto &it : m_list) { if(it != nullptr) { - std::string paramName = it->getName(); - std::string paramVal = it->getString(); - std::string paramInfo = it->getInfo(); - if ( _changeOnly == false - || it->isDefault() == false) { - EWOL_INFO(" | param='" << paramName << "' value=" << paramVal << " (" << paramInfo << ")"); - } - } else { - EWOL_INFO(" | param=nullptr"); - } - } -} - -std::map ewol::object::SignalList::parameterGetAll(bool _notIfDefault) const { - std::map 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)); - } + out.push_back(it->getName()); } } return out; } -#endif + +void ewol::object::SignalList::registerOnObjectEvent(const std::shared_ptr& _destinationObject, + const std::string& _objectName, + const char * _eventId, + const char * _eventIdgenerated, + const std::string& _overloadData) { + ewol::object::Manager& tmp = ewol::getContext().getEObjectManager(); + std::shared_ptr tmpObject = tmp.getObjectNamed(_objectName); + if (nullptr != tmpObject) { + EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'"); + tmpObject->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData); + } else { + EWOL_WARNING(" Can not register event : '" << _eventId << "' the object named='" << _objectName << "' does not exist"); + } +} + +void ewol::object::SignalList::registerOnEvent(const std::shared_ptr& _destinationObject, + const char * _eventId, + const char * _eventIdgenerated, + const std::string& _overloadData) { + if (_destinationObject == nullptr) { + EWOL_ERROR("Input ERROR nullptr pointer Object ..."); + return; + } + if (_eventId == nullptr) { + EWOL_ERROR("Input ERROR nullptr pointer Event Id..."); + return; + } + if ( _eventId[0] == '*' + && _eventId[1] == '\0') { + EWOL_VERBOSE("Register on all event ..."); + for(auto &it : m_list) { + if (it == nullptr) { + continue; + } + it->connect(_destinationObject, _eventIdgenerated, _overloadData); + } + return; + } + // check if event existed : + bool findIt = false; + for(auto &it : m_list) { + if (it == nullptr) { + continue; + } + if (it->getName() == _eventId) { + findIt = true; + it->connect(_destinationObject, _eventIdgenerated, _overloadData); + } + } + if (false == findIt) { + EWOL_ERROR("Can not register event on this event=\"" << _eventId << "\" == > unknow event"); + return; + } +} + +void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptr& _destinationObject, + const char * _eventId) { + if (_destinationObject == nullptr) { + EWOL_ERROR("Input ERROR nullptr pointer Object ..."); + return; + } + for(auto &it : m_list) { + if (it == nullptr) { + continue; + } + if ( it->getName() == _eventId + || ( _eventId[0] == '*' + && _eventId[1] == '\0') ) { + it->release(_destinationObject); + } + } +} diff --git a/sources/ewol/object/SignalList.h b/sources/ewol/object/SignalList.h index 38924010..dde06808 100644 --- a/sources/ewol/object/SignalList.h +++ b/sources/ewol/object/SignalList.h @@ -35,37 +35,11 @@ namespace ewol { * @param[in] pointerOnParameter Pointer on the parameter that might be added. */ void signalAdd(SignalBase* _pointerOnParameter); - #if 0 /** - * @brief Set a specific value to the parameter reference name. - * @param[in] parameter The parameter string name. - * @param[in] value The new value of the parameter (string). - * @return true Parameter update. - * @return false Parameter not update. + * @brief Get All the signal list: + * @return vector on all the signals names */ - bool parameterSet(const std::string& _parameter, const std::string& _value); - /** - * @brief Get a specific value of the parameter reference name. - * @param[in] parameter The parameter string name. - * @return The value of the parameter (string). - */ - 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) 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 parameterGetAll(bool _notIfDefault=true) const; - #endif + std::vector signalGetAll() const; /** * @brief Register an Event an named widget. @see registerOnEvent * @param[in] _destinationObject pointer on the object that might be call when an event is generated diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index 86197e9e..e6d80c9f 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -14,14 +14,6 @@ #define __class__ "Button" -const char* const ewol::widget::Button::eventPressed = "pressed"; -const char* const ewol::widget::Button::eventDown = "down"; -const char* const ewol::widget::Button::eventUp = "up"; -const char* const ewol::widget::Button::eventEnter = "enter"; -const char* const ewol::widget::Button::eventLeave = "leave"; -const char* const ewol::widget::Button::eventValue = "value"; - - // DEFINE for the shader display system : #define STATUS_UP (0) #define STATUS_HOVER (2) @@ -30,6 +22,11 @@ const char* const ewol::widget::Button::eventValue = "value"; ewol::widget::Button::Button() : signalPressed(*this, "pressed", "Button is pressed"), + signalDown(*this, "down", "Button is DOWN"), + signalUp(*this, "up", "Button is UP"), + signalEnter(*this, "enter", "The cursor enter inside the button"), + signalLeave(*this, "leave", "the cursor leave the button"), + signalValue(*this, "value", "button value change"), 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"), @@ -40,13 +37,6 @@ ewol::widget::Button::Button() : m_selectableAreaPos(0,0), m_selectableAreaSize(0,0) { addObjectType("ewol::widget::Button"); - // add basic Event generated : - addEventId(eventPressed); - addEventId(eventDown); - addEventId(eventUp); - addEventId(eventEnter); - addEventId(eventLeave); - addEventId(eventValue); // set property list: m_lock.add(lockNone, "none"); @@ -131,14 +121,14 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { if (true == m_mouseHover) { if (1 == _event.getId()) { if(ewol::key::statusDown == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << eventDown); - generateEventId(eventDown); + EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); + signalDown.emit(shared_from_this()); m_buttonPressed = true; markToRedraw(); } if(ewol::key::statusUp == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << eventUp); - generateEventId(eventUp); + EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); + signalUp.emit(shared_from_this()); m_buttonPressed = false; markToRedraw(); } @@ -152,15 +142,15 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { } else { // inverse value : setValue((m_value)?false:true); - EWOL_VERBOSE(getName() << " : Generate event : " << eventPressed); - generateEventId(eventPressed); - EWOL_VERBOSE(getName() << " : Generate event : " << eventValue << " val=" << m_value ); - generateEventId(eventValue, etk::to_string(m_value.get())); + EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); + signalPressed.emit(shared_from_this()); + EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); + signalValue.emit(shared_from_this(), m_value.get()); if( false == m_toggleMode && true == m_value) { setValue(false); - EWOL_VERBOSE(getName() << " : Generate event : " << ewol::widget::Button::eventValue << " val=" << m_value); - generateEventId(eventValue, etk::to_string(m_value.get())); + EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value); + signalValue.emit(shared_from_this(), m_value.get()); } } markToRedraw(); @@ -177,7 +167,7 @@ bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { if( _event.getType() == ewol::key::keyboardChar && _event.getStatus() == ewol::key::statusDown && _event.getChar() == '\r') { - generateEventId(eventEnter); + signalEnter.emit(shared_from_this()); return true; } return false; diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index 6f5c60db..8a06404b 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -30,12 +30,12 @@ namespace ewol { class Button : public ewol::widget::Container2 { public: // Event list of properties - ewol::object::Signal signalPressed; + ewol::object::Signal signalPressed; ewol::object::Signal signalDown; ewol::object::Signal signalUp; ewol::object::Signal signalEnter; ewol::object::Signal signalLeave; - ewol::object::Signal signalValue; + ewol::object::Signal signalValue; 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/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index 088c155b..29b79622 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -15,9 +15,6 @@ #include #include -const char * const ewol::widget::ButtonColor::eventChange = "change"; - - // DEFINE for the shader display system : #define STATUS_UP (0) #define STATUS_HOVER (2) @@ -31,10 +28,10 @@ const char * const ewol::widget::ButtonColor::eventChange = "change"; static const char* const eventColorHasChange = "ewol-widget-ButtonColor-colorChange"; ewol::widget::ButtonColor::ButtonColor() : + signalChange(*this, "change", "Button color change value"), m_textColorFg(etk::color::black), m_widgetContextMenu(nullptr) { addObjectType("ewol::widget::ButtonColor"); - addEventId(eventChange); changeStatusIn(STATUS_UP); setCanHaveFocus(true); // Limit event at 1: @@ -227,7 +224,9 @@ void ewol::widget::ButtonColor::onReceiveMessage(const ewol::object::Message& _m EWOL_INFO("Receive MSG : " << _msg.getData()); if (_msg.getMessage() == eventColorHasChange) { m_textColorFg = _msg.getData(); - generateEventId(eventChange, _msg.getData()); + // TODO : set a proper call + //signalChange.emit(shared_from_this(), _msg.getData()); + EWOL_TODO("generate signal of change color : " << _msg.getData()); markToRedraw(); } } diff --git a/sources/ewol/widget/ButtonColor.h b/sources/ewol/widget/ButtonColor.h index 53bd0bb7..590bf70b 100644 --- a/sources/ewol/widget/ButtonColor.h +++ b/sources/ewol/widget/ButtonColor.h @@ -17,13 +17,14 @@ #include #include #include +#include namespace ewol { namespace widget { class ButtonColor : public ewol::Widget { public: // Event list of properties - static const char * const eventChange; + ewol::object::Signal> signalChange; private: ewol::compositing::Shaper m_shaper; //!< Compositing theme. ewol::compositing::Text m_text; //!< Compositing Test display. diff --git a/sources/ewol/widget/CheckBox.cpp b/sources/ewol/widget/CheckBox.cpp index 99fbabed..45c9ada0 100644 --- a/sources/ewol/widget/CheckBox.cpp +++ b/sources/ewol/widget/CheckBox.cpp @@ -9,13 +9,6 @@ #include #include -const char* const ewol::widget::CheckBox::eventPressed = "pressed"; -const char* const ewol::widget::CheckBox::eventDown = "down"; -const char* const ewol::widget::CheckBox::eventUp = "up"; -const char* const ewol::widget::CheckBox::eventEnter = "enter"; -const char* const ewol::widget::CheckBox::eventValue = "value"; - - // DEFINE for the shader display system : #define STATUS_UP (0) #define STATUS_HOVER (2) @@ -26,6 +19,11 @@ const char* const ewol::widget::CheckBox::eventValue = "value"; ewol::widget::CheckBox::CheckBox() : + signalPressed(*this, "pressed", "CheckBox is pressed"), + signalDown(*this, "down", "CheckBox is DOWN"), + signalUp(*this, "up", "CheckBox is UP"), + signalEnter(*this, "enter", "The cursor enter inside the CheckBox"), + signalValue(*this, "value", "CheckBox value change"), m_shaper(*this, "shaper", "The display name for config file"), m_mouseHover(false), m_buttonPressed(false), @@ -35,12 +33,6 @@ ewol::widget::CheckBox::CheckBox() : m_shaperIdSizeInsize(-1), m_value(*this, "value", false, "Basic value of the widget") { addObjectType("ewol::widget::CheckBox"); - // add basic Event generated : - addEventId(eventPressed); - addEventId(eventDown); - addEventId(eventUp); - addEventId(eventEnter); - addEventId(eventValue); m_shaperIdSize = m_shaper->requestConfig("box-size"); m_shaperIdSizeInsize = m_shaper->requestConfig("box-inside"); @@ -135,24 +127,24 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { if (true == m_mouseHover) { if (1 == _event.getId()) { if(ewol::key::statusDown == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << eventDown); - generateEventId(eventDown); + EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); + signalDown.emit(shared_from_this()); m_buttonPressed = true; markToRedraw(); } if(ewol::key::statusUp == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << eventUp); - generateEventId(eventUp); + EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); + signalUp.emit(shared_from_this()); m_buttonPressed = false; markToRedraw(); } if(ewol::key::statusSingle == _event.getStatus()) { // inverse value : setValue((m_value)?false:true); - EWOL_VERBOSE(getName() << " : Generate event : " << eventPressed); - generateEventId(eventPressed); - EWOL_VERBOSE(getName() << " : Generate event : " << eventValue << " val=" << m_value ); - generateEventId(eventValue, etk::to_string(m_value.get())); + EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); + signalPressed.emit(shared_from_this()); + EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); + signalValue.emit(shared_from_this(), m_value.get()); markToRedraw(); } } @@ -170,7 +162,7 @@ bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { if( _event.getType() == ewol::key::keyboardChar && _event.getStatus() == ewol::key::statusDown && _event.getChar() == '\r') { - generateEventId(eventEnter); + signalEnter.emit(shared_from_this()); return true; } return false; diff --git a/sources/ewol/widget/CheckBox.h b/sources/ewol/widget/CheckBox.h index 741ef2df..20cbfeee 100644 --- a/sources/ewol/widget/CheckBox.h +++ b/sources/ewol/widget/CheckBox.h @@ -14,6 +14,7 @@ #include #include #include +#include namespace ewol { @@ -21,11 +22,11 @@ namespace ewol { class CheckBox : public ewol::widget::Container2 { public: // Event list of properties - static const char* const eventPressed; - static const char* const eventDown; - static const char* const eventUp; - static const char* const eventEnter; - static const char* const eventValue; + ewol::object::Signal signalPressed; + ewol::object::Signal signalDown; + ewol::object::Signal signalUp; + ewol::object::Signal signalEnter; + ewol::object::Signal signalValue; private: ewol::object::Param m_shaper; //!< Compositing theme. bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). diff --git a/sources/ewol/widget/ColorBar.cpp b/sources/ewol/widget/ColorBar.cpp index b4e28ae1..b5958014 100644 --- a/sources/ewol/widget/ColorBar.cpp +++ b/sources/ewol/widget/ColorBar.cpp @@ -13,16 +13,12 @@ #include -const char * const ewol::widget::ColorBar::eventChange = "change"; - - - #undef __class__ #define __class__ "ColorBar" -ewol::widget::ColorBar::ColorBar() { +ewol::widget::ColorBar::ColorBar() : + signalChange(*this, "change", "Color value change") { addObjectType("ewol::widget::ColorBar"); - addEventId(eventChange); m_currentUserPos.setValue(0,0); m_currentColor = etk::color::black; setCanHaveFocus(true); @@ -224,7 +220,7 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { } if(m_currentColor != estimateColor) { m_currentColor = estimateColor; - generateEventId(eventChange); + signalChange.emit(shared_from_this(), m_currentColor); } return true; } diff --git a/sources/ewol/widget/ColorBar.h b/sources/ewol/widget/ColorBar.h index 5597771a..98a1f7ab 100644 --- a/sources/ewol/widget/ColorBar.h +++ b/sources/ewol/widget/ColorBar.h @@ -14,6 +14,7 @@ #include #include #include +#include namespace ewol { @@ -21,7 +22,7 @@ namespace ewol { class ColorBar : public ewol::Widget { public: // Event list of properties - static const char * const eventChange; + ewol::object::Signal> signalChange; protected: ColorBar(); void init(); diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index 4e9bb379..d0c723da 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -29,11 +29,10 @@ const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-sele #define STATUS_HOVER (1) #define STATUS_SELECTED (2) -const char * const ewol::widget::Entry::eventClick = "click"; -const char * const ewol::widget::Entry::eventEnter = "enter"; -const char * const ewol::widget::Entry::eventModify = "modify"; - ewol::widget::Entry::Entry() : + signalClick(*this, "click", "the user Click on the Entry box"), + signalEnter(*this, "enter", "The cursor enter inside the button"), + signalModify(*this, "modify", "Entry box value change"), m_shaper(*this, "shaper", "Shaper to display the background"), m_data(*this, "value", "", "Value display in the entry (decorated text)"), m_maxCharacter(*this, "max", 0x7FFFFFFF, 0, 0x7FFFFFFF, "Maximum cgar that can be set on the Entry"), @@ -46,9 +45,6 @@ ewol::widget::Entry::Entry() : m_textWhenNothing(*this, "emptytext", "", "Text that is displayed when the Entry is empty (decorated text)") { addObjectType("ewol::widget::Entry"); setCanHaveFocus(true); - addEventId(eventClick); - addEventId(eventEnter); - addEventId(eventModify); shortCutAdd("ctrl+w", ewolEventEntryClean); shortCutAdd("ctrl+x", ewolEventEntryCut); shortCutAdd("ctrl+c", ewolEventEntryCopy); @@ -244,7 +240,7 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { if (ewol::key::statusSingle == _event.getStatus()) { keepFocus(); - generateEventId(eventClick); + signalClick.emit(shared_from_this()); //nothing to do ... return true; } else if (ewol::key::statusDouble == _event.getStatus()) { @@ -335,13 +331,11 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { if (_event.getType() == ewol::key::keyboardChar) { if(_event.getStatus() == ewol::key::statusDown) { - //EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " ); - //return GenEventInputExternal(eventEnter, -1, -1); // remove curent selected data ... removeSelected(); if( _event.getChar() == '\n' || _event.getChar() == '\r') { - generateEventId(eventEnter, m_data); + signalEnter.emit(shared_from_this(), m_data); return true; } else if (_event.getChar() == 0x7F) { // SUPPR : @@ -371,7 +365,7 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { } } } - generateEventId(eventModify, m_data); + signalModify.emit(shared_from_this(), m_data); markToRedraw(); return true; } @@ -443,7 +437,7 @@ void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipbo markToRedraw(); } } - generateEventId(eventModify, m_data); + signalModify.emit(shared_from_this(), m_data); } @@ -458,7 +452,7 @@ void ewol::widget::Entry::onReceiveMessage(const ewol::object::Message& _msg) { } else if(_msg.getMessage() == ewolEventEntryCut) { copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); removeSelected(); - generateEventId(eventModify, m_data); + signalModify.emit(shared_from_this(), m_data); } else if(_msg.getMessage() == ewolEventEntryCopy) { copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); } else if(_msg.getMessage() == ewolEventEntryPaste) { diff --git a/sources/ewol/widget/Entry.h b/sources/ewol/widget/Entry.h index 93024b50..52e58a89 100644 --- a/sources/ewol/widget/Entry.h +++ b/sources/ewol/widget/Entry.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -33,10 +34,9 @@ namespace ewol { */ class Entry : public ewol::Widget { public: - // Event list of properties - static const char * const eventClick; - static const char * const eventEnter; - static const char * const eventModify; // return in the data the new string inside it ... + ewol::object::Signal signalClick; //!< bang on click the entry box + ewol::object::Signal signalEnter; //!< Enter key is pressed + ewol::object::Signal signalModify; //!< data change private: ewol::object::Param m_shaper; int32_t m_colorIdTextFg; //!< color property of the text foreground diff --git a/sources/ewol/widget/Image.cpp b/sources/ewol/widget/Image.cpp index 45b70b42..b44a775a 100644 --- a/sources/ewol/widget/Image.cpp +++ b/sources/ewol/widget/Image.cpp @@ -16,9 +16,8 @@ #undef __class__ #define __class__ "Image" -const char * const ewol::widget::Image::eventPressed = "pressed"; - ewol::widget::Image::Image() : + signalPressed(*this, "pressed", "Image is pressed"), m_colorProperty(nullptr), m_colorId(-1), m_fileName(*this, "src", "", "Image source path"), @@ -29,7 +28,6 @@ ewol::widget::Image::Image() : m_posStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), m_distanceFieldMode(*this, "distance-field", false, "Distance field mode") { addObjectType("ewol::widget::Image"); - addEventId(eventPressed); m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Image.json"); if (m_colorProperty != nullptr) { m_colorId = m_colorProperty->request("foreground"); @@ -135,7 +133,7 @@ bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on BT ..."); if (1 == _event.getId()) { if(ewol::key::statusSingle == _event.getStatus()) { - generateEventId(eventPressed); + signalPressed.emit(shared_from_this()); return true; } } diff --git a/sources/ewol/widget/Image.h b/sources/ewol/widget/Image.h index df2a07d7..0954722e 100644 --- a/sources/ewol/widget/Image.h +++ b/sources/ewol/widget/Image.h @@ -16,6 +16,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -25,7 +26,7 @@ namespace ewol { class Image :public ewol::Widget { public: // Event list of properties - static const char * const eventPressed; + ewol::object::Signal signalPressed; protected: ewol::compositing::Image m_compositing; //!< compositing element of the image. std::shared_ptr m_colorProperty; //!< theme color property diff --git a/sources/ewol/widget/Joystick.cpp b/sources/ewol/widget/Joystick.cpp index 73fd63a6..d3e5b46a 100644 --- a/sources/ewol/widget/Joystick.cpp +++ b/sources/ewol/widget/Joystick.cpp @@ -12,10 +12,6 @@ #include #include -const char * const ewol::widget::Joystick::eventEnable = "enable"; -const char * const ewol::widget::Joystick::eventDisable = "disable"; -const char * const ewol::widget::Joystick::eventMove = "move"; - static bool l_displayBackground(true); static std::string l_background(""); static std::string l_foreground(""); @@ -24,11 +20,11 @@ static float l_ratio(1.0/7.0); #undef __class__ #define __class__ "Joystick" -ewol::widget::Joystick::Joystick() { +ewol::widget::Joystick::Joystick() : + signalEnable(*this, "enable"), + signalDisable(*this, "disable"), + signalMove(*this, "move") { addObjectType("ewol::widget::Joystick"); - addEventId(eventEnable); - addEventId(eventDisable); - addEventId(eventMove); // by default the joy does not lock when free out m_lock = false; m_displayMode = modeNormal; @@ -148,10 +144,10 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { } markToRedraw(); if(ewol::key::statusDown == typeEvent) { - generateEventId(eventEnable); + signalEnable.emit(shared_from_this()); } else { std::string tmp = std::string("distance=") + std::string(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2); - generateEventId(eventMove, tmp); + signalMove.emit(shared_from_this(), m_angle+M_PI/2); } //teta += M_PI/2; //EWOL_DEBUG("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance); @@ -167,7 +163,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { m_distance = 0; } markToRedraw(); - generateEventId(eventDisable); + signalDisable.emit(shared_from_this()); return true; } return false; diff --git a/sources/ewol/widget/Joystick.h b/sources/ewol/widget/Joystick.h index 5ead150b..a5cbff2d 100644 --- a/sources/ewol/widget/Joystick.h +++ b/sources/ewol/widget/Joystick.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace ewol { @@ -23,9 +24,9 @@ namespace ewol { class Joystick :public ewol::Widget { public: // Event list of properties - static const char * const eventEnable; - static const char * const eventDisable; - static const char * const eventMove; + ewol::object::Signal signalEnable; + ewol::object::Signal signalDisable; + ewol::object::Signal signalMove; public: enum joystickMode { modeNormal, @@ -34,7 +35,7 @@ namespace ewol { private: draw::Color m_colorFg; //!< Forground color draw::Color m_colorBg; //!< Background color - vec2 m_displayPos; //!< direction of the cursor ... + vec2 m_displayPos; //!< direction of the cursor ... float m_distance; //!< dintance from the center float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ... bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle diff --git a/sources/ewol/widget/Label.cpp b/sources/ewol/widget/Label.cpp index 46424a74..d6ec3794 100644 --- a/sources/ewol/widget/Label.cpp +++ b/sources/ewol/widget/Label.cpp @@ -15,10 +15,9 @@ #undef __class__ #define __class__ "Label" -const char * const ewol::widget::Label::eventPressed = "pressed"; - // TODO : Remove the label name in the constructor ... ewol::widget::Label::Label() : + signalPressed(*this, "pressed"), m_label(*this, "value", U"", "displayed value string"), m_colorProperty(nullptr), m_colorDefaultFgText(-1), @@ -29,7 +28,6 @@ ewol::widget::Label::Label() : m_colorDefaultFgText = m_colorProperty->request("foreground"); m_colorDefaultBgText = m_colorProperty->request("background"); } - addEventId(eventPressed); setCanHaveFocus(false); setMouseLimit(1); } @@ -126,7 +124,7 @@ bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { if (ewol::key::statusSingle == _event.getStatus()) { // nothing to do ... - generateEventId(eventPressed); + signalPressed.emit(shared_from_this()); return true; } } diff --git a/sources/ewol/widget/Label.h b/sources/ewol/widget/Label.h index f1d9f887..3ee63a80 100644 --- a/sources/ewol/widget/Label.h +++ b/sources/ewol/widget/Label.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -24,7 +25,7 @@ namespace ewol { class Label : public ewol::Widget { public: // Event list of properties - static const char * const eventPressed; + ewol::object::Signal signalPressed; private: ewol::compositing::Text m_text; //!< Compositing text element. ewol::object::Param m_label; //!< decorated text to display. diff --git a/sources/ewol/widget/ListFileSystem.cpp b/sources/ewol/widget/ListFileSystem.cpp index 31b35f09..271954ea 100644 --- a/sources/ewol/widget/ListFileSystem.cpp +++ b/sources/ewol/widget/ListFileSystem.cpp @@ -15,13 +15,11 @@ #undef __class__ #define __class__ "ListFileSystem" -const char * const ewol::widget::ListFileSystem::eventFileSelect = "file-select"; -const char * const ewol::widget::ListFileSystem::eventFileValidate = "file-validate"; -const char * const ewol::widget::ListFileSystem::eventFolderSelect = "folder-select"; -const char * const ewol::widget::ListFileSystem::eventFolderValidate = "folder-validate"; - - ewol::widget::ListFileSystem::ListFileSystem() : + signalFileSelect(*this, "file-select"), + signalFileValidate(*this, "file-validate"), + signalFolderSelect(*this, "folder-select"), + signalFolderValidate(*this, "folder-validate"), m_selectedLine(-1), m_folder(*this, "path", "/", "Path to display"), m_selectFile(*this, "select", "", "selection af a specific file"), @@ -40,11 +38,6 @@ ewol::widget::ListFileSystem::ListFileSystem() : m_colorIdBackground2 = m_colorProperty->request("background2"); m_colorIdBackgroundSelected = m_colorProperty->request("selected"); } - addEventId(eventFileSelect); - addEventId(eventFileValidate); - addEventId(eventFolderSelect); - addEventId(eventFolderValidate); - setMouseLimit(1); }; @@ -192,21 +185,21 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, if( m_showFolder == true && m_selectedLine == 0) { // "." folder - generateEventId(eventFolderSelect, "."); + signalFolderSelect.emit(shared_from_this(), "."); } else if ( m_showFolder == true && m_selectedLine == 1) { // ".." folder - generateEventId(eventFolderSelect, ".."); + signalFolderSelect.emit(shared_from_this(), ".."); } else if( m_selectedLine-offset >= 0 && m_selectedLine-offset < (int32_t)m_list.size() && nullptr != m_list[m_selectedLine-offset] ) { // generate event extern : switch(m_list[m_selectedLine-offset]->getNodeType()) { case etk::FSN_FILE : - generateEventId(eventFileSelect, m_list[m_selectedLine-offset]->getNameFile()); + signalFileSelect.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); break; case etk::FSN_FOLDER : - generateEventId(eventFolderSelect, m_list[m_selectedLine-offset]->getNameFile()); + signalFolderSelect.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); break; default: EWOL_ERROR("Can not generate event on an unknow type"); @@ -217,21 +210,20 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, if( m_showFolder == true && m_selectedLine == 0) { // "." folder - generateEventId(eventFolderValidate, "."); + signalFolderValidate.emit(shared_from_this(), "."); } else if ( m_showFolder == true && m_selectedLine == 1) { // ".." folder - generateEventId(eventFolderValidate, ".."); + signalFolderValidate.emit(shared_from_this(), ".."); } else if( m_selectedLine-offset >= 0 && m_selectedLine-offset < (int32_t)m_list.size() && nullptr != m_list[m_selectedLine-offset] ) { - switch(m_list[m_selectedLine-offset]->getNodeType()) - { + switch(m_list[m_selectedLine-offset]->getNodeType()) { case etk::FSN_FILE : - generateEventId(eventFileValidate, m_list[m_selectedLine-offset]->getNameFile()); + signalFileValidate.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); break; case etk::FSN_FOLDER : - generateEventId(eventFolderValidate, m_list[m_selectedLine-offset]->getNameFile()); + signalFolderValidate.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); break; default: EWOL_ERROR("Can not generate event on an unknow type"); diff --git a/sources/ewol/widget/ListFileSystem.h b/sources/ewol/widget/ListFileSystem.h index 3de039bf..49ce10f5 100644 --- a/sources/ewol/widget/ListFileSystem.h +++ b/sources/ewol/widget/ListFileSystem.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -21,10 +22,10 @@ namespace ewol { class ListFileSystem : public ewol::widget::List { public: // Event list of properties - static const char * const eventFileSelect; //!< @event "file-select" Generated when a file is selected. - static const char * const eventFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element - static const char * const eventFolderSelect; - static const char * const eventFolderValidate; + ewol::object::Signal signalFileSelect; //!< @event "file-select" Generated when a file is selected. + ewol::object::Signal signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element + ewol::object::Signal signalFolderSelect; + ewol::object::Signal signalFolderValidate; protected: ListFileSystem(); void init(); diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index 94d310c5..b6cbb78d 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -60,6 +60,8 @@ int32_t ewol::widget::Menu::addTitle(std::string _label, return add(-1, _label, _image, _generateEvent, _message); } +static const char* eventButtonPressed = "menu-local-pressed"; + int32_t ewol::widget::Menu::add(int32_t _parent, std::string _label, std::string _image, @@ -95,7 +97,7 @@ int32_t ewol::widget::Menu::add(int32_t _parent, // add it in the widget list ewol::widget::Sizer::subWidgetAdd(myButton); // keep the specific event ... - myButton->registerOnEvent(shared_from_this(), ewol::widget::Button::eventPressed, widget::Button::eventPressed); + myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); tmpObject.m_widgetPointer = myButton; } m_listElement.push_back(tmpObject); @@ -114,7 +116,7 @@ void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) { } */ EWOL_ERROR(" receive message : " << _msg); - if (_msg.getMessage() == ewol::widget::Button::eventPressed) { + if (_msg.getMessage() == eventButtonPressed) { for (auto &it : m_listElement) { if (_msg.getCaller() == it.m_widgetPointer.lock()) { // 2 posible case (have a message or have a child ... @@ -215,7 +217,7 @@ void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) { } } // set the image if one is present ... - myButton->registerOnEvent(shared_from_this(), ewol::widget::Button::eventPressed, widget::Button::eventPressed); + myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); myButton->setExpand(bvec2(true,false)); myButton->setFill(bvec2(true,false)); // add it in the widget list diff --git a/sources/ewol/widget/Slider.cpp b/sources/ewol/widget/Slider.cpp index 0395da27..8dd4bf30 100644 --- a/sources/ewol/widget/Slider.cpp +++ b/sources/ewol/widget/Slider.cpp @@ -10,16 +10,14 @@ #include -const char * const ewol::widget::Slider::eventChange = "change"; - #undef __class__ #define __class__ "Slider" const int32_t dotRadius = 6; -ewol::widget::Slider::Slider() { +ewol::widget::Slider::Slider() : + signalChange(*this, "change") { addObjectType("ewol::widget::Slider"); - addEventId(eventChange); m_value = 0; m_min = 0; @@ -109,7 +107,7 @@ bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { m_value = std::max(std::min(m_value, m_max), m_min); if (oldValue != m_value) { EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]"); - generateEventId(eventChange, etk::to_string(m_value)); + signalChange.emit(shared_from_this(), m_value); markToRedraw(); } return true; diff --git a/sources/ewol/widget/Slider.h b/sources/ewol/widget/Slider.h index 4d3dd1ee..d6f02210 100644 --- a/sources/ewol/widget/Slider.h +++ b/sources/ewol/widget/Slider.h @@ -14,6 +14,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -23,7 +24,7 @@ namespace ewol { class Slider : public ewol::Widget { public: // Event list of properties - static const char * const eventChange; + ewol::object::Signal signalChange; protected: Slider(); void init(); diff --git a/sources/ewol/widget/WSlider.cpp b/sources/ewol/widget/WSlider.cpp index 3b3159d6..0a9d7671 100644 --- a/sources/ewol/widget/WSlider.cpp +++ b/sources/ewol/widget/WSlider.cpp @@ -23,11 +23,9 @@ std::ostream& operator <<(std::ostream& _os, const enum ewol::widget::WSlider::s #undef __class__ #define __class__ "WSlider" -// Event list of properties -const char* const ewol::widget::WSlider::eventStartSlide = "ewol-widget-wslider-event-start-slide"; -const char* const ewol::widget::WSlider::eventStopSlide = "ewol-widget-wslider-event-stop-slide"; - ewol::widget::WSlider::WSlider() : + signalStartSlide(*this, "start"), + signalStopSlide(*this, "stop"), m_windowsSources(0), m_windowsDestination(0), m_windowsRequested(-1), @@ -36,8 +34,6 @@ ewol::widget::WSlider::WSlider() : m_transitionSpeed(*this, "speed", 1.0f, 0.0f, 200.0f, "Transition speed of the slider"), m_transitionSlide(*this, "mode", sladingTransitionHori, "Transition mode of the slider") { addObjectType("ewol::widget::WSlider"); - addEventId(eventStartSlide); - addEventId(eventStopSlide); m_transitionSlide.add(sladingTransitionVert, "vert"); m_transitionSlide.add(sladingTransitionHori, "hori"); } @@ -105,7 +101,7 @@ void ewol::widget::WSlider::subWidgetSelectSetVectorId(int32_t _id) { } if (_id != m_windowsDestination) { m_windowsRequested = _id; - generateEventId(eventStartSlide); + signalStartSlide.emit(shared_from_this()); periodicCallEnable(); markToRedraw(); } @@ -189,7 +185,7 @@ void ewol::widget::WSlider::periodicCall(const ewol::event::Time& _event) { } else { // end of periodic : periodicCallDisable(); - generateEventId(eventStopSlide); + signalStopSlide.emit(shared_from_this()); } m_windowsRequested = -1; } diff --git a/sources/ewol/widget/WSlider.h b/sources/ewol/widget/WSlider.h index 5e56de7c..1deec94d 100644 --- a/sources/ewol/widget/WSlider.h +++ b/sources/ewol/widget/WSlider.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -22,8 +23,8 @@ namespace ewol { class WSlider :public ewol::widget::ContainerN { public: // Event list of properties - static const char* const eventStartSlide; - static const char* const eventStopSlide; + ewol::object::Signal signalStartSlide; + ewol::object::Signal signalStopSlide; enum sladingMode { sladingTransitionVert, sladingTransitionHori, diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index ef20011c..b59c72d6 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -86,11 +86,6 @@ std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::gravity _obj #undef __class__ #define __class__ "Widget" -// event generated : -const char* const ewol::Widget::eventAnnimationStart = "annimation-start"; -const char* const ewol::Widget::eventAnnimationRatio = "annimation-ratio"; -const char* const ewol::Widget::eventAnnimationStop = "annimation-stop"; - ewol::Widget::Widget() : m_size(10,10), m_minSize(0,0), @@ -113,6 +108,9 @@ ewol::Widget::Widget() : m_needRegenerateDisplay(true), m_grabCursor(false), m_cursorDisplay(ewol::context::cursorArrow), + signalAnnimationStart(*this, "annimation-start"), + signalAnnimationRatio(*this, "annimation-ratio"), + signalAnnimationStop(*this, "annimation-stop"), m_annimationMode(annimationModeDisable), m_annimationratio(0.0f), m_annimationTypeStart(*this, "annimation-start-type", 0, "Annimation type, when adding/show a widget"), @@ -133,10 +131,6 @@ ewol::Widget::Widget() : m_gravity.add(ewol::gravityLeft, "left"); m_annimationTypeStart.add(0, "none"); m_annimationTypeStop.add(0, "none"); - - addEventId(eventAnnimationStart); - addEventId(eventAnnimationRatio); - addEventId(eventAnnimationStop); } void ewol::Widget::init() { diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index 2ec51867..032135c5 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -31,6 +31,7 @@ namespace ewol { #include #include #include +#include #define ULTIMATE_MAX_SIZE (99999999) @@ -713,9 +714,9 @@ namespace ewol { */ public: // event generated : - static const char* const eventAnnimationStart; //!< event when start annimation - static const char* const eventAnnimationRatio; //!< event when % of annimation change (integer) - static const char* const eventAnnimationStop; //!< event when stop annimation + ewol::object::Signal signalAnnimationStart; //!< event when start annimation + ewol::object::Signal signalAnnimationRatio; //!< event when % of annimation change (integer) + ewol::object::Signal signalAnnimationStop; //!< event when stop annimation protected: enum annimationMode { annimationModeEnableAdd, diff --git a/sources/ewol/widget/meta/ColorChooser.cpp b/sources/ewol/widget/meta/ColorChooser.cpp index ffd47df2..3972dfe1 100644 --- a/sources/ewol/widget/meta/ColorChooser.cpp +++ b/sources/ewol/widget/meta/ColorChooser.cpp @@ -22,17 +22,13 @@ extern "C" { #undef __class__ #define __class__ "ColorChooser" - -const char * const ewol::widget::ColorChooser::eventChange = "change"; - - static const char * const eventColorBarHasChange = "event-color-bar-has-change"; static const char * const eventColorSpecificHasChange = "event-color-specific-has-change"; -ewol::widget::ColorChooser::ColorChooser() { +ewol::widget::ColorChooser::ColorChooser() : + signalChange(*this, "change") { addObjectType("ewol::widget::ColorChooser"); - addEventId(eventChange); } void ewol::widget::ColorChooser::init() { @@ -140,7 +136,7 @@ void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _ if (nullptr != m_widgetAlpha) { m_widgetAlpha->setValue(m_currentColor.a()); } - generateEventId(eventChange, m_currentColor.getString()); + signalChange.emit(shared_from_this(), m_currentColor); } else if (eventColorSpecificHasChange == _msg.getMessage()) { // Slider has changes his color == > get the one change ... if (_msg.getCaller() == m_widgetRed) { @@ -158,7 +154,7 @@ void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _ if (nullptr != m_widgetColorBar) { m_widgetColorBar->setCurrentColor(m_currentColor); } - generateEventId(eventChange, m_currentColor.getString()); + signalChange.emit(shared_from_this(), m_currentColor); } }; diff --git a/sources/ewol/widget/meta/ColorChooser.h b/sources/ewol/widget/meta/ColorChooser.h index 187f5731..445b081b 100644 --- a/sources/ewol/widget/meta/ColorChooser.h +++ b/sources/ewol/widget/meta/ColorChooser.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -27,7 +28,7 @@ namespace ewol { class ColorChooser : public ewol::widget::Sizer { public: // Event list of properties - static const char * const eventChange; + ewol::object::Signal> signalChange; protected: ColorChooser(); void init(); diff --git a/sources/ewol/widget/meta/FileChooser.cpp b/sources/ewol/widget/meta/FileChooser.cpp index d716c73b..16c3d5c7 100644 --- a/sources/ewol/widget/meta/FileChooser.cpp +++ b/sources/ewol/widget/meta/FileChooser.cpp @@ -30,9 +30,8 @@ extern "C" { #define __class__ "FileChooser" -const char * const ewol::widget::FileChooser::eventCancel = "cancel"; -const char * const ewol::widget::FileChooser::eventValidate = "validate"; - +static const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel"; +static const char * const ewolEventFileChooserValidate = "ewol-event-file-chooser-validate"; static const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files"; static const char * const ewolEventFileChooserEntryFolder = "ewol-event-file-chooser-modify-entry-folder"; static const char * const ewolEventFileChooserEntryFolderEnter = "ewol-event-file-chooser-modify-entry-folder-enter"; @@ -44,10 +43,10 @@ static const char * const ewolEventFileChooserListFileValidate = "ewol-event-fil static const char * const ewolEventFileChooserHome = "ewol-event-file-chooser-home"; -ewol::widget::FileChooser::FileChooser() { +ewol::widget::FileChooser::FileChooser() : + signalCancel(*this, "cancel"), + signalValidate(*this, "validate") { addObjectType("ewol::widget::FileChooser"); - addEventId(eventCancel); - addEventId(eventValidate); } void ewol::widget::FileChooser::init() { @@ -107,8 +106,8 @@ void ewol::widget::FileChooser::init() { + ""; loadFromString(myDescription); registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", "value", ewolEventFileChooserHidenFileChange); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-validate", "pressed", eventValidate); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-cancel", "pressed", eventCancel); + registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-validate", "pressed", ewolEventFileChooserValidate); + registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-cancel", "pressed", ewolEventFileChooserCancel); registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "folder-validate", ewolEventFileChooserListFolder); registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-select", ewolEventFileChooserListFile); registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-validate", ewolEventFileChooserListFileValidate); @@ -163,9 +162,9 @@ void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _m m_file = _msg.getData(); // update the selected file in the list : parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file); - } else if (eventCancel == _msg.getMessage()) { + } else if (ewolEventFileChooserCancel == _msg.getMessage()) { // == > Auto remove ... - generateEventId(_msg.getMessage()); + signalCancel.emit(shared_from_this()); autoDestroy(); } else if (_msg.getMessage() == ewolEventFileChooserHidenFileChange) { if (_msg.getData() == "true") { @@ -187,16 +186,16 @@ void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _m setFileName(_msg.getData()); std::string tmpFileCompleatName = m_folder; tmpFileCompleatName += m_file; - generateEventId(_msg.getMessage(), tmpFileCompleatName); + // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); } else if( _msg.getMessage() == ewolEventFileChooserListFileValidate - || (_msg.getMessage() == eventValidate && m_file != "" ) + || (_msg.getMessage() == ewolEventFileChooserValidate && m_file != "" ) || (_msg.getMessage() == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) { // select the file == > generate a validate if (_msg.getData() != "") { setFileName(_msg.getData()); } EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); - generateEventId(eventValidate, getCompleateFileName()); + signalValidate.emit(shared_from_this(), getCompleateFileName()); autoDestroy(); } else if(_msg.getMessage() == ewolEventFileChooserHome) { std::string tmpUserFolder = etk::getUserHomeFolder(); diff --git a/sources/ewol/widget/meta/FileChooser.h b/sources/ewol/widget/meta/FileChooser.h index aab643b2..eaa9b806 100644 --- a/sources/ewol/widget/meta/FileChooser.h +++ b/sources/ewol/widget/meta/FileChooser.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace ewol { namespace widget { @@ -74,8 +75,8 @@ namespace ewol { class FileChooser : public ewol::widget::Composer { public: // Event list of properties - static const char* const eventCancel; - static const char* const eventValidate; + ewol::object::Signal signalCancel; + ewol::object::Signal signalValidate; protected: FileChooser(); void init(); diff --git a/sources/ewol/widget/meta/Parameter.cpp b/sources/ewol/widget/meta/Parameter.cpp index 7d84aae0..9825fc25 100644 --- a/sources/ewol/widget/meta/Parameter.cpp +++ b/sources/ewol/widget/meta/Parameter.cpp @@ -20,19 +20,17 @@ #undef __class__ #define __class__ "Parameter" - -const char * const ewol::widget::Parameter::eventClose = "close"; - static const char * const ewolEventParameterValidate = "ewol-event-parameter-validate"; static const char * const ewolEventParameterSave = "ewol-event-parameter-save"; static const char * const l_eventMenuSelected = "local-event-menu-selected"; +static const char * const ewolEventMenuclosed = "local-event-menu-closed"; ewol::widget::Parameter::Parameter() : + signalClose(*this, "close"), m_currentIdList(0), m_widgetTitle(), m_paramList() { addObjectType("ewol::widget::Parameter"); - addEventId(eventClose); } void ewol::widget::Parameter::init() { @@ -106,7 +104,7 @@ void ewol::widget::Parameter::init() { " \n" " \n" "\n")); - tmpButton->registerOnEvent(shared_from_this(), "pressed", eventClose); + tmpButton->registerOnEvent(shared_from_this(), "pressed", ewolEventMenuclosed); mySizerHori->subWidgetAdd(tmpButton); } } @@ -200,9 +198,9 @@ void ewol::widget::Parameter::setTitle(std::string _label) { void ewol::widget::Parameter::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::PopUp::onReceiveMessage(_msg); EWOL_DEBUG("event on the parameter : " << _msg); - if (_msg.getMessage() == eventClose) { + if (_msg.getMessage() == ewolEventMenuclosed) { // inform that the parameter windows is closed - generateEventId(eventClose); + signalClose.emit(shared_from_this()); // close this widget ... autoDestroy(); } else if (_msg.getMessage() == ewolEventParameterSave) { diff --git a/sources/ewol/widget/meta/Parameter.h b/sources/ewol/widget/meta/Parameter.h index 1adc531a..a8ad5d6b 100644 --- a/sources/ewol/widget/meta/Parameter.h +++ b/sources/ewol/widget/meta/Parameter.h @@ -29,7 +29,7 @@ namespace ewol { class Parameter : public ewol::widget::PopUp { public: // Event list of properties - static const char * const eventClose; + ewol::object::Signal signalClose; protected: Parameter(); void init(); diff --git a/sources/ewol/widget/meta/ParameterList.cpp b/sources/ewol/widget/meta/ParameterList.cpp index b32286ec..29ef9695 100644 --- a/sources/ewol/widget/meta/ParameterList.cpp +++ b/sources/ewol/widget/meta/ParameterList.cpp @@ -15,15 +15,13 @@ #include #include -const char * const ewol::widget::ParameterList::eventSelect = "select"; - #undef __class__ #define __class__ "List" -ewol::widget::ParameterList::ParameterList() { +ewol::widget::ParameterList::ParameterList() : + signalSelect(*this, "select") { addObjectType("ewol::widget::ParameterList"); - addEventId(eventSelect); m_idSelected = -1; m_paddingSizeX = 2; @@ -192,7 +190,7 @@ bool ewol::widget::ParameterList::onEventInput(const ewol::event::Input& _event) if (rawID >= 0 && (size_t)rawID < m_list.size()) { if (m_list[rawID]!=nullptr) { if (m_list[rawID]->m_refId >= 0) { - generateEventId(eventSelect, etk::to_string(m_list[rawID]->m_refId)); + signalSelect.emit(shared_from_this(), m_list[rawID]->m_refId); m_idSelected = rawID; markToRedraw(); return true; diff --git a/sources/ewol/widget/meta/ParameterList.h b/sources/ewol/widget/meta/ParameterList.h index 4def9ec2..df6d026b 100644 --- a/sources/ewol/widget/meta/ParameterList.h +++ b/sources/ewol/widget/meta/ParameterList.h @@ -39,7 +39,7 @@ namespace ewol { class ParameterList :public ewol::widget::WidgetScrolled { public: // Event list of properties - static const char * const eventSelect; + ewol::object::Signal signalSelect; private: int32_t m_idSelected; std::vector m_list; diff --git a/sources/ewol/widget/meta/StdPopUp.cpp b/sources/ewol/widget/meta/StdPopUp.cpp index 53b37a46..7a10b83a 100644 --- a/sources/ewol/widget/meta/StdPopUp.cpp +++ b/sources/ewol/widget/meta/StdPopUp.cpp @@ -107,7 +107,7 @@ std::shared_ptr ewol::widget::StdPopUp::addButton(const st } myButton->setSubWidget(ewol::widget::Label::create(_text)); if(_autoExit == true) { - myButton->registerOnEvent(shared_from_this(), ewol::widget::Button::eventPressed, eventButtonExit); + myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonExit); } m_subBar->subWidgetAdd(myButton); markToRedraw(); From 153774177ef5ffc9f8d389f22fa4b3f068eea664 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 21 Aug 2014 21:00:13 +0200 Subject: [PATCH 05/22] [DEBUG] gcc compilation warning --- external/etk | 2 +- sources/ewol/Dimension.cpp | 31 ++++++++++++++--------------- sources/ewol/compositing/Shaper.cpp | 31 ++++++++++++++--------------- sources/ewol/widget/Button.cpp | 22 ++++++++++---------- sources/ewol/widget/CheckBox.cpp | 2 +- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/external/etk b/external/etk index 2c6a1b8f..3ad4738a 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit 2c6a1b8fc877f4f496bd6f6fdaae333d7d808a94 +Subproject commit 3ad4738a3a0697252a5ecc8ce8fdee5c75f2404b diff --git a/sources/ewol/Dimension.cpp b/sources/ewol/Dimension.cpp index 52ccc211..b993327c 100644 --- a/sources/ewol/Dimension.cpp +++ b/sources/ewol/Dimension.cpp @@ -299,19 +299,18 @@ std::ostream& ewol::operator <<(std::ostream& _os, const ewol::Dimension& _obj) return _os; } - -template<> std::string etk::to_string(const ewol::Dimension& _obj) { - return _obj; -} -template<> std::u32string etk::to_u32string(const ewol::Dimension& _obj) { - return etk::to_u32string(etk::to_string(_obj)); -} - - -template<> bool etk::from_string(ewol::Dimension& _variableRet, const std::string& _value) { - _variableRet = ewol::Dimension(_value); - return true; -} -template<> bool etk::from_string(ewol::Dimension& _variableRet, const std::u32string& _value) { - return from_string(_variableRet, etk::to_string(_value)); -} +namespace etk { + template<> std::string to_string(const ewol::Dimension& _obj) { + return _obj; + } + template<> std::u32string to_u32string(const ewol::Dimension& _obj) { + return etk::to_u32string(etk::to_string(_obj)); + } + template<> bool from_string(ewol::Dimension& _variableRet, const std::string& _value) { + _variableRet = ewol::Dimension(_value); + return true; + } + template<> bool from_string(ewol::Dimension& _variableRet, const std::u32string& _value) { + return from_string(_variableRet, etk::to_string(_value)); + } +}; diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index 0856d86a..781f5c46 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -623,20 +623,19 @@ const etk::Color& ewol::compositing::Shaper::getColor(int32_t _id) { return m_colorProperty->get(_id); } +namespace etk { + template<> std::string to_string(const ewol::compositing::Shaper& _obj) { + return _obj.getSource(); + } + template<> std::u32string to_u32string(const ewol::compositing::Shaper& _obj) { + return etk::to_u32string(etk::to_string(_obj)); + } + template<> bool from_string(ewol::compositing::Shaper& _variableRet, const std::string& _value) { + _variableRet.setSource(_value); + return true; + } + template<> bool from_string(ewol::compositing::Shaper& _variableRet, const std::u32string& _value) { + return from_string(_variableRet, etk::to_string(_value)); + } +}; - -template<> std::string etk::to_string(const ewol::compositing::Shaper& _obj) { - return _obj.getSource(); -} - -template<> std::u32string etk::to_u32string(const ewol::compositing::Shaper& _obj) { - return etk::to_u32string(etk::to_string(_obj)); -} - -template<> bool etk::from_string(ewol::compositing::Shaper& _variableRet, const std::string& _value) { - _variableRet.setSource(_value); - return true; -} -template<> bool etk::from_string(ewol::compositing::Shaper& _variableRet, const std::u32string& _value) { - return from_string(_variableRet, etk::to_string(_value)); -} \ No newline at end of file diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index e6d80c9f..f4d3c83d 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -133,21 +133,21 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { markToRedraw(); } if(ewol::key::statusSingle == _event.getStatus()) { - if( ( m_value == true + if( ( m_value.get() == true && ewol::widget::Button::lockWhenPressed == m_lock) - || ( m_value == false + || ( m_value.get() == false && ewol::widget::Button::lockWhenReleased == m_lock) ) { // nothing to do : Lock mode ... // user might set himself the new correct value with @ref setValue(xxx) } else { // inverse value : - setValue((m_value)?false:true); + setValue((m_value.get())?false:true); EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); signalPressed.emit(shared_from_this()); EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); signalValue.emit(shared_from_this(), m_value.get()); - if( false == m_toggleMode - && true == m_value) { + if( m_toggleMode.get() == false + && m_value.get() == true) { setValue(false); EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value); signalValue.emit(shared_from_this(), m_value.get()); @@ -216,7 +216,7 @@ void ewol::widget::Button::onParameterChangeValue(const ewol::object::ParameterR markToRedraw(); } else if (_paramPointer == m_value) { if (m_toggleMode == true) { - if (m_value == false) { + if (m_value.get() == false) { m_idWidgetDisplayed = 0; } else { m_idWidgetDisplayed = 1; @@ -243,20 +243,20 @@ void ewol::widget::Button::onParameterChangeValue(const ewol::object::ParameterR CheckStatus(); markToRedraw(); } else if (_paramPointer == m_toggleMode) { - if (m_value == true) { - m_value = false; + if (m_value.get() == true) { + m_value.get() = false; // TODO : change display and send event ... } - if (m_toggleMode == false) { + if (m_toggleMode.get() == false) { m_idWidgetDisplayed = 0; } else { - if (m_value == false) { + if (m_value.get() == false) { m_idWidgetDisplayed = 0; } else { m_idWidgetDisplayed = 1; } } - if (m_enableSingle == true) { + if (m_enableSingle.get() == true) { if ( m_idWidgetDisplayed == 0 && m_subWidget[0] == nullptr && m_subWidget[1] != nullptr) { diff --git a/sources/ewol/widget/CheckBox.cpp b/sources/ewol/widget/CheckBox.cpp index 45c9ada0..1b6dc839 100644 --- a/sources/ewol/widget/CheckBox.cpp +++ b/sources/ewol/widget/CheckBox.cpp @@ -200,7 +200,7 @@ void ewol::widget::CheckBox::onParameterChangeValue(const ewol::object::Paramete if (_paramPointer == m_shaper) { markToRedraw(); } else if (_paramPointer == m_value) { - if (m_value == false) { + if (m_value.get() == false) { m_idWidgetDisplayed = convertId(0); } else { m_idWidgetDisplayed = convertId(1); From 12c4a88c88cfd76fce3bf7f3a9cb929c1dc50a97 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 21 Aug 2014 21:22:51 +0200 Subject: [PATCH 06/22] [DEV] rework Signal implementation callback ==> must update all soft --- sources/ewol/object/Message.h | 11 +- sources/ewol/object/MultiCast.cpp | 2 +- sources/ewol/object/Signal.h | 178 +++++++++++++++++++++--------- 3 files changed, 128 insertions(+), 63 deletions(-) diff --git a/sources/ewol/object/Message.h b/sources/ewol/object/Message.h index 8c4d60bf..53057b40 100644 --- a/sources/ewol/object/Message.h +++ b/sources/ewol/object/Message.h @@ -15,24 +15,15 @@ namespace ewol { namespace object { class Message { private: - std::shared_ptr m_callerObject; //!< Caller class. const char* m_event; //!< Event pointer == > unique Id define by the system ... std::string m_data; //!< compositing additionnal message Value. public: - Message(const std::shared_ptr& _caller, - const char* _message, + Message(const char* _message, const std::string& _data) : - m_callerObject(_caller), m_event(_message), m_data(_data) { }; - void setCaller(const std::shared_ptr& _caller) { - m_callerObject = _caller; - }; - inline std::shared_ptr getCaller() const { - return m_callerObject; - }; void setMessage(const char* _message) { m_event = _message; }; diff --git a/sources/ewol/object/MultiCast.cpp b/sources/ewol/object/MultiCast.cpp index e6166ef7..1ec76ae1 100644 --- a/sources/ewol/object/MultiCast.cpp +++ b/sources/ewol/object/MultiCast.cpp @@ -71,7 +71,7 @@ void ewol::object::MultiCast::send(const std::shared_ptr& _object, if (obj != nullptr) { EWOL_VERBOSE(" id = " << obj->getId() << " type=" << obj->getObjectType()); // generate event ... (create message before ... - ewol::object::Message tmpMsg(_object, it.m_message, _data); + ewol::object::Message tmpMsg(it.m_message, _data); obj->onReceiveMessage(tmpMsg); } } diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index fc6b517c..314a8ca7 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -11,11 +11,11 @@ #ifndef __EWOL_SIGNAL_H__ #define __EWOL_SIGNAL_H__ +#include #include #include #include - namespace ewol { namespace object { class SignalCallerIdentifier { @@ -32,7 +32,8 @@ namespace ewol { }; template class Signal : public SignalBase { private: - //std::vector> m_callerList; + std::vector, + std::function>> m_callerList; std::vector m_serializedCallerList; public: /** @@ -54,9 +55,39 @@ namespace ewol { * @brief Destructor. */ virtual ~Signal() { }; - void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { + /** + * @brief Bind a callback function to the current signal (generic methis (simplest)) + * @param[in] _obj Shared pointer on the caller object + * @param[in] _func Link on the fuction that might be called (inside a class) + * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); + */ + template void bind(std::shared_ptr _obj, void (TYPE::*_func)(const T&)) { + std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); + if (obj2 == nullptr) { + EWOL_ERROR("Can not bind signal ..."); + return; + } + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1))); + } + /** + * @brief Advanced binding a callback function to the current signal. + * @param[in] _obj Shared pointer on the caller object + * @param[in] _func functor to call (do it yourself) + * @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1)); + */ + void connect(std::shared_ptr _obj, std::function _function ) { + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), _function)); + } + /** + * @brief DEPRECATED: old connect signal between Objects + */ + void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) __attribute__ ((deprecated)) { m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data)); } + /** + * @brief remove link on the signal. + * @param[in] _obj shared pointer on the removing object + */ void release(std::shared_ptr _obj) { for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { if (it->m_object.lock() == _obj) { @@ -64,68 +95,63 @@ namespace ewol { it = m_serializedCallerList.begin(); } } - } - /* - bool emitString(const std::shared_ptr& _source, const std::string& _data) { - // note : this can not emit on function .... - for (auto &it : m_serializedCallerList) { - std::shared_ptr destObject = std::get<0>(it).lock(); - if (destObject == nullptr) { - // TODO : Remove instance ... - EWOL_VERBOSE(" nullptr dest"); - continue; - } - const char* eventId = m_name.c_str(); - if (std::get<1>(it) != nullptr) { - eventId = std::get<1>(it); - } - if (std::get<2>(it).size() <= 0){ - ewol::object::Message tmpMsg(_source, eventId, _data); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } else { - // set the user requested data ... - ewol::object::Message tmpMsg(_source, eventId, std::get<2>(it)); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); + for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) { + if (it->first.lock() == _obj) { + m_callerList.erase(it); + it = m_callerList.begin(); } } } - */ - void emit(const std::shared_ptr& _source, const T& _data) { + /** + * @brief Generate a signal on all interface listening. + * @param[in] _data data to emit + */ + void emit(const std::shared_ptr& _source, const T& _data) __attribute__ ((deprecated)) { + emit(_data); + } + void emit(const T& _data) { // note : this can not emit on function .... - std::string stringData; if (m_serializedCallerList.size()>0 ) { - stringData = etk::to_string(_data); + std::string stringData = etk::to_string(_data); + for (auto &it : m_serializedCallerList) { + std::shared_ptr destObject = it.m_object.lock(); + if (destObject == nullptr) { + // TODO : Remove instance ... + EWOL_VERBOSE(" nullptr dest"); + continue; + } + const char* eventId = m_name.c_str(); + if (it.m_enevntId != nullptr) { + eventId = it.m_enevntId; + } + if (it.m_data.size() <= 0){ + ewol::object::Message tmpMsg(eventId, stringData); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } else { + // set the user requested data ... + ewol::object::Message tmpMsg(eventId, it.m_data); + EWOL_VERBOSE("send message " << tmpMsg); + destObject->onReceiveMessage(tmpMsg); + } + } } - for (auto &it : m_serializedCallerList) { - std::shared_ptr destObject = it.m_object.lock(); + for (auto &it : m_callerList) { + std::shared_ptr destObject = it.first.lock(); if (destObject == nullptr) { // TODO : Remove instance ... EWOL_VERBOSE(" nullptr dest"); continue; } - const char* eventId = m_name.c_str(); - if (it.m_enevntId != nullptr) { - eventId = it.m_enevntId; - } - if (it.m_data.size() <= 0){ - ewol::object::Message tmpMsg(_source, eventId, stringData); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } else { - // set the user requested data ... - ewol::object::Message tmpMsg(_source, eventId, it.m_data); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } + it.second(_data); } } }; template<> class Signal : public SignalBase { private: - //std::vector> m_callerList; + std::vector, + std::function>> m_callerList; std::vector m_serializedCallerList; public: /** @@ -148,9 +174,39 @@ namespace ewol { */ virtual ~Signal() { }; - void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) { + /** + * @brief Bind a callback function to the current signal (generic methis (simplest)) + * @param[in] _obj Shared pointer on the caller object + * @param[in] _func Link on the fuction that might be called (inside a class) + * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); + */ + template void bind(std::shared_ptr _obj, void (TYPE::*_func)()) { + std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); + if (obj2 == nullptr) { + EWOL_ERROR("Can not bind signal ..."); + return; + } + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1))); + } + /** + * @brief Advanced binding a callback function to the current signal. + * @param[in] _obj Shared pointer on the caller object + * @param[in] _func functor to call (do it yourself) + * @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1)); + */ + void connect(std::shared_ptr _obj, std::function _function ) { + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), _function)); + } + /** + * @brief DEPRECATED: old connect signal between Objects + */ + void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) __attribute__ ((deprecated)) { m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data)); } + /** + * @brief remove link on the signal. + * @param[in] _obj shared pointer on the removing object + */ void release(std::shared_ptr _obj) { for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { if (it->m_object.lock() == _obj) { @@ -158,8 +214,17 @@ namespace ewol { it = m_serializedCallerList.begin(); } } + for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) { + if (it->first.lock() == _obj) { + m_callerList.erase(it); + it = m_callerList.begin(); + } + } } - void emit(const std::shared_ptr& _source) { + void emit(const std::shared_ptr& _source) __attribute__ ((deprecated)) { + emit(); + } + void emit() { // note : this can not emit on function .... std::string stringData; for (auto &it : m_serializedCallerList) { @@ -174,16 +239,25 @@ namespace ewol { eventId = it.m_enevntId; } if (it.m_data.size() <= 0){ - ewol::object::Message tmpMsg(_source, eventId, stringData); + ewol::object::Message tmpMsg(eventId, stringData); EWOL_VERBOSE("send message " << tmpMsg); destObject->onReceiveMessage(tmpMsg); } else { // set the user requested data ... - ewol::object::Message tmpMsg(_source, eventId, it.m_data); + ewol::object::Message tmpMsg(eventId, it.m_data); EWOL_VERBOSE("send message " << tmpMsg); destObject->onReceiveMessage(tmpMsg); } } + for (auto &it : m_callerList) { + std::shared_ptr destObject = it.first.lock(); + if (destObject == nullptr) { + // TODO : Remove instance ... + EWOL_VERBOSE(" nullptr dest"); + continue; + } + it.second(); + } } }; From e3f71e5201654e0afb221ebb80bc0ffc92d6e8d7 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 22 Aug 2014 05:20:27 +0200 Subject: [PATCH 07/22] [DEV] remove caller in signal emit --- sources/ewol/object/Object.cpp | 2 +- sources/ewol/object/Signal.h | 8 +- sources/ewol/widget/Button.cpp | 12 +- sources/ewol/widget/ButtonColor.cpp | 2 +- sources/ewol/widget/CheckBox.cpp | 10 +- sources/ewol/widget/ColorBar.cpp | 2 +- sources/ewol/widget/Entry.cpp | 10 +- sources/ewol/widget/Image.cpp | 2 +- sources/ewol/widget/Joystick.cpp | 6 +- sources/ewol/widget/Label.cpp | 2 +- sources/ewol/widget/ListFileSystem.cpp | 16 +- sources/ewol/widget/Menu.cpp | 255 +++++++++++---------- sources/ewol/widget/Menu.h | 3 + sources/ewol/widget/Slider.cpp | 2 +- sources/ewol/widget/WSlider.cpp | 4 +- sources/ewol/widget/Widget.cpp | 2 +- sources/ewol/widget/meta/ColorChooser.cpp | 60 ++--- sources/ewol/widget/meta/ColorChooser.h | 4 + sources/ewol/widget/meta/FileChooser.cpp | 4 +- sources/ewol/widget/meta/Parameter.cpp | 2 +- sources/ewol/widget/meta/ParameterList.cpp | 2 +- 21 files changed, 214 insertions(+), 196 deletions(-) diff --git a/sources/ewol/object/Object.cpp b/sources/ewol/object/Object.cpp index 3c3033f9..59cdb0f1 100644 --- a/sources/ewol/object/Object.cpp +++ b/sources/ewol/object/Object.cpp @@ -63,7 +63,7 @@ ewol::Object::~Object() { void ewol::Object::init() { getObjectManager().add(shared_from_this()); - parameterDisplay(); + //parameterDisplay(); m_objectHasBeenInit = true; } diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index 314a8ca7..701ea0ea 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -61,13 +61,13 @@ namespace ewol { * @param[in] _func Link on the fuction that might be called (inside a class) * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); */ - template void bind(std::shared_ptr _obj, void (TYPE::*_func)(const T&)) { + template void bind(std::shared_ptr _obj, void (TYPE::*_func)(const T&), Args... args) { std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); if (obj2 == nullptr) { EWOL_ERROR("Can not bind signal ..."); return; } - m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1))); + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, args...))); } /** * @brief Advanced binding a callback function to the current signal. @@ -180,13 +180,13 @@ namespace ewol { * @param[in] _func Link on the fuction that might be called (inside a class) * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); */ - template void bind(std::shared_ptr _obj, void (TYPE::*_func)()) { + template void bind(std::shared_ptr _obj, void (TYPE::*_func)(), Args... args) { std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); if (obj2 == nullptr) { EWOL_ERROR("Can not bind signal ..."); return; } - m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1))); + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), args...))); } /** * @brief Advanced binding a callback function to the current signal. diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index f4d3c83d..bbd0371f 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -122,13 +122,13 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { if(ewol::key::statusDown == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); - signalDown.emit(shared_from_this()); + signalDown.emit(); m_buttonPressed = true; markToRedraw(); } if(ewol::key::statusUp == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); - signalUp.emit(shared_from_this()); + signalUp.emit(); m_buttonPressed = false; markToRedraw(); } @@ -143,14 +143,14 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { // inverse value : setValue((m_value.get())?false:true); EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); - signalPressed.emit(shared_from_this()); + signalPressed.emit(); EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); - signalValue.emit(shared_from_this(), m_value.get()); + signalValue.emit(m_value.get()); if( m_toggleMode.get() == false && m_value.get() == true) { setValue(false); EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value); - signalValue.emit(shared_from_this(), m_value.get()); + signalValue.emit(m_value.get()); } } markToRedraw(); @@ -167,7 +167,7 @@ bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { if( _event.getType() == ewol::key::keyboardChar && _event.getStatus() == ewol::key::statusDown && _event.getChar() == '\r') { - signalEnter.emit(shared_from_this()); + signalEnter.emit(); return true; } return false; diff --git a/sources/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index 29b79622..411e3c7b 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -225,7 +225,7 @@ void ewol::widget::ButtonColor::onReceiveMessage(const ewol::object::Message& _m if (_msg.getMessage() == eventColorHasChange) { m_textColorFg = _msg.getData(); // TODO : set a proper call - //signalChange.emit(shared_from_this(), _msg.getData()); + //signalChange.emit(_msg.getData()); EWOL_TODO("generate signal of change color : " << _msg.getData()); markToRedraw(); } diff --git a/sources/ewol/widget/CheckBox.cpp b/sources/ewol/widget/CheckBox.cpp index 1b6dc839..56d3e05d 100644 --- a/sources/ewol/widget/CheckBox.cpp +++ b/sources/ewol/widget/CheckBox.cpp @@ -128,13 +128,13 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { if(ewol::key::statusDown == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); - signalDown.emit(shared_from_this()); + signalDown.emit(); m_buttonPressed = true; markToRedraw(); } if(ewol::key::statusUp == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); - signalUp.emit(shared_from_this()); + signalUp.emit(); m_buttonPressed = false; markToRedraw(); } @@ -142,9 +142,9 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { // inverse value : setValue((m_value)?false:true); EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); - signalPressed.emit(shared_from_this()); + signalPressed.emit(); EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); - signalValue.emit(shared_from_this(), m_value.get()); + signalValue.emit(m_value.get()); markToRedraw(); } } @@ -162,7 +162,7 @@ bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { if( _event.getType() == ewol::key::keyboardChar && _event.getStatus() == ewol::key::statusDown && _event.getChar() == '\r') { - signalEnter.emit(shared_from_this()); + signalEnter.emit(); return true; } return false; diff --git a/sources/ewol/widget/ColorBar.cpp b/sources/ewol/widget/ColorBar.cpp index b5958014..4ba95fa6 100644 --- a/sources/ewol/widget/ColorBar.cpp +++ b/sources/ewol/widget/ColorBar.cpp @@ -220,7 +220,7 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { } if(m_currentColor != estimateColor) { m_currentColor = estimateColor; - signalChange.emit(shared_from_this(), m_currentColor); + signalChange.emit(m_currentColor); } return true; } diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index d0c723da..4b4536d4 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -240,7 +240,7 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { if (ewol::key::statusSingle == _event.getStatus()) { keepFocus(); - signalClick.emit(shared_from_this()); + signalClick.emit(); //nothing to do ... return true; } else if (ewol::key::statusDouble == _event.getStatus()) { @@ -335,7 +335,7 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { removeSelected(); if( _event.getChar() == '\n' || _event.getChar() == '\r') { - signalEnter.emit(shared_from_this(), m_data); + signalEnter.emit(m_data); return true; } else if (_event.getChar() == 0x7F) { // SUPPR : @@ -365,7 +365,7 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { } } } - signalModify.emit(shared_from_this(), m_data); + signalModify.emit(m_data); markToRedraw(); return true; } @@ -437,7 +437,7 @@ void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipbo markToRedraw(); } } - signalModify.emit(shared_from_this(), m_data); + signalModify.emit(m_data); } @@ -452,7 +452,7 @@ void ewol::widget::Entry::onReceiveMessage(const ewol::object::Message& _msg) { } else if(_msg.getMessage() == ewolEventEntryCut) { copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); removeSelected(); - signalModify.emit(shared_from_this(), m_data); + signalModify.emit(m_data); } else if(_msg.getMessage() == ewolEventEntryCopy) { copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); } else if(_msg.getMessage() == ewolEventEntryPaste) { diff --git a/sources/ewol/widget/Image.cpp b/sources/ewol/widget/Image.cpp index b44a775a..919dd241 100644 --- a/sources/ewol/widget/Image.cpp +++ b/sources/ewol/widget/Image.cpp @@ -133,7 +133,7 @@ bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on BT ..."); if (1 == _event.getId()) { if(ewol::key::statusSingle == _event.getStatus()) { - signalPressed.emit(shared_from_this()); + signalPressed.emit(); return true; } } diff --git a/sources/ewol/widget/Joystick.cpp b/sources/ewol/widget/Joystick.cpp index d3e5b46a..b4be3bea 100644 --- a/sources/ewol/widget/Joystick.cpp +++ b/sources/ewol/widget/Joystick.cpp @@ -144,10 +144,10 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { } markToRedraw(); if(ewol::key::statusDown == typeEvent) { - signalEnable.emit(shared_from_this()); + signalEnable.emit(); } else { std::string tmp = std::string("distance=") + std::string(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2); - signalMove.emit(shared_from_this(), m_angle+M_PI/2); + signalMove.emit(m_angle+M_PI/2); } //teta += M_PI/2; //EWOL_DEBUG("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance); @@ -163,7 +163,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { m_distance = 0; } markToRedraw(); - signalDisable.emit(shared_from_this()); + signalDisable.emit(); return true; } return false; diff --git a/sources/ewol/widget/Label.cpp b/sources/ewol/widget/Label.cpp index d6ec3794..c0e14fa9 100644 --- a/sources/ewol/widget/Label.cpp +++ b/sources/ewol/widget/Label.cpp @@ -124,7 +124,7 @@ bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { if (ewol::key::statusSingle == _event.getStatus()) { // nothing to do ... - signalPressed.emit(shared_from_this()); + signalPressed.emit(); return true; } } diff --git a/sources/ewol/widget/ListFileSystem.cpp b/sources/ewol/widget/ListFileSystem.cpp index 271954ea..f16ae7b6 100644 --- a/sources/ewol/widget/ListFileSystem.cpp +++ b/sources/ewol/widget/ListFileSystem.cpp @@ -185,21 +185,21 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, if( m_showFolder == true && m_selectedLine == 0) { // "." folder - signalFolderSelect.emit(shared_from_this(), "."); + signalFolderSelect.emit("."); } else if ( m_showFolder == true && m_selectedLine == 1) { // ".." folder - signalFolderSelect.emit(shared_from_this(), ".."); + signalFolderSelect.emit(".."); } else if( m_selectedLine-offset >= 0 && m_selectedLine-offset < (int32_t)m_list.size() && nullptr != m_list[m_selectedLine-offset] ) { // generate event extern : switch(m_list[m_selectedLine-offset]->getNodeType()) { case etk::FSN_FILE : - signalFileSelect.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); + signalFileSelect.emit(m_list[m_selectedLine-offset]->getNameFile()); break; case etk::FSN_FOLDER : - signalFolderSelect.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); + signalFolderSelect.emit(m_list[m_selectedLine-offset]->getNameFile()); break; default: EWOL_ERROR("Can not generate event on an unknow type"); @@ -210,20 +210,20 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, if( m_showFolder == true && m_selectedLine == 0) { // "." folder - signalFolderValidate.emit(shared_from_this(), "."); + signalFolderValidate.emit("."); } else if ( m_showFolder == true && m_selectedLine == 1) { // ".." folder - signalFolderValidate.emit(shared_from_this(), ".."); + signalFolderValidate.emit(".."); } else if( m_selectedLine-offset >= 0 && m_selectedLine-offset < (int32_t)m_list.size() && nullptr != m_list[m_selectedLine-offset] ) { switch(m_list[m_selectedLine-offset]->getNodeType()) { case etk::FSN_FILE : - signalFileValidate.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); + signalFileValidate.emit(m_list[m_selectedLine-offset]->getNameFile()); break; case etk::FSN_FOLDER : - signalFolderValidate.emit(shared_from_this(), m_list[m_selectedLine-offset]->getNameFile()); + signalFolderValidate.emit(m_list[m_selectedLine-offset]->getNameFile()); break; default: EWOL_ERROR("Can not generate event on an unknow type"); diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index b6cbb78d..11527680 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -97,7 +97,10 @@ int32_t ewol::widget::Menu::add(int32_t _parent, // add it in the widget list ewol::widget::Sizer::subWidgetAdd(myButton); // keep the specific event ... - myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); + //myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); + std::weak_ptr myButtonWeak(myButton); + //myButton->signalPressed.bind(shared_from_this(), &ewol::widget::Menu::onButtonPressed, myButtonWeak); + myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr(myButton))); tmpObject.m_widgetPointer = myButton; } m_listElement.push_back(tmpObject); @@ -108,136 +111,138 @@ void ewol::widget::Menu::addSpacer() { EWOL_TODO("NOT now..."); } - -void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) { - /* - if (true == ewol::sizer::onReceiveMessage(_msg) { - return true; +void ewol::widget::Menu::onButtonPressed(std::weak_ptr _button) { + std::shared_ptr caller = _button.lock(); + if (caller == nullptr) { + return; } - */ - EWOL_ERROR(" receive message : " << _msg); - if (_msg.getMessage() == eventButtonPressed) { - for (auto &it : m_listElement) { - if (_msg.getCaller() == it.m_widgetPointer.lock()) { - // 2 posible case (have a message or have a child ... - if (it.m_generateEvent != nullptr) { - EWOL_DEBUG("Menu == > generate Event"); - // Send a multicast event ... - sendMultiCast(it.m_generateEvent, it.m_message); - std::shared_ptr tmpContext = m_widgetContextMenu.lock(); - if (tmpContext != nullptr) { - EWOL_DEBUG("Mark the menu to remove ..."); - tmpContext->destroy(); - } - return; - } else{ - EWOL_DEBUG("Menu == > load Sub Menu"); - bool findChild = false; - for (auto &it2 : m_listElement) { - if (it.m_localId == it2.m_parentId) { - findChild = true; - break; - } - } - if (false == findChild) { - EWOL_WARNING("Event on menu element with no child an no event... label=" << it.m_label); - return; - } - // create a context menu : - std::shared_ptr tmpContext = ewol::widget::ContextMenu::create(); - m_widgetContextMenu = tmpContext; - if (tmpContext == nullptr) { - EWOL_ERROR("Allocation Error"); - return; - } - // get the button widget : - vec2 newPosition; - std::shared_ptr eventFromWidget = std::dynamic_pointer_cast(_msg.getCaller()); - if (eventFromWidget != nullptr) { - vec2 tmpOri = eventFromWidget->getOrigin(); - vec2 tmpSize = eventFromWidget->getSize(); - // calculate the correct position - newPosition.setValue(tmpOri.x() + tmpSize.x()/2, - tmpOri.y() ); - } - tmpContext->setPositionMark(ewol::widget::ContextMenu::markTop, newPosition ); - - std::shared_ptr mySizer; - std::shared_ptr myButton; - - mySizer = ewol::widget::Sizer::create(widget::Sizer::modeVert); - if (nullptr != mySizer) { - mySizer->lockExpand(vec2(true,true)); - // set it in the pop-up-system : - tmpContext->setSubWidget(mySizer); - - bool menuHaveImage = false; - for (auto &it2 : m_listElement) { - if (it.m_localId == it2.m_parentId) { - if (it2.m_image.size()!=0) { - menuHaveImage = true; - break; - } - } - } - for (auto it2=m_listElement.rbegin(); it2!=m_listElement.rend() ; ++it2) { - if (it.m_localId == it2->m_parentId) { - myButton = ewol::widget::Button::create(); - if (myButton == nullptr) { - EWOL_ERROR("Allocation Error"); - } else { - if (it2->m_image.size()!=0) { - std::string composeString = "\n"; - composeString+= " \n"; - if (etk::end_with(it2->m_image, ".edf") == true) { - composeString+=" m_image + "\" size=\"8,8mm\" distance-field='true'/>\n"; - } else { - composeString+=" m_image + "\" size=\"8,8mm\"/>\n"; - } - composeString+=" \n"; - composeString+=" \n"; - composeString+="\n"; - myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString)); - } else { - if (true == menuHaveImage) { - myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, - std::string("\n") + - " \n" - " \n" - " \n" - " \n" - "\n")); - } else { - std::shared_ptr tmpLabel = widget::Label::create(std::string("") + it2->m_label + "\n"); - if (tmpLabel != nullptr) { - tmpLabel->setExpand(bvec2(true,false)); - tmpLabel->setFill(bvec2(true,true)); - myButton->setSubWidget(tmpLabel); - } - } - } - // set the image if one is present ... - myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); - myButton->setExpand(bvec2(true,false)); - myButton->setFill(bvec2(true,false)); - // add it in the widget list - mySizer->subWidgetAdd(myButton); - it2->m_widgetPointer = myButton; - } - } - } - } - std::shared_ptr currentWindows = getWindows(); - if (currentWindows == nullptr) { - EWOL_ERROR("Can not get the curent Windows..."); - } else { - currentWindows->popUpWidgetPush(tmpContext); - } + for (auto &it : m_listElement) { + if (caller == it.m_widgetPointer.lock()) { + // 2 posible case (have a message or have a child ... + if (it.m_generateEvent != nullptr) { + EWOL_DEBUG("Menu == > generate Event"); + // Send a multicast event ... + sendMultiCast(it.m_generateEvent, it.m_message); + std::shared_ptr tmpContext = m_widgetContextMenu.lock(); + if (tmpContext != nullptr) { + EWOL_DEBUG("Mark the menu to remove ..."); + tmpContext->destroy(); } return; + } else{ + EWOL_DEBUG("Menu == > load Sub Menu"); + bool findChild = false; + for (auto &it2 : m_listElement) { + if (it.m_localId == it2.m_parentId) { + findChild = true; + break; + } + } + if (false == findChild) { + EWOL_WARNING("Event on menu element with no child an no event... label=" << it.m_label); + return; + } + // create a context menu : + std::shared_ptr tmpContext = ewol::widget::ContextMenu::create(); + m_widgetContextMenu = tmpContext; + if (tmpContext == nullptr) { + EWOL_ERROR("Allocation Error"); + return; + } + // get the button widget : + vec2 newPosition; + std::shared_ptr eventFromWidget = std::dynamic_pointer_cast(caller); + if (eventFromWidget != nullptr) { + vec2 tmpOri = eventFromWidget->getOrigin(); + vec2 tmpSize = eventFromWidget->getSize(); + // calculate the correct position + newPosition.setValue(tmpOri.x() + tmpSize.x()/2, + tmpOri.y() ); + } + tmpContext->setPositionMark(ewol::widget::ContextMenu::markTop, newPosition ); + + std::shared_ptr mySizer; + std::shared_ptr myButton; + + mySizer = ewol::widget::Sizer::create(widget::Sizer::modeVert); + if (nullptr != mySizer) { + mySizer->lockExpand(vec2(true,true)); + // set it in the pop-up-system : + tmpContext->setSubWidget(mySizer); + + bool menuHaveImage = false; + for (auto &it2 : m_listElement) { + if (it.m_localId == it2.m_parentId) { + if (it2.m_image.size()!=0) { + menuHaveImage = true; + break; + } + } + } + for (auto it2=m_listElement.rbegin(); it2!=m_listElement.rend() ; ++it2) { + if (it.m_localId == it2->m_parentId) { + myButton = ewol::widget::Button::create(); + if (myButton == nullptr) { + EWOL_ERROR("Allocation Error"); + } else { + if (it2->m_image.size()!=0) { + std::string composeString = "\n"; + composeString+= " \n"; + if (etk::end_with(it2->m_image, ".edf") == true) { + composeString+=" m_image + "\" size=\"8,8mm\" distance-field='true'/>\n"; + } else { + composeString+=" m_image + "\" size=\"8,8mm\"/>\n"; + } + composeString+=" \n"; + composeString+=" \n"; + composeString+="\n"; + myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString)); + } else { + if (true == menuHaveImage) { + myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, + std::string("\n") + + " \n" + " \n" + " \n" + " \n" + "\n")); + } else { + std::shared_ptr tmpLabel = widget::Label::create(std::string("") + it2->m_label + "\n"); + if (tmpLabel != nullptr) { + tmpLabel->setExpand(bvec2(true,false)); + tmpLabel->setFill(bvec2(true,true)); + myButton->setSubWidget(tmpLabel); + } + } + } + // set the image if one is present ... + //myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); + myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr(myButton))); + myButton->setExpand(bvec2(true,false)); + myButton->setFill(bvec2(true,false)); + // add it in the widget list + mySizer->subWidgetAdd(myButton); + it2->m_widgetPointer = myButton; + } + } + } + } + std::shared_ptr currentWindows = getWindows(); + if (currentWindows == nullptr) { + EWOL_ERROR("Can not get the curent Windows..."); + } else { + currentWindows->popUpWidgetPush(tmpContext); + } } + return; } } } +void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) { + /* + */ +} + + diff --git a/sources/ewol/widget/Menu.h b/sources/ewol/widget/Menu.h index eeb67f53..36c5be3e 100644 --- a/sources/ewol/widget/Menu.h +++ b/sources/ewol/widget/Menu.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,8 @@ namespace ewol { void addSpacer(); // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); + private: + void onButtonPressed(std::weak_ptr _button); }; }; }; diff --git a/sources/ewol/widget/Slider.cpp b/sources/ewol/widget/Slider.cpp index 8dd4bf30..9b1cb3fc 100644 --- a/sources/ewol/widget/Slider.cpp +++ b/sources/ewol/widget/Slider.cpp @@ -107,7 +107,7 @@ bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { m_value = std::max(std::min(m_value, m_max), m_min); if (oldValue != m_value) { EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]"); - signalChange.emit(shared_from_this(), m_value); + signalChange.emit(m_value); markToRedraw(); } return true; diff --git a/sources/ewol/widget/WSlider.cpp b/sources/ewol/widget/WSlider.cpp index 0a9d7671..76aa3b82 100644 --- a/sources/ewol/widget/WSlider.cpp +++ b/sources/ewol/widget/WSlider.cpp @@ -101,7 +101,7 @@ void ewol::widget::WSlider::subWidgetSelectSetVectorId(int32_t _id) { } if (_id != m_windowsDestination) { m_windowsRequested = _id; - signalStartSlide.emit(shared_from_this()); + signalStartSlide.emit(); periodicCallEnable(); markToRedraw(); } @@ -185,7 +185,7 @@ void ewol::widget::WSlider::periodicCall(const ewol::event::Time& _event) { } else { // end of periodic : periodicCallDisable(); - signalStopSlide.emit(shared_from_this()); + signalStopSlide.emit(); } m_windowsRequested = -1; } diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index b59c72d6..93e78bef 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -556,7 +556,7 @@ bool ewol::Widget::onEventShortCut(ewol::key::Special& _special, sendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData); } // send message direct to the current widget (in every case, really useful for some generic windows shortcut) - ewol::object::Message tmpMsg(shared_from_this(), m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData); + ewol::object::Message tmpMsg(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData); onReceiveMessage(tmpMsg); } // no else return true; diff --git a/sources/ewol/widget/meta/ColorChooser.cpp b/sources/ewol/widget/meta/ColorChooser.cpp index 3972dfe1..db6ed379 100644 --- a/sources/ewol/widget/meta/ColorChooser.cpp +++ b/sources/ewol/widget/meta/ColorChooser.cpp @@ -23,7 +23,6 @@ extern "C" { #define __class__ "ColorChooser" static const char * const eventColorBarHasChange = "event-color-bar-has-change"; -static const char * const eventColorSpecificHasChange = "event-color-specific-has-change"; ewol::widget::ColorChooser::ColorChooser() : @@ -43,7 +42,7 @@ void ewol::widget::ColorChooser::init() { sliderColor = etk::color::black; m_widgetRed = ewol::widget::Slider::create(); - m_widgetRed->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange); + m_widgetRed->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeRed); m_widgetRed->setExpand(bvec2(true,false)); m_widgetRed->setFill(bvec2(true,false)); m_widgetRed->setMin(0); @@ -52,7 +51,7 @@ void ewol::widget::ColorChooser::init() { m_widgetRed->setColor(sliderColor); subWidgetAdd(m_widgetRed); m_widgetGreen = ewol::widget::Slider::create(); - m_widgetGreen->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange); + m_widgetGreen->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeGreen); m_widgetGreen->setExpand(bvec2(true,false)); m_widgetGreen->setFill(bvec2(true,false)); m_widgetGreen->setMin(0); @@ -61,7 +60,7 @@ void ewol::widget::ColorChooser::init() { m_widgetGreen->setMax(255); subWidgetAdd(m_widgetGreen); m_widgetBlue = ewol::widget::Slider::create(); - m_widgetBlue->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange); + m_widgetBlue->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeBlue); m_widgetBlue->setExpand(bvec2(true,false)); m_widgetBlue->setFill(bvec2(true,false)); m_widgetBlue->setMin(0); @@ -70,7 +69,7 @@ void ewol::widget::ColorChooser::init() { m_widgetBlue->setMax(255); subWidgetAdd(m_widgetBlue); m_widgetAlpha = ewol::widget::Slider::create(); - m_widgetAlpha->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange); + m_widgetAlpha->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeAlpha); m_widgetAlpha->setExpand(bvec2(true,false)); m_widgetAlpha->setFill(bvec2(true,false)); m_widgetAlpha->setMin(0); @@ -112,9 +111,6 @@ etk::Color<> ewol::widget::ColorChooser::getColor() { void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _msg) { - if (nullptr == _msg.getCaller()) { - return; - } //EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" == > data=\"" << data << "\"" ); if (eventColorBarHasChange == _msg.getMessage()) { // == > colorBar has change ... @@ -136,25 +132,35 @@ void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _ if (nullptr != m_widgetAlpha) { m_widgetAlpha->setValue(m_currentColor.a()); } - signalChange.emit(shared_from_this(), m_currentColor); - } else if (eventColorSpecificHasChange == _msg.getMessage()) { - // Slider has changes his color == > get the one change ... - if (_msg.getCaller() == m_widgetRed) { - m_currentColor.setR(m_widgetRed->getValue()); - } - if (_msg.getCaller() == m_widgetGreen) { - m_currentColor.setG(m_widgetGreen->getValue()); - } - if (_msg.getCaller() == m_widgetBlue) { - m_currentColor.setB(m_widgetBlue->getValue()); - } - if (_msg.getCaller() == m_widgetAlpha) { - m_currentColor.setA(m_widgetAlpha->getValue()); - } - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); - } - signalChange.emit(shared_from_this(), m_currentColor); + signalChange.emit(m_currentColor); } }; +void ewol::widget::ColorChooser::onCallbackColorChangeRed(const int32_t& _newColor) { + m_currentColor.setR(_newColor); + if (nullptr != m_widgetColorBar) { + m_widgetColorBar->setCurrentColor(m_currentColor); + } + signalChange.emit(m_currentColor); +} +void ewol::widget::ColorChooser::onCallbackColorChangeGreen(const int32_t& _newColor) { + m_currentColor.setG(_newColor); + if (nullptr != m_widgetColorBar) { + m_widgetColorBar->setCurrentColor(m_currentColor); + } + signalChange.emit(m_currentColor); +} +void ewol::widget::ColorChooser::onCallbackColorChangeBlue(const int32_t& _newColor) { + m_currentColor.setB(_newColor); + if (nullptr != m_widgetColorBar) { + m_widgetColorBar->setCurrentColor(m_currentColor); + } + signalChange.emit(m_currentColor); +} +void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const int32_t& _newColor) { + m_currentColor.setA(_newColor); + if (nullptr != m_widgetColorBar) { + m_widgetColorBar->setCurrentColor(m_currentColor); + } + signalChange.emit(m_currentColor); +} diff --git a/sources/ewol/widget/meta/ColorChooser.h b/sources/ewol/widget/meta/ColorChooser.h index 445b081b..ccb66dea 100644 --- a/sources/ewol/widget/meta/ColorChooser.h +++ b/sources/ewol/widget/meta/ColorChooser.h @@ -47,6 +47,10 @@ namespace ewol { std::shared_ptr m_widgetBlue; std::shared_ptr m_widgetAlpha; etk::Color<> m_currentColor; + void onCallbackColorChangeRed(const int32_t& _newColor); + void onCallbackColorChangeGreen(const int32_t& _newColor); + void onCallbackColorChangeBlue(const int32_t& _newColor); + void onCallbackColorChangeAlpha(const int32_t& _newColor); }; }; }; diff --git a/sources/ewol/widget/meta/FileChooser.cpp b/sources/ewol/widget/meta/FileChooser.cpp index 16c3d5c7..e7c930f0 100644 --- a/sources/ewol/widget/meta/FileChooser.cpp +++ b/sources/ewol/widget/meta/FileChooser.cpp @@ -164,7 +164,7 @@ void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _m parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file); } else if (ewolEventFileChooserCancel == _msg.getMessage()) { // == > Auto remove ... - signalCancel.emit(shared_from_this()); + signalCancel.emit(); autoDestroy(); } else if (_msg.getMessage() == ewolEventFileChooserHidenFileChange) { if (_msg.getData() == "true") { @@ -195,7 +195,7 @@ void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _m setFileName(_msg.getData()); } EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); - signalValidate.emit(shared_from_this(), getCompleateFileName()); + signalValidate.emit(getCompleateFileName()); autoDestroy(); } else if(_msg.getMessage() == ewolEventFileChooserHome) { std::string tmpUserFolder = etk::getUserHomeFolder(); diff --git a/sources/ewol/widget/meta/Parameter.cpp b/sources/ewol/widget/meta/Parameter.cpp index 9825fc25..f7f454c3 100644 --- a/sources/ewol/widget/meta/Parameter.cpp +++ b/sources/ewol/widget/meta/Parameter.cpp @@ -200,7 +200,7 @@ void ewol::widget::Parameter::onReceiveMessage(const ewol::object::Message& _msg EWOL_DEBUG("event on the parameter : " << _msg); if (_msg.getMessage() == ewolEventMenuclosed) { // inform that the parameter windows is closed - signalClose.emit(shared_from_this()); + signalClose.emit(); // close this widget ... autoDestroy(); } else if (_msg.getMessage() == ewolEventParameterSave) { diff --git a/sources/ewol/widget/meta/ParameterList.cpp b/sources/ewol/widget/meta/ParameterList.cpp index 29ef9695..4d3cd2c3 100644 --- a/sources/ewol/widget/meta/ParameterList.cpp +++ b/sources/ewol/widget/meta/ParameterList.cpp @@ -190,7 +190,7 @@ bool ewol::widget::ParameterList::onEventInput(const ewol::event::Input& _event) if (rawID >= 0 && (size_t)rawID < m_list.size()) { if (m_list[rawID]!=nullptr) { if (m_list[rawID]->m_refId >= 0) { - signalSelect.emit(shared_from_this(), m_list[rawID]->m_refId); + signalSelect.emit(m_list[rawID]->m_refId); m_idSelected = rawID; markToRedraw(); return true; From 7edbc3a0cf54799026d7c482e499bacbed5ae169 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 22 Aug 2014 22:21:23 +0200 Subject: [PATCH 08/22] [DEV] update new signal system --- external/ege | 2 +- sources/ewol/object/Signal.h | 105 +------------- sources/ewol/object/SignalBase.h | 1 - sources/ewol/object/SignalList.cpp | 10 +- sources/ewol/object/SignalList.h | 4 +- sources/ewol/widget/ButtonColor.cpp | 7 +- sources/ewol/widget/ButtonColor.h | 4 +- sources/ewol/widget/Composer.h | 27 +++- sources/ewol/widget/Menu.cpp | 3 - sources/ewol/widget/meta/ColorChooser.cpp | 9 +- sources/ewol/widget/meta/ColorChooser.h | 1 + sources/ewol/widget/meta/FileChooser.cpp | 166 +++++++++++----------- sources/ewol/widget/meta/FileChooser.h | 12 +- sources/ewol/widget/meta/Parameter.cpp | 43 +++--- sources/ewol/widget/meta/Parameter.h | 6 +- sources/ewol/widget/meta/StdPopUp.cpp | 12 +- sources/ewol/widget/meta/StdPopUp.h | 4 +- 17 files changed, 182 insertions(+), 234 deletions(-) diff --git a/external/ege b/external/ege index 87b68c40..cddef975 160000 --- a/external/ege +++ b/external/ege @@ -1 +1 @@ -Subproject commit 87b68c408e3bceff1923e84d2e08fcee9d868561 +Subproject commit cddef97574c4066bc778b529791bd168ecf731cf diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index 701ea0ea..b7694d6c 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -18,23 +18,10 @@ namespace ewol { namespace object { - class SignalCallerIdentifier { - public: - std::weak_ptr m_object; - const char* m_enevntId; - std::string m_data; - SignalCallerIdentifier(std::shared_ptr _object, const char* _enevntId, const std::string& _data) : - m_object(_object), - m_enevntId(_enevntId), - m_data(_data) { - // nothing to do ... - } - }; template class Signal : public SignalBase { private: std::vector, std::function>> m_callerList; - std::vector m_serializedCallerList; public: /** * @brief Create a parameter with a specific type. @@ -61,13 +48,13 @@ namespace ewol { * @param[in] _func Link on the fuction that might be called (inside a class) * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); */ - template void bind(std::shared_ptr _obj, void (TYPE::*_func)(const T&), Args... args) { + template void bind(std::shared_ptr _obj, void (TYPE::*_func)(const T&)) { std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); if (obj2 == nullptr) { EWOL_ERROR("Can not bind signal ..."); return; } - m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, args...))); + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), std::placeholders::_1))); } /** * @brief Advanced binding a callback function to the current signal. @@ -78,23 +65,11 @@ namespace ewol { void connect(std::shared_ptr _obj, std::function _function ) { m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), _function)); } - /** - * @brief DEPRECATED: old connect signal between Objects - */ - void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) __attribute__ ((deprecated)) { - m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data)); - } /** * @brief remove link on the signal. * @param[in] _obj shared pointer on the removing object */ void release(std::shared_ptr _obj) { - for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { - if (it->m_object.lock() == _obj) { - m_serializedCallerList.erase(it); - it = m_serializedCallerList.begin(); - } - } for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) { if (it->first.lock() == _obj) { m_callerList.erase(it); @@ -106,36 +81,7 @@ namespace ewol { * @brief Generate a signal on all interface listening. * @param[in] _data data to emit */ - void emit(const std::shared_ptr& _source, const T& _data) __attribute__ ((deprecated)) { - emit(_data); - } void emit(const T& _data) { - // note : this can not emit on function .... - if (m_serializedCallerList.size()>0 ) { - std::string stringData = etk::to_string(_data); - for (auto &it : m_serializedCallerList) { - std::shared_ptr destObject = it.m_object.lock(); - if (destObject == nullptr) { - // TODO : Remove instance ... - EWOL_VERBOSE(" nullptr dest"); - continue; - } - const char* eventId = m_name.c_str(); - if (it.m_enevntId != nullptr) { - eventId = it.m_enevntId; - } - if (it.m_data.size() <= 0){ - ewol::object::Message tmpMsg(eventId, stringData); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } else { - // set the user requested data ... - ewol::object::Message tmpMsg(eventId, it.m_data); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } - } - } for (auto &it : m_callerList) { std::shared_ptr destObject = it.first.lock(); if (destObject == nullptr) { @@ -150,9 +96,7 @@ namespace ewol { template<> class Signal : public SignalBase { private: - std::vector, - std::function>> m_callerList; - std::vector m_serializedCallerList; + std::vector, std::function>> m_callerList; public: /** * @brief Create a parameter with a specific type. @@ -180,13 +124,13 @@ namespace ewol { * @param[in] _func Link on the fuction that might be called (inside a class) * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); */ - template void bind(std::shared_ptr _obj, void (TYPE::*_func)(), Args... args) { + template void bind(std::shared_ptr _obj, void (TYPE::*_func)()) { std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); if (obj2 == nullptr) { EWOL_ERROR("Can not bind signal ..."); return; } - m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get(), args...))); + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get()))); } /** * @brief Advanced binding a callback function to the current signal. @@ -197,23 +141,11 @@ namespace ewol { void connect(std::shared_ptr _obj, std::function _function ) { m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), _function)); } - /** - * @brief DEPRECATED: old connect signal between Objects - */ - void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) __attribute__ ((deprecated)) { - m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data)); - } /** * @brief remove link on the signal. * @param[in] _obj shared pointer on the removing object */ void release(std::shared_ptr _obj) { - for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) { - if (it->m_object.lock() == _obj) { - m_serializedCallerList.erase(it); - it = m_serializedCallerList.begin(); - } - } for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) { if (it->first.lock() == _obj) { m_callerList.erase(it); @@ -221,34 +153,7 @@ namespace ewol { } } } - void emit(const std::shared_ptr& _source) __attribute__ ((deprecated)) { - emit(); - } void emit() { - // note : this can not emit on function .... - std::string stringData; - for (auto &it : m_serializedCallerList) { - std::shared_ptr destObject = it.m_object.lock(); - if (destObject == nullptr) { - // TODO : Remove instance ... - EWOL_VERBOSE(" nullptr dest"); - continue; - } - const char* eventId = m_name.c_str(); - if (it.m_enevntId != nullptr) { - eventId = it.m_enevntId; - } - if (it.m_data.size() <= 0){ - ewol::object::Message tmpMsg(eventId, stringData); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } else { - // set the user requested data ... - ewol::object::Message tmpMsg(eventId, it.m_data); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } - } for (auto &it : m_callerList) { std::shared_ptr destObject = it.first.lock(); if (destObject == nullptr) { diff --git a/sources/ewol/object/SignalBase.h b/sources/ewol/object/SignalBase.h index f6951795..e45b4cac 100644 --- a/sources/ewol/object/SignalBase.h +++ b/sources/ewol/object/SignalBase.h @@ -42,7 +42,6 @@ namespace ewol { const std::string& getDescription() const { return m_description; } - virtual void connect(std::shared_ptr _obj, const char* _destId=nullptr, const std::string& _data="" ) = 0; virtual void release(std::shared_ptr _obj) = 0; }; std::ostream& operator <<(std::ostream& _os, const SignalBase& _obj); diff --git a/sources/ewol/object/SignalList.cpp b/sources/ewol/object/SignalList.cpp index 92e9b5a3..7b41011e 100644 --- a/sources/ewol/object/SignalList.cpp +++ b/sources/ewol/object/SignalList.cpp @@ -45,7 +45,8 @@ void ewol::object::SignalList::registerOnObjectEvent(const std::shared_ptr tmpObject = tmp.getObjectNamed(_objectName); if (nullptr != tmpObject) { EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'"); @@ -53,12 +54,15 @@ void ewol::object::SignalList::registerOnObjectEvent(const std::shared_ptr& _destinationObject, const char * _eventId, const char * _eventIdgenerated, const std::string& _overloadData) { + EWOL_TODO("RegisterOnEvent ..."); + /* if (_destinationObject == nullptr) { EWOL_ERROR("Input ERROR nullptr pointer Object ..."); return; @@ -93,10 +97,13 @@ void ewol::object::SignalList::registerOnEvent(const std::shared_ptr unknow event"); return; } + */ } void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptr& _destinationObject, const char * _eventId) { + EWOL_TODO("unRegisterOnEvent ..."); + /* if (_destinationObject == nullptr) { EWOL_ERROR("Input ERROR nullptr pointer Object ..."); return; @@ -111,4 +118,5 @@ void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptrrelease(_destinationObject); } } + */ } diff --git a/sources/ewol/object/SignalList.h b/sources/ewol/object/SignalList.h index dde06808..2deb8a27 100644 --- a/sources/ewol/object/SignalList.h +++ b/sources/ewol/object/SignalList.h @@ -67,14 +67,14 @@ namespace ewol { void registerOnEvent(const std::shared_ptr& _destinationObject, const char * _eventId, const char * _eventIdgenerated = nullptr, - const std::string& _overloadData = ""); + const std::string& _overloadData = "") __attribute__ ((deprecated)); /** * @brief Un-Register an Object over an other. * @param[in] _destinationObject pointer on the object that might be call when an event is generated * @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object) */ void unRegisterOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId = nullptr); + const char * _eventId = nullptr) __attribute__ ((deprecated)); /** * @brief Receive a message from an other Object with a specific eventId and data * @param[in] _msg Message handle diff --git a/sources/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index 411e3c7b..0b9c1699 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -182,7 +182,7 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { myColorChooser->setColor(m_textColorFg); // set it in the pop-up-system : m_widgetContextMenu->setSubWidget(myColorChooser); - myColorChooser->registerOnEvent(shared_from_this(), "change", eventColorHasChange); + myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange); std::shared_ptr currentWindows = getWindows(); if (currentWindows == nullptr) { EWOL_ERROR("Can not get the curent Windows..."); @@ -209,8 +209,11 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { return m_mouseHover; } +void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color) { + setValue(_color); +} -void ewol::widget::ButtonColor::setValue(etk::Color<> _color) { +void ewol::widget::ButtonColor::setValue(const etk::Color<>& _color) { m_textColorFg = _color; markToRedraw(); } diff --git a/sources/ewol/widget/ButtonColor.h b/sources/ewol/widget/ButtonColor.h index 590bf70b..0918f855 100644 --- a/sources/ewol/widget/ButtonColor.h +++ b/sources/ewol/widget/ButtonColor.h @@ -63,7 +63,7 @@ namespace ewol { * @brief Specify the current color. * @param[in] _color The new display color. */ - void setValue(etk::Color<> _color); + void setValue(const etk::Color<>& _color); protected: // Derived function virtual void onDraw(); public: // Derived function @@ -79,6 +79,8 @@ namespace ewol { void changeStatusIn(int32_t _newStatusId); // Derived function virtual void periodicCall(const ewol::event::Time& _event); + // Callback function: + void onCallbackColorChange(const etk::Color<>& _color); }; }; }; diff --git a/sources/ewol/widget/Composer.h b/sources/ewol/widget/Composer.h index 1ab54df4..a930a844 100644 --- a/sources/ewol/widget/Composer.h +++ b/sources/ewol/widget/Composer.h @@ -58,6 +58,23 @@ namespace ewol { */ bool loadFromString(const std::string& _composerXmlString); protected: + // TODO : Create a template ... + #define composerBind(_type, _name, _event, _obj, _func) do {\ + std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getObjectNamed(_name)); \ + if (myObject != nullptr) { \ + myObject->_event.bind(_obj, _func); \ + } \ + } while (false) + /* + template void bind(std::shared_ptr _obj, void (TYPE::*_func)()) { + std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); + if (obj2 == nullptr) { + EWOL_ERROR("Can not bind signal ..."); + return; + } + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get()))); + } + */ /** * @brief Register an Event an named widget. @see registerOnEvent * @param[in] _subWidgetName Name of the subWidget. @@ -69,8 +86,14 @@ namespace ewol { void registerOnEventNameWidget(const std::string& _subWidgetName, const char * _eventId, const char * _eventIdgenerated = nullptr, - const std::string& _overloadData=""); + const std::string& _overloadData="") __attribute__ ((deprecated)); public: + #define composerExternBind(_composer, _type, _name, _event, _obj, _func) do {\ + std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_composer->getObjectNamed(_name)); \ + if (myObject != nullptr) { \ + myObject->_event.bind(_obj, _func); \ + } \ + } while (false) /** * @brief Register an Event an named widget. @see registerOnEvent * @param[in] _destinationObject pointer on the object that might be call when an event is generated @@ -84,7 +107,7 @@ namespace ewol { const std::string& _subWidgetName, const char * _eventId, const char * _eventIdgenerated = nullptr, - const std::string& _overloadData=""); + const std::string& _overloadData="") __attribute__ ((deprecated)); }; }; }; diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index 11527680..e988c5b1 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -97,9 +97,6 @@ int32_t ewol::widget::Menu::add(int32_t _parent, // add it in the widget list ewol::widget::Sizer::subWidgetAdd(myButton); // keep the specific event ... - //myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed); - std::weak_ptr myButtonWeak(myButton); - //myButton->signalPressed.bind(shared_from_this(), &ewol::widget::Menu::onButtonPressed, myButtonWeak); myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr(myButton))); tmpObject.m_widgetPointer = myButton; } diff --git a/sources/ewol/widget/meta/ColorChooser.cpp b/sources/ewol/widget/meta/ColorChooser.cpp index db6ed379..34c872df 100644 --- a/sources/ewol/widget/meta/ColorChooser.cpp +++ b/sources/ewol/widget/meta/ColorChooser.cpp @@ -34,7 +34,7 @@ void ewol::widget::ColorChooser::init() { ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); lockExpand(bvec2(true,true)); m_widgetColorBar = ewol::widget::ColorBar::create(); - m_widgetColorBar->registerOnEvent(shared_from_this(), "change", eventColorBarHasChange); + m_widgetColorBar->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChange); m_widgetColorBar->setFill(bvec2(true,true)); subWidgetAdd(m_widgetColorBar); @@ -164,3 +164,10 @@ void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const int32_t& _newC } signalChange.emit(m_currentColor); } +void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) { + m_currentColor = _newColor; + if (nullptr != m_widgetColorBar) { + m_widgetColorBar->setCurrentColor(m_currentColor); + } + signalChange.emit(m_currentColor); +} \ No newline at end of file diff --git a/sources/ewol/widget/meta/ColorChooser.h b/sources/ewol/widget/meta/ColorChooser.h index ccb66dea..74b0ba6a 100644 --- a/sources/ewol/widget/meta/ColorChooser.h +++ b/sources/ewol/widget/meta/ColorChooser.h @@ -51,6 +51,7 @@ namespace ewol { void onCallbackColorChangeGreen(const int32_t& _newColor); void onCallbackColorChangeBlue(const int32_t& _newColor); void onCallbackColorChangeAlpha(const int32_t& _newColor); + void onCallbackColorChange(const etk::Color<>& _newColor); }; }; }; diff --git a/sources/ewol/widget/meta/FileChooser.cpp b/sources/ewol/widget/meta/FileChooser.cpp index e7c930f0..cfd0ec56 100644 --- a/sources/ewol/widget/meta/FileChooser.cpp +++ b/sources/ewol/widget/meta/FileChooser.cpp @@ -10,6 +10,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -29,20 +33,6 @@ extern "C" { #undef __class__ #define __class__ "FileChooser" - -static const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel"; -static const char * const ewolEventFileChooserValidate = "ewol-event-file-chooser-validate"; -static const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files"; -static const char * const ewolEventFileChooserEntryFolder = "ewol-event-file-chooser-modify-entry-folder"; -static const char * const ewolEventFileChooserEntryFolderEnter = "ewol-event-file-chooser-modify-entry-folder-enter"; -static const char * const ewolEventFileChooserEntryFile = "ewol-event-file-chooser-modify-entry-file"; -static const char * const ewolEventFileChooserEntryFileEnter = "ewol-event-file-chooser-modify-entry-file-enter"; -static const char * const ewolEventFileChooserListFolder = "ewol-event-file-chooser-modify-list-folder"; -static const char * const ewolEventFileChooserListFile = "ewol-event-file-chooser-modify-list-file"; -static const char * const ewolEventFileChooserListFileValidate = "ewol-event-file-chooser-modify-list-file-validate"; -static const char * const ewolEventFileChooserHome = "ewol-event-file-chooser-home"; - - ewol::widget::FileChooser::FileChooser() : signalCancel(*this, "cancel"), signalValidate(*this, "validate") { @@ -105,17 +95,17 @@ void ewol::widget::FileChooser::init() { + " \n" + ""; loadFromString(myDescription); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", "value", ewolEventFileChooserHidenFileChange); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-validate", "pressed", ewolEventFileChooserValidate); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-cancel", "pressed", ewolEventFileChooserCancel); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "folder-validate", ewolEventFileChooserListFolder); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-select", ewolEventFileChooserListFile); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-validate", ewolEventFileChooserListFileValidate); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "modify", ewolEventFileChooserEntryFile); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "enter", ewolEventFileChooserEntryFileEnter); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "modify", ewolEventFileChooserEntryFolder); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "enter", ewolEventFileChooserEntryFolderEnter); - registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:img-home", "pressed", ewolEventFileChooserHome); + composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", signalValue, shared_from_this(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue); + composerBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-validate", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackListValidate); + composerBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-cancel", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed); + composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-folder", signalFolderValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFolderSelectChange); + composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileSelect, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileSelectChange); + composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate); + composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValue); + composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalEnter, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate); + composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFolderChangeValue); + //composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalEnter, shared_from_this(), &ewol::widget::FileChooser::); + composerBind(ewol::widget::Image, "[" + etk::to_string(getId()) + "]file-shooser:img-home", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackHomePressed); // set the default Folder properties: updateCurrentFolder(); setCanHaveFocus(true); @@ -152,62 +142,78 @@ void ewol::widget::FileChooser::setFileName(const std::string& _filename) { parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "value", _filename); } -void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _msg) { - EWOL_INFO("Receive Event from the LIST ... : " << _msg); - if (_msg.getMessage() == ewolEventFileChooserEntryFolder) { - // == > change the folder name - // TODO : change the folder, if it exit ... - } else if (_msg.getMessage() == ewolEventFileChooserEntryFile) { - // == > change the file name - m_file = _msg.getData(); - // update the selected file in the list : - parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file); - } else if (ewolEventFileChooserCancel == _msg.getMessage()) { - // == > Auto remove ... - signalCancel.emit(); - autoDestroy(); - } else if (_msg.getMessage() == ewolEventFileChooserHidenFileChange) { - if (_msg.getData() == "true") { - parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "true"); - parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "true"); - } else { - parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "false"); - parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "false"); - } - } else if (_msg.getMessage() == ewolEventFileChooserListFolder) { - // == > this is an internal event ... - EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _msg.getData() << "\""); - m_folder = m_folder + _msg.getData(); - EWOL_DEBUG("new PATH : \"" << m_folder << "\""); - m_folder = etk::simplifyPath(m_folder); - setFileName(""); - updateCurrentFolder(); - } else if (_msg.getMessage() == ewolEventFileChooserListFile) { - setFileName(_msg.getData()); - std::string tmpFileCompleatName = m_folder; - tmpFileCompleatName += m_file; - // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); - } else if( _msg.getMessage() == ewolEventFileChooserListFileValidate - || (_msg.getMessage() == ewolEventFileChooserValidate && m_file != "" ) - || (_msg.getMessage() == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) { - // select the file == > generate a validate - if (_msg.getData() != "") { - setFileName(_msg.getData()); - } - EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); - signalValidate.emit(getCompleateFileName()); - autoDestroy(); - } else if(_msg.getMessage() == ewolEventFileChooserHome) { - std::string tmpUserFolder = etk::getUserHomeFolder(); - EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\""); - - m_folder = etk::simplifyPath(tmpUserFolder); - - setFileName(""); - updateCurrentFolder(); + +void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue(const std::string& _value) { + // == > change the folder name + // TODO : change the folder, if it exit ... +} + +void ewol::widget::FileChooser::onCallbackEntryFileChangeValue(const std::string& _value) { + // == > change the file name + m_file = _value; + // update the selected file in the list : + parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file); +} + +void ewol::widget::FileChooser::onCallbackButtonCancelPressed() { + // == > Auto remove ... + signalCancel.emit(); + autoDestroy(); +} + +void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue(const bool& _value) { + if (_value == true) { + parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "true"); + parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "true"); + } else { + parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "false"); + parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "false"); } - return; -}; +} + +void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const std::string& _value) { + // == > this is an internal event ... + EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _value << "\""); + m_folder = m_folder + _value; + EWOL_DEBUG("new PATH : \"" << m_folder << "\""); + m_folder = etk::simplifyPath(m_folder); + setFileName(""); + updateCurrentFolder(); +} + +void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) { + setFileName(_value); + std::string tmpFileCompleatName = m_folder; + tmpFileCompleatName += m_file; + // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); +} + +void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) { + // select the file == > generate a validate + setFileName(_value); + EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); + signalValidate.emit(getCompleateFileName()); + autoDestroy(); +} + +void ewol::widget::FileChooser::onCallbackListValidate() { + if (m_file != "" ) { + return; + } + EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); + signalValidate.emit(getCompleateFileName()); + autoDestroy(); +} + +void ewol::widget::FileChooser::onCallbackHomePressed() { + std::string tmpUserFolder = etk::getUserHomeFolder(); + EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\""); + + m_folder = etk::simplifyPath(tmpUserFolder); + + setFileName(""); + updateCurrentFolder(); +} void ewol::widget::FileChooser::updateCurrentFolder() { if (m_folder != "" ) { diff --git a/sources/ewol/widget/meta/FileChooser.h b/sources/ewol/widget/meta/FileChooser.h index eaa9b806..ab47441e 100644 --- a/sources/ewol/widget/meta/FileChooser.h +++ b/sources/ewol/widget/meta/FileChooser.h @@ -95,8 +95,18 @@ namespace ewol { std::string getCompleateFileName(); void updateCurrentFolder(); public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onGetFocus(); + private: + // callback functions: + void onCallbackEntryFolderChangeValue(const std::string& _value); + void onCallbackEntryFileChangeValue(const std::string& _value); + void onCallbackButtonCancelPressed(); + void onCallbackHidenFileChangeChangeValue(const bool& _value); + void onCallbackListFolderSelectChange(const std::string& _value); + void onCallbackListFileSelectChange(const std::string& _value); + void onCallbackListFileValidate(const std::string& _value); + void onCallbackListValidate(); + void onCallbackHomePressed(); }; }; }; diff --git a/sources/ewol/widget/meta/Parameter.cpp b/sources/ewol/widget/meta/Parameter.cpp index f7f454c3..2be06985 100644 --- a/sources/ewol/widget/meta/Parameter.cpp +++ b/sources/ewol/widget/meta/Parameter.cpp @@ -20,10 +20,6 @@ #undef __class__ #define __class__ "Parameter" -static const char * const ewolEventParameterValidate = "ewol-event-parameter-validate"; -static const char * const ewolEventParameterSave = "ewol-event-parameter-save"; -static const char * const l_eventMenuSelected = "local-event-menu-selected"; -static const char * const ewolEventMenuclosed = "local-event-menu-closed"; ewol::widget::Parameter::Parameter() : signalClose(*this, "close"), @@ -80,7 +76,7 @@ void ewol::widget::Parameter::init() { " \n" " \n" "\n")); - tmpButton->registerOnEvent(shared_from_this(), "pressed", ewolEventParameterSave); + tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackParameterSave); mySizerHori->subWidgetAdd(tmpButton); } @@ -104,7 +100,7 @@ void ewol::widget::Parameter::init() { " \n" " \n" "\n")); - tmpButton->registerOnEvent(shared_from_this(), "pressed", ewolEventMenuclosed); + tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuclosed); mySizerHori->subWidgetAdd(tmpButton); } } @@ -120,7 +116,7 @@ void ewol::widget::Parameter::init() { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - m_paramList->registerOnEvent(shared_from_this(), "select", l_eventMenuSelected); + m_paramList->signalSelect.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuSelected); m_paramList->setFill(bvec2(false,true)); m_paramList->setExpand(bvec2(false,true)); mySizerHori->subWidgetAdd(m_paramList); @@ -195,26 +191,21 @@ void ewol::widget::Parameter::setTitle(std::string _label) { m_widgetTitle->setLabel(_label); } -void ewol::widget::Parameter::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::PopUp::onReceiveMessage(_msg); - EWOL_DEBUG("event on the parameter : " << _msg); - if (_msg.getMessage() == ewolEventMenuclosed) { - // inform that the parameter windows is closed - signalClose.emit(); - // close this widget ... - autoDestroy(); - } else if (_msg.getMessage() == ewolEventParameterSave) { - //ewol::userConfig::Save(); - EWOL_TODO("Save Parameter !!! "); - } else if (_msg.getMessage() == l_eventMenuSelected) { - if (nullptr != m_wSlider) { - int32_t value = 0; - sscanf(_msg.getData().c_str(), "%d", &value); - EWOL_DEBUG("event on the parameter : " << _msg.getMessage() << " select ID=" << value << ""); - m_wSlider->subWidgetSelectSet(value); - } +void ewol::widget::Parameter::onCallbackMenuclosed() { + // inform that the parameter windows is closed + signalClose.emit(); + // close this widget ... + autoDestroy(); +} +void ewol::widget::Parameter::onCallbackParameterSave() { + //ewol::userConfig::Save(); + EWOL_TODO("Save Parameter !!! "); +} +void ewol::widget::Parameter::onCallbackMenuSelected(const int32_t& _value) { + if (m_wSlider != nullptr) { + EWOL_DEBUG("event on the parameter : Menu-select select ID=" << _value << ""); + m_wSlider->subWidgetSelectSet(_value); } - return; } void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, std::shared_ptr _associateWidget) { diff --git a/sources/ewol/widget/meta/Parameter.h b/sources/ewol/widget/meta/Parameter.h index a8ad5d6b..a9e5b703 100644 --- a/sources/ewol/widget/meta/Parameter.h +++ b/sources/ewol/widget/meta/Parameter.h @@ -36,8 +36,6 @@ namespace ewol { public: DECLARE_WIDGET_FACTORY(Parameter, "Parameter"); virtual ~Parameter(); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); public: void setTitle(std::string _label); void menuAdd(std::string _label, std::string _image, std::shared_ptr _associateWidget); @@ -49,6 +47,10 @@ namespace ewol { std::shared_ptr m_widgetTitle; std::shared_ptr m_paramList; std::shared_ptr m_wSlider; + private: //callback functions: + void onCallbackMenuclosed(); + void onCallbackParameterSave(); + void onCallbackMenuSelected(const int32_t& _value); }; }; }; diff --git a/sources/ewol/widget/meta/StdPopUp.cpp b/sources/ewol/widget/meta/StdPopUp.cpp index 7a10b83a..f607c43b 100644 --- a/sources/ewol/widget/meta/StdPopUp.cpp +++ b/sources/ewol/widget/meta/StdPopUp.cpp @@ -16,8 +16,6 @@ #undef __class__ #define __class__ "ewol::StdPopUp" -static const char * const eventButtonExit = "ewol-event-pop-up-exit-button"; - ewol::widget::StdPopUp::StdPopUp() : m_title(nullptr), m_comment(nullptr), @@ -107,17 +105,13 @@ std::shared_ptr ewol::widget::StdPopUp::addButton(const st } myButton->setSubWidget(ewol::widget::Label::create(_text)); if(_autoExit == true) { - myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonExit); + myButton->signalPressed.bind(shared_from_this(), &ewol::widget::StdPopUp::onCallBackButtonExit); } m_subBar->subWidgetAdd(myButton); markToRedraw(); return myButton; } -void ewol::widget::StdPopUp::onReceiveMessage(const ewol::object::Message& _msg) { - // call parent: - ewol::widget::PopUp::onReceiveMessage(_msg); - if (_msg.getMessage() == eventButtonExit) { - autoDestroy(); - } +void ewol::widget::StdPopUp::onCallBackButtonExit() { + autoDestroy(); } diff --git a/sources/ewol/widget/meta/StdPopUp.h b/sources/ewol/widget/meta/StdPopUp.h index ba1c255f..ddb62632 100644 --- a/sources/ewol/widget/meta/StdPopUp.h +++ b/sources/ewol/widget/meta/StdPopUp.h @@ -76,8 +76,8 @@ namespace ewol { * @param[in] _text Decorated text to diplay in button. */ std::shared_ptr addButton(const std::string& _text, bool _autoExit=false); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback function + void onCallBackButtonExit(); }; }; }; From 367831116f57c9e26b3bd7dfcbcf1e7e1ae453dc Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Aug 2014 05:56:03 +0200 Subject: [PATCH 09/22] [DEV] change some Object interface (try to simplify object interface --- external/eaudiofx | 2 +- sources/ewol/object/Manager.cpp | 14 ---- sources/ewol/object/Manager.h | 11 ---- sources/ewol/object/MultiCast.cpp | 80 ----------------------- sources/ewol/object/MultiCast.h | 47 -------------- sources/ewol/object/Object.cpp | 83 +++--------------------- sources/ewol/object/Object.h | 67 +++++++++++++------ sources/ewol/object/RemoveEvent.cpp | 28 -------- sources/ewol/object/RemoveEvent.h | 25 ------- sources/ewol/object/SignalList.cpp | 74 +-------------------- sources/ewol/object/SignalList.h | 35 +--------- sources/ewol/widget/Composer.cpp | 22 ------- sources/ewol/widget/Composer.h | 51 --------------- sources/ewol/widget/Container.cpp | 10 +-- sources/ewol/widget/Container.h | 2 +- sources/ewol/widget/Container2.cpp | 15 +++-- sources/ewol/widget/Container2.h | 2 +- sources/ewol/widget/ContainerN.cpp | 14 ++-- sources/ewol/widget/ContainerN.h | 2 +- sources/ewol/widget/Widget.cpp | 8 --- sources/ewol/widget/Widget.h | 6 -- sources/ewol/widget/meta/FileChooser.cpp | 20 +++--- 22 files changed, 95 insertions(+), 523 deletions(-) diff --git a/external/eaudiofx b/external/eaudiofx index 69e1259b..428e8dfe 160000 --- a/external/eaudiofx +++ b/external/eaudiofx @@ -1 +1 @@ -Subproject commit 69e1259b273a429e871e5c2e994dea5bb45aa5cf +Subproject commit 428e8dfe393b5609e21b78267356e30a026cb0ad diff --git a/sources/ewol/object/Manager.cpp b/sources/ewol/object/Manager.cpp index 079d57f8..0f062c5a 100644 --- a/sources/ewol/object/Manager.cpp +++ b/sources/ewol/object/Manager.cpp @@ -53,7 +53,6 @@ void ewol::object::Manager::unInit() { if (m_eObjectList.size() != 0) { EWOL_ERROR("Have " << m_eObjectList.size() << " active Object"); } - m_multiCast.clear(); m_eObjectList.clear(); } @@ -101,19 +100,6 @@ std::shared_ptr ewol::object::Manager::get(const std::string& _nam } -void ewol::object::Manager::add(ewol::object::RemoveEvent* _class) { - m_removeEventList.push_back(_class); -} - -void ewol::object::Manager::rm(ewol::object::RemoveEvent* _class) { - for (size_t iii=0; iii ewol::object::Manager::getObjectNamed(const std::string& _name) { return ewol::object::Manager::get(_name); } diff --git a/sources/ewol/object/Manager.h b/sources/ewol/object/Manager.h index e55288ba..06e56521 100644 --- a/sources/ewol/object/Manager.h +++ b/sources/ewol/object/Manager.h @@ -11,7 +11,6 @@ #include #include -#include #include namespace ewol { @@ -19,7 +18,6 @@ namespace ewol { namespace object { class Manager { private: - std::vector m_removeEventList; std::vector> m_eObjectList; // all widget allocated == > all time increment ... never removed ... Context& m_context; public: @@ -47,15 +45,6 @@ namespace ewol { void cleanInternalRemoved(); std::shared_ptr get(const std::string& _name); - private: - ewol::object::MultiCast m_multiCast; //!< muticast manager - public: - ewol::object::MultiCast& multiCast() { - return m_multiCast; - }; - - void add(ewol::object::RemoveEvent* _class); - void rm(ewol::object::RemoveEvent* _class); public: /** diff --git a/sources/ewol/object/MultiCast.cpp b/sources/ewol/object/MultiCast.cpp index 1ec76ae1..e69de29b 100644 --- a/sources/ewol/object/MultiCast.cpp +++ b/sources/ewol/object/MultiCast.cpp @@ -1,80 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include - -#undef __class__ -#define __class__ "object::MultiCast" - -ewol::object::MultiCast::MultiCast() { - EWOL_INFO("EObject message Multi-Cast"); -} - - -ewol::object::MultiCast::~MultiCast() { - EWOL_INFO("EObject message Multi-Cast"); - m_messageList.clear(); -} - -void ewol::object::MultiCast::clear() { - EWOL_INFO("EObject message Multi-Cast"); - m_messageList.clear(); -} - -void ewol::object::MultiCast::add(const std::shared_ptr& _object, const char* const _message) { - if (_object == nullptr) { - EWOL_ERROR("Add with nullptr object"); - return; - } - if (_message == nullptr) { - EWOL_ERROR("Add with nullptr Message"); - return; - } - m_messageList.push_back(MessageList(_message, _object)); - EWOL_DEBUG("SendMulticast ADD listener :" << _object->getId() << " on \"" << _message << "\"" ); -} - - -void ewol::object::MultiCast::rm(const std::shared_ptr& _object) { - if (_object == nullptr) { - EWOL_ERROR("Rm with nullptr object"); - return; - } - // send the message at all registered widget ... - auto it(m_messageList.begin()); - while (it != m_messageList.end()) { - std::shared_ptr obj = it->m_object.lock(); - if(obj == _object) { - EWOL_DEBUG("SendMulticast RM listener :" << _object->getId()); - m_messageList.erase(it); - it = m_messageList.begin(); - } else { - ++it; - } - } -} - -void ewol::object::MultiCast::send(const std::shared_ptr& _object, const char* const _message, const std::string& _data) { - EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to:"); - // send the message at all registered widget ... - for (auto &it : m_messageList) { - std::shared_ptr obj = it.m_object.lock(); - if( it.m_message == _message - && obj != _object) { - if (obj != nullptr) { - EWOL_VERBOSE(" id = " << obj->getId() << " type=" << obj->getObjectType()); - // generate event ... (create message before ... - ewol::object::Message tmpMsg(it.m_message, _data); - obj->onReceiveMessage(tmpMsg); - } - } - } -} - diff --git a/sources/ewol/object/MultiCast.h b/sources/ewol/object/MultiCast.h index 3579311c..e69de29b 100644 --- a/sources/ewol/object/MultiCast.h +++ b/sources/ewol/object/MultiCast.h @@ -1,47 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_OBJECT_MULTICAST_H__ -#define __EWOL_OBJECT_MULTICAST_H__ - -#include -#include -#include -#include - -#include - -namespace ewol { - namespace object { - class MultiCast { - private: - class MessageList { - public: - MessageList(const char* _message=nullptr, std::shared_ptr _object=nullptr) : - m_message(_message), m_object(_object) { - - } - const char* m_message; - std::weak_ptr m_object; - }; - std::vector m_messageList; //!< List of all message ... - public: - MultiCast(); - virtual ~MultiCast(); - void clear(); - void anonymousSend(const char* const _messageId, const std::string& _data) { - send(nullptr, _messageId, _data); - }; - void send(const std::shared_ptr& _object, const char* const _message, const std::string& _data); - void rm(const std::shared_ptr& _object); - void add(const std::shared_ptr& _object, const char* const _message); - }; - }; -}; - -#endif diff --git a/sources/ewol/object/Object.cpp b/sources/ewol/object/Object.cpp index 59cdb0f1..c5aef84b 100644 --- a/sources/ewol/object/Object.cpp +++ b/sources/ewol/object/Object.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #undef __class__ #define __class__ "Object" @@ -107,76 +106,6 @@ bool ewol::Object::isTypeCompatible(const std::string& _type) { return false; } -/* - -void ewol::Object::addEventId(const char * _generateEventId) { - for (auto &it : m_availlableEventId) { - if (std::string(it) == _generateEventId) { - EWOL_WARNING("Event already existed : '" << it << "' == '" << _generateEventId << "'"); - return; - } - } - if (_generateEventId != nullptr) { - m_availlableEventId.push_back(_generateEventId); - } -} - -void ewol::Object::generateEventId(const char * _generateEventId, const std::string& _data) { - if (m_objectHasBeenInit == false) { - EWOL_WARNING("try to generate an event inside a constructor"); - return; - } - int32_t nbObject = getObjectManager().getNumberObject(); - EWOL_VERBOSE("try send message '" << _generateEventId << "'"); - // for every element registered ... - for (auto &it : m_externEvent) { - // if we find the event ... - if (it.localEventId != _generateEventId) { - EWOL_VERBOSE(" wrong event '" << it.localEventId << "' != '" << _generateEventId << "'"); - continue; - } - std::shared_ptr destObject = it.destObject.lock(); - if (destObject == nullptr) { - EWOL_VERBOSE(" nullptr dest"); - continue; - } - if (it.overloadData.size() <= 0){ - ewol::object::Message tmpMsg(shared_from_this(), it.destEventId, _data); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } else { - // set the user requested data ... - ewol::object::Message tmpMsg(shared_from_this(), it.destEventId, it.overloadData); - EWOL_VERBOSE("send message " << tmpMsg); - destObject->onReceiveMessage(tmpMsg); - } - } - if (nbObject > getObjectManager().getNumberObject()) { - EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->removObject() which is asynchronous"); - } -} -*/ - -void ewol::Object::sendMultiCast(const char* const _messageId, const std::string& _data) { - if (m_objectHasBeenInit == false) { - EWOL_WARNING("try to generate an multicast event inside a constructor"); - return; - } - int32_t nbObject = getObjectManager().getNumberObject(); - getMultiCast().send(shared_from_this(), _messageId, _data); - if (nbObject > getObjectManager().getNumberObject()) { - EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->removObject() which is asynchronous"); - } -} - -void ewol::Object::registerMultiCast(const char* const _messageId) { - if (m_objectHasBeenInit == false) { - EWOL_ERROR("Try to Register multicast inside a constructor (move it in the init function)"); - return; - } - getMultiCast().add(shared_from_this(), _messageId); -} - bool ewol::Object::loadXML(exml::Element* _node) { if (nullptr == _node) { return false; @@ -219,13 +148,17 @@ ewol::object::Manager& ewol::Object::getObjectManager() const { return tmp; } -ewol::object::MultiCast& ewol::Object::getMultiCast() const { - return ewol::getContext().getEObjectManager().multiCast(); -} - ewol::Context& ewol::Object::getContext() const { return ewol::getContext(); } std::shared_ptr ewol::Object::getObjectNamed(const std::string& _objectName) const { return getObjectManager().getObjectNamed(_objectName); } + +std::shared_ptr ewol::Object::getSubObjectNamed(const std::string& _objectName) { + if (_objectName == m_name.get()) { + return shared_from_this(); + } + return nullptr; +} + diff --git a/sources/ewol/object/Object.h b/sources/ewol/object/Object.h index 1e7d4407..7372acbe 100644 --- a/sources/ewol/object/Object.h +++ b/sources/ewol/object/Object.h @@ -21,7 +21,6 @@ namespace ewol { class Object; namespace object { class Manager; - class MultiCast; }; class Context; }; @@ -138,21 +137,6 @@ namespace ewol { int32_t getId(){ return m_uniqueId; }; - // TODO : Remove this section : - protected: - /** - * @brief generate Multicast event on all Object requested the event - * @param[in] _messageId Event Id that is generated - * @param[in] _data String that is send at all the destinations - */ - // TODO : Remove this ... Not really needed : user can simply create an object and send event with it ... - void sendMultiCast(const char* const _messageId, const std::string& _data = ""); - /** - * @brief Register of the arrival of a Multicast message - * @param[in] _messageId Event Id waiting for... - */ - // TODO : Remove this ... - void registerMultiCast(const char* const _messageId); public: // TODO : Rework the position on this function ... This is a convignet function ... bool parameterSetOnWidgetNamed(const std::string& _objectName, const std::string& _config, const std::string& _value); @@ -194,11 +178,6 @@ namespace ewol { * @return the requested object manager. */ ewol::object::Manager& getObjectManager() const; - /** - * @breif get the current Object Message Multicast manager. - * @return the requested object manager. - */ - ewol::object::MultiCast& getMultiCast() const; /** * @brief get the curent the system inteface. * @return current reference on the instance. @@ -228,10 +207,56 @@ namespace ewol { * @return the requested object or nullptr */ std::shared_ptr getObjectNamed(const std::string& _objectName) const; + /** + * @brief Retrive an object with his name (in the global list) + * @param[in] _name Name of the object + * @return the requested object or nullptr + */ + virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); + protected: + // TODO : Create a template ... + /** + * @brief link on an signal in the subwiget with his name + */ + #define subBind(_type, _name, _event, _obj, _func) do {\ + std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \ + if (myObject != nullptr) { \ + myObject->_event.bind(_obj, _func); \ + } \ + } while (false) + /* + template void bind(std::shared_ptr _obj, void (TYPE::*_func)()) { + std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); + if (obj2 == nullptr) { + EWOL_ERROR("Can not bind signal ..."); + return; + } + m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get()))); + } + */ }; }; +/** + * @brief link on an signal in the global object list with his name + */ +#define globalBind(_type, _name, _event, _obj, _func) do {\ + std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \ + if (myObject != nullptr) { \ + myObject->_event.bind(_obj, _func); \ + } \ +} while (false) + +/** + * @brief link on an signal in the subWidget of an object with his name + */ +#define externSubBind(_object, _type, _name, _event, _obj, _func) do {\ + std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_object->getObjectNamed(_name)); \ + if (myObject != nullptr) { \ + myObject->_event.bind(_obj, _func); \ + } \ +} while (false) //#include #endif diff --git a/sources/ewol/object/RemoveEvent.cpp b/sources/ewol/object/RemoveEvent.cpp index 2aca7d11..e69de29b 100644 --- a/sources/ewol/object/RemoveEvent.cpp +++ b/sources/ewol/object/RemoveEvent.cpp @@ -1,28 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include - -ewol::object::RemoveEvent::RemoveEvent() { - EWOL_TODO("ewol::object::RemoveEvent::RemoveEvent()"); - /* - Context& tmp = ewol::getContext(); - ewol::object::Manager& manager = tmp.getEObjectManager(); - manager.add(this); - */ -} - -ewol::object::RemoveEvent::~RemoveEvent() { - EWOL_TODO("ewol::object::RemoveEvent::~RemoveEvent()"); - /* - Context& tmp = ewol::getContext(); - ewol::object::Manager& manager = tmp.getEObjectManager(); - manager.rm(this); - */ -} diff --git a/sources/ewol/object/RemoveEvent.h b/sources/ewol/object/RemoveEvent.h index e3da2dde..e69de29b 100644 --- a/sources/ewol/object/RemoveEvent.h +++ b/sources/ewol/object/RemoveEvent.h @@ -1,25 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_OBJECT_REMOVE_EVENT_H__ -#define __EWOL_OBJECT_REMOVE_EVENT_H__ - -#include -#include - -namespace ewol { - namespace object { - class RemoveEvent { - public: - RemoveEvent(); - virtual ~RemoveEvent(); - }; - } -}; - -#endif diff --git a/sources/ewol/object/SignalList.cpp b/sources/ewol/object/SignalList.cpp index 7b41011e..d34e378b 100644 --- a/sources/ewol/object/SignalList.cpp +++ b/sources/ewol/object/SignalList.cpp @@ -40,71 +40,8 @@ std::vector ewol::object::SignalList::signalGetAll() const { return out; } -void ewol::object::SignalList::registerOnObjectEvent(const std::shared_ptr& _destinationObject, - const std::string& _objectName, - const char * _eventId, - const char * _eventIdgenerated, - const std::string& _overloadData) { - EWOL_TODO("RegisterOnEvent ... + name"); - /*ewol::object::Manager& tmp = ewol::getContext().getEObjectManager(); - std::shared_ptr tmpObject = tmp.getObjectNamed(_objectName); - if (nullptr != tmpObject) { - EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'"); - tmpObject->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData); - } else { - EWOL_WARNING(" Can not register event : '" << _eventId << "' the object named='" << _objectName << "' does not exist"); - } - */ -} - -void ewol::object::SignalList::registerOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId, - const char * _eventIdgenerated, - const std::string& _overloadData) { - EWOL_TODO("RegisterOnEvent ..."); - /* - if (_destinationObject == nullptr) { - EWOL_ERROR("Input ERROR nullptr pointer Object ..."); - return; - } - if (_eventId == nullptr) { - EWOL_ERROR("Input ERROR nullptr pointer Event Id..."); - return; - } - if ( _eventId[0] == '*' - && _eventId[1] == '\0') { - EWOL_VERBOSE("Register on all event ..."); - for(auto &it : m_list) { - if (it == nullptr) { - continue; - } - it->connect(_destinationObject, _eventIdgenerated, _overloadData); - } - return; - } - // check if event existed : - bool findIt = false; - for(auto &it : m_list) { - if (it == nullptr) { - continue; - } - if (it->getName() == _eventId) { - findIt = true; - it->connect(_destinationObject, _eventIdgenerated, _overloadData); - } - } - if (false == findIt) { - EWOL_ERROR("Can not register event on this event=\"" << _eventId << "\" == > unknow event"); - return; - } - */ -} - -void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId) { - EWOL_TODO("unRegisterOnEvent ..."); - /* - if (_destinationObject == nullptr) { +void ewol::object::SignalList::unBindAll(const std::shared_ptr& _object) { + if (_object == nullptr) { EWOL_ERROR("Input ERROR nullptr pointer Object ..."); return; } @@ -112,11 +49,6 @@ void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptrgetName() == _eventId - || ( _eventId[0] == '*' - && _eventId[1] == '\0') ) { - it->release(_destinationObject); - } + it->release(_object); } - */ } diff --git a/sources/ewol/object/SignalList.h b/sources/ewol/object/SignalList.h index 2deb8a27..af9e0c83 100644 --- a/sources/ewol/object/SignalList.h +++ b/sources/ewol/object/SignalList.h @@ -41,40 +41,11 @@ namespace ewol { */ std::vector signalGetAll() const; /** - * @brief Register an Event an named widget. @see registerOnEvent - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _objectName Name of the object. - * @param[in] _eventId Event generate inside the object. - * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) - * @param[in] _overloadData When the user prever to receive a data specificly for this event ... - * @note : To used when NOT herited from this object. + * @brief Remove binding on all event class. + * @param[in] _object Object to unlink. */ - // TODO : Change name : registerOnSignal - void registerOnObjectEvent(const std::shared_ptr& _destinationObject, - const std::string& _objectName, - const char * _eventId, - const char * _eventIdgenerated = nullptr, - const std::string& _overloadData=""); - + void unBindAll(const std::shared_ptr& _object); public: - /** - * @brief Register an Object over an other to get event on the second... - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _eventId Event generate inside the object (note : "*" event register on all event generated ) - * @param[in] _eventIdgenerated event generated when call the distant Object.onReceiveMessage(...) - * @param[in] _overloadData When the user prever to receive a data specificly for this event ... - */ - void registerOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId, - const char * _eventIdgenerated = nullptr, - const std::string& _overloadData = "") __attribute__ ((deprecated)); - /** - * @brief Un-Register an Object over an other. - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object) - */ - void unRegisterOnEvent(const std::shared_ptr& _destinationObject, - const char * _eventId = nullptr) __attribute__ ((deprecated)); /** * @brief Receive a message from an other Object with a specific eventId and data * @param[in] _msg Message handle diff --git a/sources/ewol/widget/Composer.cpp b/sources/ewol/widget/Composer.cpp index 8adcbee2..ec41cc39 100644 --- a/sources/ewol/widget/Composer.cpp +++ b/sources/ewol/widget/Composer.cpp @@ -88,25 +88,3 @@ bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlStrin requestUpdateSize(); return true; } - - -void ewol::widget::Composer::registerOnEventNameWidget(const std::string& _subWidgetName, - const char * _eventId, - const char * _eventIdgenerated, - const std::string& _overloadData) { - registerOnEventNameWidget(shared_from_this(), _subWidgetName, _eventId, _eventIdgenerated, _overloadData); -} - -void ewol::widget::Composer::registerOnEventNameWidget(const std::shared_ptr& _destinationObject, - const std::string& _subWidgetName, - const char * _eventId, - const char * _eventIdgenerated, - const std::string& _overloadData) { - std::shared_ptr tmpWidget = getWidgetNamed(_subWidgetName); - if (tmpWidget != nullptr) { - EWOL_DEBUG("Find widget named : \"" << _subWidgetName << "\" register event=\"" << _eventId << "\""); - tmpWidget->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData); - } else { - EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Can not register event : \"" << _eventId << "\" the widget named=\"" << _subWidgetName << "\" does not exist"); - } -} diff --git a/sources/ewol/widget/Composer.h b/sources/ewol/widget/Composer.h index a930a844..0ff53061 100644 --- a/sources/ewol/widget/Composer.h +++ b/sources/ewol/widget/Composer.h @@ -57,57 +57,6 @@ namespace ewol { * @return false == > some error occured */ bool loadFromString(const std::string& _composerXmlString); - protected: - // TODO : Create a template ... - #define composerBind(_type, _name, _event, _obj, _func) do {\ - std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getObjectNamed(_name)); \ - if (myObject != nullptr) { \ - myObject->_event.bind(_obj, _func); \ - } \ - } while (false) - /* - template void bind(std::shared_ptr _obj, void (TYPE::*_func)()) { - std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); - if (obj2 == nullptr) { - EWOL_ERROR("Can not bind signal ..."); - return; - } - m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::bind(_func, obj2.get()))); - } - */ - /** - * @brief Register an Event an named widget. @see registerOnEvent - * @param[in] _subWidgetName Name of the subWidget. - * @param[in] _eventId Event generate inside the object. - * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) - * @param[in] _overloadData When the user prever to receive a data specificly for this event ... - * @note : To used when herited from this object. - */ - void registerOnEventNameWidget(const std::string& _subWidgetName, - const char * _eventId, - const char * _eventIdgenerated = nullptr, - const std::string& _overloadData="") __attribute__ ((deprecated)); - public: - #define composerExternBind(_composer, _type, _name, _event, _obj, _func) do {\ - std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_composer->getObjectNamed(_name)); \ - if (myObject != nullptr) { \ - myObject->_event.bind(_obj, _func); \ - } \ - } while (false) - /** - * @brief Register an Event an named widget. @see registerOnEvent - * @param[in] _destinationObject pointer on the object that might be call when an event is generated - * @param[in] _subWidgetName Name of the subWidget. - * @param[in] _eventId Event generate inside the object. - * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) - * @param[in] _overloadData When the user prever to receive a data specificly for this event ... - * @note : To used when NOT herited from this object. - */ - void registerOnEventNameWidget(const std::shared_ptr& _destinationObject, - const std::string& _subWidgetName, - const char * _eventId, - const char * _eventIdgenerated = nullptr, - const std::string& _overloadData="") __attribute__ ((deprecated)); }; }; }; diff --git a/sources/ewol/widget/Container.cpp b/sources/ewol/widget/Container.cpp index 8e8c071f..957c766c 100644 --- a/sources/ewol/widget/Container.cpp +++ b/sources/ewol/widget/Container.cpp @@ -64,13 +64,13 @@ void ewol::widget::Container::subWidgetUnLink() { m_subWidget.reset(); } -std::shared_ptr ewol::widget::Container::getWidgetNamed(const std::string& _widgetName) { - std::shared_ptr tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName); - if (nullptr!=tmpUpperWidget) { - return tmpUpperWidget; +std::shared_ptr ewol::widget::Container::getSubObjectNamed(const std::string& _objectName) { + std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_objectName); + if (nullptr!=tmpObject) { + return tmpObject; } if (nullptr != m_subWidget) { - return m_subWidget->getWidgetNamed(_widgetName); + return m_subWidget->getSubObjectNamed(_objectName); } return nullptr; } diff --git a/sources/ewol/widget/Container.h b/sources/ewol/widget/Container.h index f5ab7078..90045a79 100644 --- a/sources/ewol/widget/Container.h +++ b/sources/ewol/widget/Container.h @@ -58,7 +58,7 @@ namespace ewol { virtual void calculateSize(const vec2& _availlable); virtual void calculateMinMaxSize(); virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual std::shared_ptr getWidgetNamed(const std::string& _widgetName); + virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); virtual bool loadXML(exml::Element* _node); virtual void setOffset(const vec2& _newVal); virtual void requestDestroyFromChild(const std::shared_ptr& _child); diff --git a/sources/ewol/widget/Container2.cpp b/sources/ewol/widget/Container2.cpp index 0a3b7088..36f27270 100644 --- a/sources/ewol/widget/Container2.cpp +++ b/sources/ewol/widget/Container2.cpp @@ -63,16 +63,19 @@ void ewol::widget::Container2::subWidgetUnLink(int32_t _idWidget) { m_subWidget[_idWidget].reset(); } -std::shared_ptr ewol::widget::Container2::getWidgetNamed(const std::string& _widgetName) { - std::shared_ptr tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName); - if (tmpUpperWidget != nullptr) { - return tmpUpperWidget; +std::shared_ptr ewol::widget::Container2::getSubObjectNamed(const std::string& _widgetName) { + std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_widgetName); + if (tmpObject != nullptr) { + return tmpObject; } if (m_subWidget[0] != nullptr) { - return m_subWidget[0]->getWidgetNamed(_widgetName); + tmpObject = m_subWidget[0]->getSubObjectNamed(_widgetName); + if (tmpObject != nullptr) { + return tmpObject; + } } if (m_subWidget[1] != nullptr) { - return m_subWidget[1]->getWidgetNamed(_widgetName); + return m_subWidget[1]->getSubObjectNamed(_widgetName); } return nullptr; } diff --git a/sources/ewol/widget/Container2.h b/sources/ewol/widget/Container2.h index d34a7370..4930d5d4 100644 --- a/sources/ewol/widget/Container2.h +++ b/sources/ewol/widget/Container2.h @@ -161,7 +161,7 @@ namespace ewol { calculateMinMaxSizePadded(); } //virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual std::shared_ptr getWidgetNamed(const std::string& _widgetName); + virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); virtual bool loadXML(exml::Element* _node); virtual void setOffset(const vec2& _newVal); virtual void requestDestroyFromChild(const std::shared_ptr& _child); diff --git a/sources/ewol/widget/ContainerN.cpp b/sources/ewol/widget/ContainerN.cpp index 4ba1bb36..ef1452d3 100644 --- a/sources/ewol/widget/ContainerN.cpp +++ b/sources/ewol/widget/ContainerN.cpp @@ -138,16 +138,16 @@ void ewol::widget::ContainerN::subWidgetRemoveAllDelayed() { subWidgetRemoveAll(); } -std::shared_ptr ewol::widget::ContainerN::getWidgetNamed(const std::string& _widgetName) { - std::shared_ptr tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName); - if (tmpUpperWidget != nullptr) { - return tmpUpperWidget; +std::shared_ptr ewol::widget::ContainerN::getSubObjectNamed(const std::string& _objectName) { + std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_objectName); + if (tmpObject != nullptr) { + return tmpObject; } for (auto &it : m_subWidget) { if (it != nullptr) { - std::shared_ptr tmpWidget = it->getWidgetNamed(_widgetName); - if (tmpWidget != nullptr) { - return tmpWidget; + tmpObject = it->getSubObjectNamed(_objectName); + if (tmpObject != nullptr) { + return tmpObject; } } } diff --git a/sources/ewol/widget/ContainerN.h b/sources/ewol/widget/ContainerN.h index 4b84449e..2a7e6845 100644 --- a/sources/ewol/widget/ContainerN.h +++ b/sources/ewol/widget/ContainerN.h @@ -94,7 +94,7 @@ namespace ewol { virtual void calculateSize(const vec2& _availlable); virtual void calculateMinMaxSize(); virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual std::shared_ptr getWidgetNamed(const std::string& _widgetName); + virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); virtual bool loadXML(exml::Element* _node); virtual void setOffset(const vec2& _newVal); virtual void requestDestroyFromChild(const std::shared_ptr& _child); diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index 93e78bef..cc3a8839 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -602,14 +602,6 @@ bool ewol::Widget::loadXML(exml::Element* _node) { return true; } -std::shared_ptr ewol::Widget::getWidgetNamed(const std::string& _widgetName) { - EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} compare : " << getName() << " == " << _widgetName ); - if (getName() == _widgetName) { - return std::dynamic_pointer_cast(shared_from_this()); - } - return nullptr; -} - bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) { std::shared_ptr up = std::dynamic_pointer_cast(m_parent.lock()); if (up != nullptr) { diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index 032135c5..d6df9624 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -532,12 +532,6 @@ namespace ewol { } return nullptr; }; - /** - * @brief get the widget if it have this name or one of the subwidget with the same name - * @param[in] _widgetName name of the widget - * @return the requested pointer on the node (or nullptr pointer) - */ - virtual std::shared_ptr getWidgetNamed(const std::string& _widgetName); // event section: public: diff --git a/sources/ewol/widget/meta/FileChooser.cpp b/sources/ewol/widget/meta/FileChooser.cpp index cfd0ec56..057cdbed 100644 --- a/sources/ewol/widget/meta/FileChooser.cpp +++ b/sources/ewol/widget/meta/FileChooser.cpp @@ -95,17 +95,17 @@ void ewol::widget::FileChooser::init() { + " \n" + ""; loadFromString(myDescription); - composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", signalValue, shared_from_this(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue); - composerBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-validate", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackListValidate); - composerBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-cancel", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed); - composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-folder", signalFolderValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFolderSelectChange); - composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileSelect, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileSelectChange); - composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate); - composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValue); - composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalEnter, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate); - composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFolderChangeValue); + subBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", signalValue, shared_from_this(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue); + subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-validate", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackListValidate); + subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-cancel", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed); + subBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-folder", signalFolderValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFolderSelectChange); + subBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileSelect, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileSelectChange); + subBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate); + subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValue); + subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalEnter, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate); + subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFolderChangeValue); //composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalEnter, shared_from_this(), &ewol::widget::FileChooser::); - composerBind(ewol::widget::Image, "[" + etk::to_string(getId()) + "]file-shooser:img-home", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackHomePressed); + subBind(ewol::widget::Image, "[" + etk::to_string(getId()) + "]file-shooser:img-home", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackHomePressed); // set the default Folder properties: updateCurrentFolder(); setCanHaveFocus(true); From 6e39002da5fdbfc8026b420b5cc23692423e554c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Aug 2014 21:08:13 +0200 Subject: [PATCH 10/22] [DEV] some rework on ewol... --- sources/ewol/object/Signal.h | 12 +++- sources/ewol/widget/Entry.cpp | 25 ++++---- sources/ewol/widget/Entry.h | 2 + sources/ewol/widget/Menu.cpp | 12 ++-- sources/ewol/widget/Menu.h | 7 ++- sources/ewol/widget/Widget.cpp | 104 ++++++++++++++------------------- sources/ewol/widget/Widget.h | 19 +++--- 7 files changed, 87 insertions(+), 94 deletions(-) diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index b7694d6c..3cae33d0 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -18,6 +18,8 @@ namespace ewol { namespace object { + #undef __class__ + #define __class__ "object::Signal" template class Signal : public SignalBase { private: std::vector, @@ -46,7 +48,7 @@ namespace ewol { * @brief Bind a callback function to the current signal (generic methis (simplest)) * @param[in] _obj Shared pointer on the caller object * @param[in] _func Link on the fuction that might be called (inside a class) - * @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX); + * @example signalXXXX.bind(shared_from_this(), &ClassName::onCallbackXXX); */ template void bind(std::shared_ptr _obj, void (TYPE::*_func)(const T&)) { std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); @@ -89,11 +91,13 @@ namespace ewol { EWOL_VERBOSE(" nullptr dest"); continue; } + EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "] data='" << etk::to_string(_data) << "'"); it.second(_data); } } }; - + #undef __class__ + #define __class__ "object::Signal" template<> class Signal : public SignalBase { private: std::vector, std::function>> m_callerList; @@ -161,11 +165,13 @@ namespace ewol { EWOL_VERBOSE(" nullptr dest"); continue; } + EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "] BANG!!!"); it.second(); } } }; - + #undef __class__ + #define __class__ nullptr }; }; #endif diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index 4b4536d4..d73d5700 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -44,22 +44,23 @@ ewol::widget::Entry::Entry() : m_displayCursorPosSelection(0), m_textWhenNothing(*this, "emptytext", "", "Text that is displayed when the Entry is empty (decorated text)") { addObjectType("ewol::widget::Entry"); - setCanHaveFocus(true); - shortCutAdd("ctrl+w", ewolEventEntryClean); - shortCutAdd("ctrl+x", ewolEventEntryCut); - shortCutAdd("ctrl+c", ewolEventEntryCopy); - shortCutAdd("ctrl+v", ewolEventEntryPaste); - shortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL"); - shortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE"); - m_regExp.setString(".*"); - markToRedraw(); } - void ewol::widget::Entry::init(const std::string& _newData) { ewol::Widget::init(); m_data.set(_newData); m_shaper.setString("THEME:GUI:Entry.json"); + setCanHaveFocus(true); + m_regExp.setString(".*"); + markToRedraw(); + + shortCutAdd("ctrl+w", "clean"); + shortCutAdd("ctrl+x", "cut"); + shortCutAdd("ctrl+c", "copy"); + shortCutAdd("ctrl+v", "paste"); + shortCutAdd("ctrl+a", "select:all"); + shortCutAdd("ctrl+shift+a", "select:none"); + signalShortcut.bind(shared_from_this(), &ewol::widget::Entry::onCallbackShortCut); } @@ -67,6 +68,10 @@ ewol::widget::Entry::~Entry() { } +void ewol::widget::Entry::onCallbackShortCut(const std::string& _value) { + EWOL_WARNING("Event from ShortCut : " << _value); +} + void ewol::widget::Entry::calculateMinMaxSize() { // call main class ewol::Widget::calculateMinMaxSize(); diff --git a/sources/ewol/widget/Entry.h b/sources/ewol/widget/Entry.h index 52e58a89..346f647f 100644 --- a/sources/ewol/widget/Entry.h +++ b/sources/ewol/widget/Entry.h @@ -176,6 +176,8 @@ namespace ewol { virtual void changeStatusIn(int32_t _newStatusId); virtual void periodicCall(const ewol::event::Time& _event); virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer); + private: // callback functions + void onCallbackShortCut(const std::string& _value); }; }; }; diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index e988c5b1..ccf233f4 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -18,7 +18,8 @@ #undef __class__ #define __class__ "Menu" -ewol::widget::Menu::Menu() { +ewol::widget::Menu::Menu() : + signalSelect(*this, "select") { addObjectType("ewol::widget::Menu"); m_staticId = 0; } @@ -55,9 +56,8 @@ void ewol::widget::Menu::clear() { int32_t ewol::widget::Menu::addTitle(std::string _label, std::string _image, - const char * _generateEvent, const std::string _message) { - return add(-1, _label, _image, _generateEvent, _message); + return add(-1, _label, _image, _message); } static const char* eventButtonPressed = "menu-local-pressed"; @@ -65,14 +65,12 @@ static const char* eventButtonPressed = "menu-local-pressed"; int32_t ewol::widget::Menu::add(int32_t _parent, std::string _label, std::string _image, - const char *_generateEvent, const std::string _message) { ewol::widget::MenuElement tmpObject; tmpObject.m_localId = m_staticId++; tmpObject.m_parentId = _parent; tmpObject.m_label = std::string("") + _label + ""; tmpObject.m_image = _image; - tmpObject.m_generateEvent = _generateEvent; tmpObject.m_message = _message; if (-1 == tmpObject.m_parentId) { std::shared_ptr myButton = ewol::widget::Button::create(); @@ -116,10 +114,10 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu for (auto &it : m_listElement) { if (caller == it.m_widgetPointer.lock()) { // 2 posible case (have a message or have a child ... - if (it.m_generateEvent != nullptr) { + if (it.m_message.size() > 0) { EWOL_DEBUG("Menu == > generate Event"); // Send a multicast event ... - sendMultiCast(it.m_generateEvent, it.m_message); + signalSelect.emit(it.m_message); std::shared_ptr tmpContext = m_widgetContextMenu.lock(); if (tmpContext != nullptr) { EWOL_DEBUG("Mark the menu to remove ..."); diff --git a/sources/ewol/widget/Menu.h b/sources/ewol/widget/Menu.h index 36c5be3e..5c00c137 100644 --- a/sources/ewol/widget/Menu.h +++ b/sources/ewol/widget/Menu.h @@ -27,13 +27,14 @@ namespace ewol { std::weak_ptr m_widgetPointer; std::string m_label; std::string m_image; - const char* m_generateEvent; std::string m_message; }; /** * @ingroup ewolWidgetGroup */ class Menu :public ewol::widget::Sizer { + public: + ewol::object::Signal signalSelect; // event on a menu button or ... protected: Menu(); void init(); @@ -51,8 +52,8 @@ namespace ewol { std::weak_ptr m_widgetContextMenu; public: void clear(); - int32_t addTitle(std::string _label, std::string _image="", const char * _generateEvent = nullptr, const std::string _message = ""); - int32_t add(int32_t _parent, std::string _label, std::string _image="", const char * _generateEvent = nullptr, const std::string _message = ""); + int32_t addTitle(std::string _label, std::string _image="", const std::string _message = ""); + int32_t add(int32_t _parent, std::string _label, std::string _image="", const std::string _message = ""); void addSpacer(); // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index cc3a8839..e0179e2c 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -105,6 +105,7 @@ ewol::Widget::Widget() : m_allowRepeateKeyboardEvent(true), m_periodicCallDeltaTime(-1), m_periodicCallTime(0), + signalShortcut(*this, "shortcut"), m_needRegenerateDisplay(true), m_grabCursor(false), m_cursorDisplay(ewol::context::cursorArrow), @@ -425,12 +426,8 @@ const bvec2& ewol::Widget::canFill() { // -- Shortcut : management of the shortcut // ---------------------------------------------------------------------------------------------------------------- -void ewol::Widget::shortCutAdd(const char * _descriptiveString, - const char * _generateEventId, - std::string _data, - bool _broadcast) { - if ( _descriptiveString == nullptr - || strlen(_descriptiveString) == 0) { +void ewol::Widget::shortCutAdd(const std::string& _descriptiveString, const std::string& _message) { + if (_descriptiveString.size() == 0) { EWOL_ERROR("try to add shortcut with no descriptive string ..."); return; } @@ -439,83 +436,81 @@ void ewol::Widget::shortCutAdd(const char * _descriptiveString, EWOL_ERROR("allocation error ... Memory error ..."); return; } - tmpElement->broadcastEvent = _broadcast; - tmpElement->generateEventId = _generateEventId; - tmpElement->eventData = _data; + if (_message.size() == 0) { + tmpElement->message = _descriptiveString; + } else { + tmpElement->message = _message; + } // parsing of the string : //"ctrl+shift+alt+meta+s" - const char * tmp = strstr(_descriptiveString, "ctrl"); - if(nullptr != tmp) { + if(_descriptiveString.find("ctrl") != std::string::npos) { tmpElement->specialKey.setCtrl(true); } - tmp = strstr(_descriptiveString, "shift"); - if(nullptr != tmp) { + if(_descriptiveString.find("shift") != std::string::npos) { tmpElement->specialKey.setShift(true); } - tmp = strstr(_descriptiveString, "alt"); - if(nullptr != tmp) { + if(_descriptiveString.find("alt") != std::string::npos) { tmpElement->specialKey.setAlt(true); } - tmp = strstr(_descriptiveString, "meta"); - if(nullptr != tmp) { + if(_descriptiveString.find("meta") != std::string::npos) { tmpElement->specialKey.setMeta(true); } - if(nullptr != strstr(_descriptiveString, "F12") ) { + if(_descriptiveString.find("F12") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF12; - } else if(nullptr != strstr(_descriptiveString, "F11") ) { + } else if(_descriptiveString.find("F11") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF11; - } else if(nullptr != strstr(_descriptiveString, "F10") ) { + } else if(_descriptiveString.find("F10") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF10; - } else if(nullptr != strstr(_descriptiveString, "F9") ) { + } else if(_descriptiveString.find("F9") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF9; - } else if(nullptr != strstr(_descriptiveString, "F8") ) { + } else if(_descriptiveString.find("F8") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF8; - } else if(nullptr != strstr(_descriptiveString, "F7") ) { + } else if(_descriptiveString.find("F7") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF7; - } else if(nullptr != strstr(_descriptiveString, "F6") ) { + } else if(_descriptiveString.find("F6") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF6; - } else if(nullptr != strstr(_descriptiveString, "F5") ) { + } else if(_descriptiveString.find("F5") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF5; - } else if(nullptr != strstr(_descriptiveString, "F4") ) { + } else if(_descriptiveString.find("F4") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF4; - } else if(nullptr != strstr(_descriptiveString, "F3") ) { + } else if(_descriptiveString.find("F3") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF3; - } else if(nullptr != strstr(_descriptiveString, "F2") ) { + } else if(_descriptiveString.find("F2") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF2; - } else if(nullptr != strstr(_descriptiveString, "F1") ) { + } else if(_descriptiveString.find("F1") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardF1; - } else if(nullptr != strstr(_descriptiveString, "LEFT") ) { + } else if(_descriptiveString.find("LEFT") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardLeft; - } else if(nullptr != strstr(_descriptiveString, "RIGHT") ) { + } else if(_descriptiveString.find("RIGHT") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardRight; - } else if(nullptr != strstr(_descriptiveString, "UP") ) { + } else if(_descriptiveString.find("UP") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardUp; - } else if(nullptr != strstr(_descriptiveString, "DOWN") ) { + } else if(_descriptiveString.find("DOWN") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardDown; - } else if(nullptr != strstr(_descriptiveString, "PAGE_UP") ) { + } else if(_descriptiveString.find("PAGE_UP") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardPageUp; - } else if(nullptr != strstr(_descriptiveString, "PAGE_DOWN") ) { + } else if(_descriptiveString.find("PAGE_DOWN") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardPageDown; - } else if(nullptr != strstr(_descriptiveString, "START") ) { + } else if(_descriptiveString.find("START") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardStart; - } else if(nullptr != strstr(_descriptiveString, "END") ) { + } else if(_descriptiveString.find("END") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardEnd; - } else if(nullptr != strstr(_descriptiveString, "PRINT") ) { + } else if(_descriptiveString.find("PRINT") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardPrint; - } else if(nullptr != strstr(_descriptiveString, "ARRET_DEFIL") ) { + } else if(_descriptiveString.find("ARRET_DEFIL") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardStopDefil; - } else if(nullptr != strstr(_descriptiveString, "WAIT") ) { + } else if(_descriptiveString.find("WAIT") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardWait; - } else if(nullptr != strstr(_descriptiveString, "INSERT") ) { + } else if(_descriptiveString.find("INSERT") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardInsert; - } else if(nullptr != strstr(_descriptiveString, "CAPLOCK") ) { + } else if(_descriptiveString.find("CAPLOCK") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardCapLock; - } else if(nullptr != strstr(_descriptiveString, "CONTEXT_MENU") ) { + } else if(_descriptiveString.find("CONTEXT_MENU") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardContextMenu; - } else if(nullptr != strstr(_descriptiveString, "NUM_LOCK") ) { + } else if(_descriptiveString.find("NUM_LOCK") != std::string::npos) { tmpElement->keyboardMoveValue = ewol::key::keyboardNumLock; } else { - tmpElement->unicodeValue = _descriptiveString[strlen(_descriptiveString) -1]; + tmpElement->unicodeValue = _descriptiveString[_descriptiveString.size() -1]; } // add it on the List ... m_localShortcut.push_back(tmpElement); @@ -523,10 +518,8 @@ void ewol::Widget::shortCutAdd(const char * _descriptiveString, void ewol::Widget::shortCutClean() { for (size_t iii=0; iiiunicodeValue == 0) ) ) { if (_isDown) { - if (true == m_localShortcut[iii]->broadcastEvent) { - // send message at all the widget (exepted this one) - sendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData); - } - // send message direct to the current widget (in every case, really useful for some generic windows shortcut) - ewol::object::Message tmpMsg(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData); - onReceiveMessage(tmpMsg); - } // no else + signalShortcut.emit(m_localShortcut[iii]->message); + } return true; } } @@ -596,8 +583,7 @@ enum ewol::context::cursorDisplay ewol::Widget::getCursor() { } bool ewol::Widget::loadXML(exml::Element* _node) { - // Call EObject basic parser - ewol::Object::loadXML(_node); // note : load standard parameters (attribute in XML) + ewol::Object::loadXML(_node); markToRedraw(); return true; } diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index d6df9624..91c31654 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -100,16 +100,12 @@ namespace ewol { */ class EventShortCut { public: - bool broadcastEvent; //!< if it is true, then the message is sent to all the system - const char* generateEventId; //!< Local generated event - std::string eventData; //!< data link with the event + std::string message; //!< data link with the event ewol::key::Special specialKey; //!< special board key char32_t unicodeValue; //!< 0 if not used enum ewol::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used EventShortCut() { - broadcastEvent = false; - generateEventId = nullptr; - eventData = ""; + message = ""; unicodeValue = 0; keyboardMoveValue = ewol::key::keyboardUnknow; }; @@ -585,19 +581,18 @@ namespace ewol { // ---------------------------------------------------------------------------------------------------------------- // -- Shortcut : management of the shortcut // ---------------------------------------------------------------------------------------------------------------- + public: + ewol::object::Signal signalShortcut; //!< signal handle of the message private: std::vector m_localShortcut; //!< list of all shortcut in the widget protected: /** * @brief add a specific shortcut with his description * @param[in] _descriptiveString Description string of the shortcut - * @param[in] _generateEventId Event generic of the element - * @param[in] _data Associate data wit the event + * @param[in] _message massage to generate (or shortcut name) */ - virtual void shortCutAdd(const char * _descriptiveString, - const char * _generateEventId, - std::string _data="", - bool _broadcast=false); + virtual void shortCutAdd(const std::string& _descriptiveString, + const std::string& _message=""); /** * @brief remove all curent shortCut */ From 29910b5cef2bacb2e160cc0911b971e218661f6a Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 27 Aug 2014 06:04:31 +0200 Subject: [PATCH 11/22] [DEV] Add log when macri binding not work --- external/egami | 2 +- external/etk | 2 +- sources/ewol/object/Object.h | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/external/egami b/external/egami index 3698cdc9..e07648a3 160000 --- a/external/egami +++ b/external/egami @@ -1 +1 @@ -Subproject commit 3698cdc92500d9e29d810fa2d7094999f4a3dfe3 +Subproject commit e07648a33c85a8886c0e9dfb806ed8585c4d7553 diff --git a/external/etk b/external/etk index 3ad4738a..bee6e067 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit 3ad4738a3a0697252a5ecc8ce8fdee5c75f2404b +Subproject commit bee6e067208eb236f45b818fde10c99147a930b1 diff --git a/sources/ewol/object/Object.h b/sources/ewol/object/Object.h index 7372acbe..aa3a4254 100644 --- a/sources/ewol/object/Object.h +++ b/sources/ewol/object/Object.h @@ -222,6 +222,8 @@ namespace ewol { std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \ if (myObject != nullptr) { \ myObject->_event.bind(_obj, _func); \ + } else { \ + EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \ } \ } while (false) /* @@ -245,6 +247,8 @@ namespace ewol { std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \ if (myObject != nullptr) { \ myObject->_event.bind(_obj, _func); \ + } else { \ + EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \ } \ } while (false) @@ -255,6 +259,8 @@ namespace ewol { std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_object->getObjectNamed(_name)); \ if (myObject != nullptr) { \ myObject->_event.bind(_obj, _func); \ + } else { \ + EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \ } \ } while (false) //#include From 6bf0c0f0cd31096da08f7aa65d231da7d0c10e99 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 27 Aug 2014 22:56:57 +0200 Subject: [PATCH 12/22] [DEV] remove onReceiveMessage fucntion (deprecated) and set work again Entry, SelectColor, List ... --- external/etk | 2 +- sources/ewol/event/Input.cpp | 2 +- sources/ewol/object/Signal.h | 18 +++++- sources/ewol/object/SignalList.h | 6 -- sources/ewol/widget/ButtonColor.cpp | 16 +---- sources/ewol/widget/ButtonColor.h | 1 - sources/ewol/widget/Entry.cpp | 77 +++++++++++++---------- sources/ewol/widget/Entry.h | 6 +- sources/ewol/widget/ListFileSystem.cpp | 2 +- sources/ewol/widget/Menu.cpp | 6 -- sources/ewol/widget/Menu.h | 2 - sources/ewol/widget/meta/ColorChooser.cpp | 44 +++++-------- sources/ewol/widget/meta/ColorChooser.h | 2 - sources/ewol/widget/meta/FileChooser.cpp | 9 ++- sources/ewol/widget/meta/FileChooser.h | 28 +++------ 15 files changed, 100 insertions(+), 121 deletions(-) diff --git a/external/etk b/external/etk index bee6e067..ce3243a5 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit bee6e067208eb236f45b818fde10c99147a930b1 +Subproject commit ce3243a5f438c6dc3158b5f1c786741132a51a6f diff --git a/sources/ewol/event/Input.cpp b/sources/ewol/event/Input.cpp index 702f47a4..39ca0b15 100644 --- a/sources/ewol/event/Input.cpp +++ b/sources/ewol/event/Input.cpp @@ -14,7 +14,7 @@ std::ostream& ewol::event::operator <<(std::ostream& _os, const ewol::event::Input& _obj) { _os << "{type=" << _obj.getType(); _os << " status=" << _obj.getStatus(); - _os << " id=" << _obj.getId(); + _os << " id=" << etk::to_string(_obj.getId()); _os << " pos=" << _obj.getPos(); _os << "}"; return _os; diff --git a/sources/ewol/object/Signal.h b/sources/ewol/object/Signal.h index 3cae33d0..1652848c 100644 --- a/sources/ewol/object/Signal.h +++ b/sources/ewol/object/Signal.h @@ -91,7 +91,14 @@ namespace ewol { EWOL_VERBOSE(" nullptr dest"); continue; } - EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "] data='" << etk::to_string(_data) << "'"); + #ifdef DEBUG + ewol::Object* srcObject = dynamic_cast(&m_objectLink); + if (srcObject != nullptr) { + EWOL_DEBUG("emit signal : " << srcObject->getObjectType() << " '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " data='" << etk::to_string(_data) << "'"); + } else { + EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " data='" << etk::to_string(_data) << "'"); + } + #endif it.second(_data); } } @@ -165,7 +172,14 @@ namespace ewol { EWOL_VERBOSE(" nullptr dest"); continue; } - EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "] BANG!!!"); + #ifdef DEBUG + ewol::Object* srcObject = dynamic_cast(&m_objectLink); + if (srcObject != nullptr) { + EWOL_DEBUG("emit signal : " << srcObject->getObjectType() << " '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " BANG!!!"); + } else { + EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " BANG!!!"); + } + #endif it.second(); } } diff --git a/sources/ewol/object/SignalList.h b/sources/ewol/object/SignalList.h index af9e0c83..bac84c74 100644 --- a/sources/ewol/object/SignalList.h +++ b/sources/ewol/object/SignalList.h @@ -45,12 +45,6 @@ namespace ewol { * @param[in] _object Object to unlink. */ void unBindAll(const std::shared_ptr& _object); - public: - /** - * @brief Receive a message from an other Object with a specific eventId and data - * @param[in] _msg Message handle - */ - virtual void onReceiveMessage(const ewol::object::Message& _msg) { }; }; }; }; diff --git a/sources/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index 0b9c1699..6424deff 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -215,6 +215,7 @@ void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color void ewol::widget::ButtonColor::setValue(const etk::Color<>& _color) { m_textColorFg = _color; + signalChange.emit(m_textColorFg); markToRedraw(); } @@ -222,19 +223,6 @@ etk::Color<> ewol::widget::ButtonColor::getValue() { return m_textColorFg; } - -void ewol::widget::ButtonColor::onReceiveMessage(const ewol::object::Message& _msg) { - EWOL_INFO("Receive MSG : " << _msg.getData()); - if (_msg.getMessage() == eventColorHasChange) { - m_textColorFg = _msg.getData(); - // TODO : set a proper call - //signalChange.emit(_msg.getData()); - EWOL_TODO("generate signal of change color : " << _msg.getData()); - markToRedraw(); - } -} - - void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { if (true == m_shaper.changeStatusIn(_newStatusId) ) { periodicCallEnable(); @@ -242,8 +230,6 @@ void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { } } - - void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) { if (false == m_shaper.periodicCall(_event) ) { periodicCallDisable(); diff --git a/sources/ewol/widget/ButtonColor.h b/sources/ewol/widget/ButtonColor.h index 0918f855..2b096c1b 100644 --- a/sources/ewol/widget/ButtonColor.h +++ b/sources/ewol/widget/ButtonColor.h @@ -70,7 +70,6 @@ namespace ewol { virtual void calculateMinMaxSize(); virtual void onRegenerateDisplay(); virtual bool onEventInput(const ewol::event::Input& _event); - virtual void onReceiveMessage(const ewol::object::Message& _msg); private: /** * @brief internal system to change the property of the current status diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index d73d5700..b3c5262e 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -13,14 +13,6 @@ #include #include - -const char * const ewolEventEntryCut = "ewol-widget-entry-event-internal-cut"; -const char * const ewolEventEntryCopy = "ewol-widget-entry-event-internal-copy"; -const char * const ewolEventEntryPaste = "ewol-widget-entry-event-internal-paste"; -const char * const ewolEventEntryClean = "ewol-widget-entry-event-internal-clean"; -const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-select"; - - #undef __class__ #define __class__ "Entry" @@ -52,6 +44,7 @@ void ewol::widget::Entry::init(const std::string& _newData) { m_shaper.setString("THEME:GUI:Entry.json"); setCanHaveFocus(true); m_regExp.setString(".*"); + m_regExp.get().setMaximize(true); markToRedraw(); shortCutAdd("ctrl+w", "clean"); @@ -69,7 +62,21 @@ ewol::widget::Entry::~Entry() { } void ewol::widget::Entry::onCallbackShortCut(const std::string& _value) { - EWOL_WARNING("Event from ShortCut : " << _value); + if (_value == "clean") { + onCallbackEntryClean(); + } else if (_value == "cut") { + onCallbackCut(); + } else if (_value == "copy") { + onCallbackCopy(); + } else if (_value == "paste") { + onCallbackPaste(); + } else if (_value == "select:all") { + onCallbackSelect(true); + } else if (_value == "select:none") { + onCallbackSelect(false); + } else { + EWOL_WARNING("Unknow event from ShortCut : " << _value); + } } void ewol::widget::Entry::calculateMinMaxSize() { @@ -407,7 +414,7 @@ void ewol::widget::Entry::setInternalValue(const std::string& _newData) { std::string previous = m_data; // check the RegExp : if (_newData.size()>0) { - if (false == m_regExp->processOneElement(_newData,0,_newData.size()) ) { + if (false == m_regExp->parse(_newData,0,_newData.size()) ) { EWOL_INFO("the input data does not match with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp->getRegExp() << "\" start=" << m_regExp->start() << " stop=" << m_regExp->stop() ); return; } @@ -445,32 +452,36 @@ void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipbo signalModify.emit(m_data); } +void ewol::widget::Entry::onCallbackEntryClean() { + m_data = ""; + m_displayStartPosition = 0; + m_displayCursorPos = 0; + m_displayCursorPosSelection = m_displayCursorPos; + markToRedraw(); +} -void ewol::widget::Entry::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::Widget::onReceiveMessage(_msg); - if(_msg.getMessage() == ewolEventEntryClean) { - m_data = ""; - m_displayStartPosition = 0; - m_displayCursorPos = 0; +void ewol::widget::Entry::onCallbackCut() { + copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); + removeSelected(); + signalModify.emit(m_data); +} + +void ewol::widget::Entry::onCallbackCopy() { + copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); +} + +void ewol::widget::Entry::onCallbackPaste() { + ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd); +} + +void ewol::widget::Entry::onCallbackSelect(bool _all) { + if(_all == true) { + m_displayCursorPosSelection = 0; + m_displayCursorPos = m_data->size(); + } else { m_displayCursorPosSelection = m_displayCursorPos; - markToRedraw(); - } else if(_msg.getMessage() == ewolEventEntryCut) { - copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); - removeSelected(); - signalModify.emit(m_data); - } else if(_msg.getMessage() == ewolEventEntryCopy) { - copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); - } else if(_msg.getMessage() == ewolEventEntryPaste) { - ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd); - } else if(_msg.getMessage() == ewolEventEntrySelect) { - if(_msg.getData() == "ALL") { - m_displayCursorPosSelection = 0; - m_displayCursorPos = m_data->size(); - } else { - m_displayCursorPosSelection = m_displayCursorPos; - } - markToRedraw(); } + markToRedraw(); } void ewol::widget::Entry::markToUpdateTextPosition() { diff --git a/sources/ewol/widget/Entry.h b/sources/ewol/widget/Entry.h index 346f647f..f486d0f9 100644 --- a/sources/ewol/widget/Entry.h +++ b/sources/ewol/widget/Entry.h @@ -166,7 +166,6 @@ namespace ewol { virtual void onRegenerateDisplay(); virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventEntry(const ewol::event::Entry& _event); - virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); virtual void calculateMinMaxSize(); protected: // Derived function @@ -178,6 +177,11 @@ namespace ewol { virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer); private: // callback functions void onCallbackShortCut(const std::string& _value); + void onCallbackEntryClean(); + void onCallbackCut(); + void onCallbackCopy(); + void onCallbackPaste(); + void onCallbackSelect(bool _all); }; }; }; diff --git a/sources/ewol/widget/ListFileSystem.cpp b/sources/ewol/widget/ListFileSystem.cpp index f16ae7b6..61f60a41 100644 --- a/sources/ewol/widget/ListFileSystem.cpp +++ b/sources/ewol/widget/ListFileSystem.cpp @@ -173,7 +173,7 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, } } if (_typeEvent == ewol::key::statusSingle) { - EWOL_DEBUG("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); + EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); if (1 == _IdInput) { int32_t previousRaw = m_selectedLine; if (_raw > (int32_t)m_list.size()+offset ) { diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index ccf233f4..bcd712f8 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -235,9 +235,3 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu } -void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) { - /* - */ -} - - diff --git a/sources/ewol/widget/Menu.h b/sources/ewol/widget/Menu.h index 5c00c137..750e9eb9 100644 --- a/sources/ewol/widget/Menu.h +++ b/sources/ewol/widget/Menu.h @@ -55,8 +55,6 @@ namespace ewol { int32_t addTitle(std::string _label, std::string _image="", const std::string _message = ""); int32_t add(int32_t _parent, std::string _label, std::string _image="", const std::string _message = ""); void addSpacer(); - // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); private: void onButtonPressed(std::weak_ptr _button); }; diff --git a/sources/ewol/widget/meta/ColorChooser.cpp b/sources/ewol/widget/meta/ColorChooser.cpp index 34c872df..f954d59b 100644 --- a/sources/ewol/widget/meta/ColorChooser.cpp +++ b/sources/ewol/widget/meta/ColorChooser.cpp @@ -109,33 +109,6 @@ etk::Color<> ewol::widget::ColorChooser::getColor() { return m_currentColor; } - -void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _msg) { - //EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" == > data=\"" << data << "\"" ); - if (eventColorBarHasChange == _msg.getMessage()) { - // == > colorBar has change ... - uint8_t tmpAlpha = m_currentColor.a(); - // the colorbar has no notion of the alpha == > keep it ... - if (nullptr != m_widgetColorBar) { - m_currentColor = m_widgetColorBar->getCurrentColor(); - } - m_currentColor.setA(tmpAlpha); - if (nullptr != m_widgetRed) { - m_widgetRed->setValue(m_currentColor.r()); - } - if (nullptr != m_widgetGreen) { - m_widgetGreen->setValue(m_currentColor.g()); - } - if (nullptr != m_widgetBlue) { - m_widgetBlue->setValue(m_currentColor.b()); - } - if (nullptr != m_widgetAlpha) { - m_widgetAlpha->setValue(m_currentColor.a()); - } - signalChange.emit(m_currentColor); - } -}; - void ewol::widget::ColorChooser::onCallbackColorChangeRed(const int32_t& _newColor) { m_currentColor.setR(_newColor); if (nullptr != m_widgetColorBar) { @@ -166,8 +139,21 @@ void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const int32_t& _newC } void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) { m_currentColor = _newColor; - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); + // == > colorBar has change ... + uint8_t tmpAlpha = m_currentColor.a(); + m_currentColor = _newColor; + m_currentColor.setA(tmpAlpha); + if (nullptr != m_widgetRed) { + m_widgetRed->setValue(m_currentColor.r()); + } + if (nullptr != m_widgetGreen) { + m_widgetGreen->setValue(m_currentColor.g()); + } + if (nullptr != m_widgetBlue) { + m_widgetBlue->setValue(m_currentColor.b()); + } + if (nullptr != m_widgetAlpha) { + m_widgetAlpha->setValue(m_currentColor.a()); } signalChange.emit(m_currentColor); } \ No newline at end of file diff --git a/sources/ewol/widget/meta/ColorChooser.h b/sources/ewol/widget/meta/ColorChooser.h index 74b0ba6a..c3044ece 100644 --- a/sources/ewol/widget/meta/ColorChooser.h +++ b/sources/ewol/widget/meta/ColorChooser.h @@ -35,8 +35,6 @@ namespace ewol { public: DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser"); virtual ~ColorChooser(); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); public: void setColor(etk::Color<> _newColor); etk::Color<> getColor(); diff --git a/sources/ewol/widget/meta/FileChooser.cpp b/sources/ewol/widget/meta/FileChooser.cpp index 057cdbed..9283f09b 100644 --- a/sources/ewol/widget/meta/FileChooser.cpp +++ b/sources/ewol/widget/meta/FileChooser.cpp @@ -183,24 +183,27 @@ void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const std::stri void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) { setFileName(_value); + /* std::string tmpFileCompleatName = m_folder; tmpFileCompleatName += m_file; // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); + */ } void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) { // select the file == > generate a validate setFileName(_value); - EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); + EWOL_VERBOSE(" generate a fiel opening : '" << m_folder << "' / '" << m_file << "'"); signalValidate.emit(getCompleateFileName()); autoDestroy(); } void ewol::widget::FileChooser::onCallbackListValidate() { - if (m_file != "" ) { + if (m_file == "" ) { + EWOL_WARNING(" Validate : '" << m_folder << "' / '" << m_file << "' ==> error No name ..."); return; } - EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); + EWOL_DEBUG(" generate a file opening : '" << m_folder << "' / '" << m_file << "'"); signalValidate.emit(getCompleateFileName()); autoDestroy(); } diff --git a/sources/ewol/widget/meta/FileChooser.h b/sources/ewol/widget/meta/FileChooser.h index ab47441e..838c6a8c 100644 --- a/sources/ewol/widget/meta/FileChooser.h +++ b/sources/ewol/widget/meta/FileChooser.h @@ -24,21 +24,19 @@ namespace ewol { * Fist global static declaration and inclusion: * [code style=c++] * #include - * static const char* const g_eventOpenFile = "appl-local-event-open-file"; - * static const char* const g_eventClosePopUp = "appl-local-event-close-pop-up"; * [/code] * - * The first step is to create the file chooser pop-up : + * The first step is to create the file chooser pop-up : (never in the constructor!!!) * [code style=c++] - * std::shared_ptr tmpWidget = ewol::object::makeShared(new ewol::Widget::FileChooser()); + * std::shared_ptr tmpWidget = ewol::Widget::FileChooser::create(); * if (tmpWidget == nullptr) { * APPL_ERROR("Can not open File chooser !!! "); * return -1; * } * // register on the Validate event: - * tmpWidget->registerOnEvent(this, "validate", g_eventOpenFile); + * tmpWidget->signalValidate.bind(shared_from_this(), &****::onCallbackOpenFile); * // no need of this event watching ... - * tmpWidget->registerOnEvent(this, "cancel", g_eventClosePopUp); + * tmpWidget->signalCancel.bind(shared_from_this(), &****::onCallbackClosePopUp); * // set the title: * tmpWidget->setTitle("Open files ..."); * // Set the validate Label: @@ -46,7 +44,7 @@ namespace ewol { * // simply set a folder (by default this is the home folder) * //tmpWidget->setFolder("/home/me"); * // add the widget as windows pop-up ... - * ewol::widget::Windows* tmpWindows = getWindows(); + * std::shared_ptr tmpWindows = getWindows(); * if (tmpWindows == nullptr) { * APPL_ERROR("Can not get the current windows !!! "); * return -1; @@ -57,17 +55,11 @@ namespace ewol { * Now we just need to wait the the open event message. * * [code style=c++] - * void ********::onReceiveMessage(const ewol::object::Message& _msg) { - * APPL_DEBUG("Receive Message: " << _msg ); - * if (_msg.getMessage() == g_eventOpenFile) { - * APPL_INFO("Request open file : '" << _msg.getData() << "'"); - * return; - * } - * if (_msg.getMessage() == g_eventClosePopUp) { - * APPL_INFO("The File chooser has been closed"); - * // generaly nothing to do ... - * return; - * } + * void ****::onCallbackOpenFile(const std::string& _value) { + * APPL_INFO("Request open file : '" << _value << "'"); + * } + * void ****::onCallbackClosePopUp() { + * APPL_INFO("The File chooser has been closed"); * } * [/code] * This is the best example of a Meta-widget. From d8ddb85a8270354c1e9ad4aec99cb20dbeab5c19 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 28 Aug 2014 21:51:55 +0200 Subject: [PATCH 13/22] [DEV] update menu interface --- build | 2 +- sources/ewol/widget/Menu.cpp | 49 +++++++++++++++++++++++++----------- sources/ewol/widget/Menu.h | 8 +++--- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/build b/build index 885a60f2..92c552fd 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 885a60f22ce3dfde99819d3471a86fdbd3836237 +Subproject commit 92c552fd59009e30388d9762b1c9e618193c8d16 diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index bcd712f8..b1cb7936 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -21,7 +21,7 @@ ewol::widget::Menu::Menu() : signalSelect(*this, "select") { addObjectType("ewol::widget::Menu"); - m_staticId = 0; + m_staticId = 666; } void ewol::widget::Menu::init() { @@ -54,22 +54,36 @@ void ewol::widget::Menu::clear() { m_listElement.clear(); } -int32_t ewol::widget::Menu::addTitle(std::string _label, - std::string _image, - const std::string _message) { +int32_t ewol::widget::Menu::addTitle(const std::string& _label, + const std::string& _image, + const std::string& _message) { return add(-1, _label, _image, _message); } static const char* eventButtonPressed = "menu-local-pressed"; +int32_t ewol::widget::Menu::get(const std::string& _label) { + for (auto &it : m_listElement) { + if (it.m_label == _label) { + return it.m_localId; + } + } + return -1; +} + int32_t ewol::widget::Menu::add(int32_t _parent, - std::string _label, - std::string _image, - const std::string _message) { + const std::string& _label, + const std::string& _image, + const std::string& _message) { + // try to find one already created : + int32_t previous = get(_label); + if (previous != -1) { + return previous; + } ewol::widget::MenuElement tmpObject; tmpObject.m_localId = m_staticId++; tmpObject.m_parentId = _parent; - tmpObject.m_label = std::string("") + _label + ""; + tmpObject.m_label = _label; tmpObject.m_image = _image; tmpObject.m_message = _message; if (-1 == tmpObject.m_parentId) { @@ -85,13 +99,12 @@ int32_t ewol::widget::Menu::add(int32_t _parent, } else { composeString+=" \n"; } - composeString+=" \n"; + composeString+=" \n"; composeString+="\n"; myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString)); } else { - myButton->setSubWidget(ewol::widget::Label::create(tmpObject.m_label) ); + myButton->setSubWidget(ewol::widget::Label::create("" + tmpObject.m_label + "") ); } - // add it in the widget list ewol::widget::Sizer::subWidgetAdd(myButton); // keep the specific event ... @@ -102,8 +115,14 @@ int32_t ewol::widget::Menu::add(int32_t _parent, return tmpObject.m_localId; } -void ewol::widget::Menu::addSpacer() { - EWOL_TODO("NOT now..."); +void ewol::widget::Menu::remove(int32_t _id) { + EWOL_TODO("NOT remove..."); +} + + +int32_t ewol::widget::Menu::addSpacer() { + EWOL_TODO("NOT addSpacer..."); + return -1; } void ewol::widget::Menu::onButtonPressed(std::weak_ptr _button) { @@ -188,7 +207,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu } else { composeString+=" m_image + "\" size=\"8,8mm\"/>\n"; } - composeString+=" \n"; + composeString+=" \n"; composeString+=" \n"; composeString+="\n"; myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString)); @@ -198,7 +217,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu std::string("\n") + " \n" " \n" - " \n" + " \n" " \n" "\n")); } else { diff --git a/sources/ewol/widget/Menu.h b/sources/ewol/widget/Menu.h index 750e9eb9..b0fce18e 100644 --- a/sources/ewol/widget/Menu.h +++ b/sources/ewol/widget/Menu.h @@ -50,11 +50,13 @@ namespace ewol { std::vector m_listElement; int32_t m_staticId; // unique ID for every element of the menu ... std::weak_ptr m_widgetContextMenu; + int32_t get(const std::string& _label); public: void clear(); - int32_t addTitle(std::string _label, std::string _image="", const std::string _message = ""); - int32_t add(int32_t _parent, std::string _label, std::string _image="", const std::string _message = ""); - void addSpacer(); + int32_t addTitle(const std::string& _label, const std::string& _image="", const std::string& _message = ""); + int32_t add(int32_t _parent, const std::string& _label, const std::string& _image="", const std::string& _message = ""); + int32_t addSpacer(); + void remove(int32_t _id); private: void onButtonPressed(std::weak_ptr _button); }; From 3f7cf66e998699bef99cba95db10d8cd4cf866e0 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 29 Aug 2014 23:30:41 +0200 Subject: [PATCH 14/22] [DEV] add remove link with a shortcut --- sources/ewol/widget/Widget.cpp | 21 ++++++++++++++++++--- sources/ewol/widget/Widget.h | 5 +++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index e0179e2c..3899aa64 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -516,10 +516,25 @@ void ewol::Widget::shortCutAdd(const std::string& _descriptiveString, const std: m_localShortcut.push_back(tmpElement); } +void ewol::Widget::shortCutRemove(const std::string& _message) { + auto it(m_localShortcut.begin()); + while(it != m_localShortcut.end()) { + if ( *it != nullptr + && (*it)->message != _message) { + ++it; + continue; + } + delete(*it); + *it = nullptr; + m_localShortcut.erase(it); + it = m_localShortcut.begin(); + } +} + void ewol::Widget::shortCutClean() { - for (size_t iii=0; iii Date: Sat, 30 Aug 2014 09:15:26 +0200 Subject: [PATCH 15/22] [DEV] remove empty files --- build | 2 +- sources/ewol/compositing/TextBasic.cpp | 0 sources/ewol/compositing/TextBasic.h | 0 sources/ewol/context/Application.cpp | 0 sources/ewol/context/Context.h | 1 - sources/ewol/context/InputManager.h | 1 - sources/ewol/object/Manager.h | 1 - sources/ewol/object/Message.cpp | 24 -------------- sources/ewol/object/Message.h | 46 -------------------------- sources/ewol/object/MultiCast.cpp | 0 sources/ewol/object/MultiCast.h | 0 sources/ewol/object/Object.h | 3 +- sources/ewol/object/Param.cpp | 0 sources/ewol/object/ParamRange.cpp | 0 sources/ewol/object/RemoveEvent.cpp | 0 sources/ewol/object/RemoveEvent.h | 0 sources/ewol/object/Signal.cpp | 0 sources/ewol/resource/Manager.h | 1 - sources/ewol/widget/Manager.h | 1 - sources/lutin_ewol.py | 8 +---- 20 files changed, 3 insertions(+), 85 deletions(-) delete mode 100644 sources/ewol/compositing/TextBasic.cpp delete mode 100644 sources/ewol/compositing/TextBasic.h delete mode 100644 sources/ewol/context/Application.cpp delete mode 100644 sources/ewol/object/Message.cpp delete mode 100644 sources/ewol/object/Message.h delete mode 100644 sources/ewol/object/MultiCast.cpp delete mode 100644 sources/ewol/object/MultiCast.h delete mode 100644 sources/ewol/object/Param.cpp delete mode 100644 sources/ewol/object/ParamRange.cpp delete mode 100644 sources/ewol/object/RemoveEvent.cpp delete mode 100644 sources/ewol/object/RemoveEvent.h delete mode 100644 sources/ewol/object/Signal.cpp diff --git a/build b/build index 92c552fd..885a60f2 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 92c552fd59009e30388d9762b1c9e618193c8d16 +Subproject commit 885a60f22ce3dfde99819d3471a86fdbd3836237 diff --git a/sources/ewol/compositing/TextBasic.cpp b/sources/ewol/compositing/TextBasic.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/compositing/TextBasic.h b/sources/ewol/compositing/TextBasic.h deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/context/Application.cpp b/sources/ewol/context/Application.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/context/Context.h b/sources/ewol/context/Context.h index 86002e47..4962b403 100644 --- a/sources/ewol/context/Context.h +++ b/sources/ewol/context/Context.h @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace ewol { diff --git a/sources/ewol/context/InputManager.h b/sources/ewol/context/InputManager.h index 5e9fcbdf..2e9a09d6 100644 --- a/sources/ewol/context/InputManager.h +++ b/sources/ewol/context/InputManager.h @@ -10,7 +10,6 @@ #define __EWOL_SYSTEM_INPUT_H__ #include -#include #define MAX_MANAGE_INPUT (15) diff --git a/sources/ewol/object/Manager.h b/sources/ewol/object/Manager.h index 06e56521..84f57b5a 100644 --- a/sources/ewol/object/Manager.h +++ b/sources/ewol/object/Manager.h @@ -11,7 +11,6 @@ #include #include -#include namespace ewol { class Context; diff --git a/sources/ewol/object/Message.cpp b/sources/ewol/object/Message.cpp deleted file mode 100644 index d303db6d..00000000 --- a/sources/ewol/object/Message.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -#undef __class__ -#define __class__ "object/Message" - -std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::Message& _obj) { - _os << "{"; - if (nullptr != _obj.getMessage()) { - _os << "msg=\"" << _obj.getMessage() << "\""; - } else { - _os << "msg={nullptr}"; - } - _os << " data=\"" << _obj.getData() << "\"}"; - return _os; -} - diff --git a/sources/ewol/object/Message.h b/sources/ewol/object/Message.h deleted file mode 100644 index 53057b40..00000000 --- a/sources/ewol/object/Message.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_OBJECT_MESSAGE_H__ -#define __EWOL_OBJECT_MESSAGE_H__ - -#include - -namespace ewol { - namespace object { - class Message { - private: - const char* m_event; //!< Event pointer == > unique Id define by the system ... - std::string m_data; //!< compositing additionnal message Value. - public: - Message(const char* _message, - const std::string& _data) : - m_event(_message), - m_data(_data) { - - }; - void setMessage(const char* _message) { - m_event = _message; - }; - inline const char* getMessage() const { - return m_event; - }; - void setData(const std::string& _data) { - m_data = _data; - }; - inline const std::string& getData() const { - return m_data; - }; - }; - std::ostream& operator <<(std::ostream& _os, const ewol::object::Message& _obj); - }; -}; - - -#endif - diff --git a/sources/ewol/object/MultiCast.cpp b/sources/ewol/object/MultiCast.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/object/MultiCast.h b/sources/ewol/object/MultiCast.h deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/object/Object.h b/sources/ewol/object/Object.h index aa3a4254..e46a0f3b 100644 --- a/sources/ewol/object/Object.h +++ b/sources/ewol/object/Object.h @@ -9,7 +9,6 @@ #ifndef __EWOL_OBJECT_H__ #define __EWOL_OBJECT_H__ -#include #include #include #include @@ -25,7 +24,7 @@ namespace ewol { class Context; }; -#include +#include #include #include #include diff --git a/sources/ewol/object/Param.cpp b/sources/ewol/object/Param.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/object/ParamRange.cpp b/sources/ewol/object/ParamRange.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/object/RemoveEvent.cpp b/sources/ewol/object/RemoveEvent.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/object/RemoveEvent.h b/sources/ewol/object/RemoveEvent.h deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/object/Signal.cpp b/sources/ewol/object/Signal.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/resource/Manager.h b/sources/ewol/resource/Manager.h index 9647fe9f..2a8bf023 100644 --- a/sources/ewol/resource/Manager.h +++ b/sources/ewol/resource/Manager.h @@ -14,7 +14,6 @@ #include #include #include -#include namespace ewol { namespace resource { diff --git a/sources/ewol/widget/Manager.h b/sources/ewol/widget/Manager.h index 60e02d71..1e8fce03 100644 --- a/sources/ewol/widget/Manager.h +++ b/sources/ewol/widget/Manager.h @@ -14,7 +14,6 @@ #include #include #include -#include namespace ewol { namespace widget { diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index aed548ef..c79ddb49 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -89,18 +89,12 @@ def create(target): # object : myModule.add_src_file([ 'ewol/object/Manager.cpp', - 'ewol/object/Message.cpp', - 'ewol/object/MultiCast.cpp', 'ewol/object/Object.cpp', - 'ewol/object/RemoveEvent.cpp', 'ewol/object/Parameter.cpp', 'ewol/object/ParameterList.cpp', 'ewol/object/ParamList.cpp', - 'ewol/object/Param.cpp', - 'ewol/object/ParamRange.cpp', 'ewol/object/SignalList.cpp', - 'ewol/object/SignalBase.cpp', - 'ewol/object/Signal.cpp' + 'ewol/object/SignalBase.cpp' ]) # OpenGL interface : From 87f4aedb952b976e4bf249885afb6aafd9d5b32e Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 1 Sep 2014 22:54:02 +0200 Subject: [PATCH 16/22] [DEV] start updating documentation --- build | 2 +- doc/001_bases.bb | 4 +- doc/index.bb | 38 ++++++++------- doc/tutorial/001_HelloWord.bb | 87 +++++++++++++++++++++++++---------- monk | 2 +- sources/ewol/object/Object.h | 1 + 6 files changed, 89 insertions(+), 45 deletions(-) diff --git a/build b/build index 885a60f2..92c552fd 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 885a60f22ce3dfde99819d3471a86fdbd3836237 +Subproject commit 92c552fd59009e30388d9762b1c9e618193c8d16 diff --git a/doc/001_bases.bb b/doc/001_bases.bb index 40c76b6f..8a6d9f62 100644 --- a/doc/001_bases.bb +++ b/doc/001_bases.bb @@ -5,7 +5,7 @@ __________________________________________________ === Overview:=== EWOL is an OpenGL library for creating graphical user interfaces. It works on many UNIX-like platforms, Windows, and OS X and some mobile platforms Android, iOs(soon). -EWOL is released under the BSD 3 clauses license (BSD v3), which allows for very flexible licensing of client applications. +EWOL is released under the APACHE-2 license, which allows for very flexible licensing of client applications. EWOL has a C++ architecture that allows for maximum flexibility. The main idea of EWOL is to create a complete abstraction of the platforms. @@ -21,7 +21,7 @@ To use ewol you need to know only C++ language. It could be usefull to know: One of the important point to know in this framwork is some of absurd things came from the multiple architecture type. I will Explain the main points: -:** IOs does [b]NOT[/b] simply support the shared object sub lib, this force ewol to be BSD, and depend on some sub-library with small license restriction. +:** IOs does [b]NOT[/b] simply support the shared object sub lib, this force ewol to be APACHE-2, and depend on some sub-library with small license restriction. :** Android have a JAVA main, then the application main will not be used with this platform :** Android event (keyboard, mouse, touch-screen and ...) will arrive in asynchron mode ==> need to be resynchronyse in one thread :** Only one graphyc framework is availlable on all platform. This is OpenGL diff --git a/doc/index.bb b/doc/index.bb index eb617652..843d58fd 100644 --- a/doc/index.bb +++ b/doc/index.bb @@ -7,10 +7,10 @@ EWOL, or Edn Widget OpenGl Layer, is a multi-platform library for creating graph ===Where can I use it?=== Everywhere! EWOL is cross-platform devolopped to support bases OS: : ** Linux (X11) (mouse) -: ** Windows (mouse) +: ** Windows (mouse) (not compile anymore ==> TODO) : ** MacOs (mouse) : ** Android (mouse + touch) -: ** IOs (in-progress) +: ** IOs (touch) ===What languages are supported?=== EWOL is written in C++ and is not (for now) supported for other languages. @@ -23,7 +23,7 @@ That allow you to use it for every program you want, including those developing [note]The static support is important for some platform like IOs, and this limit the external library use at some license like : :** BSD* :** MIT -:** APPACHE +:** APPACHE-2 :** PNG :** ZLIB This exclude the classical extern library with licence: @@ -31,33 +31,37 @@ This exclude the classical extern library with licence: :** GPL [/note] -==== License (BSD) ==== -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: +==== License (APACHE 2) ==== +Copyright ewol Edouard DUPIN -:** Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -:** Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -:** The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at -THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. ==== Sub library: ==== ===== License: ===== -:** [b][lib[etk | e-tk]][/b] : BSD 3 clauses +:** [b][lib[etk | e-tk]][/b] : APACHE-2 ::** [b][lib[linearmath | Linear-Math]][/b] : z-lib (subset of bullet lib) -::** [b][lib[earchive | e-Archive]][/b] : BSD 3 clauses +::** [b][lib[earchive | e-Archive]][/b] : APACHE-2 :::** [b][lib[z | Z lib]][/b] : z-lib -:** [b][lib[egami | e-gami]][/b] : BSD 3 clauses -::** [b][lib[esvg | e-svg]][/b] : BSD 3 clauses +:** [b][lib[egami | e-gami]][/b] : APACHE-2 +::** [b][lib[esvg | e-svg]][/b] : APACHE-2 :::** [b][lib[agg | AGG]][/b] : BSD-like ::** [b][lib[png | libPNG]][/b] : PNG :** [b][lib[portaudio | portaudio]][/b] : MIT :** [b][lib[ogg | ogg]][/b] : BSD-like :** [b][lib[freetype | Free-Type]][/b] : BSD-like -:** [b][lib[ejson | e-json]][/b] : BSD 3 clauses -:** [b][lib[exml | e-xml]][/b] : BSD 3 clauses +:** [b][lib[ejson | e-json]][/b] : APACHE-2 +:** [b][lib[exml | e-xml]][/b] : APACHE-2 ==== Description : ==== diff --git a/doc/tutorial/001_HelloWord.bb b/doc/tutorial/001_HelloWord.bb index 5d0795c2..07f904ae 100644 --- a/doc/tutorial/001_HelloWord.bb +++ b/doc/tutorial/001_HelloWord.bb @@ -12,12 +12,15 @@ __________________________________________________ A generic Ewol application is manage by creating an [class[ewol::context::Application]] that is the basis of your application. -Due to the fact the ewol librairy is a multi-platform framework, then you need to think all you will do with only one -application and only one windows displayable at the same time. +Due to the fact the ewol library is a multi-platform framework, you will have many contraint like: +:** One application at the same time +:** One Windows displayable at the time +:** Not a big CPU ... Then we will create the application: [code style=c++] +namespace appl { class MainApplication : public ewol::context::Application { public: bool init(ewol::Context& _context, size_t _initId) { @@ -32,42 +35,47 @@ Then we will create the application: APPL_INFO("==> Un-Init APPL (END)"); } }; +}; [/code] The input [class[ewol::Context]] is the main system context. [note] -It is important to know that the system can call your application in parallele, the basic exemple of this is the Wallpaper on Android. +It is important to know that the system can create your application multiple times, the basic exemple of this is the Wallpaper on Android. What is done: -** When selected, it create an intance and when it is apply Android create a new instance and remove the previous one... +** When we select the wallpaper it create a new application (to show an example) +** When applying your choice, it create the real one an remove the previous one. [/note] In all program we need to have a main() -To be portable on Android, that have a java main the User might the Wrapper call the generic main() (please do not add other things in this main). +To be portable on Android, the "main" in the java might call your main through the Android wrapper. + +To simplify compabilities between platform it is recommanded to not add other things in the application main: [code style=c++] int main(int argc, const char *argv[]) { // only one things to do : - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(new appl::MainApplication(), _argc, _argv); } [/code] ==== Some configuration are needed ==== -In your application you can use many configuration, -none of them are set in static for compilation and interface reason, -then you will to set it on dynamic. +In your application you can use many configuration, it is really better to set all your configuration dynamic. +With this basic condiction will simplify the interface of the library if you would have many different application +(never forger the compilator garbage collector is really very efficient). -Select fonts: + +[b]Select fonts:[/b] This can be a problem when you design an application for some other operating system (OS), They do not have the same default font. -And we select an order to search the font names and the system basic size. +We select an order to search the font names and the system basic size. [code style=c++] // Use External font depending on the system (for specific application, it is better to provide fonts) _context.getFontDefault().setUseExternal(true); @@ -80,7 +88,7 @@ And we select an order to search the font names and the system basic size. Create the main Windows: -For this point we will create a class that herited form the basic windows class: +For this point we will create a class that herited form the basic [class[ewol::wiget::Windows]] class: [b]Windows.h[/b] [code style=c++] @@ -91,14 +99,28 @@ For this point we will create a class that herited form the basic windows class: namespace appl { class Windows : public ewol::widget::Windows { - public: + protected: Windows(void); + init() + public: + DECLARE_FACTORY(Windows); virtual ~Windows(void) {}; }; }; #endif [/code] +At this point you will ask an important question : [b]Why we use this really bad "DECLARE_FACTORY" Macro ?[/b] + +For some reason!!! But everything might be clear: +:** In ewol we masively use std::shared_ptr (I have create my own but it is not "standard" (I like when we use genecic system)). +:** The main class : [class[ewol::Object]] herited from [i]std::enable_shared_from_this[/i] to permit to access at his own [i]std::shared_ptr[/i]. +:** Acces At his own [i]std::shared_ptr[/i] is not allowed in the class contructor/destructor. +:** Many time for meta-widget we need to propagate our [i]std::shared_ptr[/i] in child. + +Then for all these reasons, I have create a simple MACRO that create a static template funtion that create the object and just after +creation call the init(...) function to permit to create a complex widget or others with some writing convinience. + [b]Windows.cpp[/b] [code style=c++] #include @@ -110,8 +132,13 @@ For this point we will create a class that herited form the basic windows class: #define __class__ "Windows" appl::Windows::Windows(void) { + // To simplify log (if you have a better solution, I am aware) + addObjectType("appl::Windows"); + } + appl::Windows::init(void) { + ewol::widget::Windows::init(); setTitle("example 001_HelloWord"); - ewol::object::Shared tmpWidget = new ewol::widget::Label(); + std::shared_ptr tmpWidget = ewol::widget::Label::create(); if (NULL == tmpWidget) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { @@ -122,6 +149,11 @@ For this point we will create a class that herited form the basic windows class: } [/code] +The init function can not be virtual due to his polymorphic status, then we need to call parrent init +[code style=c++] + ewol::widget::Windows::init(); +[/code] + The fist basic property to set is the Title: [code style=c++] setTitle("example 001_HelloWord"); @@ -130,14 +162,17 @@ The fist basic property to set is the Title: After we simple create a [class[widget::Label]] in the main windows constructor. And we set the widget property (label). [code style=c++] - ewol::object::Shared tmpWidget = ewol::object::makeShared(new ewol::widget::Label()); - tmpWidget->setLabel("Hello Word"); + std::shared_ptr tmpWidget = ewol::widget::Label::create(); + tmpWidget->setLabel("Hello Word"); tmpWidget->setExpand(bvec2(true,true)); [/code] -We can se in this example that the label have some other property like the font color. +We can see in this example that the label have some other property like the font color. + The label can have decorated text based on the html generic writing but it is composed with really simple set of balise. -I will take a really long time to create a real html parser, the the availlable property is: +I will take a really long time to create a real html parser. + +The availlable property is: :** [b]
[/b] : New line :** [b] ... [/b] : change the font color. :** [b]
...
[/b] : center the text. @@ -156,6 +191,7 @@ The last step is to add the widget on the windows : [code style=c++] setSubWidget(tmpWidget); [/code] +When we call this function, it use the shard_from_this() function that create an exception if we are in constructor ==== Configure Ewol to have display the windows ==== @@ -164,10 +200,12 @@ At this point we have created the basic windows. But the system does not know it. Then we create windows and set it in the main contect main (in the MainApplication::init()): [code style=c++] - ewol::object::Shared basicWindows = ewol::object::makeShared(new appl::Windows()); + std::shared_ptr basicWindows = appl::Windows::create()); // create the specific windows _context.setWindows(basicWindows); [/code] +Her we call the create function that is created by the DECLARE_FACTORY macro + Then the init fuction is : [code style=c++] @@ -177,7 +215,7 @@ bool MainApplication::init(ewol::Context& _context, size_t _initId) { _context.getFontDefault().setUseExternal(true); _context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19); - ewol::Windows* basicWindows = new appl::Windows(); + std::shared_ptr basicWindows = appl::Windows::create(); // create the specific windows _context.setWindows(basicWindows); APPL_INFO("==> Init APPL (END)"); @@ -245,9 +283,9 @@ I do not explain again the lutin file, for next tutorial, show example sources . === Build your application === -go to your workspace folder and launch +Go to your workspace folder and launch [code style=shell] - ./ewol/build/lutin.py -C -mdebug -p 001_HelloWord + ./ewol/build/lutin.py -C -mdebug 001_HelloWord [/code] Your program example will build correctly... @@ -259,13 +297,14 @@ Launch it : The [b]-l6[/b] is used to specify the Log level of the application display (this log is synchronous) + The output compile in a separate folder depending on the compilation tool (gcc or clang) + It create a complete final tree in the ./out/Linux/debug/staging/gcc/001_HelloWord/ folder -The final folder contain the package generated -tree of the output +The final folder contain the package generated: :** out ::** MacOs ::** Android diff --git a/monk b/monk index eba3e4f9..9b9a5d32 160000 --- a/monk +++ b/monk @@ -1 +1 @@ -Subproject commit eba3e4f97f618b607e0fc52794b2a72c7f6902e8 +Subproject commit 9b9a5d323787b13ab5b0f7de6d064e326e143426 diff --git a/sources/ewol/object/Object.h b/sources/ewol/object/Object.h index e46a0f3b..78c05066 100644 --- a/sources/ewol/object/Object.h +++ b/sources/ewol/object/Object.h @@ -63,6 +63,7 @@ namespace ewol { */ Object(); void init(); + //! @previous void init(const std::string& _name); public: /** From d5bd35d0a4f305fdd67f9ee2a3a55a3a21227552 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 2 Sep 2014 21:26:15 +0200 Subject: [PATCH 17/22] [DOC] update documentation --- doc/faq.bb | 16 +++ doc/tutorial/000_Build.bb | 2 +- doc/tutorial/001_HelloWord.bb | 11 +- doc/tutorial/010_ObjectModel.bb | 131 ++++++------------ doc/tutorial/011_ObjectConfig.bb | 146 +++++++------------- doc/tutorial/012_ObjectMessage.bb | 217 ++++++++++++++++++------------ doc/tutorial/020_FileAccess.bb | 2 +- sources/ewol/object/Object.h | 2 +- 8 files changed, 240 insertions(+), 287 deletions(-) create mode 100644 doc/faq.bb diff --git a/doc/faq.bb b/doc/faq.bb new file mode 100644 index 00000000..c4a37b52 --- /dev/null +++ b/doc/faq.bb @@ -0,0 +1,16 @@ + + + +== Why we use "DECLARE_FACTORY" Macro ? == + +For some reason!!! But everything might be clear: +:** In ewol we masively use std::shared_ptr (I have create my own but it is not "standard" (I like when we use genecic system)). +:** The main class : [class[ewol::Object]] herited from [i]std::enable_shared_from_this[/i] to permit to access at his own [i]std::shared_ptr[/i]. +:** Acces At his own [i]std::shared_ptr[/i] is not allowed in the class contructor/destructor. +:** Many time for meta-widget we need to propagate our [i]std::shared_ptr[/i] in child. + +Then for all these reasons, I have create a simple MACRO that create a static template funtion that create the object and just after +creation call the init(...) function to permit to create a complex widget or others with some writing convinience. + + + diff --git a/doc/tutorial/000_Build.bb b/doc/tutorial/000_Build.bb index e81c1b1a..1024dac0 100644 --- a/doc/tutorial/000_Build.bb +++ b/doc/tutorial/000_Build.bb @@ -48,7 +48,7 @@ Compile software in debug for the curent platform : You can specify the platform with: [code style=shell] - ./ewol/build/lutin.py -mdebug -tAndroid + ./ewol/build/lutin.py -tAndroid -mdebug [/code] It coud be usefull to disable the package generation in local debug : diff --git a/doc/tutorial/001_HelloWord.bb b/doc/tutorial/001_HelloWord.bb index 07f904ae..9a2cb3ef 100644 --- a/doc/tutorial/001_HelloWord.bb +++ b/doc/tutorial/001_HelloWord.bb @@ -110,16 +110,7 @@ For this point we will create a class that herited form the basic [class[ewol::w #endif [/code] -At this point you will ask an important question : [b]Why we use this really bad "DECLARE_FACTORY" Macro ?[/b] - -For some reason!!! But everything might be clear: -:** In ewol we masively use std::shared_ptr (I have create my own but it is not "standard" (I like when we use genecic system)). -:** The main class : [class[ewol::Object]] herited from [i]std::enable_shared_from_this[/i] to permit to access at his own [i]std::shared_ptr[/i]. -:** Acces At his own [i]std::shared_ptr[/i] is not allowed in the class contructor/destructor. -:** Many time for meta-widget we need to propagate our [i]std::shared_ptr[/i] in child. - -Then for all these reasons, I have create a simple MACRO that create a static template funtion that create the object and just after -creation call the init(...) function to permit to create a complex widget or others with some writing convinience. +See [tutorial[010_ObjectModel | Next: Object model]] to understand why this structure is so complex. [b]Windows.cpp[/b] [code style=c++] diff --git a/doc/tutorial/010_ObjectModel.bb b/doc/tutorial/010_ObjectModel.bb index e32997ee..e7410e47 100644 --- a/doc/tutorial/010_ObjectModel.bb +++ b/doc/tutorial/010_ObjectModel.bb @@ -6,17 +6,18 @@ __________________________________________________ :** Understand ewol basic [class[ewol::Object]] :** Use [class[ewol::Object]] correctly -== Basis of the Object == +== Basis of the ewol::Object == An object in Ewol is a simple class : [class[ewol::Object]] This object is the basis of all element in the ewol system. -This is designed to manage basis element of complexe structure: +This is designed to manage many common things: :** Unique ID :** Name -:** Configuration (decriptive naming of parameters) -:** Event generation and receving +:** Parameters +:** Signal generation :** Xml configuration -:** Delayed removing +:** Removing +:** Perodic calling [note] Please do not compare with the gObject basic class... @@ -25,130 +26,86 @@ Please do not compare with the gObject basic class... == Create an Object: == -In theory you can use a simple new on an object, but you need to remove the refcounting of this one by yoursef ... really awfull. +Creating an object is really simple: -It is really better to use the ewol::object::Shared<> declaration to auto manage it. (same as std::shared_ptr) [code style=c++] - ewol::object::Shared tmpObject = ewol::object::makeShared(new widget::Label()); - if (tmpObject == NULL) { - APPL_ERROR("An error occured"); - return; - } + std::shared_ptr tmpButon = ewol::Button::create(); + APPL_INFO("We just create a button widget with unique ID=" << tmpButon->getId() << " name='" << tmpButon->getName() << "'"); [/code] -The object register itself on the object manager, now it will have a specific Id and no name +Note that all object created are std::shared_ptr. -Force the set of the name : + +Set the name of the object: [code style=c++] - tmpObject->setName("my widget name"); - APPL_INFO("We just create an Object with ID=" << tmpObject->getId() << " name='" << tmpObject->getName() << "'"); + tmpButon->setName("my widget name"); + APPL_INFO("We just create an Object with ID=" << tmpButon->getId() << " name='" << tmpButon->getName() << "'"); [/code] == Remove an Object: == -This is important to note that many element can have a reference on the Object. - -Then we need to use the fuction: -[b]removeObject()[/b] to remove the Object, This will notify avery object in the system that this -specific object has been removed. - - -Then to remove an object call: +Simply use the function: [code style=c++] - tmpObject->removeObject(); + tmpButon->destroy(); [/code] -On every object we can have an herited function: [b]virtual void onObjectRemove(const ewol::object::Shared& _removeObject);[/b] +This function request his parrent to remove the std::shared_ptr it keep on it. +And when all std::shared_ptr is removed the object will be really removed. - -We need to implement this fuction to be notify an object is removed: -[code style=c++] - void namespeceName::ClassName::onObjectRemove(const ewol::object::Shared& _removeObject) { - // Never forget to call upper Object (otherwise many object will keep theire reference) - upperClass::onObjectRemove(_removeObject); - if (_removeObject == m_object) { - m_object.reset(); - markToRedraw(); // set only for graphical object ... - } - } -[/code] +At his point we can think an object is allive all the time someone keep a reference on it, then when you are not a parrent of the object, do not keep a std::shared_ptr but a std::weak_ptr. [note] -If you have well follow the idea, you will never declare an object in local, just use shared pointer on them. +If some Object is not removed when you close the application, the system inform you with displaying all object already alive. [/note] -[note] -For some case it could be interesting to see the [class[ewol::object::Owner]] class that provide an automatic auto remove of object. - -See [class[ewol::widget::Container]] for an example. -[/note] - - -=== Particularity === - -An object can remove itself, just use the function: -[code style=c++] - autoDestroy(); -[/code] - == Retrieve an Object: == In Ewol this is possible to get a object with his name. -This is really simple. -=== In an Object === - -Call a simple function define in the Object: +=== Find a global Object (ouside an Object) === [code style=c++] - #include - - ... - - ewol::object::Shared tmpObject = getObjectManager().get("name of the object"); - if (tmpObject == NULL) { - APPL_ERROR("The Object does not exist"); - } -[/code] - -=== Not in an Object === - -In this case, we need to get the context manager and after the object manager: - -[code style=c++] - #include #include - ... - - ewol::object::Shared tmpObject = ewol::getContext().getObjectManager().get("name of the object"); + std::shared_ptr tmpObject = ewol::getContext().getEObjectManager().getObjectNamed("obj Name"); if (tmpObject == NULL) { APPL_ERROR("The Object does not exist"); } [/code] -=== Casting your object === +=== Find a global Object (inside an Object) === + +[code style=c++] + std::shared_ptr tmpObject = getObjectNamed("obj Name"); + if (tmpObject == NULL) { + APPL_ERROR("The Object does not exist"); + } +[/code] + +=== Find a sub-object === + +[code style=c++] + std::shared_ptr tmpObject = getSubObjectNamed("obj Name"); + if (tmpObject == NULL) { + APPL_ERROR("The Object does not exist"); + } +[/code] + +=== retriving your object type === It could be really interesting to retrive your own instance: [code style=c++] - ewol::object::Shared tmpObject ...; + std::shared_ptr tmpObject ...; - ewol::object::Shared myObject = ewol::dynamic_pointer_cast(tmpObject); + std::shared_ptr myObject = std::dynamic_pointer_cast(tmpObject); [/code] == conclusion == -If you follow these rules, you will not have memory leek and no segmentation fault on the ewol system. - -[note] -To be sure that the name is unique, just add the current creator object Id in the name. - -See [class[ewol::widget::FileChooser]] class for an example. -[/note] - +TODO ... diff --git a/doc/tutorial/011_ObjectConfig.bb b/doc/tutorial/011_ObjectConfig.bb index 280c0a8d..44285a09 100644 --- a/doc/tutorial/011_ObjectConfig.bb +++ b/doc/tutorial/011_ObjectConfig.bb @@ -1,153 +1,101 @@ =?= Tutorial 3: Object Config =?= __________________________________________________ -[left][tutorial[010_ObjectModel | Previous: Object model]][/left] [right][tutorial[012_ObjectMessage | Next: Object message]][/right] +[left][tutorial[010_ObjectModel | Previous: Object model]][/left] [right][tutorial[012_ObjectMessage | Next: Object signals]][/right] === Objectif === :** Understand ewol::Object configuration parameter :** Create an configurable object -== Use of Configuration == +== Configuration using == -Configuration are parameters to set some property on an object, -this is a really generic use in many system, -this is the reason why we implement one. +All [class[ewol::Object]] have a configuration of parameters (the object name is a parameter), Then we need to set get and use xml to update parameters. +=== Set a Parameter === -This is a generic interface to set and get parameter, -when you did not really know it, -but it generate many convertion to string search and many other things... +[note] + Using getter and setter is really better, and faster. +[/note] -If you know the object just interact with it with his own accessors (faster ond conpilation check). +==== With a string configuration ==== - -=== Set config === - -When you have the pointer on the object: [code style=c++] - if (tmpObject->setConfig("name", "new name of object") == false) { - APPL_ERROR("Can not set object property"); + if (tmpObject->parameterSet("name", "new name of object") == false) { + APPL_ERROR("Can not set object parameter"); } [/code] -A second methode is to request the name with his direct config name: -[code style=c++] - // to be sure that the name exist: - if (tmpObject->setConfig(ewol::Object::configName, "new name of object") == false) { - APPL_ERROR("Can not set object property"); - } -[/code] -The only aventage here is to have an automatic update on the name of the parameter. +==== whith the object name ==== -It is possible to configure an object whitout knowing his name: [code style=c++] - // in an ewol::Object only ... - if (setConfigNamed("object name", "ewol::Object::configName, "new name of object") == false) { - APPL_ERROR("Can not set object property"); + if (parameterSetOnWidgetNamed("objectName", "value", "16.2") == false) { + APPL_ERROR("Can not set object parameter"); } [/code] +=== Get Parameter === -=== Get config === - -Direct get the configuration: [code style=c++] - std::string val = tmpObject->getConfig("name"); + std::string val = tmpObject->parameterGet("name"); APPL_INFO("Get Object property : name='" << val << "'"); [/code] -Get with his direct definition name: -[code style=c++] - std::string val = tmpObject->getConfig(ewol::Object::configName); - APPL_INFO("Get Object property : " << ewol::Object::configName << "'" << val << "'"); -[/code] - - == Implement configuration == -=== Declare config === - -In the header file: [code style=c++] #include namespace appl { class MyObj : public ewol::Object { - public: - // Config list of properties - static const char* const configValue; - public: + protected: //! @brief Constructor - MyObj(void); + MyObj(void) : + m_value(*this, "value", false, "Value of the parameter (descrition string)") { + // nothing to do.. + } + void init() { + ewol::Object::init(); + } + public: //! @brief Destructor - virtual ~MyObj(void); + virtual ~MyObj(void) { } + DECLARE_FACTORY(MyObj); private: - bool m_value; //!< Internal Object value + ewol::object::Param m_value; //!< Internal Object value public: //! @brief Setter void setValue(bool _val) { - m_value = _val; + m_value.set(_val); } //! @brief Getter - bool getValue(void) const { - return m_value; + bool getValue() const { + return m_value.get(); } public: // herited function: - bool onSetConfig(const ewol::object::Config& _conf); + void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer) { + if (_paramPointer == m_value) { + APPL_DEBUG("The internal value has change, new value is : '" << m_value.get() << "'"); + } + } } } [/code] -[note] -By convention declare config started with "configXXXXXX" -[/note] - -In the source file: +In the contructor we need to add: [code style=c++] -// Declare the configuration Name: -const char* const appl::MyObj::configValue = "value"; - -appl::MyObj::MyObj(void) { - // declare the configuration on this object: - registerConfig(configValue, "bool", NULL, "object configuration description"); - // Note : This API is not compleately define ... -} -appl::MyObj::~MyObj(void) { - // nothing to do ... -} +m_value(*this, "value", false, "Value of the parameter (descrition string)") [/code] -Now an extern Object can register configure these parameter, otherwise, they will be rejected!!! +:** [b]'*this':[/b] Reference the main class to call it chen value change. +:** [b]"value":[/b] Is the name of the parameter. +:** [b]false:[/b] The default value. +:** [b]"....."[/b] Description of the parameter (optionnal). -=== Get and Set config === +The function [b]onParameterChangeValue[/b] is called only the parameter change (no historic has been registered) -You can see in these implementation that we not compare the string but just the pointer. -The ewol::Object convert the string in the correct pointer to be faster in many case. +The last point is that the m_value.get() is an inline fuction then it take no more CPU cycle to access the value than normal variable. -==== Set configuration ==== +Some other parameter are availlable : +:** ewol::object::Param Basic parameter. +:** ewol::object::ParamRange For numeric parameter that range value are check befor setting new value. +:** ewol::object::ParamList For List of parameter values. -[code style=c++] -bool appl::MyObj::onSetConfig(const ewol::object::Config& _conf) { - APPL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config : " << _conf); - if (_conf.getConfig() == configValue) { - setValue(std::stob(_conf.getData())); - return true; - } - return false; -} -[/code] - -==== Get configuration ==== - -[code style=c++] -bool appl::MyObj::onGetConfig(const char* _config, std::string& _result) const { - if (_config == configValue) { - _result = std::to_string(getValue()); - return true; - } - return false; -} -[/code] - -== Conclusion == - -Now you can choice the methode you want in your application to implement your basic configuration feature. diff --git a/doc/tutorial/012_ObjectMessage.bb b/doc/tutorial/012_ObjectMessage.bb index 9f62f5d6..fdf4e0a3 100644 --- a/doc/tutorial/012_ObjectMessage.bb +++ b/doc/tutorial/012_ObjectMessage.bb @@ -1,4 +1,4 @@ -=?= Tutorial 4: Object Message =?= +=?= Tutorial 4: Object Signals =?= __________________________________________________ [left][tutorial[011_ObjectConfig | Previous: Object config]][/left] [right][tutorial[020_FileAccess | Next: File Access]][/right] @@ -8,123 +8,164 @@ __________________________________________________ == Message system == -The message system is a simple message sending between Object. -This is composed with a pointer (const char* const) that represent the mesage ID (pointer, then unique) -and a value (std::string) +Message system is based on generic std::funtion and std::bind methode: -The message are broadcast or multicast on object watcher. +It permit to an object to generate some [b]'signals'[/b]. -== Receive Message from other object == +All signal are synchronous -=== Register on message === -We will se an example on the widget : [class[ewol::widget::Button]] +== Receive signals from other object == -By default the messageID is the event generated, But to overwrite this message Id just create a new one: +[todo] +Link with the signal name +[/todo] + +Register on the 'up' and 'value' signal of a button: + +Button header : [code style=c++] -// on the global on the file or in private class member: -static const char* const g_backMessage = "local-event-button-pressed"; -static const char* const g_backMessageValue = "local-event-button-value"; -static const char* const g_backMessageDataOverWritte = "local-event-button-data"; + ... + public: + ewol::object::Signal signalDown; + ewol::object::Signal signalUp; + ... + ewol::object::Signal signalValue; + ... [/code] - -Register with his name: -[code style=c++] -registerOnEvent(this, "pressed", g_backMessage); -[/code] - -Register with his direct name: -[code style=c++] -registerOnEvent(this, ewol::widget::Button::eventValue, g_backMessageValue); -[/code] - -It is possible to overwrote the data send by the Object : -[code style=c++] -registerOnEvent(this, ewol::widget::Button::eventPressed, g_backMessageDataOverWritte, "Data we want to receive"); -[/code] - - -=== Receive message === - -To receive message from other widget, just implement this function: +=== simple signal connection: === [code style=c++] - -void appl::ObjectName::onReceiveMessage(const ewol::object::Message& _msg) { - APPL_INFO("Receive Event : " << _msg); - if (_msg.getMessage() == g_backMessage) { - // process here - return; - } - if (_msg.getMessage() == g_backMessageValue) { - APPL_INFO("message value: '" << _msg.getData() << "'"); - return; - } - if (_msg.getMessage() == g_backMessageDataOverWritte) { - APPL_INFO("Overwrite message data: '" << _msg.getData() << "'"); - return; +#include +#include +namespace appl { + class MyObj : public ewol::Object { + private: + std::shared_ptr m_button; + protected: + //! @brief Constructor + MyObj(void) { + // nothing to do.. + } + void init() { + ewol::Object::init(); + m_button = ewol::widget::Button::Create(); + if (m_button == nullptr) { + APPL_ERROR("Can not create button..."); + return; + } + // We connect signals here : + m_button->signalUp.bind(shared_from_this(), &appl::MyObj::onCallbackUp); + m_button->signalValue.bind(shared_from_this(), &appl::MyObj::onCallbackValue); + } + public: + //! @brief Destructor + virtual ~MyObj(void) { } + DECLARE_FACTORY(MyObj); + private: + void onCallbackUp() { + APPL_INFO("button pressed: UP); + } + void onCallbackValue(const bool& _value) { + APPL_INFO("button value: " << _value); + } } } [/code] -== Declare Extern Message == +=== Advenced signal connection: === -=== Declare Message === +Here we will see how to connect an advance function on a signal -In the header file: [code style=c++] #include +#include +namespace appl { + class MyObj : public ewol::Object { + private: + std::shared_ptr m_button; + protected: + //! @brief Constructor + MyObj(void) { + // nothing to do.. + } + void init() { + ewol::Object::init(); + m_button = ewol::widget::Button::Create(); + if (m_button == nullptr) { + APPL_ERROR("Can not create button..."); + return; + } + // We connect signals here : + m_button->signalUp.register(shared_from_this(), std::bind(&appl::MyObj::onCallbackUp, this, std::string("tmpVariableToSend"))); + m_button->signalValue.register(shared_from_this(), std::bind(&appl::MyObj::onCallbackValue, this)); + } + public: + //! @brief Destructor + virtual ~MyObj(void) { } + DECLARE_FACTORY(MyObj); + private: + void onCallbackUp(const std::string& _value) { + APPL_INFO("button pressed: UP inputMessage: " << _value); + } + void onCallbackValue() { + APPL_INFO("button value: " << _value); + } + } +} +[/code] + +=== Connect to a signal with a named widget === + +TODO: documentation : +:** subBind(_type, _name, _event, _obj, _func) +:** globalBind(_type, _name, _event, _obj, _func) +:** externSubBind(_object, _type, _name, _event, _obj, _func) + + +== Declare Signal == + +=== source === + +[code style=c++] +#include +#include namespace appl { class MyObj : public ewol::Object { public: - // Event list of properties - static const char* const eventValue; - public: + ewol::object::Signal signalEmpty; + ewol::object::Signal signalBoolean; + ewol::object::Signal signalString; + protected: //! @brief Constructor - MyObj(void); + MyObj(void) : + signalEmpty(*this, "empty"), + signalBoolean(*this, "boolean"), + signalString(*this, "string") { + // nothing to do.. + } + void init() { + ewol::Object::init(); + } + public: //! @brief Destructor - virtual ~MyObj(void); + virtual ~MyObj(void) { } + DECLARE_FACTORY(MyObj); + private: + void process() { + signalEmpty.emit(); + signalBoolean.emit(false); + signalString.emit("plop... plop"); + } } } [/code] -[note] -By convention declare events started with "eventXXXXXX" -[/note] - -In the source file: -[code style=c++] -// Declare the configuration Name: -const char* const appl::MyObj::eventValue = "value"; - -appl::MyObj::MyObj(void) { - // declare Event generated on this object: - addEventId(eventValue); -} -appl::MyObj::~MyObj(void) { - // nothing to do ... -} -[/code] -Now an extern Object can register event on this object, otherwise, they will be rejected!!! - - -=== Generate Message === - -Now we have register object message, We need to have generated it, This is really simple : - -[code style=c++] - // with no data: - generateEventId(eventValue); - // With a custom data: - generateEventId(eventValue, "My sring custom data ..."); -[/code] - - == Conclusion == -You will now able to generate event between objects... +You will now able to reise signals between objects... diff --git a/doc/tutorial/020_FileAccess.bb b/doc/tutorial/020_FileAccess.bb index c8becf9d..05bfc8f5 100644 --- a/doc/tutorial/020_FileAccess.bb +++ b/doc/tutorial/020_FileAccess.bb @@ -1,6 +1,6 @@ =?= Tutorial 5: File Access =?= __________________________________________________ -[left][tutorial[012_ObjectMessage | Previous: Object message]][/left] [right][tutorial[021_Resources | Next: Resources management]][/right] +[left][tutorial[012_ObjectMessage | Previous: Object signal]][/left] [right][tutorial[021_Resources | Next: Resources management]][/right] === Objectif === :** Understand why we wrap interface on file system diff --git a/sources/ewol/object/Object.h b/sources/ewol/object/Object.h index 78c05066..8f083cc4 100644 --- a/sources/ewol/object/Object.h +++ b/sources/ewol/object/Object.h @@ -138,7 +138,7 @@ namespace ewol { return m_uniqueId; }; public: - // TODO : Rework the position on this function ... This is a convignet function ... + // TODO : Rework the position on this function ... This is a convignent function ... bool parameterSetOnWidgetNamed(const std::string& _objectName, const std::string& _config, const std::string& _value); protected: ewol::object::Param m_name; //!< name of the element ... From 886f4ddc76784cf2be3df6c9ca58ecc247466ec0 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 3 Sep 2014 22:02:02 +0200 Subject: [PATCH 18/22] [DOC] update doc titles system --- doc/faq.bb | 20 ++++++++++++++++++++ doc/index.bb | 2 +- doc/tutorial/001_HelloWord.bb | 3 --- doc/tutorial/010_ObjectModel.bb | 3 --- doc/tutorial/011_ObjectConfig.bb | 4 ---- doc/tutorial/012_ObjectMessage.bb | 3 --- doc/tutorial/020_FileAccess.bb | 3 --- doc/tutorial/021_Resources.bb | 6 ++++++ doc/tutorial/030_ConplexeXmlGui.bb | 7 +++++++ doc/tutorial/050_CreateCustomWidget.bb | 1 - doc/tutorial/051_AddWidgetCustumInXML.bb | 3 --- monk | 2 +- 12 files changed, 35 insertions(+), 22 deletions(-) diff --git a/doc/faq.bb b/doc/faq.bb index c4a37b52..4a760745 100644 --- a/doc/faq.bb +++ b/doc/faq.bb @@ -1,3 +1,23 @@ +=?= FAQ =?= + +== What is ewol licence == + +This is really simple : APACHE-2 : + +Copyright ewol Edouard DUPIN + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + [[http://www.apache.org/licenses/LICENSE-2.0]] + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + diff --git a/doc/index.bb b/doc/index.bb index 843d58fd..fd1d8095 100644 --- a/doc/index.bb +++ b/doc/index.bb @@ -38,7 +38,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + [[http://www.apache.org/licenses/LICENSE-2.0]] Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/doc/tutorial/001_HelloWord.bb b/doc/tutorial/001_HelloWord.bb index 9a2cb3ef..e48d38b9 100644 --- a/doc/tutorial/001_HelloWord.bb +++ b/doc/tutorial/001_HelloWord.bb @@ -1,6 +1,3 @@ -=?= Tutorial 1: Hello Word =?= -__________________________________________________ -[left][tutorial[000_Build | Previous: Download & Build]][/left] [right][tutorial[010_ObjectModel | Next: Object model]][/right] === Objectif === :** Understand basis of ewol diff --git a/doc/tutorial/010_ObjectModel.bb b/doc/tutorial/010_ObjectModel.bb index e7410e47..b0725b76 100644 --- a/doc/tutorial/010_ObjectModel.bb +++ b/doc/tutorial/010_ObjectModel.bb @@ -1,6 +1,3 @@ -=?= Tutorial 2: Object Model =?= -__________________________________________________ -[left][tutorial[001_HelloWord | Previous: Hello Word]][/left] [right][tutorial[011_ObjectConfig | Next: Object config]][/right] === Objectif === :** Understand ewol basic [class[ewol::Object]] diff --git a/doc/tutorial/011_ObjectConfig.bb b/doc/tutorial/011_ObjectConfig.bb index 44285a09..ce4e8ae4 100644 --- a/doc/tutorial/011_ObjectConfig.bb +++ b/doc/tutorial/011_ObjectConfig.bb @@ -1,7 +1,3 @@ -=?= Tutorial 3: Object Config =?= -__________________________________________________ -[left][tutorial[010_ObjectModel | Previous: Object model]][/left] [right][tutorial[012_ObjectMessage | Next: Object signals]][/right] - === Objectif === :** Understand ewol::Object configuration parameter :** Create an configurable object diff --git a/doc/tutorial/012_ObjectMessage.bb b/doc/tutorial/012_ObjectMessage.bb index fdf4e0a3..bf405568 100644 --- a/doc/tutorial/012_ObjectMessage.bb +++ b/doc/tutorial/012_ObjectMessage.bb @@ -1,6 +1,3 @@ -=?= Tutorial 4: Object Signals =?= -__________________________________________________ -[left][tutorial[011_ObjectConfig | Previous: Object config]][/left] [right][tutorial[020_FileAccess | Next: File Access]][/right] === Objectif === :** Understand ewol::Object Messaging system diff --git a/doc/tutorial/020_FileAccess.bb b/doc/tutorial/020_FileAccess.bb index 05bfc8f5..6034022c 100644 --- a/doc/tutorial/020_FileAccess.bb +++ b/doc/tutorial/020_FileAccess.bb @@ -1,6 +1,3 @@ -=?= Tutorial 5: File Access =?= -__________________________________________________ -[left][tutorial[012_ObjectMessage | Previous: Object signal]][/left] [right][tutorial[021_Resources | Next: Resources management]][/right] === Objectif === :** Understand why we wrap interface on file system diff --git a/doc/tutorial/021_Resources.bb b/doc/tutorial/021_Resources.bb index e69de29b..db231f87 100644 --- a/doc/tutorial/021_Resources.bb +++ b/doc/tutorial/021_Resources.bb @@ -0,0 +1,6 @@ + +=== Objectif === +:** Understand What is a resource +:** Use resources + + diff --git a/doc/tutorial/030_ConplexeXmlGui.bb b/doc/tutorial/030_ConplexeXmlGui.bb index e69de29b..3df63f30 100644 --- a/doc/tutorial/030_ConplexeXmlGui.bb +++ b/doc/tutorial/030_ConplexeXmlGui.bb @@ -0,0 +1,7 @@ +=== Objectif === +:** What is a Widget +:** Simply create a comple Gui + + + + diff --git a/doc/tutorial/050_CreateCustomWidget.bb b/doc/tutorial/050_CreateCustomWidget.bb index 0477cd9e..c6dbd4eb 100644 --- a/doc/tutorial/050_CreateCustomWidget.bb +++ b/doc/tutorial/050_CreateCustomWidget.bb @@ -1,4 +1,3 @@ -=?=Create a custum widget=?= To create a custum widget, this is as simple as complex. The first things to do is to choice a methode to display you widget: diff --git a/doc/tutorial/051_AddWidgetCustumInXML.bb b/doc/tutorial/051_AddWidgetCustumInXML.bb index 33094160..12370b6f 100644 --- a/doc/tutorial/051_AddWidgetCustumInXML.bb +++ b/doc/tutorial/051_AddWidgetCustumInXML.bb @@ -1,7 +1,4 @@ - - - == Declare object in XML == Object can be declared in some XML, (like gui decription), then we need to declare the Object in the system recognition. diff --git a/monk b/monk index 9b9a5d32..6c7b028c 160000 --- a/monk +++ b/monk @@ -1 +1 @@ -Subproject commit 9b9a5d323787b13ab5b0f7de6d064e326e143426 +Subproject commit 6c7b028c50b5c5862ad1c2c1a7f3c0cce8b29aae From 6ad49453ba291b1002b9bf3aa4fe767d7917e81f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 5 Sep 2014 21:42:04 +0200 Subject: [PATCH 19/22] [DOC] add documentations --- doc/tutorial/021_Resources.bb | 109 ++++++++++++++++++++++++++++- doc/tutorial/030_ConplexeXmlGui.bb | 12 +++- monk | 2 +- sources/ewol/resource/Resource.h | 46 ++++++++++-- 4 files changed, 161 insertions(+), 8 deletions(-) diff --git a/doc/tutorial/021_Resources.bb b/doc/tutorial/021_Resources.bb index db231f87..d64c1806 100644 --- a/doc/tutorial/021_Resources.bb +++ b/doc/tutorial/021_Resources.bb @@ -1,6 +1,113 @@ -=== Objectif === +=== Objectifs === :** Understand What is a resource :** Use resources +=== What is a resource: === +A resource is an usique element that can be used by manny element like: +:** An image (special resolution) +:** A configuration file +:** An application manager (special case) +:** A sound file +:** ... + +A resource have an other objective, form some platform, the graphic interface can be stopped, then we need to reload texture in the graphic inteface... +Then the texture is an other graphic interface. + +=== Get a resource: === + +For this example we will load a configuration file: +[code style=c++] +#include +#include +namespace appl { + class MyObj : public ewol::Object { + private: + std::shared_ptr m_config; + int32_t m_configValId; + protected: + //! @brief Constructor + MyObj(void) : + m_configValId(-1) { + // nothing to do.. + } + void init() { + ewol::Object::init(); + m_config = ewol::resource::ConfigFile::create("DATA:ExapleConfig.json"); + m_configValId = m_config->request("exampleConfigName"); + } + public: + //! @brief Destructor + virtual ~MyObj(void) { } + DECLARE_FACTORY(MyObj); + public: + void process() { + double value = m_config->getNumber(m_configValId); + APPL_DEBUG("example value : " << value); + } + } +} +[/code] + + +=== Create a new resource: === + +A resource is a generic [class[ewol::Resource]] that hrited form a generic [class[ewol::Object]], simply change the FACTORY macro in : +:** DECLARE_RESOURCE_FACTORY(className) To declare a resource with no name (unique for every creation) +:** DECLARE_RESOURCE_NAMED_FACTORY(className) To create a resource that have a specific name. When created, we will find the previous resource with the specify name in the fanctory. +:** DECLARE_RESOURCE_SINGLE_FACTORY(className,uniqueName) This is to have a unique resource for all the application (name is specify in the Macro) + +we have now some specific interface to compleate (if needed): + +==== The Resource Level ==== + +The resources can be reloaded, then we need to reaload in the good order (level [0 .. 5]) + +The resources are loaded fron 0 to 5. + +Then for basic resource : + +[code style=c++] +#include +namespace appl { + class MyResource : public ewol::Resource { + protected: + //! @brief Constructor + MyResource() : + m_configValId(-1) { + m_resourceLevel = 4; + addObjectType("ewol::MyResource"); + } + void init(const std::& _name) { + ewol::Resource::init(_name); + } + public: + //! @brief Destructor + virtual ~MyResource(void) { } + DECLARE_RESOURCE_NAMED_FACTORY(MyResource); + } +} +[/code] + +Now we need to implement somme functions: + +To send data on the hardware (openGL): +[code style=c++] + void updateContext(); +[/code] + +To remove data from the the hardware (openGL): +[code style=c++] + void removeContext(); +[/code] + +When loose hardware (juste update internal state): +[code style=c++] + void removeContextToLate(); +[/code] + +When user request to reload all resources (can be usefull when using file type : THEME:GUI:xxx) +[code style=c++] + void reload(); +[/code] \ No newline at end of file diff --git a/doc/tutorial/030_ConplexeXmlGui.bb b/doc/tutorial/030_ConplexeXmlGui.bb index 3df63f30..bdbdc9e5 100644 --- a/doc/tutorial/030_ConplexeXmlGui.bb +++ b/doc/tutorial/030_ConplexeXmlGui.bb @@ -1,7 +1,15 @@ === Objectif === :** What is a Widget -:** Simply create a comple Gui - +:** Simply create a complex Gui + +=== What is a Widget === + + +=== Simple load of a widget: === + +see the basic tuttorial: [tutorial[001_Hello_Word | Hello world]] + +=== Create an interface with a XML form: === diff --git a/monk b/monk index 6c7b028c..71ded394 160000 --- a/monk +++ b/monk @@ -1 +1 @@ -Subproject commit 6c7b028c50b5c5862ad1c2c1a7f3c0cce8b29aae +Subproject commit 71ded394c57b4ed8954643eacde359c1a9bab52c diff --git a/sources/ewol/resource/Resource.h b/sources/ewol/resource/Resource.h index 66e367c7..a267374d 100644 --- a/sources/ewol/resource/Resource.h +++ b/sources/ewol/resource/Resource.h @@ -90,31 +90,69 @@ namespace ewol { namespace resource { class Manager; }; - // class resources is pure virtual + /** + * @brief A Resource is a generic interface to have an instance that have things that can be used by many people, ad have some hardware dependency. + * For example of resources : + * :** Shaders: openGL display interface. + * :** Texture: openGL imega interface. + * :** Font: Single file interface to store many glyphe ==> reduce the number of parallele loaded files. + * :** ConfigFile: simple widget configuration files + * :** ... + */ class Resource : public ewol::Object { protected: + /** + * @brief generic protected contructor (use factory to create this class) + */ Resource() : m_resourceLevel(MAX_RESOURCE_LEVEL-1) { addObjectType("ewol::Resource"); setStatusResource(true); }; + /** + * @brief Initialisation of the class and previous classes. + * @param[in] _name Name of the resource. + */ void init(); + //! @previous void init(const std::string& _name); public: - + //! geenric destructor virtual ~Resource() { }; protected: - uint8_t m_resourceLevel; //!< Level of the resource ==> for updata priority [0..5] 0 must be update first. + uint8_t m_resourceLevel; //!< Level of the resource ==> for update priority [0..5] 0 must be update first. public: - uint8_t getResourceLevel() { + /** + * @brief Get the current resource level; + * @return value in [0..5] + */ + uint8_t getResourceLevel() { return m_resourceLevel; }; + /** + * @brief Call when need to send data on the harware (openGL) + * @note This is done asynchronously with the create of the Resource. + */ virtual void updateContext(); + /** + * @brief The current OpenGl context is removing ==> remove yout own system data + */ virtual void removeContext(); + /** + * @brief The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android). + * Juste update your internal state + */ virtual void removeContextToLate(); + /** + * @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ... + */ virtual void reload(); + protected: + /** + * @brief Get the current resource Manager + */ static ewol::resource::Manager& getManager(); }; }; From f49bc5f50cf0bb50ac2c1a86b4b399eba5ab095f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 8 Sep 2014 23:09:34 +0200 Subject: [PATCH 20/22] [DEV] add trvis base file --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..28328570 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: cpp +before_script: git submodule init; git submodule update +script: ./build/lutin.py -cclang -mdebug -p ewol + From cc5e966ba4df1618dc70a0659919b6c2360d6800 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 9 Sep 2014 20:48:19 +0200 Subject: [PATCH 21/22] [DEV] Update travis file --- .travis.yml | 37 +++++++++++++++++++++++++++++++++++-- build | 2 +- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28328570..fcf86cb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,37 @@ +# language type: language: cpp -before_script: git submodule init; git submodule update -script: ./build/lutin.py -cclang -mdebug -p ewol +# compilator system: +compiler: +- clang +- gcc + +# build branch requested +branches: + only: + - master + - dev + +# previous actions: +before_script: + - git submodule init + - git submodule update + +install: + - if [ "$CXX" == "g++" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi + - if [ "$CXX" == "g++" ]; then sudo apt-get update -qq; fi + - if [ "$CXX" == "g++" ]; then sudo apt-get install -qq g++-4.8; fi + - if [ "$CXX" == "g++" ]; then sudo rm /usr/bin/gcc /usr/bin/g++; fi + - if [ "$CXX" == "g++" ]; then sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc; fi + - if [ "$CXX" == "g++" ]; then sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++; fi + + +# build sequence with Lutin : +script: + - if [ "$CXX" == "clang++" ]; then ./build/lutin.py -cclang -mdebug -p ewol; fi + - if [ "$CXX" == "g++" ]; then ./build/lutin.py -cgcc -mdebug -p ewol; fi + +#send e-mail on compilation result: +notifications: + email: + - yui.heero@gmail.com diff --git a/build b/build index 92c552fd..02a72568 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 92c552fd59009e30388d9762b1c9e618193c8d16 +Subproject commit 02a72568c9336e6a2ab0639af494c12443a75879 From 6c92b706423be6aec6161e4d4c6054ccac808796 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 9 Sep 2014 21:15:50 +0200 Subject: [PATCH 22/22] [DEV] update doc --- doc/tutorial/011_ObjectConfig.bb | 1 + doc/tutorial/021_Resources.bb | 3 ++- doc/tutorial/030_ConplexeXmlGui.bb | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/tutorial/011_ObjectConfig.bb b/doc/tutorial/011_ObjectConfig.bb index ce4e8ae4..0855fb92 100644 --- a/doc/tutorial/011_ObjectConfig.bb +++ b/doc/tutorial/011_ObjectConfig.bb @@ -1,3 +1,4 @@ + === Objectif === :** Understand ewol::Object configuration parameter :** Create an configurable object diff --git a/doc/tutorial/021_Resources.bb b/doc/tutorial/021_Resources.bb index d64c1806..a386656f 100644 --- a/doc/tutorial/021_Resources.bb +++ b/doc/tutorial/021_Resources.bb @@ -110,4 +110,5 @@ When loose hardware (juste update internal state): When user request to reload all resources (can be usefull when using file type : THEME:GUI:xxx) [code style=c++] void reload(); -[/code] \ No newline at end of file +[/code] + diff --git a/doc/tutorial/030_ConplexeXmlGui.bb b/doc/tutorial/030_ConplexeXmlGui.bb index bdbdc9e5..9aeafd40 100644 --- a/doc/tutorial/030_ConplexeXmlGui.bb +++ b/doc/tutorial/030_ConplexeXmlGui.bb @@ -1,15 +1,24 @@ + === Objectif === :** What is a Widget :** Simply create a complex Gui === What is a Widget === +A widget is a simple entity of a graphical Object. It herited of every [class[ewol::Object]] class with many graphical interface to draw a complex gui. + +We can consider some widget: +:** Windows: Main gui interface to display the unique "windows". +:** Simple widget: all widget that display somthing. +:** Meta widget: Widget composed with some wodget. === Simple load of a widget: === -see the basic tuttorial: [tutorial[001_Hello_Word | Hello world]] + === Create an interface with a XML form: === +=== Create in C++ the interface: === +