[DEV] Rework the library to support multiple instance (step 2)

This commit is contained in:
Edouard DUPIN 2013-08-29 21:50:41 +02:00
parent 1fd451961e
commit 4a8aa9f7b0
62 changed files with 689 additions and 2122 deletions

2
external/ege vendored

@ -1 +1 @@
Subproject commit c79473d01239d7192ae1b21287ba7e563cf4738f
Subproject commit c213ebb32b1379fc601ef8ee9adcecebb15ea04d

View File

@ -8,94 +8,9 @@
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#include <ewol/eObject/EObjectMessageMultiCast.h>
#include <ewol/debug.h>
#undef __class__
#define __class__ "EObjectMessageMultiCast"
extern "C" {
typedef struct {
const char* message;
ewol::EObject* object;
} messageList_ts;
};
// internal element of the widget manager :
static etk::Vector<messageList_ts> m_messageList; // all widget allocated ==> all time increment ... never removed ...
void ewol::EObjectMessageMultiCast::Init(void)
{
EWOL_INFO("EObject message Multi-Cast");
m_messageList.Clear();
}
void ewol::EObjectMessageMultiCast::UnInit(void)
{
EWOL_INFO("EObject message Multi-Cast");
m_messageList.Clear();
}
static void MultiCastAdd(ewol::EObject* _object, const char* const _message)
{
if (NULL == _object) {
EWOL_ERROR("Add with NULL object");
return;
}
if (NULL == _message) {
EWOL_ERROR("Add with NULL Message");
return;
}
messageList_ts tmpMessage;
tmpMessage.object = _object;
tmpMessage.message = _message;
m_messageList.PushBack(tmpMessage);
EWOL_DEBUG("SendMulticast ADD listener :" << _object->GetId() << " on \"" << _message << "\"" );
}
static void MultiCastRm(ewol::EObject* _object)
{
if (NULL == _object) {
EWOL_ERROR("Rm with NULL object");
return;
}
// send the message at all registered widget ...
for (int32_t iii=m_messageList.Size()-1; iii>=0; iii--) {
if(m_messageList[iii].object == _object) {
EWOL_DEBUG("SendMulticast RM listener :" << _object->GetId());
m_messageList[iii].message = NULL;
m_messageList[iii].object = NULL;
m_messageList.Erase(iii);
}
}
}
static void MultiCastSend(ewol::EObject* _object, const char* const _message, const etk::UString& _data)
{
EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to :");
// send the message at all registered widget ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if( m_messageList[iii].message == _message
&& m_messageList[iii].object != _object)
{
if (NULL != m_messageList[iii].object) {
EWOL_VERBOSE(" id = " << m_messageList[iii].object->GetId() << " type=" << m_messageList[iii].object->GetObjectType());
// generate event ... (create message before ...
ewol::EMessage tmpMsg(_object, m_messageList[iii].message, _data);
m_messageList[iii].object->OnReceiveMessage(tmpMsg);
}
}
}
}
void ewol::EObjectMessageMultiCast::AnonymousSend(const char* const _messageId, const etk::UString& _data)
{
MultiCastSend(NULL, _messageId, _data);
}
#include <ewol/renderer/os/eSystem.h>
#undef __class__
#define __class__ "ewol::EObject"
@ -111,15 +26,15 @@ ewol::EObject::EObject(void) :
// note this is nearly atomic ... (but it is enough)
m_uniqueId = ss_globalUniqueId++;
EWOL_DEBUG("new EObject : [" << m_uniqueId << "]");
ewol::EObjectManager::Add(this);
GetEObjectManager().Add(this);
RegisterConfig(ewol::EObject::configName, "string", NULL, "EObject name, might be a unique reference in all the program");
}
ewol::EObject::~EObject(void)
{
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
ewol::EObjectManager::Rm(this);
MultiCastRm(this);
GetEObjectManager().Rm(this);
GetEObjectMessageMultiCast().Rm(this);
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
delete(m_externEvent[iii]);
@ -134,11 +49,11 @@ ewol::EObject::~EObject(void)
void ewol::EObject::AutoDestroy(void)
{
ewol::EObjectManager::AutoRemove(this);
GetEObjectManager().AutoRemove(this);
}
void ewol::EObject::RemoveObject(void)
{
ewol::EObjectManager::AutoRemove(this);
GetEObjectManager().AutoRemove(this);
}
void ewol::EObject::AddEventId(const char * _generateEventId)
@ -150,7 +65,7 @@ void ewol::EObject::AddEventId(const char * _generateEventId)
void ewol::EObject::GenerateEventId(const char * _generateEventId, const etk::UString& _data)
{
int32_t nbObject = ewol::EObjectManager::GetNumberObject();
int32_t nbObject = GetEObjectManager().GetNumberObject();
// for every element registered ...
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
@ -169,23 +84,23 @@ void ewol::EObject::GenerateEventId(const char * _generateEventId, const etk::US
}
}
}
if (nbObject > ewol::EObjectManager::GetNumberObject()) {
if (nbObject > GetEObjectManager().GetNumberObject()) {
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->RemoveObject() which is asynchronous");
}
}
void ewol::EObject::SendMultiCast(const char* const _messageId, const etk::UString& _data)
{
int32_t nbObject = ewol::EObjectManager::GetNumberObject();
MultiCastSend(this, _messageId, _data);
if (nbObject > ewol::EObjectManager::GetNumberObject()) {
int32_t nbObject = GetEObjectManager().GetNumberObject();
GetEObjectMessageMultiCast().Send(this, _messageId, _data);
if (nbObject > GetEObjectManager().GetNumberObject()) {
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->RemoveObject() which is asynchronous");
}
}
void ewol::EObject::RegisterMultiCast(const char* const _messageId)
{
MultiCastAdd(this, _messageId);
GetEObjectMessageMultiCast().Add(this, _messageId);
}
void ewol::EObject::RegisterOnEvent(ewol::EObject * _destinationObject,
@ -375,7 +290,7 @@ etk::UString ewol::EObject::GetConfig(const etk::UString& _config) const
bool ewol::EObject::SetConfigNamed(const etk::UString& _name, const ewol::EConfig& _conf)
{
ewol::EObject* object = ewol::EObjectManager::Get(_name);
ewol::EObject* object = GetEObjectManager().Get(_name);
if (object == NULL) {
return false;
}
@ -384,7 +299,7 @@ bool ewol::EObject::SetConfigNamed(const etk::UString& _name, const ewol::EConfi
bool ewol::EObject::SetConfigNamed(const etk::UString& _name, const etk::UString& _config, const etk::UString& _value)
{
ewol::EObject* object = ewol::EObjectManager::Get(_name);
ewol::EObject* object = GetEObjectManager().Get(_name);
if (object == NULL) {
return false;
}
@ -392,3 +307,17 @@ bool ewol::EObject::SetConfigNamed(const etk::UString& _name, const etk::UString
}
ewol::EObjectManager& ewol::EObject::GetEObjectManager(void)
{
return ewol::eSystem::GetSystem().GetEObjectManager();
}
ewol::EObjectMessageMultiCast& ewol::EObject::GetEObjectMessageMultiCast(void)
{
return ewol::eSystem::GetSystem().GetEObjectMessageMultiCast();
}
ewol::eSystem& ewol::EObject::GetSystem(void)
{
return ewol::eSystem::GetSystem();
}

View File

@ -16,17 +16,15 @@
namespace ewol {
// some class need to define element befor other ...
class EObject;
class EObjectManager;
class EObjectMessageMultiCast;
class eSystem;
};
#include <ewol/eObject/EConfig.h>
#include <ewol/eObject/EMessage.h>
namespace ewol {
namespace EObjectMessageMultiCast {
void Init(void);
void UnInit(void);
void AnonymousSend(const char* const _messageId, const etk::UString& _data);
};
/**
* local class for event generation
@ -220,9 +218,26 @@ namespace ewol {
* @return false : An error occured.
*/
virtual bool StoreXML(exml::Element* _node) const;
public:
/**
* @breif Get the current EObject manager.
* @return the requested object manager.
*/
ewol::EObjectManager& GetEObjectManager(void);
/**
* @breif Get the current EObject Message Multicast manager.
* @return the requested object manager.
*/
ewol::EObjectMessageMultiCast& GetEObjectMessageMultiCast(void);
/**
* @brief Get the curent the system inteface.
* @return current reference on the instance.
*/
eSystem& GetSystem(void);
};
};
#endif

View File

@ -19,7 +19,6 @@ ewol::EObjectManager::EObjectManager(void)
// Can create mlemory leak ... ==> but not predictable comportement otherwise ...
m_eObjectAutoRemoveList.Clear();
m_eObjectList.Clear();
IsInit = true;
}
ewol::EObjectManager::~EObjectManager(void)
@ -41,8 +40,6 @@ ewol::EObjectManager::~EObjectManager(void)
m_eObjectList.Erase(iii);
}
}
IsInit = false;
}
void ewol::EObjectManager::Add(ewol::EObject* _object)
@ -59,7 +56,7 @@ int32_t ewol::EObjectManager::GetNumberObject(void)
return m_eObjectList.Size() + m_eObjectAutoRemoveList.Size();
}
void informOneObjectIsRemoved(ewol::EObject* _object)
void ewol::EObjectManager::informOneObjectIsRemoved(ewol::EObject* _object)
{
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] != NULL) {
@ -73,7 +70,7 @@ void informOneObjectIsRemoved(ewol::EObject* _object)
}
}
// call input event manager to remove linked widget ...
eSystem::OnObjectRemove(_object);
ewol::eSystem::GetSystem().OnObjectRemove(_object);
}
void ewol::EObjectManager::Rm(ewol::EObject* _object)
@ -116,7 +113,7 @@ void ewol::EObjectManager::AutoRemove(ewol::EObject* _object)
EWOL_DEBUG("Auto-Remove EObject : [" << _object->GetId() << "] type=\"" << _object->GetObjectType() << "\"");
informOneObjectIsRemoved(_object);
m_eObjectAutoRemoveList.PushBack(_object);
ewol::ForceRedrawAll();
ewol::eSystem::GetSystem().ForceRedrawAll();
return;
}
}

View File

@ -30,6 +30,8 @@ namespace ewol
void RemoveAllAutoRemove(void);
ewol::EObject* Get(const etk::UString& _name);
private:
void informOneObjectIsRemoved(ewol::EObject* _object);
};
};

View File

@ -0,0 +1,79 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/eObject/EObjectMessageMultiCast.h>
#include <ewol/renderer/os/eSystem.h>
#undef __class__
#define __class__ "EObjectMessageMultiCast"
ewol::EObjectMessageMultiCast::EObjectMessageMultiCast(void)
{
EWOL_INFO("EObject message Multi-Cast");
}
ewol::EObjectMessageMultiCast::~EObjectMessageMultiCast(void)
{
EWOL_INFO("EObject message Multi-Cast");
m_messageList.Clear();
}
void ewol::EObjectMessageMultiCast::Add(ewol::EObject* _object, const char* const _message)
{
if (NULL == _object) {
EWOL_ERROR("Add with NULL object");
return;
}
if (NULL == _message) {
EWOL_ERROR("Add with NULL Message");
return;
}
m_messageList.PushBack(MessageList(_message, _object));
EWOL_DEBUG("SendMulticast ADD listener :" << _object->GetId() << " on \"" << _message << "\"" );
}
void ewol::EObjectMessageMultiCast::Rm(ewol::EObject* _object)
{
if (NULL == _object) {
EWOL_ERROR("Rm with NULL object");
return;
}
// send the message at all registered widget ...
for (int32_t iii=m_messageList.Size()-1; iii>=0; iii--) {
if(m_messageList[iii].m_object == _object) {
EWOL_DEBUG("SendMulticast RM listener :" << _object->GetId());
m_messageList[iii].m_message = NULL;
m_messageList[iii].m_object = NULL;
m_messageList.Erase(iii);
}
}
}
void ewol::EObjectMessageMultiCast::Send(ewol::EObject* _object, const char* const _message, const etk::UString& _data)
{
EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to :");
// send the message at all registered widget ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if( m_messageList[iii].m_message == _message
&& m_messageList[iii].m_object != _object)
{
if (NULL != m_messageList[iii].m_object) {
EWOL_VERBOSE(" id = " << m_messageList[iii].m_object->GetId() << " type=" << m_messageList[iii].m_object->GetObjectType());
// generate event ... (create message before ...
ewol::EMessage tmpMsg(_object, m_messageList[iii].m_message, _data);
m_messageList[iii].m_object->OnReceiveMessage(tmpMsg);
}
}
}
}

View File

@ -0,0 +1,40 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_E_OBJECT_MESSAGE_MULTICAST_H__
#define __EWOL_E_OBJECT_MESSAGE_MULTICAST_H__
#include <etk/types.h>
#include <etk/UString.h>
#include <etk/Vector.h>
#include <exml/exml.h>
#include <ewol/eObject/EObject.h>
namespace ewol {
class EObjectMessageMultiCast
{
private:
class MessageList {
public:
MessageList(const char* _message=NULL, ewol::EObject* _object=NULL) : m_message(_message), m_object(_object) { }
const char* m_message;
ewol::EObject* m_object;
};
etk::Vector<MessageList> m_messageList; //!< List of all message ...
public:
EObjectMessageMultiCast(void);
~EObjectMessageMultiCast(void);
void AnonymousSend(const char* const _messageId, const etk::UString& _data) { Send(NULL, _messageId, _data); };
void Send(ewol::EObject* _object, const char* const _message, const etk::UString& _data);
void Rm(ewol::EObject* _object);
void Add(ewol::EObject* _object, const char* const _message);
};
};
#endif

View File

@ -67,12 +67,34 @@ int32_t ewol::Run(int32_t _argc, const char* _argv[])
return error;
}
/*
void ewol::Stop(void)
etk::UString ewol::GetCompilationMode(void)
{
guiInterface::Stop();
#ifdef MODE_RELEASE
return "Release";
#else
return "Debug";
#endif
}
etk::UString ewol::GetBoardType(void)
{
#ifdef __TARGET_OS__Linux
return "Linux";
#elif defined(__TARGET_OS__Android)
return "Android";
#elif defined(__TARGET_OS__Windows)
return "Windows";
#elif defined(__TARGET_OS__IOs)
return "IOs";
#elif defined(__TARGET_OS__MacOs)
return "MacOs";
#else
return "Unknown";
#endif
}
/*
void ewol::WindowsSet(ewol::Windows* _windows)
{

View File

@ -36,6 +36,17 @@ namespace ewol
* @return The current time
*/
int64_t GetTime(void);
/**
* @brief Get compilation mode (release/debug)
* @return the string of the mode of commpilation
*/
etk::UString GetCompilationMode(void);
/**
* @brief Get the board type ()
* @return the string of the mode of commpilation
*/
etk::UString GetBoardType(void);
typedef enum {
SCREEN_ORIENTATION_AUTO = 0,
SCREEN_ORIENTATION_LANDSCAPE,

View File

@ -1,54 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/game/Camera.h>
#include <ewol/debug.h>
void game::Camera::Update(void)
{
m_matrix.Identity();
m_matrix.Rotate(vec3(0,0,1), M_PI/2.0 );
m_matrix.Rotate(vec3(0,1,0), M_PI/2.0 );
m_matrix.Rotate(vec3(1,0,0), m_angles.x() );
m_matrix.Rotate(vec3(0,1,0), m_angles.y() );
m_matrix.Rotate(vec3(0,0,1), m_angles.z() );
vec3 tmpp = m_position * -1;
m_matrix.Translate(tmpp);
m_needUpdate = false;
//EWOL_DEBUG("camera: pos=" << m_position << " angle=" << m_angles);
}
game::Camera::Camera(vec3 pos, vec3 angles) :
m_position(pos),
m_angles(angles)
{
m_needUpdate = true;
}
void game::Camera::SetPosition(vec3 pos)
{
m_needUpdate = true;
m_position = pos;
}
void game::Camera::SetAngle(vec3 angles)
{
m_needUpdate = true;
m_angles = angles;
}
mat4& game::Camera::GetMatrix(void)
{
if(m_needUpdate==true) {
Update();
}
return m_matrix;
};

View File

@ -1,67 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __GAME_CAMERA_H__
#define __GAME_CAMERA_H__
#include <etk/types.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Matrix4.h>
namespace game
{
class Camera
{
private:
vec3 m_position; //!< position of the camera.
vec3 m_angles; //!< Angles to the camera is seing.
mat4 m_matrix; //!< transformation matrix.
bool m_needUpdate; //!< matrix is nor anymore correct...
/**
* @brief Update the matrix property
*/
void Update(void);
public:
/**
* @brief Constructor.
* @param[in] pos Position of the camera.
* @param[in] angles Rotations angles of the camera
*/
Camera(vec3 pos=vec3(0,0,0), vec3 angles=vec3(0,0,0));
/**
* @brief Set the position of the camera.
* @param[in] pos Position of the camera.
*/
void SetPosition(vec3 pos);
/**
* @brief Get the curent Camera position.
* @return the current position.
*/
vec3& GetPosition(void) { return m_position; };
/**
* @brief Set the angle on the camera
* @param[in] angles Rotations angles of the camera
*/
void SetAngle(vec3 angles);
/**
* @brief Get the curent Camera angles.
* @return the current angles.
*/
vec3& GetAngle(void) { return m_angles; };
/**
* @brief Get the transformation matix for the camera.
* @return the current transformation matrix
*/
mat4& GetMatrix(void);
};
};
#endif

View File

@ -83,7 +83,8 @@ void ewol::resource::ReLoadResources(void)
}
}
}
ewol::RequestUpdateSize();
// TODO : UNderstand why it is set here ...
//ewol::RequestUpdateSize();
EWOL_INFO("------------- Resources -------------");
}

View File

@ -28,11 +28,62 @@
#include <ewol/widget/WidgetManager.h>
#include <etk/os/FSNode.h>
#include <etk/os/Mutex.h>
#include <date/date.h>
/**
* @brief Get the main ewol mutex (event or periodic call mutex).
* @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time.
* @return the main inteface Mutex
*/
static etk::Mutex& MutexInterface(void)
{
static etk::Mutex s_interfaceMutex;
return s_interfaceMutex;
}
/**
* @brief Get the draw mutex (ewol render).
* @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time.
* @return the main inteface Mutex
*/
static etk::Mutex& MutexDraw(void)
{
static etk::Mutex s_drawMutex;
return s_drawMutex;
}
static ewol::eSystem* l_curentInterface=NULL;
ewol::eSystem& ewol::eSystem::GetSystem(void)
{
#if DEBUG_LEVEL > 2
if(NULL == l_curentInterface){
EWOL_CRITICAL("[CRITICAL] try acces at an empty interface");
}
#endif
return *l_curentInterface;
}
/**
* @brief Set the curent interface.
* @note this lock the main mutex
*/
void ewol::eSystem::SetSystem(void)
{
MutexInterface().Lock();
l_curentInterface = this;
}
/**
* @brief Set the curent interface at NULL.
* @note this un-lock the main mutex
*/
void ewol::eSystem::ReleaseSystem(void)
{
l_curentInterface = NULL;
MutexInterface().UnLock();
}
void ewol::eSystem::InputEventTransfertWidget(ewol::Widget* source, ewol::Widget* destination)
{
@ -63,7 +114,7 @@ void ewol::eSystem::ProcessEvents(void)
switch (data.TypeMessage) {
case THREAD_INIT:
// this is due to the openGL context
APP_Init();
/*bool returnVal = */APP_Init(*this);
break;
case THREAD_RECALCULATE_SIZE:
eSystem::ForceRedrawAll();
@ -96,7 +147,7 @@ void ewol::eSystem::ProcessEvents(void)
data.keyboardMove,
data.stateIsDown) ) {
// Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
ewol::Widget * tmpWidget = m_widgetManager.FocusGet();
if (NULL != tmpWidget) {
// check if the widget allow repeating key events.
//EWOL_DEBUG("repeating test :" << data.repeateKey << " widget=" << tmpWidget->GetKeyboardRepeate() << " state=" << data.stateIsDown);
@ -133,7 +184,7 @@ void ewol::eSystem::ProcessEvents(void)
break;
case THREAD_CLIPBOARD_ARRIVE:
{
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
ewol::Widget * tmpWidget = m_widgetManager.FocusGet();
if (tmpWidget != NULL) {
tmpWidget->OnEventClipboard(data.clipboardID);
}
@ -194,17 +245,15 @@ ewol::eSystem::eSystem(void) :
m_windowsSize(320,480)
{
EWOL_INFO("==> Ewol System Init (BEGIN)");
// set the curent interface :
SetSystem();
EWOL_INFO("v:" << ewol::GetVersion());
EWOL_INFO("Build Date: " << date::GetYear() << "/" << date::GetMonth() << "/" << date::GetDay() << " " << date::GetHour() << "h" << date::GetMinute());
// TODO : Remove this ...
etk::InitDefaultFolder("ewolApplNoName");
// TODO : Remove all of this gloabals ...
ewol::openGL::Init();
ewol::EObjectManager::Init();
ewol::EObjectMessageMultiCast::Init();
m_managementInput.Reset();
ewol::resource::Init();
ewol::widgetManager::Init();
ewol::config::Init();
// request the init of the application in the main context of openGL ...
{
@ -221,24 +270,26 @@ ewol::eSystem::eSystem(void) :
#else
ForceOrientation(ewol::SCREEN_ORIENTATION_AUTO);
#endif
// release the curent interface :
ReleaseSystem();
EWOL_INFO("==> Ewol System Init (END)");
}
ewol::eSystem::~eSystem(void)
{
EWOL_INFO("==> Ewol System Un-Init (BEGIN)");
// set the curent interface :
SetSystem();
// call application to uninit
APP_UnInit();
APP_UnInit(*this);
// unset all windows
SetCurrentWindows(NULL);
ewol::widgetManager::UnInit();
m_windowsCurrent = NULL;
ewol::config::UnInit();
ewol::EObjectMessageMultiCast::UnInit();
ewol::EObjectManager::UnInit();
ewol::resource::UnInit();
ewol::openGL::UnInit();
m_managementInput.Reset();
m_msgSystem.Clean();
// release the curent interface :
ReleaseSystem();
EWOL_INFO("==> Ewol System Un-Init (END)");
}
@ -382,54 +433,68 @@ bool ewol::eSystem::OS_Draw(bool _displayEveryTime)
// process the events
m_FpsSystemEvent.Tic();
ProcessEvents();
// call all the widget that neded to do something periodicly
ewol::widgetManager::PeriodicCall(currentTime);
// Remove all widget that they are no more usefull (these who decided to destroy themself)
ewol::EObjectManager::RemoveAllAutoRemove();
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
// check if the user selected a windows
if (NULL != tmpWindows) {
// Redraw all needed elements
tmpWindows->OnRegenerateDisplay();
}
m_FpsSystemEvent.IncrementCounter();
m_FpsSystemEvent.Toc();
bool needRedraw = ewol::widgetManager::IsDrawingNeeded();
m_FpsSystemContext.Tic();
if (NULL != tmpWindows) {
if( true == needRedraw
|| true == _displayEveryTime) {
ewol::resource::UpdateContext();
m_FpsSystemContext.IncrementCounter();
bool needRedraw = false;
//! Event management section ...
{
// set the curent interface :
SetSystem();
ProcessEvents();
// call all the widget that neded to do something periodicly
//! ewol::widgetManager::PeriodicCall(currentTime);
m_widgetManager.PeriodicCall(currentTime);
// Remove all widget that they are no more usefull (these who decided to destroy themself)
//! ewol::EObjectManager::RemoveAllAutoRemove();
m_EObjectManager.RemoveAllAutoRemove();
// check if the user selected a windows
if (NULL != m_windowsCurrent) {
// Redraw all needed elements
m_windowsCurrent->OnRegenerateDisplay();
}
m_FpsSystemEvent.IncrementCounter();
m_FpsSystemEvent.Toc();
//! bool needRedraw = ewol::widgetManager::IsDrawingNeeded();
needRedraw = m_widgetManager.IsDrawingNeeded();
// release the curent interface :
ReleaseSystem();
}
m_FpsSystemContext.Toc();
bool hasDisplayDone = false;
m_FpsSystem.Tic();
if (NULL != tmpWindows) {
if( true == needRedraw
|| true == _displayEveryTime) {
m_FpsSystem.IncrementCounter();
tmpWindows->SysDraw();
hasDisplayDone = true;
//! Drawing section :
{
// Lock OpenGl context:
MutexDraw().Lock();
m_FpsSystemContext.Tic();
if (NULL != m_windowsCurrent) {
if( true == needRedraw
|| true == _displayEveryTime) {
ewol::resource::UpdateContext();
m_FpsSystemContext.IncrementCounter();
}
}
m_FpsSystemContext.Toc();
m_FpsSystem.Tic();
if (NULL != m_windowsCurrent) {
if( true == needRedraw
|| true == _displayEveryTime) {
m_FpsSystem.IncrementCounter();
m_windowsCurrent->SysDraw();
hasDisplayDone = true;
}
}
m_FpsSystem.Toc();
m_FpsFlush.Tic();
m_FpsFlush.IncrementCounter();
glFlush();
//glFinish();
m_FpsFlush.Toc();
// Release Open GL Context
MutexDraw().UnLock();
}
m_FpsSystem.Toc();
m_FpsFlush.Tic();
m_FpsFlush.IncrementCounter();
glFlush();
//glFinish();
m_FpsFlush.Toc();
m_FpsSystemEvent.Draw();
m_FpsSystemContext.Draw();
m_FpsSystem.Draw();
m_FpsFlush.Draw();
return hasDisplayDone;
return false;
}
/*
@ -451,7 +516,7 @@ void ewol::eSystem::OS_OpenGlContextDestroy(void)
}
void ewol::eSystem::SetCurrentWindows(ewol::Windows* _windows)
void ewol::eSystem::SetWindows(ewol::Windows* _windows)
{
// set the new pointer as windows system
m_windowsCurrent = _windows;

View File

@ -17,6 +17,9 @@
#include <ewol/renderer/os/eSystemInput.h>
#include <ewol/renderer/os/Fps.h>
#include <etk/MessageFifo.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/eObject/EObjectManager.h>
#include <ewol/eObject/EObjectMessageMultiCast.h>
// TODO : Remove this from here ...
@ -74,9 +77,38 @@ namespace ewol
{
class eSystem
{
private:
ewol::WidgetManager m_widgetManager; //!< global widget manager
public:
ewol::WidgetManager& GetWidgetManager(void) { return m_widgetManager; };
private:
ewol::EObjectManager m_EObjectManager; //!< eObject Manager main instance
public:
ewol::EObjectManager& GetEObjectManager(void) { return m_EObjectManager; };
private:
ewol::EObjectMessageMultiCast m_MessageMulticast; //!< global message multicastiong system
public:
ewol::EObjectMessageMultiCast& GetEObjectMessageMultiCast(void) { return m_MessageMulticast; };
public:
eSystem(void);
virtual ~eSystem(void);
public:
/**
* @brief From everyware in the program, we can get the system inteface.
* @return curent pointer on the instance.
*/
static eSystem& GetSystem(void);
protected:
/**
* @brief Set the curent interface.
* @note this lock the main mutex
*/
void SetSystem(void);
/**
* @brief Set the curent interface at NULL.
* @note this un-lock the main mutex
*/
void ReleaseSystem(void);
private:
int64_t m_previousDisplayTime; // this is to limit framerate ... in case...
ewol::eSystemInput m_managementInput;
@ -117,10 +149,12 @@ namespace ewol
bool OS_Draw(bool _displayEveryTime);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @param[in] removeObject Pointer on the EObject removed ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
*/
void OnObjectRemove(ewol::EObject * removeObject);
void OnObjectRemove(ewol::EObject * removeObject) {
// TODO : I did not remember what I must do ...
};
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
@ -136,7 +170,7 @@ namespace ewol
/**
* @brief The application request that the Window will be killed
*/
virtual void Stop(void);
virtual void Stop(void) { };
private:
ewol::Windows* m_windowsCurrent; //!< curent displayed windows
public:
@ -144,12 +178,12 @@ namespace ewol
* @brief set the current windows to display :
* @param _windows Windows that might be displayed
*/
void SetCurrentWindows(ewol::Windows* _windows);
void SetWindows(ewol::Windows* _windows);
/**
* @brief Get the current windows that is displayed
* @return the current handle on the windows (can be null)
*/
ewol::Windows* GetCurrentWindows(void) { return m_windowsCurrent; };
ewol::Windows* GetWindows(void) { return m_windowsCurrent; };
private:
vec2 m_windowsSize; //!< current size of the system
public:
@ -219,11 +253,11 @@ namespace ewol
/**
* @brief Display the virtal keyboard (for touch system only)
*/
void KeyboardShow(void);
void KeyboardShow(void) {};
/**
* @brief Hide the virtal keyboard (for touch system only)
*/
void KeyboardHide(void);
void KeyboardHide(void) {};
/**
* @brief Inform the Gui that we want to have a copy of the clipboard
@ -293,9 +327,9 @@ namespace ewol
};
//!< must be define in CPP by the application ... this are the main init and unInit of the Application
ewol::Windows* APP_Init(void);
void APP_UnInit(void);
// return false if an error occured
bool APP_Init(ewol::eSystem& _system);
void APP_UnInit(ewol::eSystem& _system);
#endif

View File

@ -170,29 +170,23 @@ void ewol::eSystemInput::NewLayerSet(void)
}
}
void ewol::eSystemInput::Reset(void)
{
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ...
CleanElement(m_eventInputSaved, iii);
CleanElement(m_eventMouseSaved, iii);
}
}
ewol::eSystemInput::eSystemInput(ewol::eSystem& _system) :
m_grabWidget(NULL),
m_system(_system)
{
SetDpi(200);
EWOL_INFO("Init (start)");
Reset();
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ...
CleanElement(m_eventInputSaved, iii);
CleanElement(m_eventMouseSaved, iii);
}
EWOL_INFO("Init (end)");
}
ewol::eSystemInput::~eSystemInput(void)
{
EWOL_INFO("Un-Init (start)");
Reset();
EWOL_INFO("Un-Init (end)");
}
@ -237,7 +231,7 @@ void ewol::eSystemInput::Motion(ewol::keyEvent::type_te type, int pointerID, vec
// not manage input
return;
}
ewol::Windows* tmpWindows = m_system.GetCurrentWindows();
ewol::Windows* tmpWindows = m_system.GetWindows();
// special case for the mouse event 0 that represent the hover event of the system :
if (type == ewol::keyEvent::typeMouse && pointerID == 0) {
// this event is all time on the good widget ... and manage the enter and leave ...
@ -337,7 +331,7 @@ void ewol::eSystemInput::State(ewol::keyEvent::type_te type, int pointerID, bool
}
// get the curent time ...
int64_t currentTime = ewol::GetTime();
ewol::Windows* tmpWindows = m_system.GetCurrentWindows();
ewol::Windows* tmpWindows = m_system.GetWindows();
if (true == isDown) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos);

View File

@ -80,7 +80,6 @@ namespace ewol
public:
eSystemInput(ewol::eSystem& _system);
~eSystemInput(void);
void Reset(void);
void SetDpi(int32_t newDPI);
// note if id<0 ==> the it was finger event ...

View File

@ -9,7 +9,7 @@
#include <ewol/ewol.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/renderer/os/eSystem.h>
#undef __class__
#define __class__ "Button"
@ -40,14 +40,9 @@ static ewol::Widget* Create(void)
return new widget::Button();
}
void widget::Button::Init(void)
void widget::Button::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Button::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
widget::Button::Button(const etk::UString& _shaperName) :
@ -111,7 +106,7 @@ void widget::Button::SetSubWidget(ewol::Widget* _subWidget)
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
RequestUpdateSize();
MarkToRedraw();
}
@ -129,7 +124,7 @@ void widget::Button::SetSubWidgetToggle(ewol::Widget* _subWidget)
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
RequestUpdateSize();
}
void widget::Button::CalculateSize(const vec2& _availlable)
@ -449,8 +444,8 @@ bool widget::Button::LoadXML(exml::Element* _element)
continue;
}
etk::UString widgetName = pNode->GetValue();
if (ewol::widgetManager::Exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->GetPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
if (GetWidgetManager().Exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->GetPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << GetWidgetManager().List() << "]" );
continue;
}
bool toogleMode=false;
@ -462,7 +457,7 @@ bool widget::Button::LoadXML(exml::Element* _element)
}
}
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName);
ewol::Widget* tmpWidget = GetWidgetManager().Create(widgetName);
if (tmpWidget == NULL) {
EWOL_ERROR ("(l "<<pNode->GetPos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;

View File

@ -16,6 +16,7 @@
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Image.h>
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
@ -25,8 +26,7 @@ namespace widget {
class Button : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
// Event list of properties
static const char* const eventPressed;
static const char* const eventDown;

View File

@ -12,8 +12,9 @@
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/widget/meta/ColorChooser.h>
#include <ewol/widget/Windows.h>
#include <ewol/ewol.h>
#include <ewol/renderer/os/eSystem.h>
extern const char * const ewolEventButtonColorChange = "ewol-Button-Color-Change";
@ -35,17 +36,11 @@ static ewol::Widget* Create(void)
return new widget::ButtonColor();
}
void widget::ButtonColor::Init(void)
void widget::ButtonColor::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
void widget::ButtonColor::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::ButtonColor::ButtonColor(etk::Color<> baseColor, etk::UString shaperName) :
m_shaper(shaperName),
m_textColorFg(baseColor),
@ -203,7 +198,14 @@ bool widget::ButtonColor::OnEventInput(const ewol::EventInput& _event)
// set it in the pop-up-system :
m_widgetContextMenu->SetSubWidget(myColorChooser);
myColorChooser->RegisterOnEvent(this, ewolEventColorChooserChange, ewolEventColorChooserChange);
ewol::WindowsPopUpAdd(m_widgetContextMenu);
ewol::Windows* currentWindows = GetWindows();
if (NULL == currentWindows) {
EWOL_ERROR("Can not get the curent Windows...");
delete(m_widgetContextMenu);
m_widgetContextMenu=NULL;
} else {
currentWindows->PopUpWidgetPush(m_widgetContextMenu);
}
MarkToRedraw();
}
}

View File

@ -16,6 +16,7 @@
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h>
extern const char * const ewolEventButtonColorChange;
@ -23,8 +24,7 @@ namespace widget {
class ButtonColor : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Text m_text; //!< Compositing Test display.

View File

@ -20,17 +20,11 @@ static ewol::Widget* Create(void)
return new widget::CheckBox();
}
void widget::CheckBox::Init(void)
void widget::CheckBox::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
void widget::CheckBox::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::CheckBox::CheckBox(const etk::UString& newLabel)
{
m_label = newLabel;
@ -127,7 +121,7 @@ bool widget::CheckBox::OnEventInput(const ewol::EventInput& _event)
m_value = true;
GenerateEventId(ewolEventCheckBoxClicked, "true");
}
ewol::widgetManager::FocusKeep(this);
KeepFocus();
MarkToRedraw();
return true;
}

View File

@ -14,6 +14,7 @@
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h>
extern const char* const ewolEventCheckBoxClicked;
@ -21,8 +22,7 @@ namespace widget {
class CheckBox : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
public:
CheckBox(const etk::UString& newLabel = "No Label");
virtual ~CheckBox(void);

View File

@ -43,7 +43,7 @@ void widget::Container::SetSubWidget(ewol::Widget* _newWidget)
m_subWidget->SetUpperWidget(this);
}
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
@ -57,7 +57,7 @@ void widget::Container::SubWidgetRemove(void)
EWOL_ERROR("Composer : An error Occured when removing main node");
}
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
}
@ -68,7 +68,7 @@ void widget::Container::SubWidgetRemoveDelayed(void)
m_subWidget->RemoveObject();
m_subWidget=NULL;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
}
@ -89,7 +89,7 @@ void widget::Container::OnObjectRemove(ewol::EObject* _removeObject)
if (m_subWidget==_removeObject) {
m_subWidget=NULL;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
}
@ -184,8 +184,8 @@ bool widget::Container::LoadXML(exml::Element* _node)
continue;
}
etk::UString widgetName = pNode->GetValue();
if (ewol::widgetManager::Exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->GetPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
if (GetWidgetManager().Exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->GetPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << GetWidgetManager().List() << "]" );
continue;
}
if (NULL != GetSubWidget()) {
@ -193,7 +193,7 @@ bool widget::Container::LoadXML(exml::Element* _node)
continue;
}
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName);
ewol::Widget* tmpWidget = GetWidgetManager().Create(widgetName);
if (tmpWidget == NULL) {
EWOL_ERROR ("(l "<<pNode->GetPos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;

View File

@ -50,7 +50,7 @@ void widget::ContainerN::LockExpand(const bvec2& _lockExpand)
if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
}
@ -66,7 +66,7 @@ int32_t widget::ContainerN::SubWidgetAdd(ewol::Widget* _newWidget)
}
m_subWidget.PushBack(_newWidget);
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
// added at the last eelement :
return _newWidget->GetId();
}
@ -82,7 +82,7 @@ int32_t widget::ContainerN::SubWidgetAddStart(ewol::Widget* _newWidget)
}
m_subWidget.PushFront(_newWidget);
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
return _newWidget->GetId();
}
@ -103,7 +103,7 @@ void widget::ContainerN::SubWidgetRemove(ewol::Widget* _newWidget)
m_subWidget.Erase(iii);
}
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
return;
}
}
@ -120,7 +120,7 @@ void widget::ContainerN::SubWidgetUnLink(ewol::Widget* _newWidget)
m_subWidget[iii] = NULL;
m_subWidget.Erase(iii);
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
return;
}
}
@ -310,12 +310,12 @@ bool widget::ContainerN::LoadXML(exml::Element* _node)
continue;
}
etk::UString widgetName = pNode->GetValue();
if (ewol::widgetManager::Exist(widgetName) == false) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->GetPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
if (GetWidgetManager().Exist(widgetName) == false) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->GetPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << GetWidgetManager().List() << "]" );
continue;
}
EWOL_DEBUG("[" << GetId() << "] {" << GetObjectType() << "} load new element : \"" << widgetName << "\"");
ewol::Widget *subWidget = ewol::widgetManager::Create(widgetName);
ewol::Widget *subWidget = GetWidgetManager().Create(widgetName);
if (subWidget == NULL) {
EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->GetPos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;

View File

@ -25,14 +25,9 @@ static ewol::Widget* Create(void)
return new widget::ContextMenu();
}
void widget::ContextMenu::Init(void)
void widget::ContextMenu::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::ContextMenu::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}

View File

@ -15,6 +15,7 @@
#include <ewol/widget/Container.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
typedef enum {
@ -27,8 +28,7 @@ namespace widget {
class ContextMenu : public widget::Container
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configArrowPosition;
static const char* const configArrowMode;

View File

@ -10,6 +10,7 @@
#include <ewol/widget/Entry.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/ewol.h>
#include <ewol/renderer/os/eSystem.h>
@ -33,14 +34,9 @@ static ewol::Widget* Create(void)
return new widget::Entry();
}
void widget::Entry::Init(void)
void widget::Entry::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Entry::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
const char * const widget::Entry::eventClick = "ewol-widget-entry-event-click";
@ -560,7 +556,7 @@ void widget::Entry::OnGetFocus(void)
{
m_displayCursor = true;
ChangeStatusIn(STATUS_SELECTED);
ewol::Keyboard(true);
GetSystem().KeyboardShow();
MarkToRedraw();
}
@ -569,7 +565,7 @@ void widget::Entry::OnLostFocus(void)
{
m_displayCursor = false;
ChangeStatusIn(STATUS_NORMAL);
ewol::Keyboard(false);
GetSystem().KeyboardHide();
MarkToRedraw();
}

View File

@ -17,6 +17,7 @@
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/Widget.h>
#include <etk/Color.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
@ -42,8 +43,7 @@ namespace widget {
static const char* const configColorBg;
static const char* const configEmptyMessage;
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
private:
ewol::Shaper m_shaper;
ewol::Text m_oObjectText; //!< text display m_text

View File

@ -20,14 +20,9 @@ static ewol::Widget* Create(void)
return new widget::Gird();
}
void widget::Gird::Init(void)
void widget::Gird::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Gird::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
@ -38,7 +33,7 @@ widget::Gird::Gird(int32_t colNumber) :
m_borderSize(0,0)
{
SetColNumber(colNumber);
ewol::RequestUpdateSize();
RequestUpdateSize();
}
widget::Gird::~Gird(void)
@ -59,7 +54,7 @@ void widget::Gird::SetBorderSize(const ivec2& newBorderSize)
m_borderSize.setY(0);
}
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
void widget::Gird::CalculateSize(const vec2& availlable)

View File

@ -13,13 +13,13 @@
#include <etk/Vector.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class Gird :public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
private:
class GirdProperties {
public:

View File

@ -21,14 +21,9 @@ static ewol::Widget* Create(void)
return new widget::Image();
}
void widget::Image::Init(void)
void widget::Image::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Image::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
@ -73,7 +68,7 @@ void widget::Image::SetBorder(const ewol::Dimension& _border)
// Force redraw all :
MarkToRedraw();
// TODO : Change the size with no size requested ...
ewol::RequestUpdateSize();
RequestUpdateSize();
}
void widget::Image::SetKeepRatio(bool _keep)
@ -83,7 +78,7 @@ void widget::Image::SetKeepRatio(bool _keep)
m_keepRatio = _keep;
// Force redraw all :
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
}
@ -93,7 +88,7 @@ void widget::Image::SetImageSize(const ewol::Dimension& _size)
if (_size != m_imageSize) {
m_imageSize = _size;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
EWOL_VERBOSE("Set sources : " << m_fileName << " size=" << m_imageSize);
m_compositing.SetSource(m_fileName, m_imageSize.GetPixel());
}
@ -105,7 +100,7 @@ void widget::Image::Set(const etk::UString& _file, const ewol::Dimension& _borde
// copy data :
if (m_border != _border) {
m_border = _border;
ewol::RequestUpdateSize();
RequestUpdateSize();
MarkToRedraw();
}
SetFile(_file);

View File

@ -14,6 +14,7 @@
#include <draw/Color.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Image.h>
#include <ewol/widget/WidgetManager.h>
extern const char * const ewolEventImagePressed;
@ -32,11 +33,7 @@ namespace widget {
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void Init(void);
/**
* @brief Main call to unrecord the widget from the list of "widget named creator"
*/
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
protected:
ewol::Image m_compositing; //!< compositing element of the image.
public:

View File

@ -22,14 +22,9 @@ static ewol::Widget* Create(void)
return new widget::Label();
}
void widget::Label::Init(void)
void widget::Label::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Label::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
widget::Label::Label(etk::UString _newLabel)
@ -59,7 +54,7 @@ void widget::Label::SetLabel(const etk::UString& _newLabel)
{
m_label = _newLabel;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
etk::UString widget::Label::GetLabel(void)

View File

@ -13,6 +13,7 @@
#include <ewol/debug.h>
#include <ewol/compositing/Text.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class Label : public ewol::Widget
@ -23,11 +24,7 @@ namespace widget {
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void Init(void);
/**
* @brief Main call to unrecord the widget from the list of "widget named creator"
*/
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
private:
ewol::Text m_text; //!< Compositing text element.
etk::UString m_label; //!< decorated text to display.

View File

@ -18,17 +18,11 @@ static ewol::Widget* Create(void)
return new widget::Layer();
}
void widget::Layer::Init(void)
void widget::Layer::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
void widget::Layer::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Layer::Layer(void)
{
// nothing to do ...

View File

@ -12,6 +12,7 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/ContainerN.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class Layer : public widget::ContainerN
@ -20,11 +21,7 @@ namespace widget {
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void Init(void);
/**
* @brief Main call to unrecord the widget from the list of "widget named creator"
*/
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
public:
/**
* @brief Constructor

View File

@ -228,7 +228,7 @@ bool widget::List::OnEventInput(const ewol::EventInput& _event)
vec2 relativePos = RelativePosition(_event.GetPos());
if (true == WidgetScrooled::OnEventInput(_event)) {
ewol::widgetManager::FocusKeep(this);
KeepFocus();
// nothing to do ... done on upper widet ...
return true;
}

View File

@ -14,6 +14,7 @@
#include <ewol/widget/ContextMenu.h>
#include <ewol/widget/Composer.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Windows.h>
#undef __class__
#define __class__ "Menu"
@ -239,7 +240,14 @@ void widget::Menu::OnReceiveMessage(const ewol::EMessage& _msg)
}
}
}
ewol::WindowsPopUpAdd(m_widgetContextMenu);
ewol::Windows* currentWindows = GetWindows();
if (NULL == currentWindows) {
EWOL_ERROR("Can not get the curent Windows...");
delete(m_widgetContextMenu);
m_widgetContextMenu=NULL;
} else {
currentWindows->PopUpWidgetPush(m_widgetContextMenu);
}
}
return;
}

View File

@ -27,14 +27,9 @@ static ewol::Widget* Create(void)
return new widget::PopUp();
}
void widget::PopUp::Init(void)
void widget::PopUp::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::PopUp::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
@ -63,7 +58,7 @@ void widget::PopUp::LockExpand(const bvec2& _lockExpand)
if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
}

View File

@ -15,13 +15,13 @@
#include <ewol/widget/Container.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class PopUp : public widget::Container
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configShaper;
static const char* const configRemoveOnExternClick;

View File

@ -19,14 +19,9 @@ static ewol::Widget* Create(void)
return new widget::ProgressBar();
}
void widget::ProgressBar::Init(void)
void widget::ProgressBar::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::ProgressBar::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}

View File

@ -14,14 +14,13 @@
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class ProgressBar : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
private:
ewol::Drawing m_draw; // basic drawing element
public:

File diff suppressed because it is too large Load Diff

View File

@ -1,123 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_SCENE_H__
#define __EWOL_SCENE_H__
#ifdef BUILD_BULLET
#include <etk/types.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Matrix4.h>
#include <etk/Vector.h>
#include <ewol/debug.h>
#include <ewol/game/Camera.h>
#include <ewol/widget/Widget.h>
#include <ewol/renderer/openGL.h>
#include <ewol/renderer/ResourceManager.h>
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class btDynamicsWorld;
#include <LinearMath/btScalar.h>
class btVector3;
namespace widget {
class Scene :public ewol::Widget
{
protected:
///this is the most important class
btDefaultCollisionConfiguration* m_collisionConfiguration;
btCollisionDispatcher* m_dispatcher;
btBroadphaseInterface* m_broadphase;
btConstraintSolver* m_solver;
btDynamicsWorld* m_dynamicsWorld;
//keep the collision shapes, for deletion/cleanup
etk::Vector<btCollisionShape*> m_collisionShapes;
game::Camera m_camera; //!< Display point of view
bool m_isRunning; //!< the display is running (not in pause)
double m_lastCallTime; //!< previous call Time
float m_ratioTime; //!< Ratio time for the speed of the game ...
uint32_t m_walk; //!< Wolk properties
int32_t m_debugMode;
ewol::Colored3DObject* m_directDrawObject; // system to draw special object ...
public:
/**
* @brief Main scene constructor
* @param[in] gameEngine Used game engine for the display (can be NULL).
*/
Scene(btDynamicsWorld* gameEngine=NULL);
/**
* @brief Destructor
* @note The engine is not destroy, it is the reponsability of the user
*/
virtual ~Scene(void);
/**
* @brief Set the scene in pause for a while
*/
void Pause(void);
/**
* @brief Resume the scene activity
*/
void Resume(void);
/**
* @brief Toggle between pause and running
*/
void PauseToggle(void);
// Derived function
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
protected:
// Derived function
virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { };
// camera properties :
private:
float m_zoom;
public:
/**
* @brief Get the current camera reference for the scene rendering
*/
game::Camera& GetCamera(void) { return m_camera; };
/**
* @brief Set the curent Time Ratio (default 1)
*/
void SetRatioTime(float newRatio) { m_ratioTime = newRatio; };
/**
* @brief Convert the absolute position in the local Position (Relative)
* @param[in] pos Absolute position that you request convertion
* @return the relative position
*/
virtual vec2 RelativePosition(vec2 pos);
protected: // Derived function
virtual void OnDraw(void);
public: // dericed function:
virtual const char * const GetObjectType(void) { return "Ewol::Scene"; };
virtual void OnRegenerateDisplay(void);
virtual void PeriodicCall(int64_t localTime);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
void renderscene(int pass);
void DrawOpenGL(btScalar* m,
const btCollisionShape* shape,
const btVector3& color,
int32_t debugMode,
const btVector3& worldBoundsMin,
const btVector3& worldBoundsMax);
void DrawSphere(btScalar radius, int lats, int longs, mat4& transformationMatrix, draw::Colorf& tmpColor);
};
};
#endif
#endif

View File

@ -19,14 +19,9 @@ static ewol::Widget* Create(void)
return new widget::Scroll();
}
void widget::Scroll::Init(void)
void widget::Scroll::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Scroll::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
const char* const widget::Scroll::configLimit = "limit";

View File

@ -14,6 +14,7 @@
#include <ewol/widget/Container.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
typedef enum {
@ -31,8 +32,7 @@ namespace widget {
// Cinfig parameter list:
static const char* const configLimit;
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
private:
ewol::Drawing m_draw; // TODO : Change in shaper ... ==> better for annimation and dynamic display ...
protected:

View File

@ -19,14 +19,9 @@ static ewol::Widget* Create(void)
return new widget::Sizer();
}
void widget::Sizer::Init(void)
void widget::Sizer::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Sizer::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
@ -52,14 +47,14 @@ void widget::Sizer::SetBorderSize(const ewol::Dimension& _newBorderSize)
{
m_borderSize = _newBorderSize;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
void widget::Sizer::SetMode(widget::Sizer::displayMode_te _mode)
{
m_mode = _mode;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
widget::Sizer::displayMode_te widget::Sizer::GetMode(void)

View File

@ -12,6 +12,7 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/ContainerN.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class Sizer : public widget::ContainerN
@ -20,11 +21,7 @@ namespace widget {
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void Init(void);
/**
* @brief Main call to unrecord the widget from the list of "widget named creator"
*/
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
public:
typedef enum {
modeVert, //!< Vertical mode

View File

@ -25,17 +25,11 @@ static ewol::Widget* Create(void)
return new widget::Slider();
}
void widget::Slider::Init(void)
void widget::Slider::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
void widget::Slider::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
const int32_t dotRadius = 6;

View File

@ -13,6 +13,7 @@
#include <etk/Color.h>
#include <ewol/debug.h>
#include <ewol/widget/Drawable.h>
#include <ewol/widget/WidgetManager.h>
extern const char * const ewolEventSliderChange;
@ -20,8 +21,7 @@ namespace widget {
class Slider :public widget::Drawable
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
public:
Slider(void);
virtual ~Slider(void);

View File

@ -22,14 +22,9 @@ static ewol::Widget* Create(void)
return new widget::Spacer();
}
void widget::Spacer::Init(void)
void widget::Spacer::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Spacer::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}

View File

@ -14,13 +14,13 @@
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class Spacer :public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configColor;
private:

View File

@ -7,7 +7,6 @@
*/
#include <ewol/widget/WSlider.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/ewol.h>
@ -39,14 +38,9 @@ static ewol::Widget* Create(void)
return new widget::WSlider();
}
void widget::WSlider::Init(void)
void widget::WSlider::Init(ewol::WidgetManager& _widgetManager)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::WSlider::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
_widgetManager.AddWidgetCreator(__class__,&Create);
}
widget::WSlider::WSlider(void) :

View File

@ -12,14 +12,14 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/ContainerN.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
class WSlider :public widget::ContainerN
{
public:
static void Init(void);
static void UnInit(void);
static void Init(ewol::WidgetManager& _widgetManager);
// Event list of properties
static const char* const eventStartSlide;
static const char* const eventStopSlide;

View File

@ -139,7 +139,7 @@ ewol::Widget::Widget(void) :
ewol::Widget::~Widget(void)
{
// Remove his own focus...
ewol::widgetManager::Rm(this);
GetWidgetManager().Rm(this);
// clean all the short-cut ...
ShortCutClean();
}
@ -169,7 +169,7 @@ void ewol::Widget::Hide(void)
{
m_hide = true;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
@ -177,7 +177,7 @@ void ewol::Widget::Show(void)
{
m_hide = false;
MarkToRedraw();
ewol::RequestUpdateSize();
RequestUpdateSize();
}
@ -222,7 +222,7 @@ void ewol::Widget::SetCanHaveFocus(bool _canFocusState)
void ewol::Widget::KeepFocus(void)
{
ewol::widgetManager::FocusKeep(this);
GetWidgetManager().FocusKeep(this);
}
void ewol::Widget::SetOffset(const vec2& _newVal)
@ -361,7 +361,7 @@ void ewol::Widget::PeriodicCallDisable(void)
{
m_periodicCallDeltaTime=0;
m_periodicCallTime=-1;
ewol::widgetManager::PeriodicCallRm(this);
GetWidgetManager().PeriodicCallRm(this);
}
void ewol::Widget::PeriodicCallEnable(float _callInSecond)
@ -369,7 +369,7 @@ void ewol::Widget::PeriodicCallEnable(float _callInSecond)
if (_callInSecond < 0) {
PeriodicCallDisable();
} else {
ewol::widgetManager::PeriodicCallAdd(this);
GetWidgetManager().PeriodicCallAdd(this);
m_periodicCallDeltaTime = _callInSecond*1000000.0;
m_periodicCallTime = ewol::GetTime();
}
@ -379,7 +379,7 @@ void ewol::Widget::PeriodicCallEnable(float _callInSecond)
void ewol::Widget::MarkToRedraw(void)
{
m_needRegenerateDisplay = true;
ewol::widgetManager::MarkDrawingIsNeeded();
GetWidgetManager().MarkDrawingIsNeeded();
}
@ -456,7 +456,7 @@ void ewol::Widget::SetMinSize(const ewol::Dimension& _size)
return;
}
m_userMinSize = _size;
ewol::RequestUpdateSize();
RequestUpdateSize();
}
void ewol::Widget::SetNoMinSize(void)
@ -488,7 +488,7 @@ void ewol::Widget::SetMaxSize(const ewol::Dimension& _size)
return;
}
m_userMaxSize = _size;
ewol::RequestUpdateSize();
RequestUpdateSize();
}
void ewol::Widget::SetNoMaxSize(void)
@ -516,7 +516,7 @@ void ewol::Widget::SetExpand(const bvec2& _newExpand)
if( m_userExpand.x() != _newExpand.x()
|| m_userExpand.y() != _newExpand.y()) {
m_userExpand = _newExpand;
ewol::RequestUpdateSize();
RequestUpdateSize();
MarkToRedraw();
}
}
@ -535,7 +535,7 @@ void ewol::Widget::SetFill(const bvec2& _newFill)
if( m_userFill.x() != _newFill.x()
|| m_userFill.y() != _newFill.y()) {
m_userFill = _newFill;
ewol::RequestUpdateSize();
RequestUpdateSize();
MarkToRedraw();
}
}
@ -696,7 +696,7 @@ bool ewol::Widget::OnEventShortCut(ewol::SpecialKey& _special, uniChar_t _unicod
void ewol::Widget::GrabCursor(void)
{
if (false == m_grabCursor) {
eSystem::InputEventGrabPointer(this);
GetSystem().InputEventGrabPointer(this);
m_grabCursor = true;
}
}
@ -704,7 +704,7 @@ void ewol::Widget::GrabCursor(void)
void ewol::Widget::UnGrabCursor(void)
{
if (true==m_grabCursor) {
eSystem::InputEventUnGrabPointer();
GetSystem().InputEventUnGrabPointer();
m_grabCursor = false;
}
}
@ -721,7 +721,7 @@ void ewol::Widget::SetCursor(ewol::cursorDisplay_te _newCursor)
{
EWOL_DEBUG("Change Cursor in " << _newCursor);
m_cursorDisplay = _newCursor;
guiInterface::SetCursor(m_cursorDisplay);
GetSystem().SetCursor(m_cursorDisplay);
}
ewol::cursorDisplay_te ewol::Widget::GetCursor(void)
@ -855,3 +855,20 @@ bool ewol::Widget::OnGetConfig(const char* _config, etk::UString& _result) const
}
return false;
}
void ewol::Widget::RequestUpdateSize(void)
{
GetSystem().RequestUpdateSize();
}
ewol::WidgetManager& ewol::Widget::GetWidgetManager(void)
{
return GetSystem().GetWidgetManager();
}
ewol::Windows* ewol::Widget::GetWindows(void)
{
return GetSystem().GetWindows();
}

View File

@ -14,6 +14,8 @@
namespace ewol {
class Widget;
class WidgetManager;
class Windows;
};
#include <etk/types.h>
#include <etk/Vector.h>
@ -34,7 +36,7 @@ namespace ewol {
/*
/--> m_windowsSize
*--------------------------------------------------*
| |
| g |
| |
| m_size |
| / |
@ -620,6 +622,19 @@ namespace ewol {
protected: // Derived function
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
public:
/**
* @brief Need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions
*/
void RequestUpdateSize(void);
/**
* @brief Get the current Widget Manager
*/
ewol::WidgetManager& GetWidgetManager(void);
/**
* @brief Get the curent Windows
*/
ewol::Windows* GetWindows(void);
}; // end of the class Widget declaration
};// end of namespace

View File

@ -29,92 +29,48 @@
#undef __class__
#define __class__ "WidgetManager"
static bool IsInit = false;
// For the focus Management
static ewol::Widget * m_focusWidgetDefault = NULL;
static ewol::Widget * m_focusWidgetCurrent = NULL;
static etk::Vector<ewol::Widget*> l_listOfPeriodicWidget;
static bool l_havePeriodic = false;
static bool l_haveRedraw = true;
class dataStructCreator
{
public:
etk::UString name;
ewol::widgetManager::creator_tf pointer;
};
static etk::Vector<dataStructCreator> l_creatorList;
int64_t l_applWakeUpTime = 0; //!< Time of the application initialize
int64_t l_lastPeriodicCallTime = 0; //!< last call time ...
void ewol::widgetManager::Init(void)
ewol::WidgetManager::WidgetManager(void) :
m_focusWidgetDefault(NULL),
m_focusWidgetCurrent(NULL),
m_havePeriodic(false),
m_haveRedraw(true),
m_applWakeUpTime(0),
m_lastPeriodicCallTime(0)
{
EWOL_DEBUG("==> Init Widget-Manager");
// set the basic time properties :
l_applWakeUpTime = ewol::GetTime();
l_lastPeriodicCallTime = ewol::GetTime();
m_applWakeUpTime = ewol::GetTime();
m_lastPeriodicCallTime = ewol::GetTime();
// prevent android error ==> can create memory leak but I prefer
m_focusWidgetDefault = NULL;
m_focusWidgetCurrent = NULL;
l_creatorList.Clear();
l_listOfPeriodicWidget.Clear();
l_havePeriodic = false;
l_haveRedraw = true;
//ewol::WIDGET_SceneInit();
widget::Button::Init();
widget::ButtonColor::Init();
widget::Spacer::Init();
widget::Slider::Init();
widget::Sizer::Init();
widget::ProgressBar::Init();
widget::Layer::Init();
widget::Label::Init();
widget::Image::Init();
widget::Gird::Init();
widget::Entry::Init();
widget::CheckBox::Init();
widget::Scroll::Init();
widget::ContextMenu::Init();
widget::PopUp::Init();
IsInit = true;
widget::Button::Init(*this);
widget::ButtonColor::Init(*this);
widget::Spacer::Init(*this);
widget::Slider::Init(*this);
widget::Sizer::Init(*this);
widget::ProgressBar::Init(*this);
widget::Layer::Init(*this);
widget::Label::Init(*this);
widget::Image::Init(*this);
widget::Gird::Init(*this);
widget::Entry::Init(*this);
widget::CheckBox::Init(*this);
widget::Scroll::Init(*this);
widget::ContextMenu::Init(*this);
widget::PopUp::Init(*this);
}
void ewol::widgetManager::UnInit(void)
ewol::WidgetManager::~WidgetManager(void)
{
EWOL_DEBUG("==> Un-Init Widget-Manager");
EWOL_INFO("Realease all FOCUS");
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
FocusSetDefault(NULL);
FocusRelease();
widget::PopUp::UnInit();
widget::ContextMenu::UnInit();
widget::Scroll::UnInit();
widget::CheckBox::UnInit();
widget::Entry::UnInit();
widget::Gird::UnInit();
widget::Image::UnInit();
widget::Label::UnInit();
widget::Layer::UnInit();
widget::ProgressBar::UnInit();
widget::Sizer::UnInit();
widget::Slider::UnInit();
widget::Spacer::UnInit();
widget::ButtonColor::UnInit();
widget::Button::UnInit();
IsInit = false;
l_listOfPeriodicWidget.Clear();
l_creatorList.Clear();
m_listOfPeriodicWidget.Clear();
m_creatorList.Clear();
}
void ewol::widgetManager::Rm(ewol::Widget * newWidget)
void ewol::WidgetManager::Rm(ewol::Widget * newWidget)
{
PeriodicCallRm(newWidget);
FocusRemoveIfRemove(newWidget);
@ -124,7 +80,7 @@ void ewol::widgetManager::Rm(ewol::Widget * newWidget)
* Focus Area :
* *************************************************************************/
void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
void ewol::WidgetManager::FocusKeep(ewol::Widget * newWidget)
{
if (NULL == newWidget) {
// nothing to do ...
@ -150,7 +106,7 @@ void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
}
void ewol::widgetManager::FocusSetDefault(ewol::Widget * newWidget)
void ewol::WidgetManager::FocusSetDefault(ewol::Widget * newWidget)
{
if (NULL != newWidget && false == newWidget->CanHaveFocus()) {
EWOL_VERBOSE("Widget can not have Focus, id=" << newWidget->GetId() );
@ -171,7 +127,7 @@ void ewol::widgetManager::FocusSetDefault(ewol::Widget * newWidget)
}
void ewol::widgetManager::FocusRelease(void)
void ewol::WidgetManager::FocusRelease(void)
{
if (m_focusWidgetDefault == m_focusWidgetCurrent) {
// nothink to do ...
@ -189,12 +145,12 @@ void ewol::widgetManager::FocusRelease(void)
}
ewol::Widget * ewol::widgetManager::FocusGet(void)
ewol::Widget * ewol::WidgetManager::FocusGet(void)
{
return m_focusWidgetCurrent;
}
void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
void ewol::WidgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
{
if (m_focusWidgetCurrent == newWidget) {
EWOL_WARNING("Release Focus when remove widget");
@ -208,60 +164,60 @@ void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
void ewol::widgetManager::PeriodicCallAdd(ewol::Widget * pWidget)
void ewol::WidgetManager::PeriodicCallAdd(ewol::Widget * pWidget)
{
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
if (l_listOfPeriodicWidget[iii] == pWidget) {
for (int32_t iii=0; iii < m_listOfPeriodicWidget.Size(); iii++) {
if (m_listOfPeriodicWidget[iii] == pWidget) {
return;
}
}
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
if (NULL == l_listOfPeriodicWidget[iii]) {
l_listOfPeriodicWidget[iii] = pWidget;
for (int32_t iii=0; iii < m_listOfPeriodicWidget.Size(); iii++) {
if (NULL == m_listOfPeriodicWidget[iii]) {
m_listOfPeriodicWidget[iii] = pWidget;
return;
}
}
l_listOfPeriodicWidget.PushBack(pWidget);
l_havePeriodic = true;
m_listOfPeriodicWidget.PushBack(pWidget);
m_havePeriodic = true;
}
void ewol::widgetManager::PeriodicCallRm(ewol::Widget * pWidget)
void ewol::WidgetManager::PeriodicCallRm(ewol::Widget * pWidget)
{
int32_t nbElement = 0;
for (int32_t iii=l_listOfPeriodicWidget.Size()-1; iii>=0 ; iii--) {
if (l_listOfPeriodicWidget[iii] == pWidget) {
l_listOfPeriodicWidget[iii] = NULL;
for (int32_t iii=m_listOfPeriodicWidget.Size()-1; iii>=0 ; iii--) {
if (m_listOfPeriodicWidget[iii] == pWidget) {
m_listOfPeriodicWidget[iii] = NULL;
} else {
nbElement++;
}
}
if (0 == nbElement) {
l_havePeriodic = false;
m_havePeriodic = false;
}
}
void ewol::widgetManager::PeriodicCall(int64_t _localTime)
void ewol::WidgetManager::PeriodicCall(int64_t _localTime)
{
int64_t previousTime = l_lastPeriodicCallTime;
l_lastPeriodicCallTime = _localTime;
if (l_listOfPeriodicWidget.Size() <= 0) {
int64_t previousTime = m_lastPeriodicCallTime;
m_lastPeriodicCallTime = _localTime;
if (m_listOfPeriodicWidget.Size() <= 0) {
return;
}
float deltaTime = (float)(_localTime - previousTime)/1000000.0;
EventTime myTime(_localTime, l_applWakeUpTime, deltaTime, deltaTime);
EventTime myTime(_localTime, m_applWakeUpTime, deltaTime, deltaTime);
EWOL_VERBOSE("periodic : " << _localTime);
for (int32_t iii=l_listOfPeriodicWidget.Size()-1; iii>=0 ; iii--) {
if (NULL != l_listOfPeriodicWidget[iii]) {
int64_t deltaTimeCallUser = l_listOfPeriodicWidget[iii]->SystemGetCallDeltaTime();
for (int32_t iii=m_listOfPeriodicWidget.Size()-1; iii>=0 ; iii--) {
if (NULL != m_listOfPeriodicWidget[iii]) {
int64_t deltaTimeCallUser = m_listOfPeriodicWidget[iii]->SystemGetCallDeltaTime();
if (deltaTimeCallUser<=0) {
myTime.SetDeltaCall(deltaTime);
EWOL_VERBOSE("[" << iii << "] periodic : " << myTime);
l_listOfPeriodicWidget[iii]->SystemSetLastCallTime(_localTime);
l_listOfPeriodicWidget[iii]->PeriodicCall(myTime);
m_listOfPeriodicWidget[iii]->SystemSetLastCallTime(_localTime);
m_listOfPeriodicWidget[iii]->PeriodicCall(myTime);
} else {
int64_t lastCallTime = l_listOfPeriodicWidget[iii]->SystemGetLastCallTime();
int64_t lastCallTime = m_listOfPeriodicWidget[iii]->SystemGetLastCallTime();
if (lastCallTime == 0) {
lastCallTime = _localTime;
}
@ -269,86 +225,71 @@ void ewol::widgetManager::PeriodicCall(int64_t _localTime)
if (deltaLocalTime>= lastCallTime) {
myTime.SetDeltaCall(deltaLocalTime);
EWOL_VERBOSE("[" << iii << "] periodic : " << myTime);
l_listOfPeriodicWidget[iii]->SystemSetLastCallTime(_localTime);
l_listOfPeriodicWidget[iii]->PeriodicCall(myTime);
m_listOfPeriodicWidget[iii]->SystemSetLastCallTime(_localTime);
m_listOfPeriodicWidget[iii]->PeriodicCall(myTime);
}
}
}
}
}
bool ewol::widgetManager::PeriodicCallHave(void)
bool ewol::WidgetManager::PeriodicCallHave(void)
{
return l_havePeriodic;
return m_havePeriodic;
}
void ewol::widgetManager::MarkDrawingIsNeeded(void)
void ewol::WidgetManager::MarkDrawingIsNeeded(void)
{
l_haveRedraw = true;
m_haveRedraw = true;
}
bool ewol::widgetManager::IsDrawingNeeded(void)
bool ewol::WidgetManager::IsDrawingNeeded(void)
{
bool tmp = l_haveRedraw;
l_haveRedraw = false;
bool tmp = m_haveRedraw;
m_haveRedraw = false;
return tmp;
}
// element that generate the list of elements
void ewol::widgetManager::AddWidgetCreator(const etk::UString& name, ewol::widgetManager::creator_tf pointer)
void ewol::WidgetManager::AddWidgetCreator(const etk::UString& _name, ewol::WidgetManager::creator_tf _pointer)
{
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
if (name.CompareNoCase(l_creatorList[iii].name)) {
if (NULL==pointer) {
EWOL_INFO("Remove Creator of a specify widget : " << name);
} else {
EWOL_WARNING("Replace Creator of a specify widget : " << name);
l_creatorList[iii].pointer = pointer;
}
return;
}
}
if (NULL==pointer) {
if (NULL==_pointer) {
return;
}
EWOL_INFO("Add Creator of a specify widget : " << name);
dataStructCreator tmpStruct;
tmpStruct.name = name;
tmpStruct.pointer = pointer;
l_creatorList.PushBack(tmpStruct);
if (true==m_creatorList.Exist(_name)) {
EWOL_WARNING("Replace Creator of a specify widget : " << _name);
m_creatorList[_name] = _pointer;
return;
}
EWOL_INFO("Add Creator of a specify widget : " << _name);
m_creatorList.Add(_name, _pointer);
}
ewol::Widget* ewol::widgetManager::Create(const etk::UString& name)
ewol::Widget* ewol::WidgetManager::Create(const etk::UString& _name)
{
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
if (name.CompareNoCase(l_creatorList[iii].name)) {
if (NULL != l_creatorList[iii].pointer) {
return (*l_creatorList[iii].pointer)();
}
if (true==m_creatorList.Exist(_name)) {
ewol::WidgetManager::creator_tf pointerFunction = m_creatorList[_name];
if (NULL != pointerFunction) {
return pointerFunction();
}
}
EWOL_WARNING("try to create an UnExistant widget : " << name);
EWOL_WARNING("try to create an UnExistant widget : " << _name);
return NULL;
}
bool ewol::widgetManager::Exist(const etk::UString& name)
bool ewol::WidgetManager::Exist(const etk::UString& _name)
{
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
if (name.CompareNoCase(l_creatorList[iii].name)) {
return true;
}
}
return false;
return m_creatorList.Exist(_name);
}
etk::UString ewol::widgetManager::List(void)
etk::UString ewol::WidgetManager::List(void)
{
etk::UString tmpVal;
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
tmpVal += l_creatorList[iii].name;
for (int32_t iii=0; iii<m_creatorList.Size() ; iii++) {
tmpVal += m_creatorList.GetKey(iii);
tmpVal += ",";
}
return tmpVal;

View File

@ -12,35 +12,50 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <etk/Vector.h>
#include <etk/Hach.h>
#include <ewol/widget/Widget.h>
namespace ewol {
namespace widgetManager {
void Init(void);
void UnInit(void);
// need to call when remove a widget to clear all dependency of the focus system
void Rm(ewol::Widget * newWidget);
void FocusKeep(ewol::Widget * newWidget); // set the focus at the specific widget
void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter
void FocusRelease(void); // Release focus from the current widget to the default
ewol::Widget* FocusGet(void);
void FocusRemoveIfRemove(ewol::Widget * newWidget);
void PeriodicCallAdd(ewol::Widget* pWidget);
void PeriodicCallRm(ewol::Widget* pWidget);
void PeriodicCall(int64_t localTime);
bool PeriodicCallHave(void);
void MarkDrawingIsNeeded(void);
bool IsDrawingNeeded(void);
typedef ewol::Widget* (*creator_tf)(void);
// element that generate the list of elements
void AddWidgetCreator(const etk::UString& name, creator_tf pointer);
ewol::Widget* Create(const etk::UString& name);
bool Exist(const etk::UString& name);
etk::UString List(void);
namespace ewol
{
class WidgetManager
{
public:
typedef ewol::Widget* (*creator_tf)(void);
private:
// For the focus Management
ewol::Widget * m_focusWidgetDefault;
ewol::Widget * m_focusWidgetCurrent;
etk::Vector<ewol::Widget*> m_listOfPeriodicWidget;
bool m_havePeriodic;
bool m_haveRedraw;
etk::Hash<creator_tf> m_creatorList;
int64_t m_applWakeUpTime; //!< Time of the application initialize
int64_t m_lastPeriodicCallTime; //!< last call time ...
public:
WidgetManager(void);
~WidgetManager(void);
// need to call when remove a widget to clear all dependency of the focus system
void Rm(ewol::Widget * newWidget);
void FocusKeep(ewol::Widget * newWidget); // set the focus at the specific widget
void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter
void FocusRelease(void); // Release focus from the current widget to the default
ewol::Widget* FocusGet(void);
void FocusRemoveIfRemove(ewol::Widget * newWidget);
void PeriodicCallAdd(ewol::Widget* pWidget);
void PeriodicCallRm(ewol::Widget* pWidget);
void PeriodicCall(int64_t localTime);
bool PeriodicCallHave(void);
void MarkDrawingIsNeeded(void);
bool IsDrawingNeeded(void);
// element that generate the list of elements
void AddWidgetCreator(const etk::UString& _name, creator_tf _pointer);
ewol::Widget* Create(const etk::UString& _name);
bool Exist(const etk::UString& _name);
etk::UString List(void);
};
};

View File

@ -205,7 +205,7 @@ void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget)
// Regenerate the size calculation :
CalculateSize(m_size);
// TODO : it is dansgerous to access directly to the system ...
eSystem::ResetIOEvent();
GetSystem().ResetIOEvent();
}
@ -236,3 +236,10 @@ void ewol::Windows::SetBackgroundColor(const etk::Color<float>& _color)
MarkToRedraw();
}
}
void ewol::Windows::SetTitle(const etk::UString& _title)
{
// TODO : Remove this ...
etk::UString title = _title;
GetSystem().SetTitle(title);
}

View File

@ -72,6 +72,7 @@ namespace ewol {
virtual void OnObjectRemove(ewol::EObject * removeObject);
virtual void CalculateSize(const vec2& availlable);
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos);
void SetTitle(const etk::UString& _title);
};
};

View File

@ -187,7 +187,7 @@ void widget::ParameterList::OnRegenerateDisplay(void)
bool widget::ParameterList::OnEventInput(const ewol::EventInput& _event)
{
if (true == WidgetScrooled::OnEventInput(_event)) {
ewol::widgetManager::FocusKeep(this);
KeepFocus();
// nothing to do ... done on upper widet ...
return true;
}

View File

@ -27,7 +27,8 @@ def Create(target):
'ewol/eObject/EConfig.cpp',
'ewol/eObject/EMessage.cpp',
'ewol/eObject/EObject.cpp',
'ewol/eObject/EObjectManager.cpp'])
'ewol/eObject/EObjectManager.cpp',
'ewol/eObject/EObjectMessageMultiCast.cpp'])
#openGl Basic access abstraction (for the model matrix and include
myModule.AddSrcFile([
@ -42,7 +43,7 @@ def Create(target):
myModule.AddSrcFile([
'ewol/renderer/os/eSystem.cpp',
'ewol/renderer/os/eSystemInput.cpp'])
"""
# renderer :
myModule.AddSrcFile([
'ewol/renderer/resources/Shader.cpp',
@ -117,12 +118,6 @@ def Create(target):
'ewol/widget/meta/Parameter.cpp',
'ewol/widget/meta/ParameterList.cpp'])
# game mode area :
myModule.AddSrcFile([
'ewol/widget/Scene.cpp',
'ewol/game/Camera.cpp'])
"""
myModule.CopyFolder('../data/theme/default/widgetEntry.*','theme/default')
myModule.CopyFolder('../data/theme/rounded/widgetEntry.*','theme/rounded')
myModule.CopyFolder('../data/theme/default/widgetButton.*','theme/default')