From 9e7d41f266d0261bdb72056e188adf179299ac18 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 7 Mar 2016 23:32:59 +0100 Subject: [PATCH] [DEV] start abstraction of using shared_ptr and weak_ptr to bench some other implementation thread safe ... --- ewol/context/Context.cpp | 18 ++++++------ ewol/context/Context.h | 10 +++---- ewol/context/InputManager.cpp | 22 +++++++-------- ewol/context/InputManager.h | 12 ++++---- ewol/event/Input.h | 8 +++--- ewol/memory.h | 28 +++++++++++++++++++ ewol/object/Manager.cpp | 16 +++++------ ewol/object/Manager.h | 14 +++++----- ewol/object/Object.cpp | 14 +++++----- ewol/object/Object.h | 48 +++++++++++++++++--------------- ewol/object/Worker.h | 3 ++ ewol/widget/Button.h | 3 ++ ewol/widget/ButtonColor.cpp | 4 +-- ewol/widget/ButtonColor.h | 5 +++- ewol/widget/CheckBox.h | 3 ++ ewol/widget/ColorBar.h | 3 ++ ewol/widget/Composer.cpp | 8 +++--- ewol/widget/Composer.h | 7 +++-- ewol/widget/Container.cpp | 18 ++++++------ ewol/widget/Container.h | 19 +++++++------ ewol/widget/Container2.cpp | 16 +++++------ ewol/widget/Container2.h | 27 ++++++++++-------- ewol/widget/ContainerN.cpp | 24 ++++++++-------- ewol/widget/ContainerN.h | 29 ++++++++++--------- ewol/widget/ContextMenu.cpp | 6 ++-- ewol/widget/ContextMenu.h | 5 +++- ewol/widget/Entry.h | 3 ++ ewol/widget/Gird.cpp | 10 +++---- ewol/widget/Gird.h | 15 ++++++---- ewol/widget/Image.h | 3 ++ ewol/widget/Joystick.h | 3 ++ ewol/widget/Label.h | 3 ++ ewol/widget/Layer.cpp | 4 +-- ewol/widget/Layer.h | 5 +++- ewol/widget/List.cpp | 2 +- ewol/widget/List.h | 3 ++ ewol/widget/ListFileSystem.h | 3 ++ ewol/widget/Manager.cpp | 22 +++++++-------- ewol/widget/Manager.h | 16 +++++------ ewol/widget/Menu.cpp | 30 ++++++++++---------- ewol/widget/Menu.h | 15 ++++++---- ewol/widget/PopUp.cpp | 4 +-- ewol/widget/PopUp.h | 5 +++- ewol/widget/ProgressBar.h | 3 ++ ewol/widget/Scroll.cpp | 4 +-- ewol/widget/Scroll.h | 5 +++- ewol/widget/Select.cpp | 8 +++--- ewol/widget/Select.h | 3 ++ ewol/widget/Sizer.cpp | 8 +++--- ewol/widget/Sizer.h | 11 +++++--- ewol/widget/Slider.h | 3 ++ ewol/widget/Spacer.h | 5 +++- ewol/widget/Spin.h | 3 ++ ewol/widget/WSlider.cpp | 10 +++---- ewol/widget/WSlider.h | 7 +++-- ewol/widget/Widget.cpp | 6 ++-- ewol/widget/Widget.h | 8 ++++-- ewol/widget/WidgetScrolled.h | 3 ++ ewol/widget/Windows.cpp | 14 +++++----- ewol/widget/Windows.h | 17 ++++++----- ewol/widget/meta/ColorChooser.h | 13 +++++---- ewol/widget/meta/FileChooser.h | 7 +++-- ewol/widget/meta/Parameter.cpp | 14 +++++----- ewol/widget/meta/Parameter.h | 11 +++++--- ewol/widget/meta/ParameterList.h | 6 ++-- ewol/widget/meta/SpinBase.cpp | 4 +-- ewol/widget/meta/SpinBase.h | 9 ++++-- ewol/widget/meta/StdPopUp.cpp | 8 +++--- ewol/widget/meta/StdPopUp.h | 11 +++++--- lutin_ewol.py | 3 +- 70 files changed, 430 insertions(+), 290 deletions(-) create mode 100644 ewol/memory.h diff --git a/ewol/context/Context.cpp b/ewol/context/Context.cpp index 9cd827f4..7c2cd060 100644 --- a/ewol/context/Context.cpp +++ b/ewol/context/Context.cpp @@ -52,13 +52,13 @@ void ewol::Context::setInitImage(const std::string& _fileName) { -void ewol::Context::inputEventTransfertWidget(std::shared_ptr _source, - std::shared_ptr _destination) { +void ewol::Context::inputEventTransfertWidget(ewol::WidgetShared _source, + ewol::WidgetShared _destination) { m_input.transfertEvent(_source, _destination); } -void ewol::Context::inputEventGrabPointer(std::shared_ptr _widget) { +void ewol::Context::inputEventGrabPointer(ewol::WidgetShared _widget) { m_input.grabPointer(_widget); } @@ -138,7 +138,7 @@ void ewol::Context::onResume(gale::Context& _context) { void ewol::Context::onRegenerateDisplay(gale::Context& _context) { //EWOL_INFO("REGENERATE_DISPLAY"); // check if the user selected a windows - std::shared_ptr window = m_windowsCurrent; + ewol::widget::WindowsShared window = m_windowsCurrent; if (window == nullptr) { EWOL_DEBUG("No windows ..."); return; @@ -156,7 +156,7 @@ void ewol::Context::onDraw(gale::Context& _context) { // clean internal data... m_objectManager.cleanInternalRemoved(); // real draw... - std::shared_ptr window = m_windowsCurrent; + ewol::widget::WindowsShared window = m_windowsCurrent; if (window == nullptr) { return; } @@ -249,7 +249,7 @@ void ewol::Context::onKeyboard(const gale::key::Special& _special, return; } // get the current focused Widget : - std::shared_ptr tmpWidget = m_widgetManager.focusGet(); + ewol::WidgetShared tmpWidget = m_widgetManager.focusGet(); if (tmpWidget == nullptr) { // no Widget ... return; @@ -301,7 +301,7 @@ void ewol::Context::processEvents() { */ void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) { - std::shared_ptr tmpWidget = m_widgetManager.focusGet(); + ewol::WidgetShared tmpWidget = m_widgetManager.focusGet(); if (tmpWidget != nullptr) { tmpWidget->onEventClipboard(_clipboardId); } @@ -434,7 +434,7 @@ void ewol::Context::resetIOEvent() { } -void ewol::Context::setWindows(const std::shared_ptr& _windows) { +void ewol::Context::setWindows(const ewol::widget::WindowsShared& _windows) { EWOL_INFO("set New windows"); // remove current focus : m_widgetManager.focusSetDefault(nullptr); @@ -447,7 +447,7 @@ void ewol::Context::setWindows(const std::shared_ptr& _wi forceRedrawAll(); } -std::shared_ptr ewol::Context::getWindows() { +ewol::widget::WindowsShared ewol::Context::getWindows() { return m_windowsCurrent; }; void ewol::Context::onResize(const ivec2& _size) { diff --git a/ewol/context/Context.h b/ewol/context/Context.h index bf7f009d..02268dd8 100644 --- a/ewol/context/Context.h +++ b/ewol/context/Context.h @@ -92,18 +92,18 @@ namespace ewol { */ virtual void stop(); private: - std::shared_ptr m_windowsCurrent; //!< curent displayed windows + ewol::widget::WindowsShared m_windowsCurrent; //!< curent displayed windows public: /** * @brief set the current windows to display : * @param _windows Windows that might be displayed */ - void setWindows(const std::shared_ptr& _windows); + void setWindows(const ewol::widget::WindowsShared& _windows); /** * @brief get the current windows that is displayed * @return the current handle on the windows (can be null) */ - std::shared_ptr getWindows(); + ewol::widget::WindowsShared getWindows(); /** * @brief Redraw all the windows @@ -116,12 +116,12 @@ namespace ewol { * @param source the widget where the event came from * @param destination the widget where the event mitgh be generated now */ - void inputEventTransfertWidget(std::shared_ptr _source, std::shared_ptr _destination); + void inputEventTransfertWidget(ewol::WidgetShared _source, ewol::WidgetShared _destination); /** * @brief This fonction lock the pointer properties to move in relative instead of absolute * @param[in] widget The widget that lock the pointer events */ - void inputEventGrabPointer(std::shared_ptr _widget); + void inputEventGrabPointer(ewol::WidgetShared _widget); /** * @brief This fonction un-lock the pointer properties to move in relative instead of absolute */ diff --git a/ewol/context/InputManager.cpp b/ewol/context/InputManager.cpp index 494f54eb..b3c2398d 100644 --- a/ewol/context/InputManager.cpp +++ b/ewol/context/InputManager.cpp @@ -42,7 +42,7 @@ void ewol::context::InputManager::setDpi(int32_t newDPI) { } bool ewol::context::InputManager::localEventInput(enum gale::key::type _type, - std::shared_ptr _destWidget, + ewol::WidgetShared _destWidget, int32_t _IdInput, enum gale::key::status _status, vec2 _pos) { @@ -93,14 +93,14 @@ void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable, _eventTable[_idInput].posEvent.setValue(0,0); } -void ewol::context::InputManager::transfertEvent(std::shared_ptr _source, std::shared_ptr _destination) { +void ewol::context::InputManager::transfertEvent(ewol::WidgetShared _source, ewol::WidgetShared _destination) { if( _source == nullptr || _destination == nullptr) { // prevent errors ... return; } for(int32_t iii=0; iii tmpWidget = m_eventInputSaved[iii].curentWidgetEvent.lock(); + ewol::WidgetShared tmpWidget = m_eventInputSaved[iii].curentWidgetEvent.lock(); if (tmpWidget == _source) { // inform the widget that it does not receive the event now EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventInputSaved[iii].posEvent); @@ -125,7 +125,7 @@ void ewol::context::InputManager::transfertEvent(std::shared_ptr _ } } -void ewol::context::InputManager::grabPointer(std::shared_ptr _widget) { +void ewol::context::InputManager::grabPointer(ewol::WidgetShared _widget) { if(_widget == nullptr) { return; } @@ -171,13 +171,13 @@ ewol::context::InputManager::~InputManager() { } int32_t ewol::context::InputManager::localGetDestinationId(enum gale::key::type _type, - std::shared_ptr _destWidget, + ewol::WidgetShared _destWidget, int32_t _realInputId) { if (_type == gale::key::type_finger) { int32_t lastMinimum = 0; for(int32_t iii=0; iii tmpWidget = m_eventInputSaved[iii].curentWidgetEvent.lock(); + ewol::WidgetShared tmpWidget = m_eventInputSaved[iii].curentWidgetEvent.lock(); if (tmpWidget == _destWidget) { if (iii != _realInputId) { lastMinimum = std::max(lastMinimum, m_eventInputSaved[iii].destinationInputId); @@ -213,12 +213,12 @@ void ewol::context::InputManager::motion(enum gale::key::type _type, // not manage input return; } - std::shared_ptr tmpWindows = m_context.getWindows(); + ewol::widget::WindowsShared tmpWindows = m_context.getWindows(); // special case for the mouse event 0 that represent the hover event of the system : if (_type == gale::key::type_mouse && _pointerID == 0) { // this event is all time on the good widget ... and manage the enter and leave ... // NOTE : the "layer widget" force us to get the widget at the specific position all the time : - std::shared_ptr tmpWidget; + ewol::WidgetShared tmpWidget; if (m_grabWidget.lock() != nullptr) { // grab all events ... tmpWidget = m_grabWidget.lock(); @@ -349,7 +349,7 @@ void ewol::context::InputManager::state(enum gale::key::type _type, } // get the curent time ... int64_t currentTime = ewol::getTime(); - std::shared_ptr tmpWindows = m_context.getWindows(); + ewol::widget::WindowsShared tmpWindows = m_context.getWindows(); if (true == _isDown) { EVENT_DEBUG("GUI : Input ID=" << _pointerID @@ -386,7 +386,7 @@ void ewol::context::InputManager::state(enum gale::key::type _type, eventTable[_pointerID].lastTimeEvent = currentTime; // set the element inside ... eventTable[_pointerID].isInside = true; - std::shared_ptr tmpWidget = m_grabWidget.lock(); + ewol::WidgetShared tmpWidget = m_grabWidget.lock(); // get destination widget : if(nullptr != tmpWindows) { if ( tmpWidget != nullptr @@ -429,7 +429,7 @@ void ewol::context::InputManager::state(enum gale::key::type _type, // revove the widget ... eventTable[_pointerID].curentWidgetEvent.reset(); } else { - std::shared_ptr tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); + ewol::WidgetShared tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); // generate UP Event EVENT_DEBUG("GUI : Input ID=" << _pointerID << " == >" << eventTable[_pointerID].destinationInputId diff --git a/ewol/context/InputManager.h b/ewol/context/InputManager.h index bdf89508..cead788a 100644 --- a/ewol/context/InputManager.h +++ b/ewol/context/InputManager.h @@ -21,7 +21,7 @@ namespace ewol { bool isUsed; int32_t destinationInputId; int64_t lastTimeEvent; - std::weak_ptr curentWidgetEvent; + ewol::WidgetWeak curentWidgetEvent; vec2 origin; vec2 size; vec2 downStart; @@ -44,7 +44,7 @@ namespace ewol { class InputManager{ // special grab pointer mode : private: - std::weak_ptr m_grabWidget; //!< widget that grab the curent pointer. + ewol::WidgetWeak m_grabWidget; //!< widget that grab the curent pointer. private: int32_t m_dpi; InputLimit m_eventInputLimit; @@ -64,7 +64,7 @@ namespace ewol { * @return true if event has been greped */ bool localEventInput(enum gale::key::type _type, - std::shared_ptr _destWidget, + ewol::WidgetShared _destWidget, int32_t _IdInput, enum gale::key::status _typeEvent, vec2 _pos); @@ -78,7 +78,7 @@ namespace ewol { * @return the ewol input id */ int32_t localGetDestinationId(enum gale::key::type _type, - std::shared_ptr _destWidget, + ewol::WidgetShared _destWidget, int32_t _realInputId); private: ewol::Context& m_context; @@ -100,12 +100,12 @@ namespace ewol { * @param _source the widget where the event came from * @param _destination the widget where the event mitgh be generated now */ - void transfertEvent(std::shared_ptr _source, std::shared_ptr _destination); + void transfertEvent(ewol::WidgetShared _source, ewol::WidgetShared _destination); /** * @brief This fonction lock the pointer properties to move in relative instead of absolute * @param[in] _widget The widget that lock the pointer events */ - void grabPointer(std::shared_ptr _widget); + void grabPointer(ewol::WidgetShared _widget); /** * @brief This fonction un-lock the pointer properties to move in relative instead of absolute */ diff --git a/ewol/event/Input.h b/ewol/event/Input.h index 3a3c8024..5ba47dfe 100644 --- a/ewol/event/Input.h +++ b/ewol/event/Input.h @@ -76,7 +76,7 @@ namespace ewol { enum gale::key::status _status, uint8_t _id, const vec2& _pos, - std::shared_ptr _dest, + ewol::WidgetShared _dest, int32_t _realIdEvent, gale::key::Special _specialKey) : m_event(_type, _status, _id, _pos, _specialKey), @@ -84,13 +84,13 @@ namespace ewol { m_realIdEvent(_realIdEvent) { }; ewol::event::Input m_event; private: - std::shared_ptr m_dest; + ewol::WidgetShared m_dest; int32_t m_realIdEvent; public: - void setDestWidget(std::shared_ptr _dest) { + void setDestWidget(ewol::WidgetShared _dest) { m_dest = _dest; }; - inline std::shared_ptr getDestWidget() const { + inline ewol::WidgetShared getDestWidget() const { return m_dest; }; void setRealId(int32_t _realIdEvent) { diff --git a/ewol/memory.h b/ewol/memory.h new file mode 100644 index 00000000..cf30e17f --- /dev/null +++ b/ewol/memory.h @@ -0,0 +1,28 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ +#pragma once + +#include +#include +#include +#include +#include + +namespace ewol { + template + using SharedPtr = std::shared_ptr; + template + using WeakPtr = std::weak_ptr; + template + using EnableSharedFromThis = std::enable_shared_from_this; + /* + template + using DynamicPointerCastZZ = std::dynamic_pointer_cast; + */ +} + diff --git a/ewol/object/Manager.cpp b/ewol/object/Manager.cpp index 2a98ce46..89cc86cf 100644 --- a/ewol/object/Manager.cpp +++ b/ewol/object/Manager.cpp @@ -42,7 +42,7 @@ ewol::object::Manager::~Manager() { void ewol::object::Manager::displayListObject() { EWOL_INFO("List loaded object : "); for (auto &it : m_eObjectList) { - std::shared_ptr element = it.lock(); + ewol::ObjectShared element = it.lock(); if (element != nullptr) { EWOL_INFO(" [" << element->getId() << "] ref=" << element.use_count()-1 << " name='" << element->propertyName.get() << "' type=" << element->getObjectType()); } @@ -56,7 +56,7 @@ void ewol::object::Manager::unInit() { m_workerList.clear(); } for (auto &it : m_eObjectList) { - std::shared_ptr element = it.lock(); + ewol::ObjectShared element = it.lock(); if (element != nullptr) { //it->removeObject(); } @@ -67,7 +67,7 @@ void ewol::object::Manager::unInit() { m_eObjectList.clear(); } -void ewol::object::Manager::add(const std::shared_ptr& _object) { +void ewol::object::Manager::add(const ewol::ObjectShared& _object) { if (_object == nullptr) { EWOL_ERROR("try to add an inexistant Object in manager"); } @@ -95,12 +95,12 @@ void ewol::object::Manager::cleanInternalRemoved() { } } -std::shared_ptr ewol::object::Manager::get(const std::string& _name) { +ewol::ObjectShared ewol::object::Manager::get(const std::string& _name) { if (_name == "") { return nullptr; } for (auto &it : m_eObjectList) { - std::shared_ptr element = it.lock(); + ewol::ObjectShared element = it.lock(); if ( element != nullptr && element->propertyName.get() == _name) { return element; @@ -110,16 +110,16 @@ std::shared_ptr ewol::object::Manager::get(const std::string& _nam } -std::shared_ptr ewol::object::Manager::getObjectNamed(const std::string& _name) { +ewol::ObjectShared ewol::object::Manager::getObjectNamed(const std::string& _name) { return ewol::object::Manager::get(_name); } -void ewol::object::Manager::workerAdd(const std::shared_ptr& _worker) { +void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) { m_workerList.push_back(_worker); } -void ewol::object::Manager::workerRemove(const std::shared_ptr& _worker) { +void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) { auto it(m_workerList.begin()); while (it != m_workerList.end()) { if (*it == _worker) { diff --git a/ewol/object/Manager.h b/ewol/object/Manager.h index 13b09d65..bb7bc460 100644 --- a/ewol/object/Manager.h +++ b/ewol/object/Manager.h @@ -17,7 +17,7 @@ namespace ewol { namespace object { class Manager : public esignal::Interface { private: - std::vector> m_eObjectList; // all widget allocated == > all time increment ... never removed ... + std::vector m_eObjectList; // all widget allocated == > all time increment ... never removed ... Context& m_context; public: Manager(Context& _context); @@ -43,7 +43,7 @@ namespace ewol { * @note The manager remove the object when the refecence Low down 1 (last keeper) * @param[in] _object Reference shared pointer on the object */ - void add(const std::shared_ptr& _object); + void add(const ewol::ObjectShared& _object); public: /** * @brief clean the weak pointer list (remove weak_ptr that is remoed) @@ -54,27 +54,27 @@ namespace ewol { * @param[in] _name Name of the Object * @return Pointer on the finded Object. */ - std::shared_ptr get(const std::string& _name); + ewol::ObjectShared get(const std::string& _name); public: /** * @brief retrive an object with his name * @param[in] _name Name of the object * @return the requested object or nullptr */ - std::shared_ptr getObjectNamed(const std::string& _name); + ewol::ObjectShared getObjectNamed(const std::string& _name); private: - std::vector> m_workerList; + std::vector m_workerList; public: /** * @brief Add a worker on the system list. * @param[in] _worker Worker to add in the list. */ - void workerAdd(const std::shared_ptr& _worker); + void workerAdd(const ewol::ObjectShared& _worker); /** * @brief Remove a worker on the system list. * @param[in] _worker Worker to add in the list. */ - void workerRemove(const std::shared_ptr& _worker); + void workerRemove(const ewol::ObjectShared& _worker); public: esignal::ISignal periodicCall; private: diff --git a/ewol/object/Object.cpp b/ewol/object/Object.cpp index 428d6c30..cb4629e5 100644 --- a/ewol/object/Object.cpp +++ b/ewol/object/Object.cpp @@ -22,7 +22,7 @@ void ewol::Object::autoDestroy() { return; } EWOL_VERBOSE("Destroy object : [" << getId() << "] type:" << getObjectType()); - std::shared_ptr parent = m_parent.lock(); + ewol::ObjectShared parent = m_parent.lock(); // TODO : set a signal to do this ... if (parent != nullptr) { parent->requestDestroyFromChild(shared_from_this()); @@ -31,12 +31,12 @@ void ewol::Object::autoDestroy() { m_destroy = true; } -void ewol::Object::requestDestroyFromChild(const std::shared_ptr& _child) { +void ewol::Object::requestDestroyFromChild(const ewol::ObjectShared& _child) { EWOL_INFO("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ..."); EWOL_CRITICAL("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)"); } -void ewol::Object::setParent(const std::shared_ptr& _newParent) { +void ewol::Object::setParent(const ewol::ObjectShared& _newParent) { // TODO : Implement change of parent ... m_parent = _newParent; } @@ -133,7 +133,7 @@ bool ewol::Object::storeXML(const std::shared_ptr& _node) const { } bool ewol::Object::propertySetOnWidgetNamed(const std::string& _objectName, const std::string& _config, const std::string& _value) { - std::shared_ptr object = getObjectManager().get(_objectName); + ewol::ObjectShared object = getObjectManager().get(_objectName); if (object == nullptr) { return false; } @@ -149,11 +149,11 @@ ewol::Context& ewol::Object::getContext() { return ewol::getContext(); } -std::shared_ptr ewol::Object::getObjectNamed(const std::string& _objectName) { +ewol::ObjectShared ewol::Object::getObjectNamed(const std::string& _objectName) { return getObjectManager().getObjectNamed(_objectName); } -std::shared_ptr ewol::Object::getSubObjectNamed(const std::string& _objectName) { +ewol::ObjectShared ewol::Object::getSubObjectNamed(const std::string& _objectName) { EWOL_VERBOSE("check if name : " << _objectName << " ?= " << propertyName.get()); if (_objectName == propertyName.get()) { return shared_from_this(); @@ -163,7 +163,7 @@ std::shared_ptr ewol::Object::getSubObjectNamed(const std::string& bool ewol::propertySetOnObjectNamed(const std::string& _objectName, const std::string& _config, const std::string& _value) { - std::shared_ptr object = ewol::getContext().getEObjectManager().get(_objectName); + ewol::ObjectShared object = ewol::getContext().getEObjectManager().get(_objectName); if (object == nullptr) { return false; } diff --git a/ewol/object/Object.h b/ewol/object/Object.h index 899cc087..05518192 100644 --- a/ewol/object/Object.h +++ b/ewol/object/Object.h @@ -15,27 +15,29 @@ #include #include +#include #include #include #include #include #include + namespace ewol { // some class need to define element befor other ... class Object; namespace object { class Manager; - }; + } class Context; -}; +} -template static void baseInit(const std::shared_ptr& _object) { +template static void baseInit(const ewol::SharedPtr& _object) { // end of recurtion return; } -template static void baseInit(const std::shared_ptr& _object, const std::string& _name, const TYPE_VAL& _val, TYPE&& ... _all ) { +template static void baseInit(const ewol::SharedPtr& _object, const std::string& _name, const TYPE_VAL& _val, TYPE&& ... _all ) { eproperty::Property* prop(nullptr); eproperty::PropertyType* propType(nullptr); if (_object == nullptr) { @@ -59,11 +61,11 @@ exit_on_error: } #define UN_DECLARE_FACTORY(className) \ - template static std::shared_ptr create(const TYPE& ... _all) = delete; + template static ewol::SharedPtr create(const TYPE& ... _all) = delete; #define DECLARE_FACTORY(className) \ - template static std::shared_ptr create(const TYPE& ... _all) { \ - std::shared_ptr object(new className()); \ + template static ewol::SharedPtr create(const TYPE& ... _all) { \ + ewol::SharedPtr object(new className()); \ if (object == nullptr) { \ EWOL_ERROR("Factory error"); \ return nullptr; \ @@ -79,9 +81,9 @@ exit_on_error: } #define DECLARE_SINGLE_FACTORY(className, uniqueName) \ - template static std::shared_ptr create(const TYPE& ... _all) { \ - std::shared_ptr object; \ - std::shared_ptr object2 = getObjectNamed(uniqueName); \ + template static ewol::SharedPtr create(const TYPE& ... _all) { \ + ewol::SharedPtr object; \ + ewol::SharedPtr object2 = getObjectNamed(uniqueName); \ if (object2 != nullptr) { \ object = std::dynamic_pointer_cast(object2); \ if (object == nullptr) { \ @@ -96,11 +98,13 @@ exit_on_error: } namespace ewol { + using ObjectShared = ewol::SharedPtr; + using ObjectWeak = ewol::WeakPtr; /** * @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, + class Object : public ewol::EnableSharedFromThis, public eproperty::Interface, public esignal::Interface { public: // Event list @@ -130,7 +134,7 @@ namespace ewol { return m_objectHasBeenInit; } protected: - std::weak_ptr m_parent; //!< Reference on the current parrent. + ewol::ObjectWeak m_parent; //!< Reference on the current parrent. bool m_destroy; //!< Flag to know if the object is requesting has destroy. protected: /** @@ -157,12 +161,12 @@ namespace ewol { * @brief Called by a whild that want to remove pointer of itself from the current list of his parrent * @param[in] _child Object of the child that want to remove itself */ - virtual void requestDestroyFromChild(const std::shared_ptr& _child); + virtual void requestDestroyFromChild(const ewol::ObjectShared& _child); /** * @brief Set the Object has new parrent. * @param[in] _newParent Object that requesting the parenting */ - virtual void setParent(const std::shared_ptr& _newParent); + virtual void setParent(const ewol::ObjectShared& _newParent); /** * @brief Remove the current parenting. */ @@ -264,20 +268,20 @@ namespace ewol { * @param[in] _name Name of the object * @return the requested object or nullptr */ - static std::shared_ptr getObjectNamed(const std::string& _objectName); + static ewol::ObjectShared getObjectNamed(const std::string& _objectName); /** * @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); + virtual ewol::ObjectShared 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, _shared_ptr, _func, ...) do {\ - std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \ + ewol::SharedPtr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \ if (myObject != nullptr) { \ myObject->_event.connect(_shared_ptr, _func, ##__VA_ARGS__); \ } else { \ @@ -285,13 +289,13 @@ namespace ewol { } \ } while (false) /* - template void subBind(std::shared_ptr _obj, void (TYPE::*_func)()) { - std::shared_ptr obj2 = std::dynamic_pointer_cast(_obj); + template void subBind(ewol::SharedPtr _obj, void (TYPE::*_func)()) { + ewol::SharedPtr obj2 = std::dynamic_pointer_cast(_obj); if (obj2 == nullptr) { EWOL_ERROR("Can not connect signal ..."); return; } - m_callerList.push_back(std::make_pair(std::weak_ptr(_obj), std::connect(_func, obj2.get()))); + m_callerList.push_back(std::make_pair(ewol::ObjectWeak(_obj), std::connect(_func, obj2.get()))); } */ }; @@ -302,7 +306,7 @@ namespace ewol { * @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)); \ + ewol::SharedPtr<_type> myObject = std::dynamic_pointer_cast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \ if (myObject != nullptr) { \ myObject->_event.connect(_obj, _func, ##__VA_ARGS__); \ } else { \ @@ -314,7 +318,7 @@ namespace ewol { * @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)); \ + ewol::SharedPtr<_type> myObject = std::dynamic_pointer_cast<_type>(_object->getObjectNamed(_name)); \ if (myObject != nullptr) { \ myObject->_event.connect(_obj, _func, ##__VA_ARGS__); \ } else { \ diff --git a/ewol/object/Worker.h b/ewol/object/Worker.h index 09300b3b..06de2519 100644 --- a/ewol/object/Worker.h +++ b/ewol/object/Worker.h @@ -12,6 +12,9 @@ namespace ewol { namespace object { + class Worker; + using WorkerShared = ewol::SharedPtr; + using WorkerWeak = ewol::WeakPtr; /** * @brief A worker might not been possesed by someone, then the system might keep a pointer on it. */ diff --git a/ewol/widget/Button.h b/ewol/widget/Button.h index 22e15362..9f430c25 100644 --- a/ewol/widget/Button.h +++ b/ewol/widget/Button.h @@ -20,6 +20,9 @@ namespace ewol { namespace widget { + class Button; + using ButtonShared = ewol::SharedPtr; + using ButtonWeak = ewol::WeakPtr; /** * @brief a composed button is a button with an inside composed with the specify XML element * ==> this permit to generate standard element simple diff --git a/ewol/widget/ButtonColor.cpp b/ewol/widget/ButtonColor.cpp index 48c97bd2..35b8d502 100644 --- a/ewol/widget/ButtonColor.cpp +++ b/ewol/widget/ButtonColor.cpp @@ -171,12 +171,12 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { tmpPos.setX( tmpPos.x() - m_minSize.x()/2.0); m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); - std::shared_ptr myColorChooser = widget::ColorChooser::create(); + ewol::widget::ColorChooserShared myColorChooser = widget::ColorChooser::create(); myColorChooser->propertyValue.set(propertyValue.get()); // set it in the pop-up-system : m_widgetContextMenu->setSubWidget(myColorChooser); myColorChooser->signalChange.connect(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange); - std::shared_ptr currentWindows = getWindows(); + ewol::widget::WindowsShared currentWindows = getWindows(); if (currentWindows == nullptr) { EWOL_ERROR("Can not get the curent Windows..."); m_widgetContextMenu.reset(); diff --git a/ewol/widget/ButtonColor.h b/ewol/widget/ButtonColor.h index a237727a..978e2f72 100644 --- a/ewol/widget/ButtonColor.h +++ b/ewol/widget/ButtonColor.h @@ -19,6 +19,9 @@ namespace ewol { namespace widget { + class ButtonColor; + using ButtonColorShared = ewol::SharedPtr; + using ButtonColorWeak = ewol::WeakPtr; class ButtonColor : public ewol::Widget { public: // signals esignal::ISignal> signalChange; @@ -28,7 +31,7 @@ namespace ewol { private: ewol::compositing::Shaper m_shaper; //!< Compositing theme. ewol::compositing::Text m_text; //!< Compositing Test display. - std::shared_ptr m_widgetContextMenu; //!< Specific context menu. + ewol::widget::ContextMenuShared m_widgetContextMenu; //!< Specific context menu. bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). bool m_buttonPressed; //!< Flag to know if the button is curently pressed. // hover area : diff --git a/ewol/widget/CheckBox.h b/ewol/widget/CheckBox.h index 01f4e0b4..d379575a 100644 --- a/ewol/widget/CheckBox.h +++ b/ewol/widget/CheckBox.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class CheckBox; + using CheckBoxShared = ewol::SharedPtr; + using CheckBoxWeak = ewol::WeakPtr; class CheckBox : public ewol::widget::Container2 { public: // Event list esignal::ISignal<> signalPressed; diff --git a/ewol/widget/ColorBar.h b/ewol/widget/ColorBar.h index 936cfb56..4e3830dd 100644 --- a/ewol/widget/ColorBar.h +++ b/ewol/widget/ColorBar.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class ColorBar; + using ColorBarShared = ewol::SharedPtr; + using ColorBarWeak = ewol::WeakPtr; class ColorBar : public ewol::Widget { public: // signals esignal::ISignal> signalChange; diff --git a/ewol/widget/Composer.cpp b/ewol/widget/Composer.cpp index cbdc55b0..2784ecba 100644 --- a/ewol/widget/Composer.cpp +++ b/ewol/widget/Composer.cpp @@ -21,7 +21,7 @@ ewol::widget::Composer::Composer() { // nothing to do ... } -static std::shared_ptr composerGenerate(bool _modeFile, const std::string& _data) { +static ewol::WidgetShared composerGenerate(bool _modeFile, const std::string& _data) { ewol::widget::Manager& widgetManager = ewol::getContext().getWidgetManager(); if (_data == "") { return nullptr; @@ -57,7 +57,7 @@ static std::shared_ptr composerGenerate(bool _modeFile, const std: return nullptr; } EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); - std::shared_ptr tmpWidget = widgetManager.create(widgetName); + ewol::WidgetShared tmpWidget = widgetManager.create(widgetName); if (tmpWidget == nullptr) { EWOL_ERROR ("(l "<getPos()<<") Can not create the widget : \"" << widgetName << "\""); return nullptr; @@ -68,11 +68,11 @@ static std::shared_ptr composerGenerate(bool _modeFile, const std: return tmpWidget; } -std::shared_ptr ewol::widget::composerGenerateFile(const std::string& _data) { +ewol::WidgetShared ewol::widget::composerGenerateFile(const std::string& _data) { return composerGenerate(true, _data); } -std::shared_ptr ewol::widget::composerGenerateString(const std::string& _data) { +ewol::WidgetShared ewol::widget::composerGenerateString(const std::string& _data) { return composerGenerate(false, _data); } diff --git a/ewol/widget/Composer.h b/ewol/widget/Composer.h index 7f740b0a..069fde8d 100644 --- a/ewol/widget/Composer.h +++ b/ewol/widget/Composer.h @@ -13,6 +13,9 @@ namespace ewol { namespace widget { + class Composer; + using ComposerShared = ewol::SharedPtr; + using ComposerWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree @@ -44,7 +47,7 @@ namespace ewol { */ bool loadFromString(const std::string& _composerXmlString); }; - std::shared_ptr composerGenerateString(const std::string& _data = ""); - std::shared_ptr composerGenerateFile(const std::string& _data = ""); + ewol::WidgetShared composerGenerateString(const std::string& _data = ""); + ewol::WidgetShared composerGenerateFile(const std::string& _data = ""); }; }; diff --git a/ewol/widget/Container.cpp b/ewol/widget/Container.cpp index 21f8d94c..945841a4 100644 --- a/ewol/widget/Container.cpp +++ b/ewol/widget/Container.cpp @@ -25,11 +25,11 @@ ewol::widget::Container::~Container() { subWidgetRemove(); } -std::shared_ptr ewol::widget::Container::getSubWidget() { +ewol::WidgetShared ewol::widget::Container::getSubWidget() { return m_subWidget; } -void ewol::widget::Container::setSubWidget(std::shared_ptr _newWidget) { +void ewol::widget::Container::setSubWidget(ewol::WidgetShared _newWidget) { if (_newWidget == nullptr) { return; } @@ -42,8 +42,8 @@ void ewol::widget::Container::setSubWidget(std::shared_ptr _newWid requestUpdateSize(); } -void ewol::widget::Container::subWidgetReplace(const std::shared_ptr& _oldWidget, - const std::shared_ptr& _newWidget) { +void ewol::widget::Container::subWidgetReplace(const ewol::WidgetShared& _oldWidget, + const ewol::WidgetShared& _newWidget) { if (m_subWidget != _oldWidget) { EWOL_WARNING("Request replace with a wrong old widget"); return; @@ -74,8 +74,8 @@ void ewol::widget::Container::subWidgetUnLink() { m_subWidget.reset(); } -std::shared_ptr ewol::widget::Container::getSubObjectNamed(const std::string& _objectName) { - std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_objectName); +ewol::ObjectShared ewol::widget::Container::getSubObjectNamed(const std::string& _objectName) { + ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_objectName); if (tmpObject != nullptr) { return tmpObject; } @@ -130,7 +130,7 @@ void ewol::widget::Container::onRegenerateDisplay() { } } -std::shared_ptr ewol::widget::Container::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::Container::getWidgetAtPos(const vec2& _pos) { if (propertyHide.get() == false) { if (m_subWidget != nullptr) { return m_subWidget->getWidgetAtPos(_pos); @@ -164,7 +164,7 @@ bool ewol::widget::Container::loadXML(const std::shared_ptr continue; } EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); - std::shared_ptr tmpWidget = getWidgetManager().create(widgetName); + ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName); if (tmpWidget == nullptr) { EWOL_ERROR ("(l "<getPos()<<") Can not create the widget : \"" << widgetName << "\""); continue; @@ -187,7 +187,7 @@ void ewol::widget::Container::setOffset(const vec2& _newVal) { } } -void ewol::widget::Container::requestDestroyFromChild(const std::shared_ptr& _child) { +void ewol::widget::Container::requestDestroyFromChild(const ewol::ObjectShared& _child) { if (m_subWidget != _child) { return; } diff --git a/ewol/widget/Container.h b/ewol/widget/Container.h index acc6b0c0..bafe75e4 100644 --- a/ewol/widget/Container.h +++ b/ewol/widget/Container.h @@ -13,13 +13,16 @@ namespace ewol { namespace widget { + class Container; + using ContainerShared = ewol::SharedPtr; + using ContainerWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the Cotainer widget is a widget that have an only one subWidget */ class Container : public ewol::Widget { protected: - std::shared_ptr m_subWidget; + ewol::WidgetShared m_subWidget; protected: /** * @brief Constructor @@ -35,19 +38,19 @@ namespace ewol { * @brief get the main node widget * @return the requested pointer on the node */ - std::shared_ptr getSubWidget(); + ewol::WidgetShared getSubWidget(); /** * @brief set the subWidget node widget. * @param[in] _newWidget The widget to add. */ - void setSubWidget(std::shared_ptr _newWidget); + void setSubWidget(ewol::WidgetShared _newWidget); /** * @brief Replace a old subwidget with a new one. * @param[in] _oldWidget The widget to replace. * @param[in] _newWidget The widget to set. */ - virtual void subWidgetReplace(const std::shared_ptr& _oldWidget, - const std::shared_ptr& _newWidget); + virtual void subWidgetReplace(const ewol::WidgetShared& _oldWidget, + const ewol::WidgetShared& _newWidget); /** * @brief remove the subWidget node (async). */ @@ -61,11 +64,11 @@ namespace ewol { virtual void onRegenerateDisplay(); virtual void onChangeSize(); virtual void calculateMinMaxSize(); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); + virtual ewol::ObjectShared getSubObjectNamed(const std::string& _objectName); virtual bool loadXML(const std::shared_ptr& _node); virtual void setOffset(const vec2& _newVal); - virtual void requestDestroyFromChild(const std::shared_ptr& _child); + virtual void requestDestroyFromChild(const ewol::ObjectShared& _child); }; }; }; diff --git a/ewol/widget/Container2.cpp b/ewol/widget/Container2.cpp index ff8f7b6c..776847fe 100644 --- a/ewol/widget/Container2.cpp +++ b/ewol/widget/Container2.cpp @@ -26,7 +26,7 @@ ewol::widget::Container2::~Container2() { subWidgetRemoveToggle(); } -void ewol::widget::Container2::setSubWidget(std::shared_ptr _newWidget, int32_t _idWidget) { +void ewol::widget::Container2::setSubWidget(ewol::WidgetShared _newWidget, int32_t _idWidget) { subWidgetRemove(_idWidget); m_subWidget[_idWidget] = _newWidget; if (m_subWidget[_idWidget] != nullptr) { @@ -37,8 +37,8 @@ void ewol::widget::Container2::setSubWidget(std::shared_ptr _newWi requestUpdateSize(); } -void ewol::widget::Container2::subWidgetReplace(const std::shared_ptr& _oldWidget, - const std::shared_ptr& _newWidget) { +void ewol::widget::Container2::subWidgetReplace(const ewol::WidgetShared& _oldWidget, + const ewol::WidgetShared& _newWidget) { bool haveChange = false; for (size_t iii=0; iii<2; ++iii) { if (m_subWidget[iii] != _oldWidget) { @@ -79,8 +79,8 @@ void ewol::widget::Container2::subWidgetUnLink(int32_t _idWidget) { m_subWidget[_idWidget].reset(); } -std::shared_ptr ewol::widget::Container2::getSubObjectNamed(const std::string& _widgetName) { - std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_widgetName); +ewol::ObjectShared ewol::widget::Container2::getSubObjectNamed(const std::string& _widgetName) { + ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_widgetName); if (tmpObject != nullptr) { return tmpObject; } @@ -165,7 +165,7 @@ void ewol::widget::Container2::onRegenerateDisplay() { } } /* -std::shared_ptr ewol::widget::Container2::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::Container2::getWidgetAtPos(const vec2& _pos) { if (isHide() == false) { if (m_subWidget[m_idWidgetDisplayed] != nullptr) { return m_subWidget[m_idWidgetDisplayed]->getWidgetAtPos(_pos); @@ -205,7 +205,7 @@ bool ewol::widget::Container2::loadXML(const std::shared_ptr tmpWidget = getWidgetManager().create(widgetName); + ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName); if (tmpWidget == nullptr) { EWOL_ERROR ("(l "<getPos()<<") Can not create the widget : \"" << widgetName << "\""); continue; @@ -232,7 +232,7 @@ void ewol::widget::Container2::setOffset(const vec2& _newVal) { } } -void ewol::widget::Container2::requestDestroyFromChild(const std::shared_ptr& _child) { +void ewol::widget::Container2::requestDestroyFromChild(const ewol::ObjectShared& _child) { if (m_subWidget[0] == _child) { if (m_subWidget[0] == nullptr) { return; diff --git a/ewol/widget/Container2.h b/ewol/widget/Container2.h index 6dbd014d..8302d8d1 100644 --- a/ewol/widget/Container2.h +++ b/ewol/widget/Container2.h @@ -14,13 +14,16 @@ namespace ewol { namespace widget { + class Container2; + using Container2Shared = ewol::SharedPtr; + using Container2Weak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the Cotainer widget is a widget that have an only one subWidget */ class Container2 : public ewol::Widget { protected: - std::shared_ptr m_subWidget[2]; //!< 2 subwidget possible + ewol::WidgetShared m_subWidget[2]; //!< 2 subwidget possible int32_t m_idWidgetDisplayed; //!< current widget displayed protected: /** @@ -40,20 +43,20 @@ namespace ewol { * @param[in] _subWidget Widget to add normal * @param[in] _idWidget Id of the widget to set */ - void setSubWidget(std::shared_ptr _subWidget, int32_t _idWidget); + void setSubWidget(ewol::WidgetShared _subWidget, int32_t _idWidget); public: /** * @brief Specify the current widget * @param[in] _subWidget Widget to add normal */ - void setSubWidget(std::shared_ptr _subWidget) { + void setSubWidget(ewol::WidgetShared _subWidget) { setSubWidget(_subWidget, 0); } /** * @brief Specify the current toggle widget * @param[in] _subWidget Widget to add Toggle */ - void setSubWidgetToggle(std::shared_ptr _subWidget) { + void setSubWidgetToggle(ewol::WidgetShared _subWidget) { setSubWidget(_subWidget, 1); } private: @@ -62,7 +65,7 @@ namespace ewol { * @param[in] _idWidget Id of the widget to set * @return The base widget */ - std::shared_ptr getSubWidget(int32_t _idWidget) const { + ewol::WidgetShared getSubWidget(int32_t _idWidget) const { return m_subWidget[_idWidget]; }; public: @@ -70,14 +73,14 @@ namespace ewol { * @brief get the current displayed composition * @return The base widget */ - std::shared_ptr getSubWidget() const { + ewol::WidgetShared getSubWidget() const { return getSubWidget(0); }; /** * @brief get the current displayed composition * @return The toggle widget */ - std::shared_ptr getSubWidgetToggle() const { + ewol::WidgetShared getSubWidgetToggle() const { return getSubWidget(1); }; private: @@ -152,8 +155,8 @@ namespace ewol { * @param[in] _oldWidget The widget to replace. * @param[in] _newWidget The widget to set. */ - virtual void subWidgetReplace(const std::shared_ptr& _oldWidget, - const std::shared_ptr& _newWidget); + virtual void subWidgetReplace(const ewol::WidgetShared& _oldWidget, + const ewol::WidgetShared& _newWidget); public: // Derived function virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void onRegenerateDisplay(); @@ -163,11 +166,11 @@ namespace ewol { virtual void calculateMinMaxSize() { calculateMinMaxSizePadded(); } - //virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); + //virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); + virtual ewol::ObjectShared getSubObjectNamed(const std::string& _objectName); virtual bool loadXML(const std::shared_ptr& _node); virtual void setOffset(const vec2& _newVal); - virtual void requestDestroyFromChild(const std::shared_ptr& _child); + virtual void requestDestroyFromChild(const ewol::ObjectShared& _child); }; }; }; diff --git a/ewol/widget/ContainerN.cpp b/ewol/widget/ContainerN.cpp index add0006b..4929a57d 100644 --- a/ewol/widget/ContainerN.cpp +++ b/ewol/widget/ContainerN.cpp @@ -51,8 +51,8 @@ void ewol::widget::ContainerN::onChangePropertyLockExpand() { requestUpdateSize(); } -void ewol::widget::ContainerN::subWidgetReplace(const std::shared_ptr& _oldWidget, - const std::shared_ptr& _newWidget) { +void ewol::widget::ContainerN::subWidgetReplace(const ewol::WidgetShared& _oldWidget, + const ewol::WidgetShared& _newWidget) { bool haveChange = false; for (auto &it : m_subWidget) { if (it != _oldWidget) { @@ -74,7 +74,7 @@ void ewol::widget::ContainerN::subWidgetReplace(const std::shared_ptr _newWidget) { +int32_t ewol::widget::ContainerN::subWidgetAdd(ewol::WidgetShared _newWidget) { if (_newWidget == nullptr) { EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add An empty Widget ... "); return -1; @@ -87,7 +87,7 @@ int32_t ewol::widget::ContainerN::subWidgetAdd(std::shared_ptr _ne return _newWidget->getId(); } -int32_t ewol::widget::ContainerN::subWidgetAddStart(std::shared_ptr _newWidget) { +int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::WidgetShared _newWidget) { if (nullptr == _newWidget) { EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add start An empty Widget ... "); return -1; @@ -101,7 +101,7 @@ int32_t ewol::widget::ContainerN::subWidgetAddStart(std::shared_ptrgetId(); } -void ewol::widget::ContainerN::subWidgetRemove(std::shared_ptr _newWidget) { +void ewol::widget::ContainerN::subWidgetRemove(ewol::WidgetShared _newWidget) { if (nullptr == _newWidget) { return; } @@ -121,7 +121,7 @@ void ewol::widget::ContainerN::subWidgetRemove(std::shared_ptr _ne } } -void ewol::widget::ContainerN::subWidgetUnLink(std::shared_ptr _newWidget) { +void ewol::widget::ContainerN::subWidgetUnLink(ewol::WidgetShared _newWidget) { if (nullptr == _newWidget) { return; } @@ -154,8 +154,8 @@ void ewol::widget::ContainerN::subWidgetRemoveAllDelayed() { subWidgetRemoveAll(); } -std::shared_ptr ewol::widget::ContainerN::getSubObjectNamed(const std::string& _objectName) { - std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_objectName); +ewol::ObjectShared ewol::widget::ContainerN::getSubObjectNamed(const std::string& _objectName) { + ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_objectName); if (tmpObject != nullptr) { return tmpObject; } @@ -229,7 +229,7 @@ void ewol::widget::ContainerN::onRegenerateDisplay() { } } -std::shared_ptr ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) { if (*propertyHide == true) { return nullptr; } @@ -241,7 +241,7 @@ std::shared_ptr ewol::widget::ContainerN::getWidgetAtPos(const vec if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - std::shared_ptr tmpWidget = it->getWidgetAtPos(_pos); + ewol::WidgetShared tmpWidget = it->getWidgetAtPos(_pos); if (tmpWidget != nullptr) { return tmpWidget; } @@ -285,7 +285,7 @@ bool ewol::widget::ContainerN::loadXML(const std::shared_ptr subWidget = getWidgetManager().create(widgetName); + ewol::WidgetShared subWidget = getWidgetManager().create(widgetName); if (subWidget == nullptr) { EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l "<getPos()<<") Can not create the widget : \"" << widgetName << "\""); continue; @@ -313,7 +313,7 @@ void ewol::widget::ContainerN::setOffset(const vec2& _newVal) { } } -void ewol::widget::ContainerN::requestDestroyFromChild(const std::shared_ptr& _child) { +void ewol::widget::ContainerN::requestDestroyFromChild(const ewol::ObjectShared& _child) { auto it = m_subWidget.begin(); while (it != m_subWidget.end()) { if (*it == _child) { diff --git a/ewol/widget/ContainerN.h b/ewol/widget/ContainerN.h index c00eb93a..aa0af262 100644 --- a/ewol/widget/ContainerN.h +++ b/ewol/widget/ContainerN.h @@ -14,6 +14,9 @@ namespace ewol { namespace widget { + class ContainerN; + using ContainerNShared = ewol::SharedPtr; + using ContainerNWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the Cotainer widget is a widget that have an only one subWidget @@ -22,7 +25,7 @@ namespace ewol { public: // properties: eproperty::Value propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget protected: - std::list> m_subWidget; + std::list m_subWidget; protected: /** * @brief Constructor @@ -51,20 +54,20 @@ namespace ewol { * @param[in] _oldWidget The widget to replace. * @param[in] _newWidget The widget to set. */ - virtual void subWidgetReplace(const std::shared_ptr& _oldWidget, - const std::shared_ptr& _newWidget); + virtual void subWidgetReplace(const ewol::WidgetShared& _oldWidget, + const ewol::WidgetShared& _newWidget); /** * @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @param[in] _newWidget the element pointer * @return the ID of the set element */ - virtual int32_t subWidgetAdd(std::shared_ptr _newWidget); + virtual int32_t subWidgetAdd(ewol::WidgetShared _newWidget); //! @previous - inline int32_t subWidgetAddBack(std::shared_ptr _newWidget) { + inline int32_t subWidgetAddBack(ewol::WidgetShared _newWidget) { return subWidgetAdd(_newWidget); }; //! @previous - inline int32_t subWidgetAddEnd(std::shared_ptr _newWidget) { + inline int32_t subWidgetAddEnd(ewol::WidgetShared _newWidget) { return subWidgetAdd(_newWidget); }; /** @@ -72,31 +75,31 @@ namespace ewol { * @param[in] _newWidget the element pointer * @return the ID of the set element */ - virtual int32_t subWidgetAddStart(std::shared_ptr _newWidget); + virtual int32_t subWidgetAddStart(ewol::WidgetShared _newWidget); //! @previous - inline int32_t subWidgetAddFront(std::shared_ptr _newWidget) { + inline int32_t subWidgetAddFront(ewol::WidgetShared _newWidget) { return subWidgetAddStart(_newWidget); }; /** * @brief remove definitly a widget from the system and this layer. * @param[in] _newWidget the element pointer. */ - virtual void subWidgetRemove(std::shared_ptr _newWidget); + virtual void subWidgetRemove(ewol::WidgetShared _newWidget); /** * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...) * @param[in] _newWidget the element pointer. */ - virtual void subWidgetUnLink(std::shared_ptr _newWidget); + virtual void subWidgetUnLink(ewol::WidgetShared _newWidget); public:// Derived function virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void onRegenerateDisplay(); virtual void onChangeSize(); virtual void calculateMinMaxSize(); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); + virtual ewol::ObjectShared getSubObjectNamed(const std::string& _objectName); virtual bool loadXML(const std::shared_ptr& _node); virtual void setOffset(const vec2& _newVal); - virtual void requestDestroyFromChild(const std::shared_ptr& _child); + virtual void requestDestroyFromChild(const ewol::ObjectShared& _child); protected: virtual void onChangePropertyLockExpand(); }; diff --git a/ewol/widget/ContextMenu.cpp b/ewol/widget/ContextMenu.cpp index d2024dd9..d5d1449d 100644 --- a/ewol/widget/ContextMenu.cpp +++ b/ewol/widget/ContextMenu.cpp @@ -225,8 +225,8 @@ bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { return false; } -std::shared_ptr ewol::widget::ContextMenu::getWidgetAtPos(const vec2& _pos) { - std::shared_ptr val = ewol::widget::Container::getWidgetAtPos(_pos); +ewol::WidgetShared ewol::widget::ContextMenu::getWidgetAtPos(const vec2& _pos) { + ewol::WidgetShared val = ewol::widget::Container::getWidgetAtPos(_pos); if (val != nullptr) { return val; } @@ -248,7 +248,7 @@ void ewol::widget::ContextMenu::onChangePropertyShape() { void ewol::widget::ContextMenu::setPositionMarkAuto(const vec2& _origin, const vec2& _size) { - std::shared_ptr windows = getWindows(); + ewol::widget::WindowsShared windows = getWindows(); vec2 globalSize = windows->getSize(); // TODO : Support left and right float upperSize = globalSize.y() - (_origin.y() + _size.y()); diff --git a/ewol/widget/ContextMenu.h b/ewol/widget/ContextMenu.h index fd776d69..ce0e5842 100644 --- a/ewol/widget/ContextMenu.h +++ b/ewol/widget/ContextMenu.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class ContextMenu; + using ContextMenuShared = ewol::SharedPtr; + using ContextMenuWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -58,7 +61,7 @@ namespace ewol { virtual bool onEventInput(const ewol::event::Input& _event); virtual void onChangeSize(); virtual void calculateMinMaxSize(); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); protected: virtual void onChangePropertyArrowPos(); virtual void onChangePropertyArrawBorder(); diff --git a/ewol/widget/Entry.h b/ewol/widget/Entry.h index fe8d5a1d..6252f921 100644 --- a/ewol/widget/Entry.h +++ b/ewol/widget/Entry.h @@ -20,6 +20,9 @@ namespace ewol { namespace widget { + class Entry; + using EntryShared = ewol::SharedPtr; + using EntryWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief Entry box display : diff --git a/ewol/widget/Gird.cpp b/ewol/widget/Gird.cpp index 7462d84b..11e4c3c5 100644 --- a/ewol/widget/Gird.cpp +++ b/ewol/widget/Gird.cpp @@ -191,7 +191,7 @@ void ewol::widget::Gird::subWidgetRemoveAll() { } -void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, std::shared_ptr _newWidget) { +void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::WidgetShared _newWidget) { if (_newWidget == nullptr) { return; } @@ -233,7 +233,7 @@ void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, std::share m_subWidget.push_back(prop); } -void ewol::widget::Gird::subWidgetRemove(std::shared_ptr _newWidget) { +void ewol::widget::Gird::subWidgetRemove(ewol::WidgetShared _newWidget) { for (size_t iii=0; iii _newWidget) { +void ewol::widget::Gird::subWidgetUnLink(ewol::WidgetShared _newWidget) { if (_newWidget == nullptr) { return; } @@ -307,7 +307,7 @@ void ewol::widget::Gird::onRegenerateDisplay() { } } -std::shared_ptr ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) { if (*propertyHide == true) { return nullptr; } @@ -320,7 +320,7 @@ std::shared_ptr ewol::widget::Gird::getWidgetAtPos(const vec2& _po vec2 tmpOrigin = it.widget->getOrigin(); if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - std::shared_ptr tmpWidget = it.widget->getWidgetAtPos(_pos); + ewol::WidgetShared tmpWidget = it.widget->getWidgetAtPos(_pos); if (tmpWidget != nullptr) { return tmpWidget; } diff --git a/ewol/widget/Gird.h b/ewol/widget/Gird.h index f42911a8..e0098f31 100644 --- a/ewol/widget/Gird.h +++ b/ewol/widget/Gird.h @@ -15,6 +15,9 @@ namespace ewol { namespace widget { + class Gird; + using GirdShared = ewol::SharedPtr; + using GirdWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -22,7 +25,7 @@ namespace ewol { private: class GirdProperties { public: - std::shared_ptr widget; + ewol::WidgetShared widget; int32_t row; int32_t col; }; @@ -30,7 +33,7 @@ namespace ewol { int32_t m_uniformSizeRow; std::vector m_sizeCol; //!< size of all colomn (if set (otherwise 0)) std::vector m_subWidget; //!< all sub widget are contained in this element - std::shared_ptr m_tmpWidget; //!< use when replace a widget ... + ewol::WidgetShared m_tmpWidget; //!< use when replace a widget ... bool m_gavityButtom; protected: /** @@ -95,12 +98,12 @@ namespace ewol { * @param[in] _rowId Id of the row [0..y]. * @param[in] _newWidget the element pointer */ - virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, std::shared_ptr _newWidget); + virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::WidgetShared _newWidget); /** * @brief remove definitly a widget from the system and this Gird. * @param[in] _newWidget the element pointer. */ - virtual void subWidgetRemove(std::shared_ptr _newWidget); + virtual void subWidgetRemove(ewol::WidgetShared _newWidget); /** * @brief remove definitly a widget from the system and this Gird. * @param[in] _colId Id of the colomn [0..x]. @@ -111,7 +114,7 @@ namespace ewol { * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). * @param[in] _newWidget the element pointer. */ - virtual void subWidgetUnLink(std::shared_ptr _newWidget); + virtual void subWidgetUnLink(ewol::WidgetShared _newWidget); /** * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). * @param[in] _colId Id of the colomn [0..x]. @@ -136,7 +139,7 @@ namespace ewol { public: // Derived function virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void onRegenerateDisplay(); - virtual std::shared_ptr getWidgetAtPos(const vec2& pos); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& pos); virtual void onChangeSize(); virtual void calculateMinMaxSize(); }; diff --git a/ewol/widget/Image.h b/ewol/widget/Image.h index 7d2eb6d4..e4d8e51c 100644 --- a/ewol/widget/Image.h +++ b/ewol/widget/Image.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class Image; + using ImageShared = ewol::SharedPtr; + using ImageWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/Joystick.h b/ewol/widget/Joystick.h index 3e37abc4..384b8d52 100644 --- a/ewol/widget/Joystick.h +++ b/ewol/widget/Joystick.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class Joystick; + using JoystickShared = ewol::SharedPtr; + using JoystickWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/Label.h b/ewol/widget/Label.h index 75f2a66f..f4141881 100644 --- a/ewol/widget/Label.h +++ b/ewol/widget/Label.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class Label; + using LabelShared = ewol::SharedPtr; + using LabelWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/Layer.cpp b/ewol/widget/Layer.cpp index 6208aa5d..3858ba54 100644 --- a/ewol/widget/Layer.cpp +++ b/ewol/widget/Layer.cpp @@ -21,7 +21,7 @@ ewol::widget::Layer::~Layer() { EWOL_DEBUG("[" << getId() << "] Layer : destroy"); } -std::shared_ptr ewol::widget::Layer::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::Layer::getWidgetAtPos(const vec2& _pos) { if (*propertyHide == true) { return nullptr; } @@ -34,7 +34,7 @@ std::shared_ptr ewol::widget::Layer::getWidgetAtPos(const vec2& _p vec2 tmpOrigin = it->getOrigin(); if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - std::shared_ptr tmpWidget = it->getWidgetAtPos(_pos); + ewol::WidgetShared tmpWidget = it->getWidgetAtPos(_pos); if (tmpWidget != nullptr) { return tmpWidget; } diff --git a/ewol/widget/Layer.h b/ewol/widget/Layer.h index 66c07015..791055d5 100644 --- a/ewol/widget/Layer.h +++ b/ewol/widget/Layer.h @@ -14,6 +14,9 @@ namespace ewol { namespace widget { + class Layer; + using LayerShared = ewol::SharedPtr; + using LayerWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -30,7 +33,7 @@ namespace ewol { */ virtual ~Layer(); public: // Derived function - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); }; }; }; diff --git a/ewol/widget/List.cpp b/ewol/widget/List.cpp index a62b040b..a5e43572 100644 --- a/ewol/widget/List.cpp +++ b/ewol/widget/List.cpp @@ -235,7 +235,7 @@ bool ewol::widget::List::onEventInput(const ewol::event::Input& _event) { bool isUsed = onItemEvent(_event.getId(), _event.getStatus(), 0, rawID, _event.getPos().x(), _event.getPos().y()); if (true == isUsed) { // TODO : this generate bugs ... I did not understand why .. - //std::shared_ptrManager::focusKeep(this); + //ewol::WidgetSharedManager::focusKeep(this); } return isUsed; } diff --git a/ewol/widget/List.h b/ewol/widget/List.h index 47c16a45..375cf715 100644 --- a/ewol/widget/List.h +++ b/ewol/widget/List.h @@ -15,6 +15,9 @@ namespace ewol { namespace widget { + class List; + using ListShared = ewol::SharedPtr; + using ListWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/ListFileSystem.h b/ewol/widget/ListFileSystem.h index 69cc2453..f61dc69f 100644 --- a/ewol/widget/ListFileSystem.h +++ b/ewol/widget/ListFileSystem.h @@ -14,6 +14,9 @@ namespace ewol { namespace widget { + class ListFileSystem; + using ListFileSystemShared = ewol::SharedPtr; + using ListFileSystemWeak = ewol::WeakPtr; /** * @brief Generic display folder class. This widget display the content of a single folder : */ diff --git a/ewol/widget/Manager.cpp b/ewol/widget/Manager.cpp index 4c2d6f24..a168f422 100644 --- a/ewol/widget/Manager.cpp +++ b/ewol/widget/Manager.cpp @@ -74,7 +74,7 @@ ewol::widget::Manager::~Manager() { * focus Area : * *************************************************************************/ -void ewol::widget::Manager::focusKeep(const std::shared_ptr& _newWidget) { +void ewol::widget::Manager::focusKeep(const ewol::WidgetShared& _newWidget) { if (_newWidget == nullptr) { // nothing to do ... return; @@ -102,14 +102,14 @@ void ewol::widget::Manager::focusKeep(const std::shared_ptr& _newW } } -void ewol::widget::Manager::focusSetDefault(const std::shared_ptr& _newWidget) { +void ewol::widget::Manager::focusSetDefault(const ewol::WidgetShared& _newWidget) { if( _newWidget != nullptr && _newWidget->propertyCanFocus.get() == false) { EWOL_VERBOSE("Widget can not have focus, id=" << _newWidget->getId() ); return; } - std::shared_ptr focusWidgetDefault = m_focusWidgetDefault.lock(); - std::shared_ptr focusWidgetCurrent = m_focusWidgetCurrent.lock(); + ewol::WidgetShared focusWidgetDefault = m_focusWidgetDefault.lock(); + ewol::WidgetShared focusWidgetCurrent = m_focusWidgetCurrent.lock(); if (focusWidgetDefault == focusWidgetCurrent) { if (focusWidgetCurrent != nullptr) { EWOL_DEBUG("Rm focus on WidgetID=" << focusWidgetCurrent->getId() ); @@ -125,8 +125,8 @@ void ewol::widget::Manager::focusSetDefault(const std::shared_ptr& } void ewol::widget::Manager::focusRelease() { - std::shared_ptr focusWidgetDefault = m_focusWidgetDefault.lock(); - std::shared_ptr focusWidgetCurrent = m_focusWidgetCurrent.lock(); + ewol::WidgetShared focusWidgetDefault = m_focusWidgetDefault.lock(); + ewol::WidgetShared focusWidgetCurrent = m_focusWidgetCurrent.lock(); if (focusWidgetDefault == focusWidgetCurrent) { // nothink to do ... return; @@ -144,13 +144,13 @@ void ewol::widget::Manager::focusRelease() { } -std::shared_ptr ewol::widget::Manager::focusGet() { +ewol::WidgetShared ewol::widget::Manager::focusGet() { return m_focusWidgetCurrent.lock(); } -void ewol::widget::Manager::focusRemoveIfRemove(const std::shared_ptr& _newWidget) { - std::shared_ptr focusWidgetDefault = m_focusWidgetDefault.lock(); - std::shared_ptr focusWidgetCurrent = m_focusWidgetCurrent.lock(); +void ewol::widget::Manager::focusRemoveIfRemove(const ewol::WidgetShared& _newWidget) { + ewol::WidgetShared focusWidgetDefault = m_focusWidgetDefault.lock(); + ewol::WidgetShared focusWidgetCurrent = m_focusWidgetCurrent.lock(); if (focusWidgetCurrent == _newWidget) { EWOL_WARNING("Release focus when remove widget"); focusRelease(); @@ -198,7 +198,7 @@ void ewol::widget::Manager::addWidgetCreator(const std::string& _name, m_creatorList.add(nameLower, _pointer); } -std::shared_ptr ewol::widget::Manager::create(const std::string& _name) { +ewol::WidgetShared ewol::widget::Manager::create(const std::string& _name) { std::string nameLower = etk::tolower(_name); if (m_creatorList.exist(nameLower) == true) { ewol::widget::Manager::creator_tf pointerFunction = m_creatorList[nameLower]; diff --git a/ewol/widget/Manager.h b/ewol/widget/Manager.h index 46f6670b..07486d32 100644 --- a/ewol/widget/Manager.h +++ b/ewol/widget/Manager.h @@ -17,11 +17,11 @@ namespace ewol { namespace widget { class Manager { public: - typedef std::shared_ptr (*creator_tf)(); + using creator_tf = std::function; private: // For the focus Management - std::weak_ptr m_focusWidgetDefault; - std::weak_ptr m_focusWidgetCurrent; + ewol::WidgetWeak m_focusWidgetDefault; + ewol::WidgetWeak m_focusWidgetCurrent; bool m_havePeriodic; bool m_haveRedraw; etk::Hash m_creatorList; @@ -29,11 +29,11 @@ namespace ewol { Manager(); virtual ~Manager(); - void focusKeep(const std::shared_ptr& _newWidget); // set the focus at the specific widget - void focusSetDefault(const std::shared_ptr& _newWidget); // select the default focus getter + void focusKeep(const ewol::WidgetShared& _newWidget); // set the focus at the specific widget + void focusSetDefault(const ewol::WidgetShared& _newWidget); // select the default focus getter void focusRelease(); // release focus from the current widget to the default - std::shared_ptr focusGet(); - void focusRemoveIfRemove(const std::shared_ptr& _newWidget); + ewol::WidgetShared focusGet(); + void focusRemoveIfRemove(const ewol::WidgetShared& _newWidget); private: std::function m_funcRedrawNeeded; public: @@ -43,7 +43,7 @@ namespace ewol { // element that generate the list of elements void addWidgetCreator(const std::string& _name, creator_tf _pointer); - std::shared_ptr create(const std::string& _name); + ewol::WidgetShared create(const std::string& _name); bool exist(const std::string& _name); std::string list(); private: diff --git a/ewol/widget/Menu.cpp b/ewol/widget/Menu.cpp index 5b69ea66..4e513838 100644 --- a/ewol/widget/Menu.cpp +++ b/ewol/widget/Menu.cpp @@ -33,16 +33,16 @@ void ewol::widget::Menu::subWidgetRemoveAll() { ewol::widget::Sizer::subWidgetRemoveAll(); } -int32_t ewol::widget::Menu::subWidgetAdd(std::shared_ptr _newWidget) { +int32_t ewol::widget::Menu::subWidgetAdd(ewol::WidgetShared _newWidget) { EWOL_ERROR("Not availlable"); return -1; } -void ewol::widget::Menu::subWidgetRemove(std::shared_ptr _newWidget) { +void ewol::widget::Menu::subWidgetRemove(ewol::WidgetShared _newWidget) { EWOL_ERROR("Not availlable"); } -void ewol::widget::Menu::subWidgetUnLink(std::shared_ptr _newWidget) { +void ewol::widget::Menu::subWidgetUnLink(ewol::WidgetShared _newWidget) { EWOL_ERROR("Not availlable"); } @@ -83,7 +83,7 @@ int32_t ewol::widget::Menu::add(int32_t _parent, tmpObject.m_image = _image; tmpObject.m_message = _message; if (-1 == tmpObject.m_parentId) { - std::shared_ptr myButton = ewol::widget::Button::create(); + ewol::widget::ButtonShared myButton = ewol::widget::Button::create(); if (myButton == nullptr) { EWOL_ERROR("Allocation button error"); return tmpObject.m_localId; @@ -104,7 +104,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->signalPressed.connect(shared_from_this(), &ewol::widget::Menu::onButtonPressed, std::weak_ptr(myButton)); + myButton->signalPressed.connect(shared_from_this(), &ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); tmpObject.m_widgetPointer = myButton; } m_listElement.push_back(tmpObject); @@ -121,8 +121,8 @@ int32_t ewol::widget::Menu::addSpacer() { return -1; } -void ewol::widget::Menu::onButtonPressed(std::weak_ptr _button) { - std::shared_ptr caller = _button.lock(); +void ewol::widget::Menu::onButtonPressed(ewol::widget::ButtonWeak _button) { + ewol::widget::ButtonShared caller = _button.lock(); if (caller == nullptr) { return; } @@ -135,7 +135,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu EWOL_DEBUG("Menu == > generate Event"); // Send a multicast event ... signalSelect.emit(it.m_message); - std::shared_ptr tmpContext = m_widgetContextMenu.lock(); + ewol::widget::ContextMenuShared tmpContext = m_widgetContextMenu.lock(); if (tmpContext != nullptr) { EWOL_DEBUG("Mark the menu to remove ..."); tmpContext->destroy(); @@ -155,7 +155,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu return; } // create a context menu: - std::shared_ptr tmpContext = ewol::widget::ContextMenu::create(); + ewol::widget::ContextMenuShared tmpContext = ewol::widget::ContextMenu::create(); m_widgetContextMenu = tmpContext; if (tmpContext == nullptr) { EWOL_ERROR("Allocation Error"); @@ -163,7 +163,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu } // get the button widget: vec2 newPosition; - std::shared_ptr eventFromWidget = std::dynamic_pointer_cast(caller); + ewol::WidgetShared eventFromWidget = std::dynamic_pointer_cast(caller); if (eventFromWidget != nullptr) { vec2 tmpOri = eventFromWidget->getOrigin(); vec2 tmpSize = eventFromWidget->getSize(); @@ -172,8 +172,8 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu tmpOri.y() ); } tmpContext->setPositionMark(ewol::widget::ContextMenu::markTop, newPosition); - std::shared_ptr mySizer; - std::shared_ptr myButton; + ewol::widget::SizerShared mySizer; + ewol::widget::ButtonShared myButton; mySizer = ewol::widget::Sizer::create("mode", widget::Sizer::modeVert); if (mySizer != nullptr) { mySizer->propertyLockExpand.set(vec2(true,true)); @@ -202,7 +202,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu myButton->propertyExpand.set(bvec2(true,true)); myButton->propertyFill.set(bvec2(true,true)); // set callback - myButton->signalPressed.connect(shared_from_this(), &ewol::widget::Menu::onButtonPressed, std::weak_ptr(myButton)); + myButton->signalPressed.connect(shared_from_this(), &ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); // add it in the widget list mySizer->subWidgetAdd(myButton); if (it2->m_image.size() != 0) { @@ -226,7 +226,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu " \n") ); } else { - std::shared_ptr tmpLabel = widget::Label::create(); + ewol::widget::LabelShared tmpLabel = widget::Label::create(); if (tmpLabel != nullptr) { tmpLabel->propertyValue.set(std::string("") + it2->m_label + "\n"); tmpLabel->propertyExpand.set(bvec2(true,false)); @@ -238,7 +238,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu it2->m_widgetPointer = myButton; } } - std::shared_ptr currentWindows = getWindows(); + ewol::widget::WindowsShared currentWindows = getWindows(); if (currentWindows == nullptr) { EWOL_ERROR("Can not get the curent Windows..."); } else { diff --git a/ewol/widget/Menu.h b/ewol/widget/Menu.h index 12a14182..46c5b7f6 100644 --- a/ewol/widget/Menu.h +++ b/ewol/widget/Menu.h @@ -22,11 +22,14 @@ namespace ewol { MenuElement() { }; int32_t m_localId; int32_t m_parentId; - std::weak_ptr m_widgetPointer; + ewol::WidgetWeak m_widgetPointer; std::string m_label; std::string m_image; std::string m_message; }; + class Menu; + using MenuShared = ewol::SharedPtr; + using MenuWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -40,13 +43,13 @@ namespace ewol { virtual ~Menu(); private: virtual void subWidgetRemoveAll(); - virtual int32_t subWidgetAdd(std::shared_ptr _newWidget); - virtual void subWidgetRemove(std::shared_ptr _newWidget); - virtual void subWidgetUnLink(std::shared_ptr _newWidget); + virtual int32_t subWidgetAdd(ewol::WidgetShared _newWidget); + virtual void subWidgetRemove(ewol::WidgetShared _newWidget); + virtual void subWidgetUnLink(ewol::WidgetShared _newWidget); private: std::vector m_listElement; int32_t m_staticId; // unique ID for every element of the menu ... - std::weak_ptr m_widgetContextMenu; + ewol::widget::ContextMenuWeak m_widgetContextMenu; int32_t get(const std::string& _label); public: void clear(); @@ -55,7 +58,7 @@ namespace ewol { int32_t addSpacer(); void remove(int32_t _id); private: - void onButtonPressed(std::weak_ptr _button); + void onButtonPressed(ewol::widget::ButtonWeak _button); }; }; }; diff --git a/ewol/widget/PopUp.cpp b/ewol/widget/PopUp.cpp index d58b1b50..93cea662 100644 --- a/ewol/widget/PopUp.cpp +++ b/ewol/widget/PopUp.cpp @@ -130,8 +130,8 @@ void ewol::widget::PopUp::onRegenerateDisplay() { } } -std::shared_ptr ewol::widget::PopUp::getWidgetAtPos(const vec2& _pos) { - std::shared_ptr val = ewol::widget::Container::getWidgetAtPos(_pos); +ewol::WidgetShared ewol::widget::PopUp::getWidgetAtPos(const vec2& _pos) { + ewol::WidgetShared val = ewol::widget::Container::getWidgetAtPos(_pos); if (val != nullptr) { return val; } diff --git a/ewol/widget/PopUp.h b/ewol/widget/PopUp.h index 73b9011b..6e2c3695 100644 --- a/ewol/widget/PopUp.h +++ b/ewol/widget/PopUp.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class PopUp; + using PopUpShared = ewol::SharedPtr; + using PopUpWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -48,7 +51,7 @@ namespace ewol { virtual void onRegenerateDisplay(); virtual void onChangeSize(); virtual bool onEventInput(const ewol::event::Input& _event); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); protected: virtual bool onStartAnnimation(enum ewol::Widget::annimationMode _mode); virtual void onStopAnnimation(); diff --git a/ewol/widget/ProgressBar.h b/ewol/widget/ProgressBar.h index 0ddd7655..fb2e85f1 100644 --- a/ewol/widget/ProgressBar.h +++ b/ewol/widget/ProgressBar.h @@ -16,6 +16,9 @@ namespace ewol { namespace widget { + class ProgressBar; + using ProgressBarShared = ewol::SharedPtr; + using ProgressBarWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/Scroll.cpp b/ewol/widget/Scroll.cpp index d7176ff3..cc95eb70 100644 --- a/ewol/widget/Scroll.cpp +++ b/ewol/widget/Scroll.cpp @@ -349,8 +349,8 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return false; } -std::shared_ptr ewol::widget::Scroll::getWidgetAtPos(const vec2& _pos) { - std::shared_ptr tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos); +ewol::WidgetShared ewol::widget::Scroll::getWidgetAtPos(const vec2& _pos) { + ewol::WidgetShared tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos); if (tmpWidget != nullptr) { return tmpWidget; } diff --git a/ewol/widget/Scroll.h b/ewol/widget/Scroll.h index 44c6805e..4d33058e 100644 --- a/ewol/widget/Scroll.h +++ b/ewol/widget/Scroll.h @@ -16,6 +16,9 @@ namespace ewol { namespace widget { + class Scroll; + using ScrollShared = ewol::SharedPtr; + using ScrollWeak = ewol::WeakPtr; class Scroll : public ewol::widget::Container { public: // properties eproperty::Range propertyLimit; //!< Set the limitation of the ratio in the sreen @@ -50,7 +53,7 @@ namespace ewol { virtual void onRegenerateDisplay(); virtual bool onEventInput(const ewol::event::Input& _event); virtual void systemDraw(const ewol::DrawProperty& _displayProp); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); protected: // Derived function virtual void onDraw(); protected: diff --git a/ewol/widget/Select.cpp b/ewol/widget/Select.cpp index dec4a5af..721a366d 100644 --- a/ewol/widget/Select.cpp +++ b/ewol/widget/Select.cpp @@ -164,14 +164,14 @@ void ewol::widget::Select::onCallbackLabelPressed(int32_t _value) { void ewol::widget::Select::onCallbackOpenMenu() { // create a context menu: - std::shared_ptr tmpContext = ewol::widget::ContextMenu::create(); + ewol::widget::ContextMenuShared tmpContext = ewol::widget::ContextMenu::create(); if (tmpContext == nullptr) { EWOL_ERROR("Allocation Error"); return; } // auto-select mark position: tmpContext->setPositionMarkAuto(m_origin, m_size); - std::shared_ptr mySizer; + ewol::widget::SizerShared mySizer; mySizer = ewol::widget::Sizer::create(); if (mySizer == nullptr) { EWOL_ERROR("Allocation Error or sizer"); @@ -183,7 +183,7 @@ void ewol::widget::Select::onCallbackOpenMenu() { // set it in the pop-up-system: tmpContext->setSubWidget(mySizer); for (auto &it : m_listElement) { - std::shared_ptr myLabel = ewol::widget::Label::create(); + ewol::widget::LabelShared myLabel = ewol::widget::Label::create(); if (myLabel == nullptr) { EWOL_ERROR("Allocation Error"); continue; @@ -201,7 +201,7 @@ void ewol::widget::Select::onCallbackOpenMenu() { // add it in the widget list mySizer->subWidgetAddStart(myLabel); } - std::shared_ptr currentWindows = getWindows(); + ewol::widget::WindowsShared currentWindows = getWindows(); if (currentWindows == nullptr) { EWOL_ERROR("Can not get the curent Windows..."); } else { diff --git a/ewol/widget/Select.h b/ewol/widget/Select.h index a0e9df09..5a65a33a 100644 --- a/ewol/widget/Select.h +++ b/ewol/widget/Select.h @@ -13,6 +13,9 @@ namespace ewol { namespace widget { + class Select; + using SelectShared = ewol::SharedPtr; + using SelectWeak = ewol::WeakPtr; /** * @brief a composed Select is a Select with an inside composed with the specify XML element * ==> this permit to generate standard element simple diff --git a/ewol/widget/Sizer.cpp b/ewol/widget/Sizer.cpp index a9ca0be6..2f824977 100644 --- a/ewol/widget/Sizer.cpp +++ b/ewol/widget/Sizer.cpp @@ -257,7 +257,7 @@ void ewol::widget::Sizer::calculateMinMaxSize() { //EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize); } -int32_t ewol::widget::Sizer::subWidgetAdd(std::shared_ptr _newWidget) { +int32_t ewol::widget::Sizer::subWidgetAdd(ewol::WidgetShared _newWidget) { if (*propertyAnimation == animationNone) { return ewol::widget::ContainerN::subWidgetAdd(_newWidget); } @@ -265,7 +265,7 @@ int32_t ewol::widget::Sizer::subWidgetAdd(std::shared_ptr _newWidg return ewol::widget::ContainerN::subWidgetAdd(_newWidget); } -int32_t ewol::widget::Sizer::subWidgetAddStart(std::shared_ptr _newWidget) { +int32_t ewol::widget::Sizer::subWidgetAddStart(ewol::WidgetShared _newWidget) { if (*propertyAnimation == animationNone) { return ewol::widget::ContainerN::subWidgetAddStart(_newWidget); } @@ -273,7 +273,7 @@ int32_t ewol::widget::Sizer::subWidgetAddStart(std::shared_ptr _ne return ewol::widget::ContainerN::subWidgetAddStart(_newWidget); } -void ewol::widget::Sizer::subWidgetRemove(std::shared_ptr _newWidget) { +void ewol::widget::Sizer::subWidgetRemove(ewol::WidgetShared _newWidget) { if (*propertyAnimation == animationNone) { ewol::widget::ContainerN::subWidgetRemove(_newWidget); return; @@ -282,7 +282,7 @@ void ewol::widget::Sizer::subWidgetRemove(std::shared_ptr _newWidg ewol::widget::ContainerN::subWidgetRemove(_newWidget); } -void ewol::widget::Sizer::subWidgetUnLink(std::shared_ptr _newWidget) { +void ewol::widget::Sizer::subWidgetUnLink(ewol::WidgetShared _newWidget) { if (*propertyAnimation == animationNone) { ewol::widget::ContainerN::subWidgetUnLink(_newWidget); return; diff --git a/ewol/widget/Sizer.h b/ewol/widget/Sizer.h index 94cbfce9..f7ff0fd4 100644 --- a/ewol/widget/Sizer.h +++ b/ewol/widget/Sizer.h @@ -16,6 +16,9 @@ namespace ewol { namespace widget { + class Sizer; + using SizerShared = ewol::SharedPtr; + using SizerWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -54,10 +57,10 @@ namespace ewol { virtual void onChangeSize(); virtual void calculateMinMaxSize(); // overwrite the set fuction to start annimations ... - virtual int32_t subWidgetAdd(std::shared_ptr _newWidget); - virtual int32_t subWidgetAddStart(std::shared_ptr _newWidget); - virtual void subWidgetRemove(std::shared_ptr _newWidget); - virtual void subWidgetUnLink(std::shared_ptr _newWidget); + virtual int32_t subWidgetAdd(ewol::WidgetShared _newWidget); + virtual int32_t subWidgetAddStart(ewol::WidgetShared _newWidget); + virtual void subWidgetRemove(ewol::WidgetShared _newWidget); + virtual void subWidgetUnLink(ewol::WidgetShared _newWidget); protected: virtual void onChangePropertyMode(); virtual void onChangePropertyBorderSize(); diff --git a/ewol/widget/Slider.h b/ewol/widget/Slider.h index b7a2f7c7..2c65535d 100644 --- a/ewol/widget/Slider.h +++ b/ewol/widget/Slider.h @@ -16,6 +16,9 @@ namespace ewol { namespace widget { + class Slider; + using SliderShared = ewol::SharedPtr; + using SliderWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/Spacer.h b/ewol/widget/Spacer.h index 81412974..1f3b5039 100644 --- a/ewol/widget/Spacer.h +++ b/ewol/widget/Spacer.h @@ -16,6 +16,9 @@ namespace ewol { namespace widget { + class Spacer; + using SpacerShared = ewol::SharedPtr; + using SpacerWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -36,7 +39,7 @@ namespace ewol { private: ewol::compositing::Drawing m_draw; //!< Compositing drawing element public: // Derived function - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos) { return nullptr; }; + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos) { return nullptr; }; virtual void onRegenerateDisplay(); virtual void onDraw(); protected: diff --git a/ewol/widget/Spin.h b/ewol/widget/Spin.h index 4fe70231..f581fccd 100644 --- a/ewol/widget/Spin.h +++ b/ewol/widget/Spin.h @@ -13,6 +13,9 @@ namespace ewol { namespace widget { + class Spin; + using SpinShared = ewol::SharedPtr; + using SpinWeak = ewol::WeakPtr; /** * @brief a composed Spin is a Spin with an inside composed with the specify XML element * ==> this permit to generate standard element simple diff --git a/ewol/widget/WSlider.cpp b/ewol/widget/WSlider.cpp index e8fa5ce2..c21b16aa 100644 --- a/ewol/widget/WSlider.cpp +++ b/ewol/widget/WSlider.cpp @@ -140,7 +140,7 @@ void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) { } } -void ewol::widget::WSlider::subWidgetSelectSet(const std::shared_ptr& _widgetPointer) { +void ewol::widget::WSlider::subWidgetSelectSet(const ewol::WidgetShared& _widgetPointer) { if (_widgetPointer == nullptr) { EWOL_ERROR("Can not change to a widget nullptr"); return; @@ -289,7 +289,7 @@ void ewol::widget::WSlider::onChangePropertyTransitionMode() { } -std::shared_ptr ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) { if (*propertyHide == true) { return nullptr; } @@ -303,7 +303,7 @@ std::shared_ptr ewol::widget::WSlider::getWidgetAtPos(const vec2& if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - std::shared_ptr tmpWidget = (*it)->getWidgetAtPos(_pos); + ewol::WidgetShared tmpWidget = (*it)->getWidgetAtPos(_pos); if (nullptr != tmpWidget) { return tmpWidget; } @@ -320,7 +320,7 @@ std::shared_ptr ewol::widget::WSlider::getWidgetAtPos(const vec2& if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - std::shared_ptr tmpWidget = (*it)->getWidgetAtPos(_pos); + ewol::WidgetShared tmpWidget = (*it)->getWidgetAtPos(_pos); if (nullptr != tmpWidget) { return tmpWidget; } @@ -336,7 +336,7 @@ std::shared_ptr ewol::widget::WSlider::getWidgetAtPos(const vec2& if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - std::shared_ptr tmpWidget = (*it)->getWidgetAtPos(_pos); + ewol::WidgetShared tmpWidget = (*it)->getWidgetAtPos(_pos); if (nullptr != tmpWidget) { return tmpWidget; } diff --git a/ewol/widget/WSlider.h b/ewol/widget/WSlider.h index 6bb082a4..de96a275 100644 --- a/ewol/widget/WSlider.h +++ b/ewol/widget/WSlider.h @@ -15,6 +15,9 @@ namespace ewol { namespace widget { + class WSlider; + using WSliderShared = ewol::SharedPtr; + using WSliderWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -58,7 +61,7 @@ namespace ewol { * @brief Select a new subwidget to display * @param[in] _widgetPointer Pointer on the widget selected (must be added before) */ - void subWidgetSelectSet(const std::shared_ptr& _widgetPointer); + void subWidgetSelectSet(const ewol::WidgetShared& _widgetPointer); /** * @brief Select a new subwidget to display * @param[in] _widgetName Name of the subwidget name @@ -68,7 +71,7 @@ namespace ewol { virtual void onChangeSize(); virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void onRegenerateDisplay(); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); virtual void periodicCall(const ewol::event::Time& _event); protected: virtual void onChangePropertySelectWidget(); diff --git a/ewol/widget/Widget.cpp b/ewol/widget/Widget.cpp index d5e5ba90..53f20332 100644 --- a/ewol/widget/Widget.cpp +++ b/ewol/widget/Widget.cpp @@ -547,7 +547,7 @@ bool ewol::Widget::loadXML(const std::shared_ptr& _node) { } bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) { - std::shared_ptr up = std::dynamic_pointer_cast(m_parent.lock()); + ewol::WidgetShared up = std::dynamic_pointer_cast(m_parent.lock()); if (up != nullptr) { if (up->systemEventEntry(_event) == true) { return true; @@ -557,7 +557,7 @@ bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) { } bool ewol::Widget::systemEventInput(ewol::event::InputSystem& _event) { - std::shared_ptr up = std::dynamic_pointer_cast(m_parent.lock()); + ewol::WidgetShared up = std::dynamic_pointer_cast(m_parent.lock()); if (up != nullptr) { if (up->systemEventInput(_event) == true) { return true; @@ -636,7 +636,7 @@ ewol::widget::Manager& ewol::Widget::getWidgetManager() { return getContext().getWidgetManager(); } -std::shared_ptr ewol::Widget::getWindows() { +ewol::widget::WindowsShared ewol::Widget::getWindows() { return getContext().getWindows(); } diff --git a/ewol/widget/Widget.h b/ewol/widget/Widget.h index 4b8b8716..370f2b03 100644 --- a/ewol/widget/Widget.h +++ b/ewol/widget/Widget.h @@ -22,6 +22,8 @@ namespace ewol { class Manager; class Windows; }; + using WidgetShared = ewol::SharedPtr; + using WidgetWeak = ewol::WeakPtr; }; #include #include @@ -39,7 +41,7 @@ namespace ewol { #define DECLARE_WIDGET_FACTORY(className, name) \ DECLARE_FACTORY(className); \ static void createManagerWidget(ewol::widget::Manager& _widgetManager) { \ - _widgetManager.addWidgetCreator(name, []() -> std::shared_ptr { \ + _widgetManager.addWidgetCreator(name, []() -> ewol::WidgetShared { \ return className::create(); \ }); \ } @@ -348,7 +350,7 @@ namespace ewol { * @return pointer on the widget found * @note : INTERNAL EWOL SYSTEM */ - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos) { + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos) { if (propertyHide.get() == false) { return std::dynamic_pointer_cast(shared_from_this()); } @@ -526,7 +528,7 @@ namespace ewol { /** * @brief get the curent Windows */ - std::shared_ptr getWindows(); + ewol::SharedPtr getWindows(); /* * Annimation section : */ diff --git a/ewol/widget/WidgetScrolled.h b/ewol/widget/WidgetScrolled.h index 195aa4b8..2fcc516f 100644 --- a/ewol/widget/WidgetScrolled.h +++ b/ewol/widget/WidgetScrolled.h @@ -17,6 +17,9 @@ namespace ewol { namespace widget { + class WidgetScrolled; + using WidgetScrolledShared = ewol::SharedPtr; + using WidgetScrolledWeak = ewol::WeakPtr; /** * @brief Widget to integrate a scrool bar in a widget. This is not a stadalone widget. */ diff --git a/ewol/widget/Windows.cpp b/ewol/widget/Windows.cpp index 1377c3cf..aa3da1aa 100644 --- a/ewol/widget/Windows.cpp +++ b/ewol/widget/Windows.cpp @@ -60,7 +60,7 @@ void ewol::widget::Windows::onChangeSize() { } } -std::shared_ptr ewol::widget::Windows::getWidgetAtPos(const vec2& _pos) { +ewol::WidgetShared ewol::widget::Windows::getWidgetAtPos(const vec2& _pos) { // calculate relative position vec2 relativePos = relativePosition(_pos); // event go directly on the pop-up @@ -160,7 +160,7 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) { #endif } -void ewol::widget::Windows::setSubWidget(std::shared_ptr _widget) { +void ewol::widget::Windows::setSubWidget(ewol::WidgetShared _widget) { if (m_subWidget != nullptr) { EWOL_INFO("Remove current main windows Widget..."); m_subWidget->removeParent(); @@ -175,7 +175,7 @@ void ewol::widget::Windows::setSubWidget(std::shared_ptr _widget) onChangeSize(); } -void ewol::widget::Windows::popUpWidgetPush(std::shared_ptr _widget) { +void ewol::widget::Windows::popUpWidgetPush(ewol::WidgetShared _widget) { if (_widget == nullptr) { // nothing to do an error appear : EWOL_ERROR("can not set widget pop-up (null pointer)"); @@ -213,7 +213,7 @@ void ewol::widget::Windows::setTitle(const std::string& _title) { void ewol::widget::Windows::createPopUpMessage(enum popUpMessageType _type, const std::string& _message) { - std::shared_ptr tmpPopUp = widget::StdPopUp::create(); + ewol::widget::StdPopUpShared tmpPopUp = widget::StdPopUp::create(); if (tmpPopUp == nullptr) { EWOL_ERROR("Can not create a simple pop-up"); return; @@ -238,7 +238,7 @@ void ewol::widget::Windows::createPopUpMessage(enum popUpMessageType _type, cons popUpWidgetPush(tmpPopUp); } -void ewol::widget::Windows::requestDestroyFromChild(const std::shared_ptr& _child) { +void ewol::widget::Windows::requestDestroyFromChild(const ewol::ObjectShared& _child) { auto it = m_popUpWidgetList.begin(); while (it != m_popUpWidgetList.end()) { if (*it == _child) { @@ -266,8 +266,8 @@ void ewol::widget::Windows::requestDestroyFromChild(const std::shared_ptr ewol::widget::Windows::getSubObjectNamed(const std::string& _objectName) { - std::shared_ptr tmpObject = ewol::Widget::getSubObjectNamed(_objectName); +ewol::ObjectShared ewol::widget::Windows::getSubObjectNamed(const std::string& _objectName) { + ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_objectName); if (tmpObject != nullptr) { return tmpObject; } diff --git a/ewol/widget/Windows.h b/ewol/widget/Windows.h index eb61f501..35967a00 100644 --- a/ewol/widget/Windows.h +++ b/ewol/widget/Windows.h @@ -16,6 +16,9 @@ namespace ewol { namespace widget { + class Windows; + using WindowsShared = ewol::SharedPtr; + using WindowsWeak = ewol::WeakPtr; /** * @brief Windows basic interface */ @@ -46,11 +49,11 @@ namespace ewol { virtual void onStateSuspend() {}; virtual void onStateResume() {}; private: - std::shared_ptr m_subWidget; - std::list> m_popUpWidgetList; + ewol::WidgetShared m_subWidget; + std::list m_popUpWidgetList; public: - void setSubWidget(std::shared_ptr _widget); - void popUpWidgetPush(std::shared_ptr _widget); + void setSubWidget(ewol::WidgetShared _widget); + void popUpWidgetPush(ewol::WidgetShared _widget); void popUpWidgetPop(); size_t popUpCount() { return m_popUpWidgetList.size(); @@ -75,9 +78,9 @@ namespace ewol { public: // Derived function virtual void onRegenerateDisplay(); virtual void onChangeSize(); - virtual std::shared_ptr getWidgetAtPos(const vec2& _pos); - virtual void requestDestroyFromChild(const std::shared_ptr& _child); - virtual std::shared_ptr getSubObjectNamed(const std::string& _objectName); + virtual ewol::WidgetShared getWidgetAtPos(const vec2& _pos); + virtual void requestDestroyFromChild(const ewol::ObjectShared& _child); + virtual ewol::ObjectShared getSubObjectNamed(const std::string& _objectName); void setTitle(const std::string& _title); public: enum popUpMessageType { diff --git a/ewol/widget/meta/ColorChooser.h b/ewol/widget/meta/ColorChooser.h index 7e9fd299..d56fe96d 100644 --- a/ewol/widget/meta/ColorChooser.h +++ b/ewol/widget/meta/ColorChooser.h @@ -20,6 +20,9 @@ namespace ewol { namespace widget { + class ColorChooser; + using ColorChooserShared = ewol::SharedPtr; + using ColorChooserWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -35,11 +38,11 @@ namespace ewol { DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser"); virtual ~ColorChooser(); private: - std::shared_ptr m_widgetColorBar; - std::shared_ptr m_widgetRed; - std::shared_ptr m_widgetGreen; - std::shared_ptr m_widgetBlue; - std::shared_ptr m_widgetAlpha; + ewol::widget::ColorBarShared m_widgetColorBar; + ewol::widget::SliderShared m_widgetRed; + ewol::widget::SliderShared m_widgetGreen; + ewol::widget::SliderShared m_widgetBlue; + ewol::widget::SliderShared m_widgetAlpha; void onCallbackColorChangeRed(const float& _newColor); void onCallbackColorChangeGreen(const float& _newColor); void onCallbackColorChangeBlue(const float& _newColor); diff --git a/ewol/widget/meta/FileChooser.h b/ewol/widget/meta/FileChooser.h index d2db772b..77e52989 100644 --- a/ewol/widget/meta/FileChooser.h +++ b/ewol/widget/meta/FileChooser.h @@ -14,6 +14,9 @@ namespace ewol { namespace widget { + class FileChooser; + using FileChooserShared = ewol::SharedPtr; + using FileChooserWeak = ewol::WeakPtr; /** * @brief File Chooser is a simple selector of file for opening, saving, and what you want ... * @@ -26,7 +29,7 @@ namespace ewol { * * The first step is to create the file chooser pop-up : (never in the constructor!!!) * [code style=c++] - * std::shared_ptr tmpWidget = ewol::Widget::FileChooser::create(); + * ewol::widget::FileChooserShared tmpWidget = ewol::Widget::FileChooser::create(); * if (tmpWidget == nullptr) { * APPL_ERROR("Can not open File chooser !!! "); * return -1; @@ -42,7 +45,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 ... - * std::shared_ptr tmpWindows = getWindows(); + * ewol::widget::WindowsShared tmpWindows = getWindows(); * if (tmpWindows == nullptr) { * APPL_ERROR("Can not get the current windows !!! "); * return -1; diff --git a/ewol/widget/meta/Parameter.cpp b/ewol/widget/meta/Parameter.cpp index cb73567d..b7cb41b2 100644 --- a/ewol/widget/meta/Parameter.cpp +++ b/ewol/widget/meta/Parameter.cpp @@ -36,9 +36,9 @@ ewol::widget::Parameter::Parameter() : void ewol::widget::Parameter::init() { ewol::widget::PopUp::init(); - std::shared_ptr mySizerVert = nullptr; - std::shared_ptr mySizerHori = nullptr; - std::shared_ptr mySpacer = nullptr; + ewol::widget::SizerShared mySizerVert = nullptr; + ewol::widget::SizerShared mySizerHori = nullptr; + ewol::widget::SpacerShared mySpacer = nullptr; #ifdef __TARGET_OS__Android propertyMinSize.set(gale::Dimension(vec2(90, 90), gale::Dimension::Pourcent)); #else @@ -71,7 +71,7 @@ void ewol::widget::Parameter::init() { mySizerHori->subWidgetAdd(mySpacer); } - std::shared_ptr tmpButton = widget::Button::create(); + ewol::widget::ButtonShared tmpButton = widget::Button::create(); if (tmpButton == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -134,7 +134,7 @@ void ewol::widget::Parameter::init() { mySizerHori->subWidgetAdd(mySpacer); } - std::shared_ptr mySizerVert2 = widget::Sizer::create(); + ewol::widget::SizerShared mySizerVert2 = widget::Sizer::create(); if (mySizerVert2 == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -212,7 +212,7 @@ void ewol::widget::Parameter::onCallbackMenuSelected(const int32_t& _value) { } } -void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, std::shared_ptr _associateWidget) { +void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, ewol::WidgetShared _associateWidget) { if (nullptr != m_paramList) { m_paramList->menuAdd(_label, m_currentIdList, _image); if (nullptr != m_wSlider) { @@ -220,7 +220,7 @@ void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, st m_wSlider->subWidgetAdd(_associateWidget); } else { EWOL_DEBUG("Associate an empty widget on it ..."); - std::shared_ptr myLabel = widget::Label::create(); + ewol::widget::LabelShared myLabel = widget::Label::create(); if (nullptr == myLabel) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { diff --git a/ewol/widget/meta/Parameter.h b/ewol/widget/meta/Parameter.h index 7ddcf8dd..e0e4124e 100644 --- a/ewol/widget/meta/Parameter.h +++ b/ewol/widget/meta/Parameter.h @@ -21,6 +21,9 @@ namespace ewol { namespace widget { + class Parameter; + using ParameterShared = ewol::SharedPtr; + using ParameterWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -36,15 +39,15 @@ namespace ewol { DECLARE_WIDGET_FACTORY(Parameter, "Parameter"); virtual ~Parameter(); public: - void menuAdd(std::string _label, std::string _image, std::shared_ptr _associateWidget); + void menuAdd(std::string _label, std::string _image, ewol::WidgetShared _associateWidget); void menuAddGroup(std::string _label); void menuClear(); void menuSeparator(); private: int32_t m_currentIdList; - std::shared_ptr m_widgetTitle; - std::shared_ptr m_paramList; - std::shared_ptr m_wSlider; + ewol::widget::LabelShared m_widgetTitle; + ewol::widget::ParameterListShared m_paramList; + ewol::widget::WSliderShared m_wSlider; private: //callback functions: void onCallbackMenuclosed(); void onCallbackParameterSave(); diff --git a/ewol/widget/meta/ParameterList.h b/ewol/widget/meta/ParameterList.h index 4eb9afcf..54082e39 100644 --- a/ewol/widget/meta/ParameterList.h +++ b/ewol/widget/meta/ParameterList.h @@ -12,8 +12,6 @@ #include #include - - namespace ewol { namespace widget { class elementPL { @@ -31,7 +29,9 @@ namespace ewol { }; virtual ~elementPL() {}; }; - + class ParameterList; + using ParameterListShared = ewol::SharedPtr; + using ParameterListWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ diff --git a/ewol/widget/meta/SpinBase.cpp b/ewol/widget/meta/SpinBase.cpp index 085d55f9..3bd39370 100644 --- a/ewol/widget/meta/SpinBase.cpp +++ b/ewol/widget/meta/SpinBase.cpp @@ -96,7 +96,7 @@ void ewol::widget::SpinBase::updateGui() { m_widgetButtonDown->propertyExpand.set(bvec2(false,false)); m_widgetButtonDown->propertyFill.set(bvec2(true,true)); std::string data = m_config->getString(m_confIdDownData); - std::shared_ptr widget = ewol::widget::composerGenerateString(data); + ewol::WidgetShared widget = ewol::widget::composerGenerateString(data); m_widgetButtonDown->setSubWidget(widget); } } @@ -111,7 +111,7 @@ void ewol::widget::SpinBase::updateGui() { m_widgetButtonUp->propertyExpand.set(bvec2(false,false)); m_widgetButtonUp->propertyFill.set(bvec2(true,true)); std::string data = m_config->getString(m_confIdUpData); - std::shared_ptr widget = ewol::widget::composerGenerateString(data); + ewol::WidgetShared widget = ewol::widget::composerGenerateString(data); m_widgetButtonUp->setSubWidget(widget); } } diff --git a/ewol/widget/meta/SpinBase.h b/ewol/widget/meta/SpinBase.h index c0b6f45f..6d9989de 100644 --- a/ewol/widget/meta/SpinBase.h +++ b/ewol/widget/meta/SpinBase.h @@ -57,6 +57,9 @@ namespace ewol { */ spinPosition_RightRight }; + class SpinBase; + using SpinBaseShared = ewol::SharedPtr; + using SpinBaseWeak = ewol::WeakPtr; /** * @ingroup ewolWidgetGroup */ @@ -86,9 +89,9 @@ namespace ewol { */ virtual ~SpinBase(); protected: - std::shared_ptr m_widgetEntry; - std::shared_ptr m_widgetButtonDown; - std::shared_ptr m_widgetButtonUp; + ewol::widget::EntryShared m_widgetEntry; + ewol::widget::ButtonShared m_widgetButtonDown; + ewol::widget::ButtonShared m_widgetButtonUp; virtual void updateGui(); public: // Derived function virtual bool loadXML(const std::shared_ptr& _node); diff --git a/ewol/widget/meta/StdPopUp.cpp b/ewol/widget/meta/StdPopUp.cpp index c451c814..f3566b97 100644 --- a/ewol/widget/meta/StdPopUp.cpp +++ b/ewol/widget/meta/StdPopUp.cpp @@ -26,8 +26,8 @@ ewol::widget::StdPopUp::StdPopUp() : void ewol::widget::StdPopUp::init() { ewol::widget::PopUp::init(); propertyMinSize.set(gale::Dimension(vec2(20,10),gale::Dimension::Pourcent)); - std::shared_ptr mySizerVert; - std::shared_ptr mySpacer; + ewol::widget::SizerShared mySizerVert; + ewol::widget::SpacerShared mySpacer; mySizerVert = ewol::widget::Sizer::create(); // set it in the pop-up-system : @@ -96,12 +96,12 @@ void ewol::widget::StdPopUp::setComment(const std::string& _text) { markToRedraw(); } -std::shared_ptr ewol::widget::StdPopUp::addButton(const std::string& _text, bool _autoExit) { +ewol::widget::ButtonShared ewol::widget::StdPopUp::addButton(const std::string& _text, bool _autoExit) { if (m_subBar == nullptr) { EWOL_ERROR("button-bar does not existed ..."); return nullptr; } - std::shared_ptr myButton = widget::Button::create(); + ewol::widget::ButtonShared myButton = widget::Button::create(); if (myButton == nullptr) { EWOL_ERROR("Can not allocate new button ..."); return nullptr; diff --git a/ewol/widget/meta/StdPopUp.h b/ewol/widget/meta/StdPopUp.h index c75fe496..66a5eb32 100644 --- a/ewol/widget/meta/StdPopUp.h +++ b/ewol/widget/meta/StdPopUp.h @@ -13,6 +13,9 @@ #include namespace ewol { namespace widget { + class StdPopUp; + using StdPopUpShared = ewol::SharedPtr; + using StdPopUpWeak = ewol::WeakPtr; /** * @brief The std pop up widget is a siple message widget to notify user of some simple things, like: * @@ -53,7 +56,7 @@ namespace ewol { */ virtual ~StdPopUp(); protected: - std::shared_ptr m_title; //!< Title Label widget + ewol::widget::LabelShared m_title; //!< Title Label widget public: /** * @brief Set the title string. @@ -61,7 +64,7 @@ namespace ewol { */ void setTitle(const std::string& _text); protected: - std::shared_ptr m_comment; //!< Comment label widget + ewol::widget::LabelShared m_comment; //!< Comment label widget public: /** * @brief Set the commentary string. @@ -69,13 +72,13 @@ namespace ewol { */ void setComment(const std::string& _text); protected: - std::shared_ptr m_subBar; //!< subwidget bar containing all the button. + ewol::widget::SizerShared m_subBar; //!< subwidget bar containing all the button. public: /** * @brief Add a buttom button. * @param[in] _text Decorated text to diplay in button. */ - std::shared_ptr addButton(const std::string& _text, bool _autoExit=false); + ewol::widget::ButtonShared addButton(const std::string& _text, bool _autoExit=false); public: // callback function void onCallBackButtonExit(); }; diff --git a/lutin_ewol.py b/lutin_ewol.py index 1bd3d319..4bf49bd7 100644 --- a/lutin_ewol.py +++ b/lutin_ewol.py @@ -48,7 +48,8 @@ def create(target, module_name): 'ewol/Padding.h', 'ewol/translate.h', 'ewol/DrawProperty.h', - 'ewol/gravity.h' + 'ewol/gravity.h', + 'ewol/memory.h' ]) # compositing: