[DEV] review interface (step 1)

This commit is contained in:
Edouard DUPIN 2016-03-16 21:42:49 +01:00
parent 2e4e1545ad
commit 6f68563d50
31 changed files with 442 additions and 458 deletions

View File

@ -0,0 +1,49 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/context/Application.h>
#include <ewol/context/Context.h>
ewol::context::Application::Application() {
}
ewol::context::Application::~Application() {
}
void ewol::context::Application::onCreate(ewol::Context& _context) {
}
void ewol::context::Application::onStart(ewol::Context& _context) {
}
void ewol::context::Application::onResume(ewol::Context& _context) {
}
void ewol::context::Application::onPause(ewol::Context& _context) {
}
void ewol::context::Application::onStop(ewol::Context& _context) {
}
void ewol::context::Application::onDestroy(ewol::Context& _context) {
}
void ewol::context::Application::onKillDemand(ewol::Context& _context) {
_context.exit(0);
}

View File

@ -13,39 +13,44 @@ namespace ewol {
namespace context {
class Application {
public:
Application() {};
virtual ~Application() {};
Application();
virtual ~Application();
public:
/**
* @brief The application is created.
* @param[in] _context Current ewol context.
*/
virtual void onCreate(ewol::Context& _context) {};
virtual void onCreate(ewol::Context& _context);
/**
* @brief The application is started.
* @param[in] _context Current ewol context.
*/
virtual void onStart(ewol::Context& _context) {};
virtual void onStart(ewol::Context& _context);
/**
* @brief The application is resumed (now visible).
* @param[in] _context Current ewol context.
*/
virtual void onResume(ewol::Context& _context) {};
virtual void onResume(ewol::Context& _context);
/**
* @brief The application is Hide / not visible.
* @param[in] _context Current ewol context.
*/
virtual void onPause(ewol::Context& _context) {};
virtual void onPause(ewol::Context& _context);
/**
* @brief The application is stopped.
* @param[in] _context Current ewol context.
*/
virtual void onStop(ewol::Context& _context) {};
virtual void onStop(ewol::Context& _context);
/**
* @brief The application is remoed (call destructor just adter it.).
* @brief The application is removed (call destructor just adter it.).
* @param[in] _context Current ewol context.
*/
virtual void onDestroy(ewol::Context& _context) {};
virtual void onDestroy(ewol::Context& _context);
/**
* @brief The user request application removing.
* @param[in] _context Current ewol context.
*/
virtual void onKillDemand(ewol::Context& _context);
};
};
};

View File

@ -201,7 +201,18 @@ void ewol::Context::onDestroy(gale::Context& _context) {
m_objectManager.displayListObject();
// now All must be removed !!!
m_objectManager.unInit();
EWOL_INFO(" == > Ewol system destroy (END)");
EWOL_INFO(" == > Ewol system destroy (END)");
}
void ewol::Context::onKillDemand(gale::Context& _context) {
EWOL_INFO(" == > User demand a destroy (BEGIN)");
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl == nullptr) {
exit(0);
return;
}
appl->onKillDemand(*this);
EWOL_INFO(" == > User demand a destroy (END)");
}
void ewol::Context::onPointer(enum gale::key::type _type,
@ -333,107 +344,10 @@ void ewol::Context::onPeriod(int64_t _time) {
m_objectManager.timeCall(_time);
}
#if 0
bool ewol::Context::OS_Draw(bool _displayEveryTime) {
int64_t currentTime = ewol::getTime();
// this is to prevent the multiple display at the a high frequency ...
m_previousDisplayTime = currentTime;
// process the events
if (m_displayFps == true) {
m_FpsSystemEvent.tic();
}
bool needRedraw = false;
//! Event management section ...
{
// set the curent interface :
processEvents();
if (m_initStepId < m_application->getNbStepInit()) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocation error of message");
} else {
data->TypeMessage = eSystemMessage::msgInit;
m_msgSystem.post(data);
}
}
// call all the widget that neded to do something periodicly
m_objectManager.timeCall(currentTime);
if (m_displayFps == true) {
m_FpsSystemEvent.incrementCounter();
m_FpsSystemEvent.toc();
}
//! bool needRedraw = ewol::widgetManager::isDrawingNeeded();
needRedraw = m_widgetManager.isDrawingNeeded();
// release the curent interface :
}
bool hasDisplayDone = false;
//! drawing section :
{
// Lock openGl context:
gale::openGL::lock();
if (m_displayFps == true) {
m_FpsSystemContext.tic();
}
if (nullptr != m_windowsCurrent) {
if( true == needRedraw
|| true == _displayEveryTime) {
m_resourceManager.updateContext();
if (m_displayFps == true) {
m_FpsSystemContext.incrementCounter();
}
}
}
if (m_displayFps == true) {
m_FpsSystemContext.toc();
m_FpsSystem.tic();
}
if (nullptr != m_windowsCurrent) {
if( true == needRedraw
|| true == _displayEveryTime) {
m_FpsSystem.incrementCounter();
m_windowsCurrent->sysDraw();
hasDisplayDone = true;
}
}
if (m_displayFps == true) {
m_FpsSystem.toc();
m_FpsFlush.tic();
}
if (hasDisplayDone == true) {
if (m_displayFps == true) {
m_FpsFlush.incrementCounter();
}
gale::openGL::flush();
}
if (m_displayFps == true) {
m_FpsFlush.toc();
}
// release open GL Context
gale::openGL::unLock();
}
{
// set the curent interface :
// release open GL Context
gale::openGL::lock();
// while The Gui is drawing in OpenGl, we do some not realTime things
m_resourceManager.updateContext();
// release open GL Context
gale::openGL::unLock();
m_objectManager.cleanInternalRemoved();
m_resourceManager.cleanInternalRemoved();
// release the curent interface :
}
return hasDisplayDone;
}
#endif
void ewol::Context::resetIOEvent() {
m_input.newLayerSet();
}
void ewol::Context::setWindows(const ewol::widget::WindowsShared& _windows) {
EWOL_INFO("set New windows");
// remove current focus :
@ -441,8 +355,12 @@ void ewol::Context::setWindows(const ewol::widget::WindowsShared& _windows) {
m_widgetManager.focusRelease();
// set the new pointer as windows system
m_windowsCurrent = _windows;
// set the new default focus :
// set the new default focus:
m_widgetManager.focusSetDefault(_windows);
// display the title of the Windows:
if (m_windowsCurrent != nullptr) {
setTitle(m_windowsCurrent->propertyTitle.get());
}
// request all the widget redrawing
forceRedrawAll();
}
@ -463,56 +381,4 @@ void ewol::Context::forceRedrawAll() {
m_windowsCurrent->setSize(vec2(size.x(), size.y()));
m_windowsCurrent->onChangeSize();
}
/*
void ewol::Context::OS_Stop() {
// set the curent interface :
EWOL_INFO("OS_Stop...");
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->sysOnKill();
}
// release the curent interface :
}
void ewol::Context::OS_Suspend() {
// set the curent interface :
EWOL_INFO("OS_Suspend...");
m_previousDisplayTime = -1;
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateSuspend();
}
// release the curent interface :
}
void ewol::Context::OS_Resume() {
// set the curent interface :
EWOL_INFO("OS_Resume...");
m_previousDisplayTime = ewol::getTime();
m_objectManager.timeCallResume(m_previousDisplayTime);
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateResume();
}
// release the curent interface :
}
void ewol::Context::OS_Foreground() {
// set the curent interface :
EWOL_INFO("OS_Foreground...");
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateForeground();
}
// release the curent interface :
}
void ewol::Context::OS_Background() {
// set the curent interface :
EWOL_INFO("OS_Background...");
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateBackground();
}
// release the curent interface :
}
*/
void ewol::Context::stop() {
}

View File

@ -64,33 +64,29 @@ namespace ewol {
private:
ewol::context::InputManager m_input;
public: // herited function:
virtual void onCreate(gale::Context& _context);
virtual void onStart(gale::Context& _context);
virtual void onResume(gale::Context& _context);
virtual void onRegenerateDisplay(gale::Context& _context);
virtual void onDraw(gale::Context& _context);
virtual void onPause(gale::Context& _context);
virtual void onStop(gale::Context& _context);
virtual void onDestroy(gale::Context& _context);
virtual void onPointer(enum gale::key::type _type,
int32_t _pointerID,
const vec2& _pos,
gale::key::status _state);
virtual void onKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state);
virtual void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId);
void onCreate(gale::Context& _context) override;
void onStart(gale::Context& _context) override;
void onResume(gale::Context& _context) override;
void onRegenerateDisplay(gale::Context& _context) override;
void onDraw(gale::Context& _context) override;
void onPause(gale::Context& _context) override;
void onStop(gale::Context& _context) override;
void onDestroy(gale::Context& _context) override;
void onKillDemand(gale::Context& _context) override;
void onPointer(enum gale::key::type _type,
int32_t _pointerID,
const vec2& _pos,
gale::key::status _state) override;
void onKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state) override;
void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) override;
public:
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
void resetIOEvent();
/**
* @brief The application request that the Window will be killed
*/
virtual void stop();
private:
ewol::widget::WindowsShared m_windowsCurrent; //!< curent displayed windows
public:
@ -126,46 +122,7 @@ namespace ewol {
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/
void inputEventUnGrabPointer();
// herited function:
virtual void onResize(const ivec2& _size);
#if 0
/**
* @brief Inform the Gui that we want to have a copy of the clipboard
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/
virtual void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief Inform the Gui that we are the new owner of the clipboard
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/
virtual void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief Call by the OS when a clipboard arrive to US (previously requested by a widget)
* @param[in] Id of the clipboard
*/
void OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardListe _clipboardID);
#endif
#if 0
/**
* @brief force the screen orientation (availlable on portable elements ...
* @param[in] _orientation Selected orientation.
*/
virtual void forceOrientation(enum ewol::orientation _orientation) { };
/**
* @brief get all the event from the X system
* @param[in] _isGrabbed "true" if all the event will be get, false if we want only ours.
* @param[in] _forcedPosition the position where the mouse might be reset at every events ...
*/
virtual void grabPointerEvents(bool _isGrabbed, const vec2& _forcedPosition) { };
/**
* @brief get the curent time in micro-second
* @note : must be implemented in all system OS implementation
* @return The curent time of the process
*/
static int64_t getTime();
#endif
void onResize(const ivec2& _size) override;
public:
/**
* @brief This is the only one things the User might done in his main();
@ -189,22 +146,12 @@ namespace ewol {
* @param[in] _fileName Name of the image to load
*/
void setInitImage(const std::string& _fileName);
protected:
# if 0
/**
* @brief HARDWARE keyboard event from the system
* @param[in] _key event type
* @param[in] _status Up or down status
* @return Keep the event or not
*/
virtual bool systemKeyboradEvent(enum gale:key::keyboardSystem _key, bool _down);
#endif
public:
/**
* @brief Request a display after call a resize
*/
void requestUpdateSize();
virtual void onPeriod(int64_t _time);
void onPeriod(int64_t _time) override;
};
/**
* @brief From everyware in the program, we can get the context inteface.

View File

@ -63,22 +63,22 @@ void ewol::resource::FontFreeType::init(const std::string& _fontName) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
ewol::resource::FontBase::init(_fontName);
etk::FSNode myfile(_fontName);
if (false == myfile.exist()) {
if (myfile.exist() == false) {
EWOL_ERROR("File Does not exist : " << myfile);
return;
}
m_FileSize = myfile.fileSize();
if (0 == m_FileSize) {
if (m_FileSize == 0) {
EWOL_ERROR("This file is empty : " << myfile);
return;
}
if (false == myfile.fileOpenRead()) {
if (myfile.fileOpenRead() == false) {
EWOL_ERROR("Can not open the file : " << myfile);
return;
}
// allocate data
m_FileBuffer = new FT_Byte[m_FileSize];
if (nullptr == m_FileBuffer) {
if (m_FileBuffer == nullptr) {
EWOL_ERROR("Error Memory allocation size=" << _fontName);
return;
}

View File

@ -99,7 +99,7 @@ void ewol::resource::TexturedFont::init(const std::string& _fontName) {
#if defined(__TARGET_OS__Android)
folderList.push_back("ROOT:system/fonts");
#elif defined(__TARGET_OS__Linux)
folderList.push_back("ROOT:usr/share/fonts/truetype");
folderList.push_back("ROOT:usr/share/fonts");
#endif
}
std::string applicationBaseFont = ewol::getContext().getFontDefault().getFolder();

70
ewol/tools/message.cpp Normal file
View File

@ -0,0 +1,70 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <ewol/tools/message.h>
#include <ewol/context/Context.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/Windows.h>
#include <ewol/widget/Manager.h>
#include <ewol/widget/meta/StdPopUp.h>
#undef __class__
#define __class__ "tools::message"
void ewol::tools::message::create(enum ewol::tools::message::type _type, const std::string& _message) {
ewol::widget::StdPopUpShared tmpPopUp = widget::StdPopUp::create();
if (tmpPopUp == nullptr) {
EWOL_ERROR("Can not create a simple pop-up");
return;
}
switch(_type) {
case ewol::tools::message::type_info:
tmpPopUp->propertyTitle.set("<bold>_T{Info}</bold>");
break;
case ewol::tools::message::type_warning:
tmpPopUp->propertyTitle.set("<bold><font color='orange'>_T{Warning}</font></bold>");
break;
case ewol::tools::message::type_error:
tmpPopUp->propertyTitle.set("<bold><font color='red'>_T{Error}</font></bold>");
break;
case ewol::tools::message::type_critical:
tmpPopUp->propertyTitle.set("<bold><font colorBg='red'>_T{Critical}</font></bold>");
break;
}
tmpPopUp->propertyComment.set(_message);
tmpPopUp->addButton("_T{close}", true);
tmpPopUp->propertyCloseOutEvent.set(true);
// get windows:
ewol::Context& context = ewol::getContext();
ewol::widget::WindowsShared windows = context.getWindows();
if (windows == nullptr) {
EWOL_ERROR("can not get the current windows ... ==> can not display message : " << _message);
return;
}
windows->popUpWidgetPush(tmpPopUp);
}
void ewol::tools::message::displayInfo(const std::string& _message) {
ewol::tools::message::create(ewol::tools::message::type_info, _message);
}
void ewol::tools::message::displayWarning(const std::string& _message) {
ewol::tools::message::create(ewol::tools::message::type_warning, _message);
}
void ewol::tools::message::displayError(const std::string& _message) {
ewol::tools::message::create(ewol::tools::message::type_error, _message);
}
void ewol::tools::message::displayCritical(const std::string& _message) {
ewol::tools::message::create(ewol::tools::message::type_critical, _message);
}

55
ewol/tools/message.h Normal file
View File

@ -0,0 +1,55 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <etk/Color.h>
#include <ewol/resource/ColorFile.h>
#include <list>
namespace ewol {
namespace tools {
namespace message {
enum type {
type_info, //!< information message pop-up
type_warning, //!< warning message pop-up
type_error, //!< Error message pop-up
type_critical //!< Critical message pop-up
};
/**
* @brief Create a simple pop-up message on the screen for application error.
* @param[in] _type Type of the error.
* @param[in] _message message to display (decorated text)
*/
void create(enum ewol::tools::message::type _type, const std::string& _message);
/**
* @brief Create a simple information message
* @param[in] _message message to display (decorated text)
*/
void displayInfo(const std::string& _message);
/**
* @brief Create a simple warning message
* @param[in] _message message to display (decorated text)
*/
void displayWarning(const std::string& _message);
/**
* @brief Create a simple error message
* @param[in] _message message to display (decorated text)
*/
void displayError(const std::string& _message);
/**
* @brief Create a simple critical message
* @param[in] _message message to display (decorated text)
*/
void displayCritical(const std::string& _message);
}
}
}

View File

@ -20,22 +20,22 @@
#undef __class__
#define __class__ "Windows"
//list of local events :
extern const char * const ewolEventWindowsHideKeyboard = "ewol Windows hideKeyboard";
ewol::widget::Windows::Windows() :
m_colorProperty(nullptr),
propertyColorConfiguration(this, "file-color", "{ewol}THEME:COLOR:Windows.json", "color file link on the theme", &ewol::widget::Windows::onChangePropertyColor),
propertyTitle(this, "title", "No title", "Title of the windows", &ewol::widget::Windows::onChangePropertyTitle),
m_resourceColor(nullptr),
m_colorBg(-1) {
addObjectType("ewol::widget::Windows");
m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:Windows.json");
if (m_colorProperty != nullptr) {
m_colorBg = m_colorProperty->request("background");
}
propertyCanFocus.setDirectCheck(true);
//KeyboardShow(KEYBOARD_MODE_CODE);
}
void ewol::widget::Windows::init() {
ewol::Widget::init();
onChangePropertyColor();
}
ewol::widget::Windows::~Windows() {
m_subWidget.reset();
m_popUpWidgetList.clear();
@ -107,7 +107,7 @@ void ewol::widget::Windows::sysDraw() {
}
void ewol::widget::Windows::onRegenerateDisplay() {
if (nullptr != m_subWidget) {
if (m_subWidget != nullptr) {
m_subWidget->onRegenerateDisplay();
}
for (auto &it : m_popUpWidgetList) {
@ -126,8 +126,8 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) {
#endif
// clear the screen with transparency ...
etk::Color<float> colorBg(0.5, 0.5, 0.5, 0.5);
if (m_colorProperty != nullptr) {
colorBg = m_colorProperty->get(m_colorBg);
if (m_resourceColor != nullptr) {
colorBg = m_resourceColor->get(m_colorBg);
}
gale::openGL::clearColor(colorBg);
gale::openGL::clear( gale::openGL::clearFlag_colorBuffer
@ -199,44 +199,20 @@ void ewol::widget::Windows::popUpWidgetPop() {
m_popUpWidgetList.pop_back();
}
void ewol::widget::Windows::setBackgroundColor(const etk::Color<float>& _color) {
if (m_backgroundColor != _color) {
m_backgroundColor = _color;
markToRedraw();
void ewol::widget::Windows::onChangePropertyColor() {
m_resourceColor = ewol::resource::ColorFile::create(*propertyColorConfiguration);
if (m_resourceColor != nullptr) {
m_colorBg = m_resourceColor->request("background");
}
}
void ewol::widget::Windows::setTitle(const std::string& _title) {
// TODO : remove this ...
std::string title = _title;
getContext().setTitle(title);
}
void ewol::widget::Windows::createPopUpMessage(enum popUpMessageType _type, const std::string& _message) {
ewol::widget::StdPopUpShared tmpPopUp = widget::StdPopUp::create();
if (tmpPopUp == nullptr) {
EWOL_ERROR("Can not create a simple pop-up");
return;
void ewol::widget::Windows::onChangePropertyTitle() {
ewol::Context& context = getContext();
if (context.getWindows() == shared_from_this()) {
context.setTitle(*propertyTitle);
} else {
EWOL_INFO("Set title is delayed ...");
}
switch(_type) {
case messageTypeInfo:
tmpPopUp->setTitle("<bold>Info</bold>");
break;
case messageTypeWarning:
tmpPopUp->setTitle("<bold><font color=\"orange\">Warning</font></bold>");
break;
case messageTypeError:
tmpPopUp->setTitle("<bold><font color=\"red\">Error</font></bold>");
break;
case messageTypeCritical:
tmpPopUp->setTitle("<bold><font colorBg=\"red\">Critical</font></bold>");
break;
}
tmpPopUp->setComment(_message);
tmpPopUp->addButton("close", true);
tmpPopUp->propertyCloseOutEvent.set(true);
popUpWidgetPush(tmpPopUp);
}
void ewol::widget::Windows::requestDestroyFromChild(const ewol::ObjectShared& _child) {
@ -295,9 +271,4 @@ ewol::ObjectShared ewol::widget::Windows::getSubObjectNamed(const std::string& _
return nullptr;
}
void ewol::widget::Windows::sysOnKill() {
if (onKill() == true) {
getContext().stop();
}
}

View File

@ -23,112 +23,64 @@ namespace ewol {
* @brief Windows basic interface
*/
class Windows : public ewol::Widget {
public:
eproperty::Value<std::string> propertyColorConfiguration; //!< Configuration file of the windows theme
eproperty::Value<std::string> propertyTitle; //!< Current title of the windows
protected:
std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
std::shared_ptr<ewol::resource::ColorFile> m_resourceColor; //!< theme color property (name of file in @ref propertyColorConfiguration)
int32_t m_colorBg; //!< Default background color of the windows
protected:
Windows();
void init() override;
public:
virtual ~Windows();
// internal event at ewol system :
// internal event at ewol system:
public:
void sysDraw();
void sysOnShow() {};
void sysOnHide() {};
void sysOnKill();
public:
virtual void onShow() { };
virtual void onHide() { };
virtual bool onKill() {
// TODO : Check this in speck for android ...
return false;
};
virtual void onReduce() { };
virtual void onStateBackground() {};
virtual void onStateForeground() {};
virtual void onStateSuspend() {};
virtual void onStateResume() {};
private:
ewol::WidgetShared m_subWidget;
std::list<ewol::WidgetShared> m_popUpWidgetList;
protected:
ewol::WidgetShared m_subWidget; //!< main sub-widget of the Windows.
public:
/**
* @brief Set the main widget of the application.
* @param[in] _widget Widget to set in the windows.
*/
void setSubWidget(ewol::WidgetShared _widget);
protected:
std::list<ewol::WidgetShared> m_popUpWidgetList; //!< List of pop-up displayed
public:
/**
* @brief Add a pop-up on the Windows.
* @param[in] _widget Widget to set on top of the pop-up.
*/
void popUpWidgetPush(ewol::WidgetShared _widget);
/**
* @brief Remove the pop-up on top.
*/
void popUpWidgetPop();
/**
* @brief Get the number of pop-up
* @return Count of pop-up
*/
size_t popUpCount() {
return m_popUpWidgetList.size();
}
private:
etk::Color<float> m_backgroundColor; //!< reset color of the Main windows
public:
/**
* @brief get the background color.
* @return A reference on the color
*/
const etk::Color<float>& getBackgroundColor() {
return m_backgroundColor;
};
/**
* @brief set the background color.
* @param[IN] the new requested color.
*/
void setBackgroundColor(const etk::Color<float>& _color);
protected:
void systemDraw(const ewol::DrawProperty& _displayProp) override;
public: // Derived function
public:
void onRegenerateDisplay() override;
void onChangeSize() override;
ewol::WidgetShared getWidgetAtPos(const vec2& _pos) override;
void requestDestroyFromChild(const ewol::ObjectShared& _child) override;
ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override;
void setTitle(const std::string& _title);
public:
enum popUpMessageType {
messageTypeInfo, //!< information message pop-up
messageTypeWarning, //!< warning message pop-up
messageTypeError, //!< Error message pop-up
messageTypeCritical //!< Critical message pop-up
};
protected:
/**
* @brief Create a simple pop-up message on the screen for application error.
* @param[in] _type Type of the error.
* @param[in] _message message to display (decorated text)
* @brief Called when property change: Title
*/
virtual void createPopUpMessage(enum popUpMessageType _type, const std::string& _message);
virtual void onChangePropertyTitle();
/**
* @brief Create a simple information message
* @param[in] _message message to display (decorated text)
* @brief Called when property change: Color configuration file
*/
void displayInfoMessage(const std::string& _message) {
createPopUpMessage(messageTypeInfo, _message);
}
/**
* @brief Create a simple warning message
* @param[in] _message message to display (decorated text)
*/
void displayWarningMessage(const std::string& _message) {
createPopUpMessage(messageTypeWarning, _message);
}
/**
* @brief Create a simple error message
* @param[in] _message message to display (decorated text)
*/
void displayErrorMessage(const std::string& _message) {
createPopUpMessage(messageTypeError, _message);
}
/**
* @brief Create a simple critical message
* @param[in] _message message to display (decorated text)
*/
void displayCriticalMessage(const std::string& _message) {
createPopUpMessage(messageTypeCritical, _message);
}
/* TODO :
virtual bool onEventHardwareInput(const gale::key::keyboardSystem& _event, bool _down) {
return false;
};
*/
virtual void onChangePropertyColor();
};
}
}

View File

@ -17,6 +17,14 @@
#define __class__ "ewol::StdPopUp"
ewol::widget::StdPopUp::StdPopUp() :
propertyTitle(this, "title",
"<bold>Message</bold>",
"Title of the pop-up",
&ewol::widget::StdPopUp::onChangePropertyTitle),
propertyComment(this, "comment",
"No Label",
"Comment of the pop-up",
&ewol::widget::StdPopUp::onChangePropertyComment),
m_title(nullptr),
m_comment(nullptr),
m_subBar(nullptr) {
@ -54,7 +62,7 @@ void ewol::widget::StdPopUp::init() {
mySizerVert->subWidgetAdd(mySpacer);
m_comment = ewol::widget::Label::create();
m_comment->propertyValue.set("No Label");
m_comment->propertyValue.set(*propertyComment);
m_comment->propertyExpand.set(bvec2(true,true));
mySizerVert->subWidgetAdd(m_comment);
@ -70,7 +78,7 @@ void ewol::widget::StdPopUp::init() {
mySizerVert->subWidgetAdd(mySpacer);
m_title = ewol::widget::Label::create();
m_title->propertyValue.set("<bold>Message</bold>");
m_title->propertyValue.set(*propertyTitle);
m_title->propertyExpand.set(bvec2(true,false));
m_title->propertyFill.set(bvec2(true,true));
mySizerVert->subWidgetAdd(m_title);
@ -80,19 +88,19 @@ ewol::widget::StdPopUp::~StdPopUp() {
}
void ewol::widget::StdPopUp::setTitle(const std::string& _text) {
void ewol::widget::StdPopUp::onChangePropertyTitle() {
if (m_title == nullptr) {
return;
}
m_title->propertyValue.set(_text);
m_title->propertyValue.set(*propertyTitle);
markToRedraw();
}
void ewol::widget::StdPopUp::setComment(const std::string& _text) {
void ewol::widget::StdPopUp::onChangePropertyComment() {
if (m_comment == nullptr) {
return;
}
m_comment->propertyValue.set(_text);
m_comment->propertyValue.set(*propertyComment);
markToRedraw();
}

View File

@ -27,7 +27,7 @@ namespace ewol {
* | |
* | |
* | +-------------------+ |
* | | Erreur: | |
* | | Title: | |
* | | | |
* | | Message to diplay | |
* | | to user | |
@ -42,7 +42,8 @@ namespace ewol {
*/
class StdPopUp : public ewol::widget::PopUp {
public: // properties:
// TODO: ...
eproperty::Value<std::string> propertyTitle; //!< Title of the pop-up
eproperty::Value<std::string> propertyComment; //!< comment in the pop-up (can be decorated text)
protected:
/**
* @brief std-pop-up constructor.
@ -57,20 +58,15 @@ namespace ewol {
virtual ~StdPopUp();
protected:
ewol::widget::LabelShared m_title; //!< Title Label widget
public:
/**
* @brief Set the title string.
* @param[in] _text Decorated text to diplay in title.
* @brief property callback when request a change of the title.
*/
void setTitle(const std::string& _text);
protected:
void onChangePropertyTitle();
ewol::widget::LabelShared m_comment; //!< Comment label widget
public:
/**
* @brief Set the commentary string.
* @param[in] _text Decorated text to diplay in Comment.
* @brief property callback when request a change of the Comment.
*/
void setComment(const std::string& _text);
void onChangePropertyComment();
protected:
ewol::widget::SizerShared m_subBar; //!< subwidget bar containing all the button.
public:
@ -79,8 +75,8 @@ namespace ewol {
* @param[in] _text Decorated text to diplay in button.
*/
ewol::widget::ButtonShared addButton(const std::string& _text, bool _autoExit=false);
public: // callback function
void onCallBackButtonExit();
public:
virtual void onCallBackButtonExit();
};
}
}

4
lutinParseSubFolders.txt Normal file
View File

@ -0,0 +1,4 @@
sample/001_HelloWord
sample/0XX_CustomWidgets
sample/examplewallpaper
tools/visual_test

View File

@ -79,6 +79,7 @@ def create(target, module_name):
my_module.add_src_file([
'ewol/context/ConfigFont.cpp',
'ewol/context/Context.cpp',
'ewol/context/Application.cpp',
'ewol/context/InputManager.cpp'
])
my_module.add_header_file([
@ -220,6 +221,14 @@ def create(target, module_name):
'ewol/widget/Spin.h'
])
# tools:
my_module.add_src_file([
'ewol/tools/message.cpp'
])
my_module.add_header_file([
'ewol/tools/message.h'
])
my_module.copy_path('data/theme/shape/square/*','theme/shape/square')
my_module.copy_path('data/theme/shape/round/*','theme/shape/round')
my_module.copy_path('data/theme/color/black/*','theme/color/black')

View File

@ -20,9 +20,16 @@
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
void onCreate(ewol::Context& _context) override {
APPL_INFO(" == > CREATE ... " << PROJECT_NAME << " v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ") (BEGIN)");
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
std::string tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h"
|| tmpppp == "--help") {
APPL_INFO(" -h/--help display this help" );
exit(0);
}
}
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
@ -30,17 +37,21 @@ class MainApplication : public ewol::context::Application {
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
ewol::widget::WindowsShared basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)");
}
void unInit(ewol::Context& _context) {
APPL_INFO("==> Un-Init APPL (START)");
void onStart(ewol::Context& _context) override {
APPL_INFO("==> START ... " PROJECT_NAME " (BEGIN)");
// nothing to do ...
APPL_INFO("==> Un-Init APPL (END)");
APPL_INFO("==> START ... " PROJECT_NAME " (END)");
}
void onStop(ewol::Context& _context) override {
APPL_INFO("==> STOP ... " PROJECT_NAME " (START)");
// nothing to do ...
APPL_INFO("==> STOP ... " PROJECT_NAME " (END)");
}
};

View File

@ -16,16 +16,16 @@
appl::Windows::Windows() {
addObjectType("appl::Windows");
propertyTitle.setDirectCheck(std::string("sample ") + PROJECT_NAME);
}
void appl::Windows::init() {
ewol::widget::Windows::init();
setTitle("example 001_HelloWorld");
std::shared_ptr<ewol::widget::Label> tmpWidget = ewol::widget::Label::create();
ewol::widget::LabelShared tmpWidget = ewol::widget::Label::create();
if (tmpWidget == nullptr) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->setLabel("Hello <font color=\"blue\">World</font>");
tmpWidget->setExpand(bvec2(true,true));
tmpWidget->propertyValue.set("Hello <font color='blue'>World</font>");
tmpWidget->propertyExpand.set(bvec2(true,true));
setSubWidget(tmpWidget);
}
}

View File

@ -10,6 +10,9 @@
#include <ewol/widget/Windows.h>
namespace appl {
class Windows;
using WindowsShared = ememory::SharedPtr<appl::Windows>;
using WindowsWeak = ememory::WeakPtr<appl::Windows>;
class Windows : public ewol::widget::Windows {
protected:
Windows();

View File

@ -35,7 +35,9 @@ def create(target, module_name):
])
my_module.add_module_depend(['ewol'])
my_module.compile_flags('c++', [
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""])
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\"",
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
])
my_module.add_path(tools.get_current_path(__file__))
return my_module

View File

@ -21,9 +21,16 @@
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
void onCreate(ewol::Context& _context) override {
APPL_INFO(" == > CREATE ... " << PROJECT_NAME << " v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ") (BEGIN)");
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
std::string tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h"
|| tmpppp == "--help") {
APPL_INFO(" -h/--help display this help" );
exit(0);
}
}
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
@ -33,16 +40,21 @@ class MainApplication : public ewol::context::Application {
appl::widget::VectorDisplay::createManagerWidget(_context.getWidgetManager());
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
ewol::widget::WindowsShared basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)");
}
void unInit(ewol::Context& _context) {
APPL_INFO("==> Un-Init APPL (START)");
// nothing to do...
APPL_INFO("==> Un-Init APPL (END)");
void onStart(ewol::Context& _context) override {
APPL_INFO("==> START ... " PROJECT_NAME " (BEGIN)");
// nothing to do ...
APPL_INFO("==> START ... " PROJECT_NAME " (END)");
}
void onStop(ewol::Context& _context) override {
APPL_INFO("==> STOP ... " PROJECT_NAME " (START)");
// nothing to do ...
APPL_INFO("==> STOP ... " PROJECT_NAME " (END)");
}
};

View File

@ -21,12 +21,13 @@ static const char* const g_eventChangeValues = "appl-change-value";
static const char* const g_eventAutoMode = "appl-change-auto";
appl::Windows::Windows() :
m_composer(NULL) {
m_composer(nullptr) {
addObjectType("appl::Windows");
propertyTitle.setDirectCheck(std::string("sample ") + PROJECT_NAME);
}
void appl::Windows::init() {
setTitle("example 001_HelloWord");
ewol::widget::Windows::init();
std::string composition = std::string("");
composition += "<sizer mode='vert'>\n";
composition += " <sizer mode='hori'>\n";
@ -44,11 +45,12 @@ void appl::Windows::init() {
composition += " <VectorDisplay name='displayer' expand='true' fill='true'/>\n";
composition += "</sizer>\n";
m_composer = ewol::widget::Composer::create(ewol::widget::Composer::String, composition);
if (m_composer == NULL) {
m_composer = ewol::widget::Composer::create();
if (m_composer == nullptr) {
APPL_CRITICAL(" An error occured ... in the windows creatrion ...");
return;
}
m_composer->loadFromString(composition);
setSubWidget(m_composer);
subBind(ewol::widget::Button, "bt-change", signalPressed, shared_from_this(), &appl::Windows::onCallbackChangeValues);
subBind(ewol::widget::Button, "bt-auto", signalPressed, shared_from_this(), &appl::Windows::onCallbackAutoMode);
@ -60,14 +62,14 @@ void appl::Windows::onCallbackChangeValues() {
tmp.push_back(etk::tool::frand(-1.0, 1.0));
}
std::shared_ptr<appl::widget::VectorDisplay> tmpDisp = std::dynamic_pointer_cast<appl::widget::VectorDisplay>(getSubObjectNamed("displayer"));
if (tmpDisp != NULL) {
if (tmpDisp != nullptr) {
tmpDisp->setValue(tmp);
}
}
void appl::Windows::onCallbackAutoMode() {
std::shared_ptr<appl::widget::VectorDisplay> tmpDisp = std::dynamic_pointer_cast<appl::widget::VectorDisplay>(getSubObjectNamed("displayer"));
if (tmpDisp != NULL) {
if (tmpDisp != nullptr) {
tmpDisp->ToggleAuto();
}
}

View File

@ -11,9 +11,12 @@
#include <ewol/widget/Composer.h>
namespace appl {
class Windows;
using WindowsShared = ememory::SharedPtr<appl::Windows>;
using WindowsWeak = ememory::WeakPtr<appl::Windows>;
class Windows : public ewol::widget::Windows {
private:
std::shared_ptr<ewol::widget::Composer> m_composer;
ewol::widget::ComposerShared m_composer;
protected:
Windows();
void init();

View File

@ -36,7 +36,9 @@ def create(target, module_name):
])
my_module.add_module_depend(['ewol'])
my_module.compile_flags('c++', [
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""])
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\"",
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
])
my_module.add_path(tools.get_current_path(__file__))
return my_module

View File

@ -20,9 +20,16 @@
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
void onCreate(ewol::Context& _context) override {
APPL_INFO(" == > CREATE ... " << PROJECT_NAME << " v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ") (BEGIN)");
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
std::string tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h"
|| tmpppp == "--help") {
APPL_INFO(" -h/--help display this help" );
exit(0);
}
}
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
@ -30,17 +37,21 @@ class MainApplication : public ewol::context::Application {
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
ewol::widget::WindowsShared basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)");
}
void unInit(ewol::Context& _context) {
APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)");
void onStart(ewol::Context& _context) override {
APPL_INFO("==> START ... " PROJECT_NAME " (BEGIN)");
// nothing to do ...
APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)");
APPL_INFO("==> START ... " PROJECT_NAME " (END)");
}
void onStop(ewol::Context& _context) override {
APPL_INFO("==> STOP ... " PROJECT_NAME " (START)");
// nothing to do ...
APPL_INFO("==> STOP ... " PROJECT_NAME " (END)");
}
};

View File

@ -18,12 +18,12 @@
appl::WidgetDisplay::WidgetDisplay() {
addObjectType("appl::WidgetDisplay");
propertyCanFocus.setDirectCheck(true);
}
void appl::WidgetDisplay::init() {
ewol::Widget::init();
m_compositing.setSource("DATA:SnowFlake.svg", ivec2(128,128));
setCanHaveFocus(true);
periodicCallEnable();
for (int32_t iii=0; iii<250 ; ++iii) {
m_elements.push_back(appl::WidgetDisplay::Element());

View File

@ -7,11 +7,14 @@
*/
#pragma once
#include <draw/Color.h>
#include <etk/Color.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Image.h>
namespace appl {
class WidgetDisplay;
using WidgetDisplayShared = ememory::SharedPtr<appl::WidgetDisplay>;
using WidgetDisplayWeak = ememory::WeakPtr<appl::WidgetDisplay>;
class WidgetDisplay : public ewol::Widget {
private:
class Element {

View File

@ -17,20 +17,19 @@
appl::Windows::Windows() {
addObjectType("appl::Windows");
propertyTitle.setDirectCheck(std::string("sample ") + PROJECT_NAME);
}
void appl::Windows::init() {
ewol::widget::Windows::init();
setTitle("example Wallpaper");
std::shared_ptr<appl::WidgetDisplay> tmpWidget = appl::WidgetDisplay::create();
appl::WidgetDisplayShared tmpWidget = appl::WidgetDisplay::create();
if (tmpWidget == nullptr) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
setSubWidget(tmpWidget);
tmpWidget->setExpand(bvec2(true,true));
tmpWidget->setFill(bvec2(true,true));
tmpWidget->propertyExpand.set(bvec2(true,true));
tmpWidget->propertyFill.set(bvec2(true,true));
}
setBackgroundColor(etk::Color<float>(0,0,0,0));
}
appl::Windows::~Windows() {

View File

@ -11,6 +11,9 @@
#include <ewol/widget/Windows.h>
namespace appl {
class Windows;
using WindowsShared = ememory::SharedPtr<appl::Windows>;
using WindowsWeak = ememory::WeakPtr<appl::Windows>;
class Windows : public ewol::widget::Windows {
protected:
Windows();

View File

@ -28,6 +28,9 @@ def get_compagny_name():
def get_maintainer():
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
def get_version():
return [0,1]
def create(target, module_name):
my_module = module.Module(__file__, module_name, get_type())
my_module.add_src_file([
@ -38,14 +41,12 @@ def create(target, module_name):
])
my_module.add_module_depend(['ewol'])
my_module.compile_flags('c++', [
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\"",
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
])
my_module.copy_path('data/SnowFlake.svg','')
my_module.add_path(tools.get_current_path(__file__))
now = datetime.datetime.now()
versionID=str(now.year-2013)+"."+str(now.month)+"."+str(now.day)
# set the package properties :
my_module.pkg_set("VERSION", versionID)
my_module.pkg_set("COMPAGNY_TYPE", get_compagny_type())
my_module.pkg_set("COMPAGNY_NAME", get_compagny_name())
my_module.pkg_set("MAINTAINER", get_maintainer())

View File

@ -19,10 +19,10 @@ namespace appl {
protected:
Windows() {
addObjectType("appl::Windows");
propertyTitle.setDirectCheck("test set");
}
void init() {
ewol::widget::Windows::init();
setTitle("test set");
}
public:
DECLARE_FACTORY(Windows);

View File

@ -66,7 +66,7 @@ class MainApplication : public ewol::context::Application {
_context.setWindows(basicWindows);
if (basicWindows == nullptr) {
APPL_ERROR("Can not allocate the basic windows");
_context.stop();
_context.exit(-1);
return;
}

View File

@ -10,7 +10,7 @@ def get_sub_type():
return "TOOL"
def get_desc():
return "ewol test software (visual)"
return "ewol tools software (visual)"
def get_licence():
return "APACHE-2"
@ -28,28 +28,28 @@ def create(target, module_name):
my_module = module.Module(__file__, module_name, get_type())
# add the file to compile:
my_module.add_src_file([
'tools/visual_test/appl/debug.cpp',
'tools/visual_test/appl/init.cpp',
'tools/visual_test/appl/MainWindows.cpp',
'tools/visual_test/appl/TestDistanceField.cpp',
'tools/visual_test/appl/widget/SizerColor.cpp'
'appl/debug.cpp',
'appl/init.cpp',
'appl/MainWindows.cpp',
'appl/TestDistanceField.cpp',
'appl/widget/SizerColor.cpp'
])
my_module.add_module_depend(['ewol'])
my_module.copy_file('tools/visual_test/data/icon.png','icon.png')
my_module.copy_file('data/icon.png','icon.png')
my_module.copy_path('tools/visual_test/data/icon.*','')
my_module.copy_path('tools/visual_test/data/cube.*','')
my_module.copy_path('tools/visual_test/data/grass.*','')
my_module.copy_path('tools/visual_test/data/stone*','')
my_module.copy_path('tools/visual_test/data/sphere.png','')
my_module.copy_path('tools/visual_test/data/sphere.obj','')
my_module.copy_path('tools/visual_test/data/gui.xml','')
my_module.copy_path('data/icon.*','')
my_module.copy_path('data/cube.*','')
my_module.copy_path('data/grass.*','')
my_module.copy_path('data/stone*','')
my_module.copy_path('data/sphere.png','')
my_module.copy_path('data/sphere.obj','')
my_module.copy_path('data/gui.xml','')
my_module.add_path(os.path.join(tools.get_current_path(__file__), "tools/visual_test/"))
my_module.add_path(tools.get_current_path(__file__))
my_module.copy_path("tools/visual_test/data/FreeSerif*","fonts/")
my_module.copy_path("data/FreeSerif*","fonts/")
"""
# set the package properties :