From 3b5943c1b21a68ef24bbc671b8cf3c046a90611a Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 15 May 2013 00:05:58 +0200 Subject: [PATCH] [DEV] add button keep under element name, composer add register sub event with widget name, scroll add limit parameter --- external/etk | 2 +- sources/ewol/widget/Button.cpp | 21 +++++++++++++++++++++ sources/ewol/widget/Button.h | 1 + sources/ewol/widget/Composer.cpp | 13 +++++++++++++ sources/ewol/widget/Composer.h | 11 +++++++++++ sources/ewol/widget/Scroll.cpp | 29 +++++++++++++++++++++++++++++ sources/ewol/widget/Scroll.h | 7 ++++++- sources/ewol/widget/Sizer.cpp | 2 +- sources/ewol/widget/Sizer.h | 2 +- sources/ewol/widget/Spacer.cpp | 2 +- 10 files changed, 85 insertions(+), 5 deletions(-) diff --git a/external/etk b/external/etk index fe0d7ab9..4b07b050 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit fe0d7ab99f7a1ac523ef595dedd309d7e9a985e0 +Subproject commit 4b07b0501793357ffe59333c5d1b2229b1334b54 diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index 6697d3ac..3f1043a3 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -397,6 +397,27 @@ void widget::Button::PeriodicCall(int64_t _localTime) } +ewol::Widget* widget::Button::GetWidgetNamed(const etk::UString& _widgetName) +{ + if (GetName()==_widgetName) { + return this; + } + if (m_subWidget[0]!= NULL) { + ewol::Widget* tmpWidget = m_subWidget[0]->GetWidgetNamed(_widgetName); + if (NULL != tmpWidget) { + return tmpWidget; + } + } + if (m_subWidget[1]!= NULL) { + ewol::Widget* tmpWidget = m_subWidget[1]->GetWidgetNamed(_widgetName); + if (NULL != tmpWidget) { + return tmpWidget; + } + } + return NULL; +} + + bool widget::Button::LoadXML(TiXmlNode* _node) { if (NULL==_node) { diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index fd49f451..f1b7d241 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -154,6 +154,7 @@ namespace widget { virtual bool OnEventInput(const ewol::EventInput& _event); virtual bool OnEventEntry(const ewol::EventEntry& _event); virtual bool LoadXML(TiXmlNode* _node); + virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName); private: // derived function virtual void PeriodicCall(int64_t _localTime); }; diff --git a/sources/ewol/widget/Composer.cpp b/sources/ewol/widget/Composer.cpp index 865d3453..c4df7464 100644 --- a/sources/ewol/widget/Composer.cpp +++ b/sources/ewol/widget/Composer.cpp @@ -103,3 +103,16 @@ bool widget::Composer::CommonLoadXML(const char* data) } +void widget::Composer::RegisterOnEventNameWidget(const etk::UString& _subWidgetName, + const char * _eventId, + const char * _eventIdgenerated, + const etk::UString& _overloadData) +{ + ewol::Widget* tmpWidget = GetWidgetNamed(_subWidgetName); + if (NULL != tmpWidget) { + //EWOL_DEBUG("Find widget named : \"" << _subWidgetName << "\" register event=\"" << _eventId << "\""); + tmpWidget->RegisterOnEvent(this, _eventId, _eventIdgenerated, _overloadData); + } else { + EWOL_WARNING("Can not register event : \"" << _eventId << "\" the widget named=\"" << _subWidgetName << "\" does not exist"); + } +} diff --git a/sources/ewol/widget/Composer.h b/sources/ewol/widget/Composer.h index 106b83c9..902964db 100644 --- a/sources/ewol/widget/Composer.h +++ b/sources/ewol/widget/Composer.h @@ -55,6 +55,17 @@ namespace widget * @return false ==> some error occured */ bool LoadFromString(const etk::UString& composerXmlString); + /** + * @brief Register an Event an named widget. @see RegisterOnEvent + * @param[in] _subWidgetName Name of the subWidget. + * @param[in] _eventId Event generate inside the object. + * @param[in] _eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...) + * @param[in] _overloadData When the user prever to receive a data specificly for this event ... + */ + void RegisterOnEventNameWidget(const etk::UString& _subWidgetName, + const char * _eventId, + const char * _eventIdgenerated = NULL, + const etk::UString& _overloadData=""); private: /** * @brief Load a composition with a file. diff --git a/sources/ewol/widget/Scroll.cpp b/sources/ewol/widget/Scroll.cpp index fbb03274..e20d71c2 100644 --- a/sources/ewol/widget/Scroll.cpp +++ b/sources/ewol/widget/Scroll.cpp @@ -29,6 +29,8 @@ void widget::Scroll::UnInit(void) ewol::widgetManager::AddWidgetCreator(__class__,NULL); } +const char* const widget::Scroll::configLimit = "limit"; + widget::Scroll::Scroll(void) : m_limit(0.15,0.5), m_pixelScrolling(20), @@ -37,6 +39,7 @@ widget::Scroll::Scroll(void) : m_highSpeedButton(-1), m_highSpeedType(ewol::keyEvent::typeUnknow) { + RegisterConfig(configLimit, "vec2", NULL, "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end"); } @@ -348,3 +351,29 @@ ewol::Widget* widget::Scroll::GetWidgetAtPos(const vec2& _pos) } return this; } + +bool widget::Scroll::OnSetConfig(const ewol::EConfig& _conf) +{ + if (true == widget::Container::OnSetConfig(_conf)) { + return true; + } + if (_conf.GetConfig() == configLimit) { + SetLimit(_conf.GetData()); + return true; + } + return false; +} + +bool widget::Scroll::OnGetConfig(const char* _config, etk::UString& _result) const +{ + if (true == widget::Container::OnGetConfig(_config, _result)) { + return true; + } + if (_config == configLimit) { + _result = GetLimit(); + return true; + } + return false; +} + + diff --git a/sources/ewol/widget/Scroll.h b/sources/ewol/widget/Scroll.h index c5ec7eef..3c943e9a 100644 --- a/sources/ewol/widget/Scroll.h +++ b/sources/ewol/widget/Scroll.h @@ -27,6 +27,9 @@ namespace widget { class Scroll : public widget::Container { + public: + // Cinfig parameter list: + static const char* const configLimit; public: static void Init(void); static void UnInit(void); @@ -53,7 +56,7 @@ namespace widget { * @brief Get the limit of scrolling * @return scrolling limit */ - const vec2& GetLimit(void) { return m_limit; }; + const vec2& GetLimit(void) const { return m_limit; }; public: // Derived function virtual const char * const GetObjectType(void) { return "ewol::widget::Scroll"; }; @@ -64,6 +67,8 @@ namespace widget { virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos); protected: // Derived function virtual void OnDraw(void); + virtual bool OnSetConfig(const ewol::EConfig& _conf); + virtual bool OnGetConfig(const char* _config, etk::UString& _result) const; }; }; diff --git a/sources/ewol/widget/Sizer.cpp b/sources/ewol/widget/Sizer.cpp index 7c962970..e1072fc9 100644 --- a/sources/ewol/widget/Sizer.cpp +++ b/sources/ewol/widget/Sizer.cpp @@ -180,7 +180,7 @@ bool widget::Sizer::LoadXML(TiXmlNode* _node) // parse generic properties : widget::ContainerN::LoadXML(_node); - const char* tmpAttributeValue = _node->ToElement()->Attribute("borderSize"); + const char* tmpAttributeValue = _node->ToElement()->Attribute("border"); if (NULL != tmpAttributeValue) { m_borderSize = tmpAttributeValue; } diff --git a/sources/ewol/widget/Sizer.h b/sources/ewol/widget/Sizer.h index b8b966b8..78dad0c0 100644 --- a/sources/ewol/widget/Sizer.h +++ b/sources/ewol/widget/Sizer.h @@ -66,7 +66,7 @@ namespace widget { */ const ewol::Dimension& GetBorderSize(void) { return m_borderSize; }; public: // Derived function - virtual const char * const GetObjectType(void) { return "Ewol::Sizer"; }; + virtual const char * const GetObjectType(void) { return "ewol::widget::sizer"; }; virtual void CalculateSize(const vec2& _availlable); virtual void CalculateMinMaxSize(void); virtual bool LoadXML(TiXmlNode* _node); diff --git a/sources/ewol/widget/Spacer.cpp b/sources/ewol/widget/Spacer.cpp index 5c84c019..bc2cae3c 100644 --- a/sources/ewol/widget/Spacer.cpp +++ b/sources/ewol/widget/Spacer.cpp @@ -13,7 +13,7 @@ #undef __class__ -#define __class__ "Spacer" +#define __class__ "Spacer" static ewol::Widget* Create(void) {