From 5a5b358a4614a291e9692058c004343c3f1b0f67 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Tue, 22 Nov 2011 10:42:43 +0100 Subject: [PATCH] Widget manager added, and rework .eol file to simplify it --- Makefile | 1 + Sources/ewol.cpp | 3 ++ Sources/ewolWidget.cpp | 7 +-- Sources/ewolWidget.h | 4 -- Sources/ewolWidgetManager.cpp | 67 ++++++++++++++++++++++++++++ Sources/ewolWidgetManager.h | 16 +++++-- dataTest/exemple.eol | 83 ++++++++++++++++++++++++++++------- 7 files changed, 154 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index d1c05276..8c08828d 100644 --- a/Makefile +++ b/Makefile @@ -188,6 +188,7 @@ else CXXFILES += ewolFontFreeType.cpp endif CXXFILES += ewolWidget.cpp \ + ewolWidgetManager.cpp \ ewolWindows.cpp # list of widgets : CXXFILES += widget/ewolButton.cpp \ diff --git a/Sources/ewol.cpp b/Sources/ewol.cpp index b33e0c19..6745b419 100644 --- a/Sources/ewol.cpp +++ b/Sources/ewol.cpp @@ -25,6 +25,7 @@ #include "ewol.h" #include "ewolFont.h" +#include "ewolWidgetManager.h" #if __PLATFORM__ == X11 #include "guiX11.h" @@ -50,6 +51,7 @@ void ewol::Init(int argc, char *argv[]) EWOL_INFO("v" EWOL_VERSION_TAG_NAME); EWOL_INFO("Build Date: " VERSION_BUILD_TIME); guiAbstraction::Init(argc, argv); + ewol::widgetManager::Init(); ewol::InitFont(); } @@ -62,6 +64,7 @@ void ewol::UnInit(void) { guiAbstraction::UnInit(); ewol::UnInitFont(); + ewol::widgetManager::UnInit(); } diff --git a/Sources/ewolWidget.cpp b/Sources/ewolWidget.cpp index 1822c96f..85922b9b 100644 --- a/Sources/ewolWidget.cpp +++ b/Sources/ewolWidget.cpp @@ -23,6 +23,7 @@ */ #include +#include #undef __class__ #define __class__ "ewol::Widget" @@ -44,12 +45,12 @@ ewol::Widget::Widget(void) SetFillY(); m_genericDraw = true; m_specificDraw = false; - + ewol::widgetManager::Add(this); } ewol::Widget::~Widget(void) { - + ewol::widgetManager::Rm(this); } @@ -92,7 +93,7 @@ bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, e if (-1 != m_inputEvent[iii].widgetCall) { ewol::Widget * tmpWidget = NULL; //tmpWidget = ewol::GetWidgetWithID(newEvent.widgetCall); - ended = tmpWidget->OnEventAreaExternal(m_uniqueId, m_inputEvent[iii].generateEventId, x, y); + ended = tmpWidget->OnEventAreaExternal(ewol::widgetManager::GetId(this), m_inputEvent[iii].generateEventId, x, y); if (true == ended) { break; } diff --git a/Sources/ewolWidget.h b/Sources/ewolWidget.h index c2ce141e..1bfb98c2 100644 --- a/Sources/ewolWidget.h +++ b/Sources/ewolWidget.h @@ -132,10 +132,6 @@ namespace ewol { public: Widget(void); virtual ~Widget(void); - private: - int32_t m_uniqueId; //!< UniqueId to identify the widget unicly - public: - int32_t GetUniqueId(void) { return m_uniqueId; }; private: ewol::Widget * m_parrent; //!< parrent of the current widget (if NULL ==> this is the main node(root)) diff --git a/Sources/ewolWidgetManager.cpp b/Sources/ewolWidgetManager.cpp index 60989d34..2f29bb17 100644 --- a/Sources/ewolWidgetManager.cpp +++ b/Sources/ewolWidgetManager.cpp @@ -27,3 +27,70 @@ #undef __class__ #define __class__ "ewol::WidgetManager" + +// internal element of the widget manager : +static etk::VectorType m_widgetList; // all widget allocated ==> all time increment ... never removed ... + +void ewol::widgetManager::Init(void) +{ + +} + +void ewol::widgetManager::UnInit(void) +{ + for(int32_t iii=0; iii #include #include -#include +#include namespace ewol { - class widgetManager: public etk::Singleton - { - friend + namespace widgetManager { + void Init( void); + void UnInit(void); + void Add( ewol::Widget * newWidget); + void Rm( ewol::Widget * newWidget); + void Rm( int32_t widgetId); + int32_t GetId( ewol::Widget * newWidget); + ewol::Widget * Get( int32_t widgetId); }; }; + +#endif + diff --git a/dataTest/exemple.eol b/dataTest/exemple.eol index f127cba7..b857d98f 100644 --- a/dataTest/exemple.eol +++ b/dataTest/exemple.eol @@ -1,18 +1,69 @@ eol -2DColor -text +# Mode of reading file: "Text" / "Bin" +Mode=Text +# type of the file : "Single" / "Multiple" +FileType=Single +# Version : +version=1.0 -elem="myLine" -type=line -a=0.0 -c=#51625351 -p=0.2562;0.4532 -c=#51625351 -p=0.5245;0.5356 - -elem="myrect" -type=retangle -a=56.0 -c=#536254FF -p=0.53;0.56 -s=0.22;0.12 + + # Number of sub frame of the element (default 1) + NbFrame=2 + # Element display Ratio : ratio = x/y (default 1.0) + Ratio=1.0 + # Clipping mode of the element + ClipX=false + ClipY=false + # Position of internal Elements ... (use only if clipping is enable + internalElemXStart=0.25 + internalElemXStop=0.75 + internalElemYStart=0.25 + internalElemYStop=0.75 + # note we have 5 methode to reference a color : + # - #RRGGBB ==> in hexa 0x00<=x<=0xFF + # - #RRGGBBAA ==> in hexa 0x00<=x<=0xFF + # - R.R;G.G;B.B ==> in double 0<=x<=1 + # - R.R;G.G;B.B;A.A ==> in double 0<=x<=1 + # - &NameColor ==> searche internal color of the element and after global color ... + [Colors] + colorName=1.0;1.0;1.0;1.0 + Background=0.0;0.000512;1.0;0.755562535 + Border=#536254FF + [grp=basicRect] + {Rect} + color=#536254FF + position=0.53;0.56 + size=0.22;0.12 + {Rect} + color=&Background + position=0.10;0.10 + size=0.22;0.22 + #decription of the object: + [Frame=0=basic] + {Circle} + name=plop et plop + thickness=0.01 + # Start + color=#51625351 + point=0.2562;0.4532 + # Stop + color=#51625351 + point=0.5245;0.5356 + {Rect} + color=#536254FF + position=0.53;0.56 + size=0.22;0.12 + [Frame=1=clicked] + {Circle} + thickness=0.01 + color=#51625351 + point=0.2562;0.4532 + color=#51625351 + point=0.5245;0.5356 + {Rect} + color=&Border + position=0.53;0.56 + size=0.22;0.12 + # load a generic group of the object or the theme + {grp} + name=basicRect