[DEV] continue removing STL
This commit is contained in:
parent
4aada212ac
commit
b66827c6de
@ -27,7 +27,7 @@ Why we use "DECLARE_FACTORY" Macro?
|
|||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
For some reason!!! But everything might be clear:
|
For some reason!!! But everything might be clear:
|
||||||
- In ewol we masively use ememory::SharedPtr (simple wrapper over std::shared_ptr (that is not thread safe ...)).
|
- In ewol we masively use ememory::SharedPtr.
|
||||||
- The main class : ewol::Object herited from ememory::EnableSharedFromThis<ewol::Object> to permit to access at his own ememory::SharedPtr.
|
- The main class : ewol::Object herited from ememory::EnableSharedFromThis<ewol::Object> to permit to access at his own ememory::SharedPtr.
|
||||||
- Acces At his own ememory::SharedPtr is not allowed in the class contructor/destructor.
|
- Acces At his own ememory::SharedPtr is not allowed in the class contructor/destructor.
|
||||||
- Many time for meta-widget we need to propagate our ememory::SharedPtr in child through the ememory::WeakPtr.
|
- Many time for meta-widget we need to propagate our ememory::SharedPtr in child through the ememory::WeakPtr.
|
||||||
|
@ -39,9 +39,6 @@ Creating an object is really simple:
|
|||||||
APPL_INFO("We just create a button widget with unique ID=" << tmpButon->getId() << " name='" << tmpButon->propertyName.get() << "'");
|
APPL_INFO("We just create a button widget with unique ID=" << tmpButon->getId() << " name='" << tmpButon->propertyName.get() << "'");
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that all object created are ememory::SharedPtr base for the current version on std::shared_ptr.
|
|
||||||
We wrapped it because the current inplementation of std::shared_ptr is not thread safe, and we want use a thread-safe version of it.
|
|
||||||
|
|
||||||
**Note:**
|
**Note:**
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -123,6 +120,6 @@ It could be really interesting to retrive your own instance:
|
|||||||
```{.cpp}
|
```{.cpp}
|
||||||
ewol::ObjectShared tmpObject ...;
|
ewol::ObjectShared tmpObject ...;
|
||||||
|
|
||||||
appl::MyOwnObjectShared myObject = std::dynamic_pointer_cast<appl::MyOwnObject>(tmpObject);
|
appl::MyOwnObjectShared myObject = ememory::dynamicPointerCast<appl::MyOwnObject>(tmpObject);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ Get Parameter {#ewol_tutorial_object_config_param
|
|||||||
-------------
|
-------------
|
||||||
|
|
||||||
```{.cpp}
|
```{.cpp}
|
||||||
std::string val = tmpObject->properties.get("name");
|
etk::String val = tmpObject->properties.get("name");
|
||||||
APPL_INFO("Get Object property: name='" << val << "'");
|
APPL_INFO("Get Object property: name='" << val << "'");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace appl {
|
|||||||
public:
|
public:
|
||||||
ewol::object::Signal<> signalEmpty;
|
ewol::object::Signal<> signalEmpty;
|
||||||
ewol::object::Signal<bool> signalBoolean;
|
ewol::object::Signal<bool> signalBoolean;
|
||||||
ewol::object::Signal<std::string> signalString;
|
ewol::object::Signal<etk::String> signalString;
|
||||||
protected:
|
protected:
|
||||||
//! @brief Constructor
|
//! @brief Constructor
|
||||||
MyObj() :
|
MyObj() :
|
||||||
|
@ -86,7 +86,7 @@ Read a file {#ewol_tutorial_file_access_read}
|
|||||||
// get a char
|
// get a char
|
||||||
APPL_INFO("read in: " << file << " the first char='" << file.fileGet() << "'");
|
APPL_INFO("read in: " << file << " the first char='" << file.fileGet() << "'");
|
||||||
// Get a line
|
// Get a line
|
||||||
std::string output;
|
etk::String output;
|
||||||
file.fileGets(output);
|
file.fileGets(output);
|
||||||
APPL_INFO("and the end of the line ='" << output << "'");
|
APPL_INFO("and the end of the line ='" << output << "'");
|
||||||
// close the file (note : if you did not do it, it will be close automaticly with an error)
|
// close the file (note : if you did not do it, it will be close automaticly with an error)
|
||||||
|
@ -32,7 +32,7 @@ For this example we will load a configuration file:
|
|||||||
namespace appl {
|
namespace appl {
|
||||||
class MyObj : public ewol::Object {
|
class MyObj : public ewol::Object {
|
||||||
public:
|
public:
|
||||||
eproperty::Value<std::string> propertyConfig;
|
eproperty::Value<etk::String> propertyConfig;
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<ewol::resource::ConfigFile> m_config;
|
ememory::SharedPtr<ewol::resource::ConfigFile> m_config;
|
||||||
int32_t m_configValId;
|
int32_t m_configValId;
|
||||||
@ -100,7 +100,7 @@ namespace appl {
|
|||||||
m_resourceLevel = 4;
|
m_resourceLevel = 4;
|
||||||
addObjectType("appl::MyResource");
|
addObjectType("appl::MyResource");
|
||||||
}
|
}
|
||||||
void init(const std::string& _name) {
|
void init(const etk::String& _name) {
|
||||||
ewol::Resource::init(_name);
|
ewol::Resource::init(_name);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
@ -57,7 +57,7 @@ Call create and direct configuration
|
|||||||
We can configure the wiget before the init() is called.
|
We can configure the wiget before the init() is called.
|
||||||
```{.cpp}
|
```{.cpp}
|
||||||
ewol::widget::ButtonShared tmpWidget = ewol::widget::Button::create(
|
ewol::widget::ButtonShared tmpWidget = ewol::widget::Button::create(
|
||||||
"name", std::string("my name"),
|
"name", etk::String("my name"),
|
||||||
"expand", bvec2(true,false),
|
"expand", bvec2(true,false),
|
||||||
"fill", bvec2(true,true));
|
"fill", bvec2(true,true));
|
||||||
if (tmpWidget == nullptr) {
|
if (tmpWidget == nullptr) {
|
||||||
|
@ -74,7 +74,7 @@ Simple example:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Get the sub-node name:
|
// Get the sub-node name:
|
||||||
std::string widgetName = pNode.getValue();
|
etk::String widgetName = pNode.getValue();
|
||||||
if (getWidgetManager().exist(widgetName) == false) {
|
if (getWidgetManager().exist(widgetName) == false) {
|
||||||
APPL_ERROR("[" << getId() << "] (l "<<pNode->getPos()<<") Unknown basic node='" << widgetName << "' not in : [" << getWidgetManager().list() << "]" );
|
APPL_ERROR("[" << getId() << "] (l "<<pNode->getPos()<<") Unknown basic node='" << widgetName << "' not in : [" << getWidgetManager().list() << "]" );
|
||||||
continue;
|
continue;
|
||||||
|
@ -264,7 +264,7 @@ void ewol::Context::onKeyboard(const gale::key::Special& _special,
|
|||||||
//EWOL_INFO("repeating test :" << repeate << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << isDown);
|
//EWOL_INFO("repeating test :" << repeate << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << isDown);
|
||||||
if( repeate == false
|
if( repeate == false
|
||||||
|| ( repeate == true
|
|| ( repeate == true
|
||||||
&& tmpWidget->getKeyboardRepeate() == true) ) {
|
&& tmpWidget->getKeyboardRepeat() == true) ) {
|
||||||
// check Widget shortcut
|
// check Widget shortcut
|
||||||
if (tmpWidget->onEventShortCut(_special,
|
if (tmpWidget->onEventShortCut(_special,
|
||||||
_value,
|
_value,
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
//#define EVENT_DEBUG EWOL_DEBUG
|
//#define EVENT_DEBUG EWOL_DEBUG
|
||||||
|
|
||||||
void ewol::context::InputManager::calculateLimit() {
|
void ewol::context::InputManager::calculateLimit() {
|
||||||
m_eventInputLimit.sepatateTime = echrono::Duration(std::chrono::milliseconds(300));
|
m_eventInputLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300));
|
||||||
m_eventInputLimit.DpiOffset = m_dpi*100;
|
m_eventInputLimit.DpiOffset = m_dpi*100;
|
||||||
m_eventMouseLimit.sepatateTime = echrono::Duration(std::chrono::milliseconds(300));
|
m_eventMouseLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300));
|
||||||
m_eventMouseLimit.DpiOffset = float(m_dpi)*0.1f;
|
m_eventMouseLimit.DpiOffset = float(m_dpi)*0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,8 +353,8 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
|
|||||||
// we have an event previously ... check delay between click and offset position
|
// we have an event previously ... check delay between click and offset position
|
||||||
if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) {
|
if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) {
|
||||||
cleanElement(eventTable, _pointerID);
|
cleanElement(eventTable, _pointerID);
|
||||||
} else if( std::abs(eventTable[_pointerID].downStart.x() - _pos.x()) >= localLimit.DpiOffset
|
} else if( etk::abs(eventTable[_pointerID].downStart.x() - _pos.x()) >= localLimit.DpiOffset
|
||||||
|| std::abs(eventTable[_pointerID].downStart.y() - _pos.y()) >= localLimit.DpiOffset ){
|
|| etk::abs(eventTable[_pointerID].downStart.y() - _pos.y()) >= localLimit.DpiOffset ){
|
||||||
cleanElement(eventTable, _pointerID);
|
cleanElement(eventTable, _pointerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,8 +449,8 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
|
|||||||
gale::key::status::up,
|
gale::key::status::up,
|
||||||
_pos);
|
_pos);
|
||||||
// generate event (single)
|
// generate event (single)
|
||||||
if( std::abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset
|
if( etk::abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset
|
||||||
&& std::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){
|
&& etk::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){
|
||||||
// Save current position :
|
// Save current position :
|
||||||
eventTable[_pointerID].downStart = _pos;
|
eventTable[_pointerID].downStart = _pos;
|
||||||
// save start time
|
// save start time
|
||||||
|
@ -23,7 +23,7 @@ ewol::object::Manager::Manager(ewol::Context& _context) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::object::Manager::~Manager() {
|
ewol::object::Manager::~Manager() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
m_workerList.clear();
|
m_workerList.clear();
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
if (m_eObjectList.size()!=0) {
|
if (m_eObjectList.size()!=0) {
|
||||||
@ -37,7 +37,7 @@ ewol::object::Manager::~Manager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::displayListObject() {
|
void ewol::object::Manager::displayListObject() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
EWOL_INFO("List loaded object : ");
|
EWOL_INFO("List loaded object : ");
|
||||||
for (auto &it : m_eObjectList) {
|
for (auto &it : m_eObjectList) {
|
||||||
ewol::ObjectShared element = it.lock();
|
ewol::ObjectShared element = it.lock();
|
||||||
@ -48,7 +48,7 @@ void ewol::object::Manager::displayListObject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::unInit() {
|
void ewol::object::Manager::unInit() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
EWOL_DEBUG(" == > Un-Init Object-Manager");
|
EWOL_DEBUG(" == > Un-Init Object-Manager");
|
||||||
if (m_workerList.size() > 0) {
|
if (m_workerList.size() > 0) {
|
||||||
EWOL_DEBUG(" == > Remove all workers");
|
EWOL_DEBUG(" == > Remove all workers");
|
||||||
@ -67,7 +67,7 @@ void ewol::object::Manager::unInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
|
void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if (_object == nullptr) {
|
if (_object == nullptr) {
|
||||||
EWOL_ERROR("try to add an inexistant Object in manager");
|
EWOL_ERROR("try to add an inexistant Object in manager");
|
||||||
}
|
}
|
||||||
@ -75,13 +75,13 @@ void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::object::Manager::getNumberObject() {
|
int32_t ewol::object::Manager::getNumberObject() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
return m_eObjectList.size();
|
return m_eObjectList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean all Object that request an autoRemove ...
|
// clean all Object that request an autoRemove ...
|
||||||
void ewol::object::Manager::cleanInternalRemoved() {
|
void ewol::object::Manager::cleanInternalRemoved() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
size_t nbObject = m_eObjectList.size();
|
size_t nbObject = m_eObjectList.size();
|
||||||
EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectList.size() << " elements");
|
EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectList.size() << " elements");
|
||||||
auto it(m_eObjectList.begin());
|
auto it(m_eObjectList.begin());
|
||||||
@ -98,7 +98,7 @@ void ewol::object::Manager::cleanInternalRemoved() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) {
|
ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if (_name == "") {
|
if (_name == "") {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -114,18 +114,18 @@ ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) {
|
|||||||
|
|
||||||
|
|
||||||
ewol::ObjectShared ewol::object::Manager::getObjectNamed(const etk::String& _name) {
|
ewol::ObjectShared ewol::object::Manager::getObjectNamed(const etk::String& _name) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
return ewol::object::Manager::get(_name);
|
return ewol::object::Manager::get(_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) {
|
void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
m_workerList.pushBack(_worker);
|
m_workerList.pushBack(_worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
|
void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
auto it(m_workerList.begin());
|
auto it(m_workerList.begin());
|
||||||
while (it != m_workerList.end()) {
|
while (it != m_workerList.end()) {
|
||||||
if (*it == _worker) {
|
if (*it == _worker) {
|
||||||
@ -137,7 +137,7 @@ void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::timeCall(const echrono::Clock& _localTime) {
|
void ewol::object::Manager::timeCall(const echrono::Clock& _localTime) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
echrono::Clock previousTime = m_lastPeriodicCallTime;
|
echrono::Clock previousTime = m_lastPeriodicCallTime;
|
||||||
m_lastPeriodicCallTime = _localTime;
|
m_lastPeriodicCallTime = _localTime;
|
||||||
if (periodicCall.size() <= 0) {
|
if (periodicCall.size() <= 0) {
|
||||||
@ -149,11 +149,11 @@ void ewol::object::Manager::timeCall(const echrono::Clock& _localTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::timeCallResume(const echrono::Clock& _localTime) {
|
void ewol::object::Manager::timeCallResume(const echrono::Clock& _localTime) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
m_lastPeriodicCallTime = _localTime;
|
m_lastPeriodicCallTime = _localTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::object::Manager::timeCallHave() {
|
bool ewol::object::Manager::timeCallHave() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
return periodicCall.size() > 0;
|
return periodicCall.size() > 0;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
#include <ewol/event/Time.hpp>
|
#include <ewol/event/Time.hpp>
|
||||||
#include <echrono/Steady.hpp>
|
#include <echrono/Steady.hpp>
|
||||||
#include <echrono/Duration.hpp>
|
#include <echrono/Duration.hpp>
|
||||||
|
#include <ethread/MutexRecursive.hpp>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class Context;
|
class Context;
|
||||||
namespace object {
|
namespace object {
|
||||||
class Manager : public esignal::Interface {
|
class Manager : public esignal::Interface {
|
||||||
protected:
|
protected:
|
||||||
std::recursive_mutex m_mutex;
|
ethread::MutexRecursive m_mutex;
|
||||||
private:
|
private:
|
||||||
etk::Vector<ewol::ObjectWeak> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
etk::Vector<ewol::ObjectWeak> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
||||||
Context& m_context;
|
Context& m_context;
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <exml/exml.hpp>
|
#include <exml/exml.hpp>
|
||||||
#include <ethread/Mutex.hpp>
|
#include <ethread/Mutex.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
@ -49,12 +48,12 @@ template<class TYPE_OBJECT, class TYPE_VAL, class ... TYPE> static void baseInit
|
|||||||
}
|
}
|
||||||
propType = dynamic_cast<eproperty::PropertyType<TYPE_VAL>*>(prop);
|
propType = dynamic_cast<eproperty::PropertyType<TYPE_VAL>*>(prop);
|
||||||
if (propType == nullptr) {
|
if (propType == nullptr) {
|
||||||
EWOL_ERROR("property does not cast in requested type ... '" << _name << "' require type : " << typeid(_val).name() << "' instead of '" << prop->getType() << "'");
|
EWOL_ERROR("property does not cast in requested type ... '" << _name << "' require type : " << /*typeid(_val).name()*/ "?TODO?" << "' instead of '" << prop->getType() << "'");
|
||||||
goto exit_on_error;
|
goto exit_on_error;
|
||||||
}
|
}
|
||||||
propType->setDirectCheck(_val);
|
propType->setDirectCheck(_val);
|
||||||
exit_on_error:
|
exit_on_error:
|
||||||
baseInit(_object, std::forward<TYPE>(_all)... );
|
baseInit(_object, etk::forward<TYPE>(_all)... );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,16 +309,6 @@ namespace ewol {
|
|||||||
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
/*
|
|
||||||
template<class TYPE> void subBind(ememory::SharedPtr<ewol::Object> _obj, void (TYPE::*_func)()) {
|
|
||||||
ememory::SharedPtr<TYPE> obj2 = ememory::dynamicPointerCast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not connect signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_callerList.pushBack(etk::makePair(ewol::ObjectWeak(_obj), std::connect(_func, obj2.get())));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
bool propertySetOnObjectNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value);
|
bool propertySetOnObjectNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value);
|
||||||
};
|
};
|
||||||
|
@ -8,16 +8,17 @@
|
|||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ewol/resource/ColorFile.hpp>
|
#include <ewol/resource/ColorFile.hpp>
|
||||||
#include <ejson/ejson.hpp>
|
#include <ejson/ejson.hpp>
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
ewol::resource::ColorFile::ColorFile() :
|
ewol::resource::ColorFile::ColorFile() :
|
||||||
gale::Resource(),
|
gale::Resource(),
|
||||||
|
// Set the list unodered
|
||||||
|
m_list(0, false),
|
||||||
m_errorColor(etk::color::orange) {
|
m_errorColor(etk::color::orange) {
|
||||||
addResourceType("ewol::ColorFile");
|
addResourceType("ewol::ColorFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::ColorFile::init(const etk::String& _filename) {
|
void ewol::resource::ColorFile::init(const etk::String& _filename) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
gale::Resource::init(_filename);
|
gale::Resource::init(_filename);
|
||||||
EWOL_DEBUG("CF : load \"" << _filename << "\"");
|
EWOL_DEBUG("CF : load \"" << _filename << "\"");
|
||||||
reload();
|
reload();
|
||||||
@ -31,10 +32,10 @@ ewol::resource::ColorFile::~ColorFile() {
|
|||||||
|
|
||||||
|
|
||||||
void ewol::resource::ColorFile::reload() {
|
void ewol::resource::ColorFile::reload() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
// remove all previous set of value :
|
// remove all previous set of value :
|
||||||
for (int32_t iii = 0; iii < m_list.size() ; ++iii) {
|
for (int32_t iii = 0; iii < m_list.size() ; ++iii) {
|
||||||
m_list[iii] = m_errorColor;
|
m_list.getValue(iii) = m_errorColor;
|
||||||
}
|
}
|
||||||
// open and read all json elements:
|
// open and read all json elements:
|
||||||
ejson::Document doc;
|
ejson::Document doc;
|
||||||
@ -74,7 +75,7 @@ void ewol::resource::ColorFile::reload() {
|
|||||||
|
|
||||||
|
|
||||||
int32_t ewol::resource::ColorFile::request(const etk::String& _paramName) {
|
int32_t ewol::resource::ColorFile::request(const etk::String& _paramName) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
// check if the parameters existed :
|
// check if the parameters existed :
|
||||||
if (m_list.exist(_paramName) == false) {
|
if (m_list.exist(_paramName) == false) {
|
||||||
m_list.add(_paramName, m_errorColor);
|
m_list.add(_paramName, m_errorColor);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/Color.hpp>
|
#include <etk/Color.hpp>
|
||||||
#include <etk/Hash.hpp>
|
#include <etk/Map.hpp>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <gale/resource/Resource.hpp>
|
#include <gale/resource/Resource.hpp>
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class ColorFile : public gale::Resource {
|
class ColorFile : public gale::Resource {
|
||||||
private:
|
private:
|
||||||
etk::Hash<etk::Color<float> > m_list; //!< List of all color in the file
|
etk::Map<etk::String, etk::Color<float> > m_list; //!< List of all color in the file
|
||||||
etk::Color<float> m_errorColor; //!< Error returned color
|
etk::Color<float> m_errorColor; //!< Error returned color
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -11,15 +11,16 @@
|
|||||||
#include <ejson/ejson.hpp>
|
#include <ejson/ejson.hpp>
|
||||||
#include <ejson/Number.hpp>
|
#include <ejson/Number.hpp>
|
||||||
#include <ejson/String.hpp>
|
#include <ejson/String.hpp>
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
ewol::resource::ConfigFile::ConfigFile() :
|
ewol::resource::ConfigFile::ConfigFile() :
|
||||||
gale::Resource() {
|
gale::Resource(),
|
||||||
|
// set map unorderred
|
||||||
|
m_list(0, false) {
|
||||||
addResourceType("ewol::ConfigFile");
|
addResourceType("ewol::ConfigFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::ConfigFile::init(const etk::String& _filename) {
|
void ewol::resource::ConfigFile::init(const etk::String& _filename) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
gale::Resource::init(_filename);
|
gale::Resource::init(_filename);
|
||||||
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
||||||
reload();
|
reload();
|
||||||
@ -31,11 +32,11 @@ ewol::resource::ConfigFile::~ConfigFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::ConfigFile::reload() {
|
void ewol::resource::ConfigFile::reload() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
// reset all parameters
|
// reset all parameters
|
||||||
for (int32_t iii=0; iii<m_list.size(); iii++){
|
for (int32_t iii=0; iii<m_list.size(); iii++){
|
||||||
if (m_list[iii].exist() == true) {
|
if (m_list.getValue(iii).exist() == true) {
|
||||||
m_list[iii] = ejson::empty();
|
m_list.getValue(iii) = ejson::empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_doc.load(m_name);
|
m_doc.load(m_name);
|
||||||
@ -49,7 +50,7 @@ void ewol::resource::ConfigFile::reload() {
|
|||||||
|
|
||||||
|
|
||||||
int32_t ewol::resource::ConfigFile::request(const etk::String& _paramName) {
|
int32_t ewol::resource::ConfigFile::request(const etk::String& _paramName) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
// check if the parameters existed :
|
// check if the parameters existed :
|
||||||
if (m_list.exist(_paramName) == false) {
|
if (m_list.exist(_paramName) == false) {
|
||||||
m_list.add(_paramName, ejson::empty());
|
m_list.add(_paramName, ejson::empty());
|
||||||
@ -62,28 +63,28 @@ int32_t ewol::resource::ConfigFile::request(const etk::String& _paramName) {
|
|||||||
|
|
||||||
|
|
||||||
double ewol::resource::ConfigFile::getNumber(int32_t _id) {
|
double ewol::resource::ConfigFile::getNumber(int32_t _id) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if ( _id < 0
|
if ( _id < 0
|
||||||
|| m_list[_id].exist() == false) {
|
|| m_list.getValue(_id).exist() == false) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
return m_list[_id].toNumber().get();
|
return m_list.getValue(_id).toNumber().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::String ewol::resource::ConfigFile::getString(int32_t _id) {
|
etk::String ewol::resource::ConfigFile::getString(int32_t _id) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if ( _id < 0
|
if ( _id < 0
|
||||||
|| m_list[_id].exist() == false) {
|
|| m_list.getValue(_id).exist() == false) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return m_list[_id].toString().get();
|
return m_list.getValue(_id).toString().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::resource::ConfigFile::getBoolean(int32_t _id) {
|
bool ewol::resource::ConfigFile::getBoolean(int32_t _id) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if ( _id < 0
|
if ( _id < 0
|
||||||
|| m_list[_id].exist() == false) {
|
|| m_list.getValue(_id).exist() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_list[_id].toBoolean().get();
|
return m_list.getValue(_id).toBoolean().get();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/Hash.hpp>
|
#include <etk/Map.hpp>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ejson/ejson.hpp>
|
#include <ejson/ejson.hpp>
|
||||||
#include <gale/resource/Resource.hpp>
|
#include <gale/resource/Resource.hpp>
|
||||||
@ -16,7 +16,7 @@ namespace ewol {
|
|||||||
class ConfigFile : public gale::Resource {
|
class ConfigFile : public gale::Resource {
|
||||||
private:
|
private:
|
||||||
ejson::Document m_doc;
|
ejson::Document m_doc;
|
||||||
etk::Hash<ejson::Value> m_list;
|
etk::Map<etk::String, ejson::Value> m_list;
|
||||||
protected:
|
protected:
|
||||||
ConfigFile();
|
ConfigFile();
|
||||||
void init(const etk::String& _filename);
|
void init(const etk::String& _filename);
|
||||||
|
@ -32,7 +32,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) {
|
void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::Texture::init(_fontName);
|
ewol::resource::Texture::init(_fontName);
|
||||||
etk::String localName = _fontName;
|
etk::String localName = _fontName;
|
||||||
etk::Vector<etk::String> folderList;
|
etk::Vector<etk::String> folderList;
|
||||||
@ -131,13 +131,13 @@ ewol::resource::DistanceFieldFont::~DistanceFieldFont() {
|
|||||||
|
|
||||||
|
|
||||||
float ewol::resource::DistanceFieldFont::getDisplayRatio(float _size) {
|
float ewol::resource::DistanceFieldFont::getDisplayRatio(float _size) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
return _size / (float)SIZE_GENERATION;
|
return _size / (float)SIZE_GENERATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) {
|
void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
int32_t size = _input.getSize().x() * _input.getSize().y();
|
int32_t size = _input.getSize().x() * _input.getSize().y();
|
||||||
etk::Vector<short> xdist(size);
|
etk::Vector<short> xdist(size);
|
||||||
etk::Vector<short> ydist(size);
|
etk::Vector<short> ydist(size);
|
||||||
@ -217,7 +217,7 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
|
bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
bool hasChange = false;
|
bool hasChange = false;
|
||||||
if (m_font == nullptr) {
|
if (m_font == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
@ -258,9 +258,8 @@ bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
|
|||||||
if (_val == 'Z') {
|
if (_val == 'Z') {
|
||||||
for (int32_t yyy = 0; yyy < imageGlyphDistanceField.getSize().y(); ++yyy) {
|
for (int32_t yyy = 0; yyy < imageGlyphDistanceField.getSize().y(); ++yyy) {
|
||||||
for (int32_t xxx = 0; xxx < imageGlyphDistanceField.getSize().x(); ++xxx) {
|
for (int32_t xxx = 0; xxx < imageGlyphDistanceField.getSize().x(); ++xxx) {
|
||||||
std::cout << (int)(imageGlyphDistanceField.get(ivec2(xxx, yyy)).r()) << " ";
|
EWOL_DEBUG((int)(imageGlyphDistanceField.get(ivec2(xxx, yyy)).r()) << " ");
|
||||||
}
|
}
|
||||||
//std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@ -299,7 +298,7 @@ bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) {
|
int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if (_charcode < 0x20) {
|
if (_charcode < 0x20) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (_charcode < 0x80) {
|
} else if (_charcode < 0x80) {
|
||||||
@ -326,7 +325,7 @@ int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const char32_t& _charcode) {
|
ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const char32_t& _charcode) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
//EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]);
|
//EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]);
|
||||||
int32_t index = getIndex(_charcode);
|
int32_t index = getIndex(_charcode);
|
||||||
if( index < 0
|
if( index < 0
|
||||||
@ -346,7 +345,7 @@ ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::DistanceFieldFont::exportOnFile() {
|
void ewol::resource::DistanceFieldFont::exportOnFile() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
||||||
ejson::Document doc;
|
ejson::Document doc;
|
||||||
ejson::Array tmpList;
|
ejson::Array tmpList;
|
||||||
@ -374,7 +373,7 @@ void ewol::resource::DistanceFieldFont::exportOnFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::resource::DistanceFieldFont::importFromFile() {
|
bool ewol::resource::DistanceFieldFont::importFromFile() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
||||||
// test file existance:
|
// test file existance:
|
||||||
etk::FSNode fileJSON(m_fileName + ".json");
|
etk::FSNode fileJSON(m_fileName + ".json");
|
||||||
|
@ -55,7 +55,7 @@ ewol::resource::FontFreeType::FontFreeType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::FontFreeType::init(const etk::String& _fontName) {
|
void ewol::resource::FontFreeType::init(const etk::String& _fontName) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::FontBase::init(_fontName);
|
ewol::resource::FontBase::init(_fontName);
|
||||||
etk::FSNode myfile(_fontName);
|
etk::FSNode myfile(_fontName);
|
||||||
if (myfile.exist() == false) {
|
if (myfile.exist() == false) {
|
||||||
@ -96,7 +96,7 @@ void ewol::resource::FontFreeType::init(const etk::String& _fontName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::resource::FontFreeType::~FontFreeType() {
|
ewol::resource::FontFreeType::~FontFreeType() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
// clean the tmp memory
|
// clean the tmp memory
|
||||||
if (nullptr != m_FileBuffer) {
|
if (nullptr != m_FileBuffer) {
|
||||||
delete[] m_FileBuffer;
|
delete[] m_FileBuffer;
|
||||||
@ -107,7 +107,7 @@ ewol::resource::FontFreeType::~FontFreeType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::String& _unicodeString) {
|
vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::String& _unicodeString) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if(false == m_init) {
|
if(false == m_init) {
|
||||||
return vec2(0,0);
|
return vec2(0,0);
|
||||||
}
|
}
|
||||||
@ -117,16 +117,16 @@ vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::String&
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) {
|
int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
return _fontSize*1.43f; // this is a really "magic" number ...
|
return _fontSize*1.43f; // this is a really "magic" number ...
|
||||||
}
|
}
|
||||||
float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) {
|
float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
return _fontHeight*0.6993f; // this is a really "magic" number ...
|
return _fontHeight*0.6993f; // this is a really "magic" number ...
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) {
|
bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if(false == m_init) {
|
if(false == m_init) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut,
|
|||||||
ivec2 _glyphPosition,
|
ivec2 _glyphPosition,
|
||||||
ewol::GlyphProperty& _property,
|
ewol::GlyphProperty& _property,
|
||||||
int8_t _posInImage) {
|
int8_t _posInImage) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if(false == m_init) {
|
if(false == m_init) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut,
|
|||||||
int32_t _fontSize,
|
int32_t _fontSize,
|
||||||
ewol::GlyphProperty& _property,
|
ewol::GlyphProperty& _property,
|
||||||
int32_t _borderSize) {
|
int32_t _borderSize) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if(false == m_init) {
|
if(false == m_init) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut,
|
|||||||
|
|
||||||
|
|
||||||
void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, etk::Vector<ewol::GlyphProperty>& listGlyph) {
|
void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, etk::Vector<ewol::GlyphProperty>& listGlyph) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if(m_init == false) {
|
if(m_init == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, etk::Vector
|
|||||||
|
|
||||||
|
|
||||||
void ewol::resource::FontFreeType::display() {
|
void ewol::resource::FontFreeType::display() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if(m_init == false) {
|
if(m_init == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ ewol::resource::TextureFile::TextureFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::TextureFile::init() {
|
void ewol::resource::TextureFile::init() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::Texture::init();
|
ewol::resource::Texture::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::TextureFile::init(etk::String _genName, const etk::String& _tmpFilename, const ivec2& _size) {
|
void ewol::resource::TextureFile::init(etk::String _genName, const etk::String& _tmpFilename, const ivec2& _size) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::Texture::init(_genName);
|
ewol::resource::Texture::init(_genName);
|
||||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpFilename=" << _tmpFilename << " size=" << _size);
|
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpFilename=" << _tmpFilename << " size=" << _size);
|
||||||
m_data = egami::load(_tmpFilename, _size);
|
m_data = egami::load(_tmpFilename, _size);
|
||||||
|
@ -18,12 +18,12 @@ ewol::resource::ImageDF::ImageDF() {
|
|||||||
|
|
||||||
|
|
||||||
void ewol::resource::ImageDF::init() {
|
void ewol::resource::ImageDF::init() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::Texture::init();
|
ewol::resource::Texture::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::ImageDF::init(etk::String _genName, const etk::String& _tmpfileName, const ivec2& _size) {
|
void ewol::resource::ImageDF::init(etk::String _genName, const etk::String& _tmpfileName, const ivec2& _size) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::Texture::init(_genName);
|
ewol::resource::Texture::init(_genName);
|
||||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size);
|
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size);
|
||||||
m_data = egami::load(_tmpfileName, _size);
|
m_data = egami::load(_tmpfileName, _size);
|
||||||
@ -49,7 +49,7 @@ void ewol::resource::ImageDF::init(etk::String _genName, const etk::String& _tmp
|
|||||||
|
|
||||||
|
|
||||||
void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) {
|
void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
int32_t size = _input.getSize().x() * _input.getSize().y();
|
int32_t size = _input.getSize().x() * _input.getSize().y();
|
||||||
etk::Vector<short> xdist(size);
|
etk::Vector<short> xdist(size);
|
||||||
etk::Vector<short> ydist(size);
|
etk::Vector<short> ydist(size);
|
||||||
|
@ -74,9 +74,9 @@ bool ewol::resource::Texture::updateContext() {
|
|||||||
echrono::Steady toc = echrono::Steady::now();
|
echrono::Steady toc = echrono::Steady::now();
|
||||||
EWOL_VERBOSE(" updateContext [FLUSH] ==> " << (toc - tic));
|
EWOL_VERBOSE(" updateContext [FLUSH] ==> " << (toc - tic));
|
||||||
}
|
}
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
|
ethread::RecursiveLock lock(m_mutex, true);
|
||||||
echrono::Steady tic = echrono::Steady::now();
|
echrono::Steady tic = echrono::Steady::now();
|
||||||
if (lock.try_lock() == false) {
|
if (lock.tryLock() == false) {
|
||||||
//Lock error ==> try later ...
|
//Lock error ==> try later ...
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ bool ewol::resource::Texture::updateContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::Texture::removeContext() {
|
void ewol::resource::Texture::removeContext() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if (m_loaded == true) {
|
if (m_loaded == true) {
|
||||||
// Request remove texture ...
|
// Request remove texture ...
|
||||||
EWOL_DEBUG("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
|
EWOL_DEBUG("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
|
||||||
@ -276,20 +276,20 @@ void ewol::resource::Texture::removeContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::Texture::removeContextToLate() {
|
void ewol::resource::Texture::removeContextToLate() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
m_loaded = false;
|
m_loaded = false;
|
||||||
m_texId=0;
|
m_texId=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::Texture::flush() {
|
void ewol::resource::Texture::flush() {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
// request to the manager to be call at the next update ...
|
// request to the manager to be call at the next update ...
|
||||||
EWOL_VERBOSE("Request UPDATE of Element");
|
EWOL_VERBOSE("Request UPDATE of Element");
|
||||||
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
|
void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
|
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
|
||||||
m_data.resize(_newSize);
|
m_data.resize(_newSize);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ ewol::resource::TexturedFont::TexturedFont():
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
ewol::resource::Texture::init(_fontName);
|
ewol::resource::Texture::init(_fontName);
|
||||||
EWOL_DEBUG("Load font : '" << _fontName << "'" );
|
EWOL_DEBUG("Load font : '" << _fontName << "'" );
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ ewol::resource::TexturedFont::~TexturedFont() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) {
|
bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
bool hasChange = false;
|
bool hasChange = false;
|
||||||
// for each font :
|
// for each font :
|
||||||
for (int32_t iii=0; iii<4 ; iii++) {
|
for (int32_t iii=0; iii<4 ; iii++) {
|
||||||
@ -303,7 +303,7 @@ bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) {
|
int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if (_charcode < 0x20) {
|
if (_charcode < 0x20) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (_charcode < 0x80) {
|
} else if (_charcode < 0x80) {
|
||||||
@ -330,7 +330,7 @@ int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ew
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) {
|
ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) {
|
||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
//EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]);
|
//EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]);
|
||||||
int32_t index = getIndex(_charcode, _displayMode);
|
int32_t index = getIndex(_charcode, _displayMode);
|
||||||
if( index < 0
|
if( index < 0
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
#include <etk/Color.hpp>
|
#include <etk/Color.hpp>
|
||||||
#include <ewol/resource/ColorFile.hpp>
|
#include <ewol/resource/ColorFile.hpp>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace tools {
|
namespace tools {
|
||||||
|
@ -1,299 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/debug.hpp>
|
|
||||||
#include <etranslate/etranslate.hpp>
|
|
||||||
#include <etk/Map.hpp>
|
|
||||||
#include <etk/os/FSNode.hpp>
|
|
||||||
#include <ejson/ejson.hpp>
|
|
||||||
|
|
||||||
class LocalInstanceTranslation {
|
|
||||||
private:
|
|
||||||
etk::Map<etk::String,etk::String> m_listPath;
|
|
||||||
etk::String m_major;
|
|
||||||
etk::String m_languageDefault;
|
|
||||||
etk::String m_language;
|
|
||||||
bool m_translateLoadad;
|
|
||||||
etk::Map<etk::String,etk::String> m_translate;
|
|
||||||
public:
|
|
||||||
LocalInstanceTranslation() :
|
|
||||||
m_major("ewol"),
|
|
||||||
m_languageDefault("EN"),
|
|
||||||
m_language(""),
|
|
||||||
m_translateLoadad(false) {
|
|
||||||
// nothing to do ...
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
void addPath(const etk::String& _lib, const etk::String& _path, bool _major) {
|
|
||||||
auto it = m_listPath.find(_lib);
|
|
||||||
if (it == m_listPath.end()) {
|
|
||||||
m_listPath.insert(make_pair(_lib, _path));
|
|
||||||
} else {
|
|
||||||
it->second = _path;
|
|
||||||
}
|
|
||||||
if (_major == true) {
|
|
||||||
m_major = _lib;
|
|
||||||
EWOL_INFO("Change major translation : '" << m_major << "'");
|
|
||||||
}
|
|
||||||
m_translateLoadad = false;
|
|
||||||
m_translate.clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
const etk::String& getPaths(const etk::String& _lib) {
|
|
||||||
auto it = m_listPath.find(_lib);
|
|
||||||
if (it == m_listPath.end()) {
|
|
||||||
static const etk::String g_error("");
|
|
||||||
return g_error;
|
|
||||||
}
|
|
||||||
return it->second;
|
|
||||||
};
|
|
||||||
|
|
||||||
void setLanguageDefault(const etk::String& _lang) {
|
|
||||||
if (m_languageDefault == _lang) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EWOL_INFO("Change default language translation : '" << _lang << "'");
|
|
||||||
m_languageDefault = _lang;
|
|
||||||
m_translateLoadad = false;
|
|
||||||
m_translate.clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
const etk::String& getLanguageDefault() {
|
|
||||||
return m_languageDefault;
|
|
||||||
};
|
|
||||||
|
|
||||||
void setLanguage(const etk::String& _lang) {
|
|
||||||
if (m_language == _lang) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_language = _lang;
|
|
||||||
m_translateLoadad = false;
|
|
||||||
m_translate.clear();
|
|
||||||
if (_lang == "EN") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=English");
|
|
||||||
} else if (_lang == "FR") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=French");
|
|
||||||
} else if (_lang == "DE") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=German");
|
|
||||||
} else if (_lang == "SP") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Spanish");
|
|
||||||
} else if (_lang == "JA") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Japanese");
|
|
||||||
} else if (_lang == "IT") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Italian");
|
|
||||||
} else if (_lang == "KO") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Korean");
|
|
||||||
} else if (_lang == "RU") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Russian");
|
|
||||||
} else if (_lang == "PT") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Portuguese, Brazilian");
|
|
||||||
} else if (_lang == "ZH") {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Chinese");
|
|
||||||
} else {
|
|
||||||
EWOL_INFO("Change language translation: '" << _lang << "'=Unknow");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const etk::String& getLanguage() {
|
|
||||||
return m_language;
|
|
||||||
};
|
|
||||||
|
|
||||||
etk::String get(const etk::String& _instance) {
|
|
||||||
loadTranslation();
|
|
||||||
EWOL_VERBOSE("Request translate: '" << _instance << "'");
|
|
||||||
// find all iterance of '_T{' ... '}'
|
|
||||||
etk::String out;
|
|
||||||
auto itOld = _instance.begin();
|
|
||||||
size_t pos = _instance.find("_T{");
|
|
||||||
while (pos != etk::String::npos) {
|
|
||||||
out.append(itOld, _instance.begin() + pos);
|
|
||||||
auto it = _instance.begin() + pos + 3;
|
|
||||||
itOld = it;
|
|
||||||
pos = _instance.find("}", pos);
|
|
||||||
if (pos == etk::String::npos) {
|
|
||||||
EWOL_WARNING("missing end translation '}' in: '" << _instance << "'");
|
|
||||||
it = _instance.end();
|
|
||||||
} else {
|
|
||||||
it = _instance.begin() + pos;
|
|
||||||
}
|
|
||||||
etk::String basicEmptyValue = etk::String(itOld, it);
|
|
||||||
auto itTranslate = m_translate.find(basicEmptyValue);
|
|
||||||
if (itTranslate == m_translate.end()) {
|
|
||||||
EWOL_DEBUG("Can not find tranlation : '" << _instance << "'");
|
|
||||||
out += basicEmptyValue;
|
|
||||||
} else {
|
|
||||||
out += itTranslate->second;
|
|
||||||
}
|
|
||||||
if (it != _instance.end()) {
|
|
||||||
itOld = it+1;
|
|
||||||
} else {
|
|
||||||
itOld = it;
|
|
||||||
}
|
|
||||||
pos = _instance.find("_T{", pos);
|
|
||||||
}
|
|
||||||
if (itOld != _instance.end()) {
|
|
||||||
out.append(itOld, _instance.end());
|
|
||||||
}
|
|
||||||
EWOL_VERBOSE(" translation: '" << out << "'");
|
|
||||||
return out;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
void loadTranslation() {
|
|
||||||
if (m_translateLoadad == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EWOL_VERBOSE("Load Translation MAJOR='" << m_major << "' LANG='" << m_language << "' default=" << m_languageDefault );
|
|
||||||
// start parse language for Major:
|
|
||||||
auto itMajor = m_listPath.find(m_major);
|
|
||||||
if (itMajor != m_listPath.end()) {
|
|
||||||
etk::String filename(itMajor->second + "/" + m_language + ".json");
|
|
||||||
ejson::Document doc;
|
|
||||||
doc.load(filename);
|
|
||||||
for (auto element : doc.getKeys()) {
|
|
||||||
etk::String val = doc[element].toString().get();
|
|
||||||
m_translate.insert(make_pair(element, val));
|
|
||||||
}
|
|
||||||
filename = itMajor->second + "/" + m_languageDefault + ".json";
|
|
||||||
doc.load(filename);
|
|
||||||
for (auto element : doc.getKeys()) {
|
|
||||||
etk::String val = doc[element].toString().get();
|
|
||||||
auto itTrans = m_translate.find(element);
|
|
||||||
if (itTrans == m_translate.end()) {
|
|
||||||
m_translate.insert(make_pair(element, val));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// start parse language:
|
|
||||||
for (auto &it : m_listPath) {
|
|
||||||
if (it.first == m_major) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
etk::String filename(it.second + "/" + m_languageDefault + ".json");
|
|
||||||
if (etk::FSNodeExist(filename) == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ejson::Document doc;
|
|
||||||
doc.load(filename);
|
|
||||||
for (auto element : doc.getKeys()) {
|
|
||||||
etk::String val = doc[element].toString().get();
|
|
||||||
auto itTrans = m_translate.find(element);
|
|
||||||
if (itTrans == m_translate.end()) {
|
|
||||||
m_translate.insert(make_pair(element, val));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// start parse default language:
|
|
||||||
for (auto &it : m_listPath) {
|
|
||||||
if (it.first == m_major) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
etk::String filename(it.second + "/" + m_languageDefault + ".json");
|
|
||||||
if (etk::FSNodeExist(filename) == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ejson::Document doc;
|
|
||||||
doc.load(filename);
|
|
||||||
for (auto element : doc.getKeys()) {
|
|
||||||
etk::String val = doc[element].toString().get();
|
|
||||||
auto itTrans = m_translate.find(element);
|
|
||||||
if (itTrans == m_translate.end()) {
|
|
||||||
m_translate.insert(make_pair(element, val));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static LocalInstanceTranslation& getInstanceTranslation() {
|
|
||||||
static LocalInstanceTranslation g_val;
|
|
||||||
return g_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void etranslate::addPath(const etk::String& _lib, const etk::String& _path, bool _major) {
|
|
||||||
getInstanceTranslation().addPath(_lib, _path, _major);
|
|
||||||
}
|
|
||||||
|
|
||||||
const etk::String& etranslate::getPaths(const etk::String& _lib) {
|
|
||||||
return getInstanceTranslation().getPaths(_lib);
|
|
||||||
}
|
|
||||||
|
|
||||||
void etranslate::setLanguageDefault(const etk::String& _lang) {
|
|
||||||
getInstanceTranslation().setLanguageDefault(_lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
const etk::String& etranslate::getLanguageDefault() {
|
|
||||||
return getInstanceTranslation().getLanguageDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
void etranslate::setLanguage(const etk::String& _lang) {
|
|
||||||
getInstanceTranslation().setLanguage(_lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
const etk::String& etranslate::getLanguage() {
|
|
||||||
return getInstanceTranslation().getLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void etranslate::autoDetectLanguage() {
|
|
||||||
EWOL_VERBOSE("Auto-detect language of system");
|
|
||||||
etk::String nonameLocalName;
|
|
||||||
etk::String userLocalName;
|
|
||||||
etk::String globalLocalName;
|
|
||||||
try {
|
|
||||||
nonameLocalName = std::locale(std::locale(), new std::ctype<char>).name();
|
|
||||||
userLocalName = std::locale("").name();
|
|
||||||
globalLocalName = std::locale().name();
|
|
||||||
EWOL_VERBOSE(" The default locale is '" << globalLocalName << "'");
|
|
||||||
EWOL_VERBOSE(" The user's locale is '" << userLocalName << "'");
|
|
||||||
EWOL_VERBOSE(" A nameless locale is '" << nonameLocalName << "'");
|
|
||||||
} catch (std::runtime_error e) {
|
|
||||||
EWOL_ERROR("Can not get Locals ==> set English ...");
|
|
||||||
nonameLocalName = "EN";
|
|
||||||
userLocalName = "EN";
|
|
||||||
globalLocalName = "EN";
|
|
||||||
}
|
|
||||||
etk::String lang = nonameLocalName;
|
|
||||||
if ( lang == "*"
|
|
||||||
|| lang == "") {
|
|
||||||
lang = userLocalName;
|
|
||||||
}
|
|
||||||
if ( lang == "*"
|
|
||||||
|| lang == "") {
|
|
||||||
lang = globalLocalName;
|
|
||||||
}
|
|
||||||
if ( lang == "C"
|
|
||||||
|| lang == ""
|
|
||||||
|| lang.size() < 2) {
|
|
||||||
lang = "EN";
|
|
||||||
}
|
|
||||||
lang = etk::String(lang.begin(), lang.begin()+2);
|
|
||||||
lang = etk::toupper(lang);
|
|
||||||
EWOL_INFO("Select Language : '" << lang << "'");
|
|
||||||
getInstanceTranslation().setLanguage(lang);
|
|
||||||
return;
|
|
||||||
// dead code ...
|
|
||||||
#if defined(__TARGET_OS__Linux)
|
|
||||||
char *s = getenv("LANG");
|
|
||||||
if (s == nullptr || strlen(s) < 2) {
|
|
||||||
EWOL_INFO("Try to determine system language FAIL ...");
|
|
||||||
} else {
|
|
||||||
etk::String lang;
|
|
||||||
lang += s[0];
|
|
||||||
lang += s[1];
|
|
||||||
lang = etk::toupper(lang);
|
|
||||||
getInstanceTranslation().setLanguage(lang);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
EWOL_INFO("Can not auto-detect language ...");
|
|
||||||
getInstanceTranslation().setLanguage("EN");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::String etranslate::get(const etk::String& _instance) {
|
|
||||||
return getInstanceTranslation().get(_instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
/**
|
|
||||||
* @brief This is a simple interface to converte application display string in a generic current system language
|
|
||||||
* @note: The current name of language reprenent the file name, then if you want to get the machine language in an other than generic passed, juste add it.
|
|
||||||
* Generic langage char: (all translation might be done in UTF-8 this simplify interface)
|
|
||||||
* English : "EN"
|
|
||||||
* French : "FR"
|
|
||||||
* German : "DE"
|
|
||||||
* Spanish : "SP"
|
|
||||||
* Japanese : "JA"
|
|
||||||
* Italian : "IT"
|
|
||||||
* Korean : "KO"
|
|
||||||
* Russian : "RU"
|
|
||||||
* Portuguese, Brazilian : "PT"
|
|
||||||
* Chinese : "ZH"
|
|
||||||
*/
|
|
||||||
namespace translate {
|
|
||||||
/**
|
|
||||||
* @brief Set the path folder of the translation files
|
|
||||||
* @param[in] _lib Library name that the path depend
|
|
||||||
* @param[in] _path ETK generic path (DATA:... or /xxx)
|
|
||||||
* @param[in] _major This path is the major path (The last loaded, the one which overload all)
|
|
||||||
*/
|
|
||||||
void addPath(const etk::String& _lib, const etk::String& _path, bool _major = false);
|
|
||||||
/**
|
|
||||||
* @brief Get the current paths of the library
|
|
||||||
* @param[in] _lib Library name that the path depend
|
|
||||||
* @return Path name.
|
|
||||||
*/
|
|
||||||
const etk::String& getPaths(const etk::String& _lib);
|
|
||||||
/**
|
|
||||||
* @brief Set the default language to load data (the default language might contain all internal data for the basic application)
|
|
||||||
* @param[in] _lang Language to load : ("EN" for english, "FR" for french, "DE" for German, "SP" for spanish ...)
|
|
||||||
*/
|
|
||||||
void setLanguageDefault(const etk::String& _lang);
|
|
||||||
/**
|
|
||||||
* @brief Get the current language selected
|
|
||||||
* @return The 2/3 char defining the language
|
|
||||||
*/
|
|
||||||
const etk::String& getLanguageDefault();
|
|
||||||
/**
|
|
||||||
* @brief Set the language to load data. when no data availlable, we get the default language.
|
|
||||||
* @param[in] _lang Language to load : ("EN" for english, "FR" for french, "DE" for German, "SP" for spanish ...)
|
|
||||||
*/
|
|
||||||
void setLanguage(const etk::String& _lang);
|
|
||||||
/**
|
|
||||||
* @brief Get the current language loaded
|
|
||||||
* @return The 2/3 char defining the language
|
|
||||||
*/
|
|
||||||
const etk::String& getLanguage();
|
|
||||||
/**
|
|
||||||
* @brief Automatic detection of the system language
|
|
||||||
*/
|
|
||||||
void autoDetectLanguage();
|
|
||||||
/**
|
|
||||||
* @brief Translate a specific text (if not find, it will be retured the same text).
|
|
||||||
* @param[in] _instance Text to translate.
|
|
||||||
* @return The tranlated text.
|
|
||||||
*/
|
|
||||||
etk::String get(const etk::String& _instance);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
// Here we define a simple macro to Translate all string simply:
|
|
||||||
#define TRANSLATE(a) etranslate::get(a)
|
|
@ -32,7 +32,7 @@ ewol::WidgetShared ewol::widget::composerGenerateString(const etk::String& _data
|
|||||||
etk::String tmpData = _data;
|
etk::String tmpData = _data;
|
||||||
// replace all elements:
|
// replace all elements:
|
||||||
if (_id != 0) {
|
if (_id != 0) {
|
||||||
tmpData = etk::replace(tmpData, "{ID}", etk::toString(_id));
|
tmpData.replace("{ID}", etk::toString(_id));
|
||||||
}
|
}
|
||||||
if (doc.parse(tmpData) == false) {
|
if (doc.parse(tmpData) == false) {
|
||||||
EWOL_ERROR(" can not load file XML string...");
|
EWOL_ERROR(" can not load file XML string...");
|
||||||
@ -82,7 +82,7 @@ bool ewol::widget::Composer::loadFromString(const etk::String& _composerXmlStrin
|
|||||||
etk::String tmpData = _composerXmlString;
|
etk::String tmpData = _composerXmlString;
|
||||||
// replace all elements:
|
// replace all elements:
|
||||||
if (_id != 0) {
|
if (_id != 0) {
|
||||||
tmpData = etk::replace(tmpData, "{ID}", etk::toString(_id));
|
tmpData.replace("{ID}", etk::toString(_id));
|
||||||
}
|
}
|
||||||
if (doc.parse(tmpData) == false) {
|
if (doc.parse(tmpData) == false) {
|
||||||
EWOL_ERROR(" can not load file XML string...");
|
EWOL_ERROR(" can not load file XML string...");
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -23,7 +22,7 @@ namespace ewol {
|
|||||||
public: // properties:
|
public: // properties:
|
||||||
eproperty::Value<bvec2> propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
|
eproperty::Value<bvec2> propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
|
||||||
protected:
|
protected:
|
||||||
std::list<ewol::WidgetShared> m_subWidget;
|
etk::Vector<ewol::WidgetShared> m_subWidget;
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
|
@ -57,10 +57,9 @@ void ewol::widget::Entry::init() {
|
|||||||
ewol::Widget::init();
|
ewol::Widget::init();
|
||||||
propertyShape.notifyChange();
|
propertyShape.notifyChange();
|
||||||
|
|
||||||
try {
|
m_regex.compile(propertyRegex.get());
|
||||||
m_regex.assign(".*", std::regex_constants::optimize | std::regex_constants::ECMAScript);
|
if (m_regex.getStatus() == false) {
|
||||||
} catch (std::regex_error e) {
|
EWOL_ERROR("can not parse regex for : " << propertyRegex);
|
||||||
EWOL_ERROR("can not parse regex : '" << e.what() << "' for : " << propertyRegex);
|
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
|
|
||||||
@ -422,17 +421,15 @@ void ewol::widget::Entry::setInternalValue(const etk::String& _newData) {
|
|||||||
etk::String previous = propertyValue;
|
etk::String previous = propertyValue;
|
||||||
// check the RegExp :
|
// check the RegExp :
|
||||||
if (_newData.size()>0) {
|
if (_newData.size()>0) {
|
||||||
std::smatch resultMatch;
|
if (m_regex.parse(_newData, 0, _newData.size()) == false) {
|
||||||
std::regex_search(_newData.begin(), _newData.end(), resultMatch, m_regex, std::regex_constants::match_continuous);
|
|
||||||
if (resultMatch.size() <= 0) {
|
|
||||||
EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "'" );
|
EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "'" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_newData.begin() != resultMatch[0].first) {
|
if (m_regex.start() != 0) {
|
||||||
EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (start position error)" );
|
EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (start position error)" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_newData.end() != resultMatch[0].second) {
|
if (m_regex.start() != _newData.size()) {
|
||||||
EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (stop position error)" );
|
EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (stop position error)" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -596,10 +593,9 @@ void ewol::widget::Entry::onChangePropertyMaxCharacter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Entry::onChangePropertyRegex() {
|
void ewol::widget::Entry::onChangePropertyRegex() {
|
||||||
try {
|
m_regex.compile(propertyRegex.get());
|
||||||
m_regex.assign(propertyRegex.get(), std::regex_constants::optimize | std::regex_constants::ECMAScript);
|
if (m_regex.getStatus() == false) {
|
||||||
} catch (std::regex_error e) {
|
EWOL_ERROR("can not parse regex for : " << propertyRegex);
|
||||||
EWOL_ERROR("can not parse regex : '" << e.what() << "' for : " << propertyRegex);
|
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <regex>
|
#include <etk/RegEx.hpp>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ewol/compositing/Text.hpp>
|
#include <ewol/compositing/Text.hpp>
|
||||||
#include <ewol/compositing/Drawing.hpp>
|
#include <ewol/compositing/Drawing.hpp>
|
||||||
@ -70,7 +70,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
void setInternalValue(const etk::String& _newData);
|
void setInternalValue(const etk::String& _newData);
|
||||||
private:
|
private:
|
||||||
std::regex m_regex; //!< regular expression to check content
|
etk::RegEx<etk::String> m_regex; //!< regular expression to check content
|
||||||
private:
|
private:
|
||||||
bool m_needUpdateTextPos; //!< text position can have change
|
bool m_needUpdateTextPos; //!< text position can have change
|
||||||
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
|
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
|
||||||
|
@ -129,7 +129,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
|
|||||||
if(gale::key::status::down == typeEvent) {
|
if(gale::key::status::down == typeEvent) {
|
||||||
signalEnable.emit();
|
signalEnable.emit();
|
||||||
} else {
|
} else {
|
||||||
etk::String tmp = etk::String("distance=") + etk::String(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2);
|
etk::String tmp = etk::String("distance=") + etk::String(m_distance) + etk::String("angle=") + etk::String(m_angle+M_PI/2);
|
||||||
signalMove.emit(m_angle+M_PI/2);
|
signalMove.emit(m_angle+M_PI/2);
|
||||||
}
|
}
|
||||||
//teta += M_PI/2;
|
//teta += M_PI/2;
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include <etk/Vector.hpp>
|
#include <etk/Vector.hpp>
|
||||||
|
|
||||||
ewol::widget::Manager::Manager() :
|
ewol::widget::Manager::Manager() :
|
||||||
|
m_creatorList(0, false),
|
||||||
|
m_creatorListXml(0, false),
|
||||||
m_haveRedraw(true) {
|
m_haveRedraw(true) {
|
||||||
EWOL_DEBUG(" == > init Widget-Manager");
|
EWOL_DEBUG(" == > init Widget-Manager");
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <etk/Vector.hpp>
|
#include <etk/Vector.hpp>
|
||||||
#include <unordered_map>
|
|
||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -50,8 +49,8 @@ namespace ewol {
|
|||||||
using widgetCreatorFunction = etk::Function<ewol::WidgetShared()>; //!< funtion factory basic definition
|
using widgetCreatorFunction = etk::Function<ewol::WidgetShared()>; //!< funtion factory basic definition
|
||||||
using widgetCreatorFunctionXml = etk::Function<ewol::WidgetShared(const exml::Element& _node)>; //!< funtion factory basic definition
|
using widgetCreatorFunctionXml = etk::Function<ewol::WidgetShared(const exml::Element& _node)>; //!< funtion factory basic definition
|
||||||
private:
|
private:
|
||||||
std::unordered_map<etk::String, widgetCreatorFunction> m_creatorList; //!< List of factory of a widget
|
etk::Map<etk::String, widgetCreatorFunction> m_creatorList; //!< List of factory of a widget
|
||||||
std::unordered_map<etk::String, widgetCreatorFunctionXml> m_creatorListXml; //!< List of factory of a widget
|
etk::Map<etk::String, widgetCreatorFunctionXml> m_creatorListXml; //!< List of factory of a widget
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief add a factory of a specific widget.
|
* @brief add a factory of a specific widget.
|
||||||
|
@ -302,8 +302,8 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
|||||||
} else if( m_highSpeedMode == speedModeInit
|
} else if( m_highSpeedMode == speedModeInit
|
||||||
&& _event.getStatus() == gale::key::status::move) {
|
&& _event.getStatus() == gale::key::status::move) {
|
||||||
// wait that the cursor move more than 10 px to enable it :
|
// wait that the cursor move more than 10 px to enable it :
|
||||||
if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
||||||
|| std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
|| etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
||||||
// the scrooling can start :
|
// the scrooling can start :
|
||||||
// select the direction :
|
// select the direction :
|
||||||
if (relativePos.x() == m_highSpeedStartPos.x()) {
|
if (relativePos.x() == m_highSpeedStartPos.x()) {
|
||||||
@ -312,7 +312,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
|||||||
m_highSpeedMode = speedModeEnableHorizontal;
|
m_highSpeedMode = speedModeEnableHorizontal;
|
||||||
} else {
|
} else {
|
||||||
float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x());
|
float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x());
|
||||||
if (std::abs(coef) <= 1 ) {
|
if (etk::abs(coef) <= 1 ) {
|
||||||
m_highSpeedMode = speedModeEnableHorizontal;
|
m_highSpeedMode = speedModeEnableHorizontal;
|
||||||
} else {
|
} else {
|
||||||
m_highSpeedMode = speedModeEnableVertical;
|
m_highSpeedMode = speedModeEnableVertical;
|
||||||
@ -372,8 +372,8 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
|||||||
} else if ( m_highSpeedMode == speedModeInit
|
} else if ( m_highSpeedMode == speedModeInit
|
||||||
&& gale::key::status::move == _event.getStatus()) {
|
&& gale::key::status::move == _event.getStatus()) {
|
||||||
// wait that the cursor move more than 10 px to enable it :
|
// wait that the cursor move more than 10 px to enable it :
|
||||||
if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
||||||
|| std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
|| etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
||||||
// the scrooling can start :
|
// the scrooling can start :
|
||||||
// select the direction :
|
// select the direction :
|
||||||
m_highSpeedMode = speedModeEnableFinger;
|
m_highSpeedMode = speedModeEnableFinger;
|
||||||
|
@ -51,7 +51,7 @@ void ewol::widget::WSlider::onChangeSize() {
|
|||||||
ewol::widget::ContainerN::onChangeSize();
|
ewol::widget::ContainerN::onChangeSize();
|
||||||
if (m_windowsDestination == m_windowsSources) {
|
if (m_windowsDestination == m_windowsSources) {
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it+= m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
(*it)->setOrigin(m_origin+m_offset);
|
(*it)->setOrigin(m_origin+m_offset);
|
||||||
@ -64,7 +64,7 @@ void ewol::widget::WSlider::onChangeSize() {
|
|||||||
factor = 1.0f;
|
factor = 1.0f;
|
||||||
}
|
}
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsSources);
|
it += m_windowsSources;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
if (*propertyTransitionMode == sladingTransitionHori) {
|
if (*propertyTransitionMode == sladingTransitionHori) {
|
||||||
@ -80,7 +80,7 @@ void ewol::widget::WSlider::onChangeSize() {
|
|||||||
(*it)->onChangeSize();
|
(*it)->onChangeSize();
|
||||||
}
|
}
|
||||||
it = m_subWidget.begin();
|
it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
if (*propertyTransitionMode == sladingTransitionHori) {
|
if (*propertyTransitionMode == sladingTransitionHori) {
|
||||||
@ -230,7 +230,7 @@ void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
|
|||||||
if (m_windowsDestination == m_windowsSources) {
|
if (m_windowsDestination == m_windowsSources) {
|
||||||
//EWOL_DEBUG("Draw : " << m_windowsDestination);
|
//EWOL_DEBUG("Draw : " << m_windowsDestination);
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
//EWOL_INFO("Draw : [" << propertyName << "] t=" << getObjectType() << "o=" << m_origin << " s=" << m_size);
|
//EWOL_INFO("Draw : [" << propertyName << "] t=" << getObjectType() << "o=" << m_origin << " s=" << m_size);
|
||||||
@ -240,14 +240,14 @@ void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
|
|||||||
//EWOL_DEBUG("Draw : " << m_windowsSources << "=>" << m_windowsDestination << "progress=" << ((float)m_slidingProgress/1000.) );
|
//EWOL_DEBUG("Draw : " << m_windowsSources << "=>" << m_windowsDestination << "progress=" << ((float)m_slidingProgress/1000.) );
|
||||||
// draw Sources :
|
// draw Sources :
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsSources);
|
it += m_windowsSources;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
(*it)->systemDraw(prop);
|
(*it)->systemDraw(prop);
|
||||||
}
|
}
|
||||||
// draw Destination :
|
// draw Destination :
|
||||||
it = m_subWidget.begin();
|
it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
(*it)->systemDraw(prop);
|
(*it)->systemDraw(prop);
|
||||||
@ -258,20 +258,20 @@ void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
|
|||||||
void ewol::widget::WSlider::onRegenerateDisplay() {
|
void ewol::widget::WSlider::onRegenerateDisplay() {
|
||||||
if (m_windowsDestination == m_windowsSources) {
|
if (m_windowsDestination == m_windowsSources) {
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
(*it)->onRegenerateDisplay();
|
(*it)->onRegenerateDisplay();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsSources);
|
it += m_windowsSources;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
(*it)->onRegenerateDisplay();
|
(*it)->onRegenerateDisplay();
|
||||||
}
|
}
|
||||||
it = m_subWidget.begin();
|
it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
(*it)->onRegenerateDisplay();
|
(*it)->onRegenerateDisplay();
|
||||||
@ -296,7 +296,7 @@ ewol::WidgetShared ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) {
|
|||||||
}
|
}
|
||||||
if (m_windowsDestination == m_windowsSources) {
|
if (m_windowsDestination == m_windowsSources) {
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
vec2 tmpSize = (*it)->getSize();
|
vec2 tmpSize = (*it)->getSize();
|
||||||
@ -313,7 +313,7 @@ ewol::WidgetShared ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto it = m_subWidget.begin();
|
auto it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsDestination);
|
it += m_windowsDestination;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
vec2 tmpSize = (*it)->getSize();
|
vec2 tmpSize = (*it)->getSize();
|
||||||
@ -329,7 +329,7 @@ ewol::WidgetShared ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
it = m_subWidget.begin();
|
it = m_subWidget.begin();
|
||||||
std::advance(it, m_windowsSources);
|
it += m_windowsSources;
|
||||||
if ( it != m_subWidget.end()
|
if ( it != m_subWidget.end()
|
||||||
&& *it != nullptr) {
|
&& *it != nullptr) {
|
||||||
vec2 tmpSize = (*it)->getSize();
|
vec2 tmpSize = (*it)->getSize();
|
||||||
|
@ -229,8 +229,8 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
|
|||||||
} else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit
|
} else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit
|
||||||
&& _event.getStatus() == gale::key::status::move) {
|
&& _event.getStatus() == gale::key::status::move) {
|
||||||
// wait that the cursor move more than 10 px to enable it :
|
// wait that the cursor move more than 10 px to enable it :
|
||||||
if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
||||||
|| std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
|| etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
||||||
// the scrooling can start :
|
// the scrooling can start :
|
||||||
// select the direction :
|
// select the direction :
|
||||||
if (relativePos.x() == m_highSpeedStartPos.x()) {
|
if (relativePos.x() == m_highSpeedStartPos.x()) {
|
||||||
@ -239,7 +239,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
|
|||||||
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||||
} else {
|
} else {
|
||||||
float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x());
|
float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x());
|
||||||
if (std::abs(coef) <= 1 ) {
|
if (etk::abs(coef) <= 1 ) {
|
||||||
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||||
} else {
|
} else {
|
||||||
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||||
@ -338,8 +338,8 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
|
|||||||
} else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit
|
} else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit
|
||||||
&& _event.getStatus() == gale::key::status::move) {
|
&& _event.getStatus() == gale::key::status::move) {
|
||||||
// wait that the cursor move more than 10 px to enable it :
|
// wait that the cursor move more than 10 px to enable it :
|
||||||
if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|
||||||
|| std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
|| etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
|
||||||
// the scrooling can start :
|
// the scrooling can start :
|
||||||
// select the direction :
|
// select the direction :
|
||||||
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger;
|
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger;
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
#include <etk/Color.hpp>
|
#include <etk/Color.hpp>
|
||||||
#include <ewol/resource/ColorFile.hpp>
|
#include <ewol/resource/ColorFile.hpp>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -44,7 +43,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
void setSubWidget(ewol::WidgetShared _widget);
|
void setSubWidget(ewol::WidgetShared _widget);
|
||||||
protected:
|
protected:
|
||||||
std::list<ewol::WidgetShared> m_popUpWidgetList; //!< List of pop-up displayed
|
etk::Vector<ewol::WidgetShared> m_popUpWidgetList; //!< List of pop-up displayed
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Add a pop-up on the Windows.
|
* @brief Add a pop-up on the Windows.
|
||||||
|
@ -38,7 +38,7 @@ def configure(target, my_module):
|
|||||||
])
|
])
|
||||||
my_module.add_flag('c++', [
|
my_module.add_flag('c++', [
|
||||||
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
||||||
"-DAPPL_VERSION=\"\\\"" + tools.version_toString(get_version()) + "\\\"\""
|
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
|
||||||
])
|
])
|
||||||
my_module.add_path(".")
|
my_module.add_path(".")
|
||||||
return True
|
return True
|
||||||
|
@ -37,7 +37,7 @@ def configure(target, my_module):
|
|||||||
])
|
])
|
||||||
my_module.add_flag('c++', [
|
my_module.add_flag('c++', [
|
||||||
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
||||||
"-DAPPL_VERSION=\"\\\"" + tools.version_toString(get_version()) + "\\\"\""
|
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
|
||||||
])
|
])
|
||||||
my_module.add_path(".")
|
my_module.add_path(".")
|
||||||
return True
|
return True
|
||||||
|
@ -40,7 +40,7 @@ def configure(target, my_module):
|
|||||||
my_module.add_depend(['ewol'])
|
my_module.add_depend(['ewol'])
|
||||||
my_module.add_flag('c++', [
|
my_module.add_flag('c++', [
|
||||||
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"",
|
||||||
"-DAPPL_VERSION=\"\\\"" + tools.version_toString(get_version()) + "\\\"\""
|
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
|
||||||
])
|
])
|
||||||
my_module.copy_path('data/SnowFlake.svg','')
|
my_module.copy_path('data/SnowFlake.svg','')
|
||||||
my_module.add_path(".")
|
my_module.add_path(".")
|
||||||
|
@ -64,7 +64,7 @@ void appl::MainWindows::onCallbackCopy() {
|
|||||||
void appl::MainWindows::onCallbackPast() {
|
void appl::MainWindows::onCallbackPast() {
|
||||||
APPL_INFO("past");
|
APPL_INFO("past");
|
||||||
gale::context::clipBoard::request(gale::context::clipBoard::clipboardStd);
|
gale::context::clipBoard::request(gale::context::clipBoard::clipboardStd);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
ethread::sleepMilliSeconds((100));
|
||||||
etk::String value = gale::context::clipBoard::get(gale::context::clipBoard::clipboardStd);
|
etk::String value = gale::context::clipBoard::get(gale::context::clipBoard::clipboardStd);
|
||||||
APPL_INFO("past : '" << value << "'");
|
APPL_INFO("past : '" << value << "'");
|
||||||
propertySetOnWidgetNamed("appl-entry-clipboard", "value", value);
|
propertySetOnWidgetNamed("appl-entry-clipboard", "value", value);
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <elog/log.hpp>
|
#include <elog/log.hpp>
|
||||||
#include <cassert>
|
extern "C" {
|
||||||
|
#include <assert.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
/**
|
/**
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <elog/log.hpp>
|
#include <elog/log.hpp>
|
||||||
#include <cassert>
|
extern "C" {
|
||||||
|
#include <assert.h>
|
||||||
|
}
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user