[DEV] update to echrono

This commit is contained in:
Edouard DUPIN 2016-10-14 21:13:39 +02:00
parent b451e97293
commit 3cc6e1577e
14 changed files with 71 additions and 106 deletions

View File

@ -20,7 +20,7 @@
#include <gale/renderer/openGL/openGL.hpp>
#include <gale/Dimension.hpp>
#include <ewol/translate.hpp>
#include <etranslate/etranslate.hpp>
#include <ewol/object/Object.hpp>
#include <ewol/object/Manager.hpp>
#include <ewol/widget/Widget.hpp>
@ -65,8 +65,8 @@ void ewol::Context::inputEventUnGrabPointer() {
void ewol::Context::onCreate(gale::Context& _context) {
EWOL_INFO(" == > Ewol system create (BEGIN)");
// Add basic ewol translation:
ewol::translate::addPath("ewol", "{ewol}DATA:translate/ewol/");
ewol::translate::autoDetectLanguage();
etranslate::addPath("ewol", "{ewol}DATA:translate/ewol/");
etranslate::autoDetectLanguage();
// By default we set 2 themes (1 color and 1 shape ...) :
etk::theme::setNameDefault("GUI", "shape/square/");
etk::theme::setNameDefault("COLOR", "color/black/");
@ -335,7 +335,7 @@ void ewol::Context::requestUpdateSize() {
context.requestUpdateSize();
}
void ewol::Context::onPeriod(int64_t _time) {
void ewol::Context::onPeriod(const echrono::Clock& _time) {
m_objectManager.timeCall(_time);
}

View File

@ -148,7 +148,7 @@ namespace ewol {
* @brief Request a display after call a resize
*/
void requestUpdateSize();
void onPeriod(int64_t _time) override;
void onPeriod(const echrono::Clock& _time) override;
};
/**
* @brief From everyware in the program, we can get the context inteface.

View File

@ -22,10 +22,10 @@
//#define EVENT_DEBUG EWOL_DEBUG
void ewol::context::InputManager::calculateLimit() {
m_eventInputLimit.sepatateTime = 300000; // µs
m_eventInputLimit.sepatateTime = echrono::Duration(std::chrono::milliseconds(300));
m_eventInputLimit.DpiOffset = m_dpi*100;
m_eventMouseLimit.sepatateTime = 300000; // µs
m_eventMouseLimit.DpiOffset = (float)m_dpi*(float)0.1;
m_eventMouseLimit.sepatateTime = echrono::Duration(std::chrono::milliseconds(300));
m_eventMouseLimit.DpiOffset = float(m_dpi)*0.1f;
}
void ewol::context::InputManager::setDpi(int32_t newDPI) {
@ -76,7 +76,7 @@ void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable,
//EWOL_INFO("CleanElement[" << idInput << "] = @" << (int64_t)eventTable);
_eventTable[_idInput].isUsed = false;
_eventTable[_idInput].destinationInputId = 0;
_eventTable[_idInput].lastTimeEvent = 0;
_eventTable[_idInput].lastTimeEvent.reset();
_eventTable[_idInput].curentWidgetEvent.reset();
_eventTable[_idInput].origin.setValue(0,0);
_eventTable[_idInput].size.setValue(99999999,99999999);
@ -342,7 +342,7 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
return;
}
// get the curent time ...
int64_t currentTime = ewol::getTime();
echrono::Clock currentTime = echrono::Clock::now();
ewol::widget::WindowsShared tmpWindows = m_context.getWindows();
if (_isDown == true) {

View File

@ -18,7 +18,7 @@ namespace ewol {
public:
bool isUsed;
int32_t destinationInputId;
int64_t lastTimeEvent;
echrono::Clock lastTimeEvent;
ewol::WidgetWeak curentWidgetEvent;
vec2 origin;
vec2 size;
@ -35,7 +35,7 @@ namespace ewol {
*/
class InputLimit {
public:
int32_t sepatateTime;
echrono::Duration sepatateTime;
int32_t DpiOffset;
};
class Context;

View File

@ -6,20 +6,22 @@
#pragma once
#include <etk/types.hpp>
#include <echrono/Clock.hpp>
#include <echrono/Duration.hpp>
namespace ewol {
namespace event {
class Time {
private:
int64_t m_timeSystem; //!< Current system time (micro-second)
int64_t m_timeUpAppl; //!< Current application wake up-time (micro-second)
float m_timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second)
float m_timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second)
echrono::Clock m_timeSystem; //!< Current system time (micro-second)
echrono::Clock m_timeUpAppl; //!< Current application wake up-time (micro-second)
echrono::Duration m_timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second)
echrono::Duration m_timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second)
public:
Time(int64_t _timeSystem,
int64_t _timeUpAppl,
float _timeDelta,
float _timeDeltaCall) :
Time(const echrono::Clock& _timeSystem,
const echrono::Clock& _timeUpAppl,
const echrono::Duration& _timeDelta,
const echrono::Duration& _timeDeltaCall) :
m_timeSystem(_timeSystem),
m_timeUpAppl(_timeUpAppl),
m_timeDelta(_timeDelta),
@ -27,32 +29,38 @@ namespace ewol {
};
public:
void setTime(int64_t _timeSystem) {
m_timeSystem=_timeSystem;
void setTime(const echrono::Clock& _timeSystem) {
m_timeSystem = _timeSystem;
};
inline int64_t getTime() const {
inline const echrono::Clock& getTime() const {
return m_timeSystem;
};
void setApplWakeUpTime(int64_t _timeUpAppl) {
m_timeUpAppl=_timeUpAppl;
void setApplWakeUpTime(const echrono::Clock& _timeUpAppl) {
m_timeUpAppl = _timeUpAppl;
};
inline int64_t getApplWakeUpTime() const {
inline const echrono::Clock& getApplWakeUpTime() const {
return m_timeUpAppl;
};
inline int64_t getApplUpTime() const {
inline echrono::Duration getApplUpTime() const {
return m_timeSystem-m_timeUpAppl;
};
void setDelta(float _timeDelta) {
m_timeDelta=_timeDelta;
void setDelta(const echrono::Duration& _timeDelta) {
m_timeDelta = _timeDelta;
};
inline float getDelta() const {
inline const echrono::Duration& getDeltaDuration() const {
return m_timeDelta;
};
void setDeltaCall(float _timeDeltaCall) {
m_timeDeltaCall=_timeDeltaCall;
inline float getDelta() const {
return m_timeDelta.toSeconds();
};
void setDeltaCall(const echrono::Duration& _timeDeltaCall) {
m_timeDeltaCall = _timeDeltaCall;
};
inline const echrono::Duration& getDeltaCallDuration() const {
return m_timeDeltaCall;
};
inline float getDeltaCall() const {
return m_timeDeltaCall;
return m_timeDeltaCall.toSeconds();
};
};
std::ostream& operator <<(std::ostream& _os, const ewol::event::Time& _obj);

View File

@ -17,36 +17,10 @@
#define EWOL_VERSION "0.0.0"
#endif
std::string ewol::getCompilationMode() {
#ifdef MODE_RELEASE
return "Release";
#else
return "Debug";
#endif
}
std::string ewol::getBoardType() {
#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
}
std::string ewol::getVersion() {
return EWOL_VERSION;
}
int64_t ewol::getTime() {
return gale::getTime();
}
int32_t ewol::run(ewol::context::Application* _application,
int32_t _argc,

View File

@ -21,29 +21,10 @@ namespace ewol {
* @param[in] _argv Standard argv
* @return normal error int for the application error management
*/
int32_t run(ewol::context::Application* _application, int32_t _argc = 0, const char* _argv[] = NULL);
int32_t run(ewol::context::Application* _application, int32_t _argc = 0, const char* _argv[] = nullptr);
/**
* @brief get EWOL version
* @return The string that describe ewol version
*/
std::string getVersion();
/**
* @brief get current time in us...
* @return The current time
* @note is implemented by the OS implementation cf renderer/X11/...
*/
// TODO : Remove ...
int64_t getTime();
/**
* @brief get compilation mode (release/debug)
* @return the string of the mode of commpilation
*/
// TODO : Remove ...
std::string getCompilationMode();
/**
* @brief get the board type (Android/Linux/MacOs/...)
* @return the string of the mode of commpilation
*/
// TODO : Remove ...
std::string getBoardType();
};

View File

@ -18,8 +18,8 @@ ewol::object::Manager::Manager(ewol::Context& _context) :
EWOL_DEBUG(" == > init Object-Manager");
periodicCall.setPeriodic(true);
// set the basic time properties :
m_applWakeUpTime = ewol::getTime();
m_lastPeriodicCallTime = ewol::getTime();
m_applWakeUpTime = echrono::Clock::now();
m_lastPeriodicCallTime = echrono::Clock::now();
}
ewol::object::Manager::~Manager() {
@ -30,7 +30,7 @@ ewol::object::Manager::~Manager() {
EWOL_ERROR("Must not have anymore eObject !!!");
hasError = true;
}
if (true == hasError) {
if (hasError == true) {
EWOL_ERROR("Check if the function UnInit has been called !!!");
}
displayListObject();
@ -136,19 +136,19 @@ void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
}
}
void ewol::object::Manager::timeCall(int64_t _localTime) {
void ewol::object::Manager::timeCall(const echrono::Clock& _localTime) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
int64_t previousTime = m_lastPeriodicCallTime;
echrono::Clock previousTime = m_lastPeriodicCallTime;
m_lastPeriodicCallTime = _localTime;
if (periodicCall.size() <= 0) {
return;
}
float deltaTime = (float)(_localTime - previousTime)/1000000.0;
echrono::Duration deltaTime = _localTime - previousTime;
ewol::event::Time myTime(_localTime, m_applWakeUpTime, deltaTime, deltaTime);
periodicCall.emit(myTime);
}
void ewol::object::Manager::timeCallResume(int64_t _localTime) {
void ewol::object::Manager::timeCallResume(const echrono::Clock& _localTime) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_lastPeriodicCallTime = _localTime;
}

View File

@ -9,6 +9,8 @@
#include <ewol/object/Object.hpp>
#include <esignal/Signal.hpp>
#include <ewol/event/Time.hpp>
#include <echrono/Steady.hpp>
#include <echrono/Duration.hpp>
namespace ewol {
class Context;
@ -78,19 +80,19 @@ namespace ewol {
public:
esignal::Signal<ewol::event::Time> periodicCall;
private:
int64_t m_applWakeUpTime; //!< Time of the application initialize
int64_t m_lastPeriodicCallTime; //!< last call time ...
echrono::Clock m_applWakeUpTime; //!< Time of the application initialize
echrono::Clock m_lastPeriodicCallTime; //!< last call time ...
public: // ewol system internal :
/**
* @brief Call every time we can with the current time
* @param[in] _localTime Current system Time.
*/
void timeCall(int64_t _localTime);
void timeCall(const echrono::Clock& _localTime);
/**
* @brief If the application is suspended The Ewol Object manager does not know it, just call this to update delta call
* @param[in] _localTime Current system Time.
*/
void timeCallResume(int64_t _localTime);
void timeCallResume(const echrono::Clock& _localTime);
/**
* @breif check if the Interface have some user that request a periodic call
* @return true, have some periodic event...

View File

@ -5,7 +5,7 @@
*/
#include <ewol/debug.hpp>
#include <ewol/translate.hpp>
#include <etranslate/etranslate.hpp>
#include <map>
#include <etk/os/FSNode.hpp>
#include <ejson/ejson.hpp>
@ -213,31 +213,31 @@ static LocalInstanceTranslation& getInstanceTranslation() {
return g_val;
}
void ewol::translate::addPath(const std::string& _lib, const std::string& _path, bool _major) {
void etranslate::addPath(const std::string& _lib, const std::string& _path, bool _major) {
getInstanceTranslation().addPath(_lib, _path, _major);
}
const std::string& ewol::translate::getPaths(const std::string& _lib) {
const std::string& etranslate::getPaths(const std::string& _lib) {
return getInstanceTranslation().getPaths(_lib);
}
void ewol::translate::setLanguageDefault(const std::string& _lang) {
void etranslate::setLanguageDefault(const std::string& _lang) {
getInstanceTranslation().setLanguageDefault(_lang);
}
const std::string& ewol::translate::getLanguageDefault() {
const std::string& etranslate::getLanguageDefault() {
return getInstanceTranslation().getLanguageDefault();
}
void ewol::translate::setLanguage(const std::string& _lang) {
void etranslate::setLanguage(const std::string& _lang) {
getInstanceTranslation().setLanguage(_lang);
}
const std::string& ewol::translate::getLanguage() {
const std::string& etranslate::getLanguage() {
return getInstanceTranslation().getLanguage();
}
void ewol::translate::autoDetectLanguage() {
void etranslate::autoDetectLanguage() {
EWOL_VERBOSE("Auto-detect language of system");
std::string nonameLocalName;
std::string userLocalName;
@ -292,7 +292,7 @@ void ewol::translate::autoDetectLanguage() {
#endif
}
std::string ewol::translate::get(const std::string& _instance) {
std::string etranslate::get(const std::string& _instance) {
return getInstanceTranslation().get(_instance);
}

View File

@ -70,4 +70,4 @@ namespace ewol {
};
};
// Here we define a simple macro to Translate all string simply:
#define TRANSLATE(a) ewol::translate::get(a)
#define TRANSLATE(a) etranslate::get(a)

View File

@ -149,7 +149,7 @@ bool ewol::widget::Label::loadXML(const exml::Element& _node) {
void ewol::widget::Label::onChangePropertyValue() {
if (*propertyAutoTranslate == true) {
m_value = etk::to_u32string(ewol::translate::get(*propertyValue));
m_value = etk::to_u32string(etranslate::get(*propertyValue));
} else {
m_value = etk::to_u32string(*propertyValue);
}

View File

@ -29,7 +29,7 @@ namespace ewol {
#include <ewol/event/Input.hpp>
#include <ewol/event/Entry.hpp>
#include <ewol/event/Time.hpp>
#include <ewol/translate.hpp>
#include <etranslate/etranslate.hpp>
#include <esignal/Signal.hpp>
#include <ewol/DrawProperty.hpp>
#include <ewol/gravity.hpp>

View File

@ -32,7 +32,6 @@ def configure(target, my_module):
'ewol/ewol.cpp',
'ewol/debug.cpp',
'ewol/Padding.cpp',
'ewol/translate.cpp',
'ewol/DrawProperty.cpp',
'ewol/gravity.cpp'
])
@ -40,7 +39,6 @@ def configure(target, my_module):
'ewol/debug.hpp', # TODO : Remove this ...
'ewol/ewol.hpp',
'ewol/Padding.hpp',
'ewol/translate.hpp',
'ewol/DrawProperty.hpp',
'ewol/gravity.hpp'
])
@ -251,7 +249,9 @@ def configure(target, my_module):
'exml',
'ejson',
'egami',
'edtaa3'])
'edtaa3',
'etranslate',
])
my_module.add_path(".")