[DEV] Change main application start (done only for X11)

This commit is contained in:
Edouard DUPIN 2014-06-05 21:40:07 +02:00
parent 46b5eca2cb
commit e7cc0e7100
7 changed files with 61 additions and 30 deletions

View File

View File

@ -0,0 +1,33 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_CONTEXT_APPLICATION_H__
#define __EWOL_CONTEXT_APPLICATION_H__
namespace ewol {
class Context;
namespace context {
class Application {
protected:
size_t m_nbStepInit;
public:
size_t getNbStepInit() {
return m_nbStepInit;
}
public:
Application() :
m_nbStepInit(1) {};
virtual ~Application() {};
public:
virtual bool init(ewol::Context& _context, size_t _initId) = 0;
virtual void unInit(ewol::Context& _context) = 0;
};
};
};
#endif

View File

@ -165,7 +165,7 @@ void ewol::Context::processEvents() {
case eSystemMessage::msgInit: case eSystemMessage::msgInit:
// this is due to the openGL context // this is due to the openGL context
/*bool returnVal = */ /*bool returnVal = */
APP_Init(*this, m_initStepId, m_initTotalStep); m_application->init(*this, m_initStepId);
m_initStepId++; m_initStepId++;
break; break;
case eSystemMessage::msgRecalculateSize: case eSystemMessage::msgRecalculateSize:
@ -287,7 +287,9 @@ void ewol::Context::setArchiveDir(int _mode, const char* _str) {
ewol::Context::Context(int32_t _argc, const char* _argv[]) : ewol::Context::Context(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) :
//m_application(std::make_shared<ewol::context::Application>(_application)),
m_application(_application),
m_objectManager(*this), m_objectManager(*this),
m_previousDisplayTime(0), m_previousDisplayTime(0),
m_input(*this), m_input(*this),
@ -302,8 +304,10 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
m_FpsFlush( "Flush ", false), m_FpsFlush( "Flush ", false),
m_windowsCurrent(nullptr), m_windowsCurrent(nullptr),
m_windowsSize(320,480), m_windowsSize(320,480),
m_initStepId(0), m_initStepId(0) {
m_initTotalStep(1) { if (m_application == nullptr) {
EWOL_CRITICAL("Can not start context with no Application ==> rtfm ...");
}
m_commandLine.parse(_argc, _argv); m_commandLine.parse(_argc, _argv);
EWOL_INFO(" == > Ewol system init (BEGIN)"); EWOL_INFO(" == > Ewol system init (BEGIN)");
// Add basic ewol translation: // Add basic ewol translation:
@ -388,7 +392,8 @@ ewol::Context::~Context() {
m_objectManager.removeAllRemovedObject(); m_objectManager.removeAllRemovedObject();
} while (m_resourceManager.checkResourceToRemove() == true); } while (m_resourceManager.checkResourceToRemove() == true);
// call application to uninit // call application to uninit
APP_UnInit(*this); m_application->unInit(*this);
m_application.reset();
// clean all messages // clean all messages
m_msgSystem.clean(); m_msgSystem.clean();
// an other cycle of removing ... // an other cycle of removing ...
@ -580,7 +585,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
// set the curent interface : // set the curent interface :
lockContext(); lockContext();
processEvents(); processEvents();
if (m_initStepId < m_initTotalStep) { if (m_initStepId < m_application->getNbStepInit()) {
ewol::eSystemMessage *data = new ewol::eSystemMessage(); ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) { if (data == nullptr) {
EWOL_ERROR("allocation error of message"); EWOL_ERROR("allocation error of message");

View File

@ -17,12 +17,14 @@
#include <ewol/resource/Manager.h> #include <ewol/resource/Manager.h>
#include <ewol/widget/Manager.h> #include <ewol/widget/Manager.h>
#include <ewol/widget/Windows.h> #include <ewol/widget/Windows.h>
#include <ewol/context/Application.h>
#include <ewol/context/clipBoard.h> #include <ewol/context/clipBoard.h>
#include <ewol/context/ConfigFont.h> #include <ewol/context/ConfigFont.h>
#include <ewol/context/commandLine.h> #include <ewol/context/commandLine.h>
#include <ewol/context/InputManager.h> #include <ewol/context/InputManager.h>
#include <ewol/context/Fps.h> #include <ewol/context/Fps.h>
#include <ewol/object/RemoveEvent.h> #include <ewol/object/RemoveEvent.h>
#include <memory>
namespace ewol { namespace ewol {
/** /**
@ -39,6 +41,12 @@ namespace ewol {
}; };
class Context/* : private ewol::object::RemoveEvent */{ class Context/* : private ewol::object::RemoveEvent */{
private:
std::shared_ptr<ewol::context::Application> m_application; //!< Application handle
public:
std::shared_ptr<ewol::context::Application> getApplication() {
return m_application;
}
private: private:
ewol::context::CommandLine m_commandLine; //!< Start command line information ewol::context::CommandLine m_commandLine; //!< Start command line information
public: public:
@ -70,7 +78,7 @@ namespace ewol {
return m_resourceManager; return m_resourceManager;
}; };
public: public:
Context(int32_t _argc=0, const char* _argv[]=nullptr); Context(ewol::context::Application* _application, int32_t _argc=0, const char* _argv[]=nullptr);
virtual ~Context(); virtual ~Context();
protected: protected:
/** /**
@ -363,21 +371,5 @@ namespace ewol {
Context& getContext(); Context& getContext();
}; };
//!< must be define in CPP by the application ... this are the main init and unInit of the Application
/**
* @brief main application function initialisation
* @param[in] _context curent context property
* @param[in] _initId current init step
* @param[out] _nbInitStep total number of step
* @return true, all OK
* @return false, an error occured
*/
bool APP_Init(ewol::Context& _context, size_t _initId, size_t& _nbInitStep);
/**
* @brief main application function un-initialisation
*/
void APP_UnInit(ewol::Context& _context);
#endif #endif

View File

@ -142,8 +142,8 @@ class X11Interface : public ewol::Context {
enum ewol::context::cursorDisplay m_currentCursor; //!< select the current cursor to display : enum ewol::context::cursorDisplay m_currentCursor; //!< select the current cursor to display :
char32_t m_lastKeyPressed; //!< The last element key presed... char32_t m_lastKeyPressed; //!< The last element key presed...
public: public:
X11Interface(int32_t _argc, const char* _argv[]) : X11Interface(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) :
ewol::Context(_argc, _argv), ewol::Context(_application, _argc, _argv),
m_display(nullptr), m_display(nullptr),
m_originX(0), m_originX(0),
m_originY(0), m_originY(0),
@ -1343,9 +1343,9 @@ class X11Interface : public ewol::Context {
* @param std IO * @param std IO
* @return std IO * @return std IO
*/ */
int ewol::run(int _argc, const char *_argv[]) { int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) {
etk::setArgZero(_argv[0]); etk::setArgZero(_argv[0]);
X11Interface* interface = new X11Interface(_argc, _argv); X11Interface* interface = new X11Interface(_application, _argc, _argv);
if (nullptr == interface) { if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error"); EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2; return -2;

View File

@ -10,7 +10,7 @@
#define __EWOL_H__ #define __EWOL_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/types.h> #include <ewol/context/Application.h>
namespace ewol { namespace ewol {
/** /**
@ -20,11 +20,12 @@ namespace ewol {
* Does not exist in the android platform, then ewol call other start * Does not exist in the android platform, then ewol call other start
* and stop function, to permit to have only one code * and stop function, to permit to have only one code
* @note The main can not be in the ewol, due to the fact thet is an librairy * @note The main can not be in the ewol, due to the fact thet is an librairy
* @param[in] _application just created instance of the applicationo
* @param[in] _argc Standard argc * @param[in] _argc Standard argc
* @param[in] _argv Standard argv * @param[in] _argv Standard argv
* @return normal error int for the application error management * @return normal error int for the application error management
*/ */
int32_t run(int32_t _argc, const char* _argv[]); int32_t run(ewol::context::Application* _application, int32_t _argc = 0, const char* _argv[] = NULL);
/** /**
* @brief get EWOL version * @brief get EWOL version
* @return The string that describe ewol version * @return The string that describe ewol version

View File

@ -19,7 +19,7 @@
namespace ewol { namespace ewol {
namespace widget { namespace widget {
/** /**
* @ingroup ewolWidgetGroup * @brief Windows basic interface
*/ */
class Windows : public ewol::Widget { class Windows : public ewol::Widget {
protected: protected: