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
|
CXXFILES += ewolFontFreeType.cpp
|
||||||
endif
|
endif
|
||||||
CXXFILES += ewolWidget.cpp \
|
CXXFILES += ewolWidget.cpp \
|
||||||
|
ewolWidgetManager.cpp \
|
||||||
ewolWindows.cpp
|
ewolWindows.cpp
|
||||||
# list of widgets :
|
# list of widgets :
|
||||||
CXXFILES += widget/ewolButton.cpp \
|
CXXFILES += widget/ewolButton.cpp \
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "ewol.h"
|
#include "ewol.h"
|
||||||
#include "ewolFont.h"
|
#include "ewolFont.h"
|
||||||
|
#include "ewolWidgetManager.h"
|
||||||
|
|
||||||
#if __PLATFORM__ == X11
|
#if __PLATFORM__ == X11
|
||||||
#include "guiX11.h"
|
#include "guiX11.h"
|
||||||
@ -50,6 +51,7 @@ void ewol::Init(int argc, char *argv[])
|
|||||||
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
|
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
|
||||||
EWOL_INFO("Build Date: " VERSION_BUILD_TIME);
|
EWOL_INFO("Build Date: " VERSION_BUILD_TIME);
|
||||||
guiAbstraction::Init(argc, argv);
|
guiAbstraction::Init(argc, argv);
|
||||||
|
ewol::widgetManager::Init();
|
||||||
ewol::InitFont();
|
ewol::InitFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +64,7 @@ void ewol::UnInit(void)
|
|||||||
{
|
{
|
||||||
guiAbstraction::UnInit();
|
guiAbstraction::UnInit();
|
||||||
ewol::UnInitFont();
|
ewol::UnInitFont();
|
||||||
|
ewol::widgetManager::UnInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ewolWidget.h>
|
#include <ewolWidget.h>
|
||||||
|
#include <ewolWidgetManager.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol::Widget"
|
#define __class__ "ewol::Widget"
|
||||||
@ -44,12 +45,12 @@ ewol::Widget::Widget(void)
|
|||||||
SetFillY();
|
SetFillY();
|
||||||
m_genericDraw = true;
|
m_genericDraw = true;
|
||||||
m_specificDraw = false;
|
m_specificDraw = false;
|
||||||
|
ewol::widgetManager::Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::Widget::~Widget(void)
|
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) {
|
if (-1 != m_inputEvent[iii].widgetCall) {
|
||||||
ewol::Widget * tmpWidget = NULL;
|
ewol::Widget * tmpWidget = NULL;
|
||||||
//tmpWidget = ewol::GetWidgetWithID(newEvent.widgetCall);
|
//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) {
|
if (true == ended) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -132,10 +132,6 @@ namespace ewol {
|
|||||||
public:
|
public:
|
||||||
Widget(void);
|
Widget(void);
|
||||||
virtual ~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:
|
private:
|
||||||
ewol::Widget * m_parrent; //!< parrent of the current widget (if NULL ==> this is the main node(root))
|
ewol::Widget * m_parrent; //!< parrent of the current widget (if NULL ==> this is the main node(root))
|
||||||
|
@ -27,3 +27,70 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol::WidgetManager"
|
#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 <ewolDebug.h>
|
||||||
#include <ewolOObject.h>
|
#include <ewolOObject.h>
|
||||||
#include <etkVectorType.h>
|
#include <etkVectorType.h>
|
||||||
#include <etkSingleton.h>
|
#include <ewolWidget.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class widgetManager: public etk::Singleton
|
namespace widgetManager {
|
||||||
{
|
void Init( void);
|
||||||
friend
|
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
|
eol
|
||||||
2DColor
|
# Mode of reading file: "Text" / "Bin"
|
||||||
text
|
Mode=Text
|
||||||
|
# type of the file : "Single" / "Multiple"
|
||||||
|
FileType=Single
|
||||||
|
# Version :
|
||||||
|
version=1.0
|
||||||
|
|
||||||
elem="myLine"
|
<element=plop>
|
||||||
type=line
|
# Number of sub frame of the element (default 1)
|
||||||
a=0.0
|
NbFrame=2
|
||||||
c=#51625351
|
# Element display Ratio : ratio = x/y (default 1.0)
|
||||||
p=0.2562;0.4532
|
Ratio=1.0
|
||||||
c=#51625351
|
# Clipping mode of the element
|
||||||
p=0.5245;0.5356
|
ClipX=false
|
||||||
|
ClipY=false
|
||||||
elem="myrect"
|
# Position of internal Elements ... (use only if clipping is enable
|
||||||
type=retangle
|
internalElemXStart=0.25
|
||||||
a=56.0
|
internalElemXStop=0.75
|
||||||
c=#536254FF
|
internalElemYStart=0.25
|
||||||
p=0.53;0.56
|
internalElemYStop=0.75
|
||||||
s=0.22;0.12
|
# 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