Widget manager added, and rework .eol file to simplify it
This commit is contained in:
parent
f0ce27e8d7
commit
5a5b358a46
1
Makefile
1
Makefile
@ -188,6 +188,7 @@ else
|
||||
CXXFILES += ewolFontFreeType.cpp
|
||||
endif
|
||||
CXXFILES += ewolWidget.cpp \
|
||||
ewolWidgetManager.cpp \
|
||||
ewolWindows.cpp
|
||||
# list of widgets :
|
||||
CXXFILES += widget/ewolButton.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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <ewolWidget.h>
|
||||
#include <ewolWidgetManager.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -27,3 +27,70 @@
|
||||
#undef __class__
|
||||
#define __class__ "ewol::WidgetManager"
|
||||
|
||||
|
||||
// internal element of the widget manager :
|
||||
static etk::VectorType<ewol::Widget*> 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<m_widgetList.Size(); iii++) {
|
||||
ewol::widgetManager::Rm(iii);
|
||||
}
|
||||
m_widgetList.Clear();
|
||||
}
|
||||
|
||||
void ewol::widgetManager::Add(ewol::Widget * newWidget)
|
||||
{
|
||||
// Check existance
|
||||
int32_t tmpID = ewol::widgetManager::GetId(newWidget);
|
||||
if (-1 == tmpID) {
|
||||
m_widgetList.PushBack(newWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widgetManager::Rm(ewol::Widget * newWidget)
|
||||
{
|
||||
// check existance
|
||||
int32_t tmpID = ewol::widgetManager::GetId(newWidget);
|
||||
if (-1 == tmpID) {
|
||||
ewol::widgetManager::Rm(tmpID);
|
||||
} else {
|
||||
EWOL_ERROR("Widget already removed ...");
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widgetManager::Rm(int32_t widgetId)
|
||||
{
|
||||
if (0 <= widgetId && widgetId < m_widgetList.Size()) {
|
||||
if (m_widgetList[widgetId]!=NULL) {
|
||||
delete(m_widgetList[widgetId]);
|
||||
m_widgetList[widgetId]=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ewol::widgetManager::GetId(ewol::Widget * newWidget)
|
||||
{
|
||||
if (NULL == newWidget) {
|
||||
return -1;
|
||||
}
|
||||
for(int32_t iii=0; iii<m_widgetList.Size(); iii++) {
|
||||
if (m_widgetList[iii] == newWidget) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ewol::Widget * Get(int32_t widgetId)
|
||||
{
|
||||
if (0 <= widgetId && widgetId < m_widgetList.Size()) {
|
||||
return m_widgetList[widgetId];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -29,11 +29,19 @@
|
||||
#include <ewolDebug.h>
|
||||
#include <ewolOObject.h>
|
||||
#include <etkVectorType.h>
|
||||
#include <etkSingleton.h>
|
||||
#include <ewolWidget.h>
|
||||
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
<element=plop>
|
||||
# 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user