diff --git a/gale/Application.cpp b/gale/Application.cpp index 76db6d0..86a2989 100644 --- a/gale/Application.cpp +++ b/gale/Application.cpp @@ -74,7 +74,7 @@ void gale::Application::onPointer(enum gale::key::type _type, int32_t _pointerID } -void gale::Application::onKeyboard(gale::key::Special& _special, +void gale::Application::onKeyboard(const gale::key::Special& _special, enum gale::key::keyboard _type, char32_t _value, gale::key::status _state) { diff --git a/gale/Application.h b/gale/Application.h index 410709a..2b19412 100644 --- a/gale/Application.h +++ b/gale/Application.h @@ -93,7 +93,7 @@ namespace gale { * @param[in] _value Unicode value of the char pushed (viable only if _type==gale::key::keyboard_char). * @param[in] _state State of the key (up/down/upRepeate/downRepeate) */ - virtual void onKeyboard(gale::key::Special& _special, + virtual void onKeyboard(const gale::key::Special& _special, enum gale::key::keyboard _type, char32_t _value, gale::key::status _state); diff --git a/gale/context/Android/Context.cpp b/gale/context/Android/Context.cpp index 795fa2e..1d3261f 100644 --- a/gale/context/Android/Context.cpp +++ b/gale/context/Android/Context.cpp @@ -431,24 +431,19 @@ class AndroidContext : public gale::Context { java_detach_current_thread(status); } public: - void OS_SetInputMotion(int _pointerID, const vec2& _pos) { - gale::Context::OS_SetInputMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos) { - gale::Context::OS_SetInputState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void OS_SetMouseMotion(int _pointerID, const vec2& _pos) { - gale::Context::OS_SetMouseMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos) { - gale::Context::OS_SetMouseState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); + void OS_SetInput(enum gale::key::type _type, + enum gale::key::status _status, + int32_t _pointerID, + const vec2& _pos) { + gale::Context::OS_SetInput(_type, _status, _pointerID, vec2(_pos.x(),m_currentHeight-_pos.y())); } void ANDROID_SetKeyboard(char32_t _myChar, bool _isDown, bool _isARepeateKey=false) { - OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey); + OS_setKeyboard(m_guiKeyBoardSpecialKeyMode, + gale::key::keyboard_char, + (_isDown==true?gale::key::status_down:gale::key::status_up), + _isARepeateKey, + _myChar); } bool ANDROID_systemKeyboradEvent(enum gale::key::keyboardSystem _key, bool _down) { @@ -458,7 +453,10 @@ class AndroidContext : public gale::Context { // direct wrapping : enum gale::key::keyboard move = (enum gale::key::keyboard)_move; m_guiKeyBoardSpecialKeyMode.update(move, _isDown); - OS_SetKeyboardMove(m_guiKeyBoardSpecialKeyMode, move, _isDown, _isARepeateKey); + OS_setKeyboard(m_guiKeyBoardSpecialKeyMode, + move, + (_isDown==true?gale::key::status_down:gale::key::status_up), + _isARepeateKey); } void OS_Resize(const vec2& _size) { @@ -683,7 +681,10 @@ extern "C" { // TODO : generate error in java to stop the current instance return; } - s_listInstance[_id]->OS_SetInputMotion(_pointerID+1, vec2(_x,_y)); + s_listInstance[_id]->OS_SetInput(gale::key::type_finger, + gale::key::status_move, + _pointerID+1, + vec2(_x,_y)); } void Java_org_gale_Gale_EWinputEventState(JNIEnv* _env, @@ -701,7 +702,10 @@ extern "C" { // TODO : generate error in java to stop the current instance return; } - s_listInstance[_id]->OS_SetInputState(_pointerID+1, _isUp, vec2(_x,_y)); + s_listInstance[_id]->OS_SetInput(gale::key::type_finger, + (_isUp==false?gale::key::status_down:gale::key::status_up), + _pointerID+1, + vec2(_x,_y)); } void Java_org_gale_Gale_EWmouseEventMotion(JNIEnv* _env, @@ -718,7 +722,10 @@ extern "C" { // TODO : generate error in java to stop the current instance return; } - s_listInstance[_id]->OS_SetMouseMotion(_pointerID+1, vec2(_x,_y)); + s_listInstance[_id]->OS_SetInput(gale::key::type_mouse, + gale::key::status_move, + _pointerID+1, + vec2(_x,_y)); } void Java_org_gale_Gale_EWmouseEventState(JNIEnv* _env, @@ -736,7 +743,10 @@ extern "C" { // TODO : generate error in java to stop the current instance return; } - s_listInstance[_id]->OS_SetMouseState(_pointerID+1, _isUp, vec2(_x,_y)); + s_listInstance[_id]->OS_SetInput(gale::key::type_mouse, + (_isUp==false?gale::key::status_down:gale::key::status_up), + _pointerID+1, + vec2(_x,_y)); } void Java_org_gale_Gale_EWunknowEvent(JNIEnv* _env, diff --git a/gale/context/Context.cpp b/gale/context/Context.cpp index dc87b5c..c2e86e5 100644 --- a/gale/context/Context.cpp +++ b/gale/context/Context.cpp @@ -149,21 +149,14 @@ void gale::Context::inputEventUnGrabPointer() { void gale::Context::processEvents() { int32_t nbEvent = 0; //GALE_DEBUG(" ******** Event"); - std::shared_ptr data; while (m_msgSystem.count()>0) { nbEvent++; - m_msgSystem.wait(data); - if (data == nullptr) { + std::function func; + m_msgSystem.wait(func); + if (func == nullptr) { continue; } - if (m_imulationActive == true) { - std::string dataExecuted = data->createString(); - m_simulationFile.filePuts(dataExecuted); - m_simulationFile.filePuts("\n"); - GALE_VERBOSE("plop: " + dataExecuted); - } - data->doAction(*this); - data.reset(); + func(*this); } } @@ -193,7 +186,6 @@ void gale::Context::setArchiveDir(int _mode, const char* _str) { gale::Context::Context(gale::Application* _application, int32_t _argc, const char* _argv[]) : - //m_application(std::make_shared(_application)), m_application(_application), m_imulationActive(false), m_simulationFile("gale.gsim"), @@ -209,8 +201,7 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha m_FpsSystemContext("Context ", false), m_FpsSystem( "Draw ", true), m_FpsFlush( "Flush ", false), - m_windowsSize(320,480), - m_initStepId(0) { + m_windowsSize(320,480) { // set a basic etk::thread::setName("galeThread"); if (m_application == nullptr) { @@ -282,7 +273,21 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha // TODO : remove this ... etk::initDefaultFolder("galeApplNoName"); // request the init of the application in the main context of openGL ... - m_msgSystem.post(std::make_shared()); + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":INIT"); + m_simulationFile.filePuts("\n"); + } + m_msgSystem.post([](gale::Context& _context){ + std::shared_ptr appl = _context.getApplication(); + if (appl == nullptr) { + return; + } + appl->onCreate(_context); + appl->onStart(_context); + appl->onResume(_context); + }); + // force a recalculation requestUpdateSize(); #if defined(__GALE_ANDROID_ORIENTATION_LANDSCAPE__) @@ -335,13 +340,31 @@ gale::Context::~Context() { } void gale::Context::requestUpdateSize() { - m_msgSystem.post(std::make_shared()); + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":RECALCULATE_SIZE\n"); + } + m_msgSystem.post([](gale::Context& _context){ + //GALE_DEBUG("Receive MSG : THREAD_RESIZE"); + _context.forceRedrawAll(); + }); } void gale::Context::OS_Resize(const vec2& _size) { - // TODO : Better in the thread ... == > but generate some init error ... + // TODO : Better in the thread ... ==> but generate some init error ... gale::Dimension::setPixelWindowsSize(_size); - m_msgSystem.post(std::make_shared(_size)); + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":RESIZE:"); + m_simulationFile.filePuts(etk::to_string(_size)); + m_simulationFile.filePuts("\n"); + } + m_msgSystem.post([_size](gale::Context& _context){ + //GALE_DEBUG("Receive MSG : THREAD_RESIZE"); + _context.m_windowsSize = _size; + gale::Dimension::setPixelWindowsSize(_context.m_windowsSize); + _context.forceRedrawAll(); + }); } void gale::Context::OS_Move(const vec2& _pos) { /* @@ -359,7 +382,7 @@ void gale::Context::OS_SetInput(enum gale::key::type _type, const vec2& _pos ) { if (m_imulationActive == true) { m_simulationFile.filePuts(etk::to_string(gale::getTime())); - m_simulationFile.filePuts(":INPUT:";); + m_simulationFile.filePuts(":INPUT:"); m_simulationFile.filePuts(etk::to_string(_type)); m_simulationFile.filePuts(":"); m_simulationFile.filePuts(etk::to_string(_status)); @@ -381,80 +404,96 @@ void gale::Context::OS_SetInput(enum gale::key::type _type, }); } -void gale::Context::OS_SetInputMotion(int _pointerID, const vec2& _pos ) { - OS_SetInput(gale::key::type_finger, - gale::key::status_move, - _pointerID, - _pos)); -} - -void gale::Context::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) { - OS_SetInput(gale::key::type_finger, - (_isDown==true?gale::key::status_down:gale::key::status_up), - _pointerID, - _pos)); -} - -void gale::Context::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) { - OS_SetInput(gale::key::type_mouse, - gale::key::status_move, - _pointerID, - _pos)); -} - -void gale::Context::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) { - OS_SetInput(gale::key::type_mouse, - (_isDown==true?gale::key::status_down:gale::key::status_up), - _pointerID, - _pos)); -} - -void gale::Context::OS_SetKeyboard(gale::key::Special& _special, - char32_t _myChar, - bool _isDown, - bool _isARepeateKey) { - enum gale::key::status state = _isDown==true?gale::key::status_down:gale::key::status_up; +void gale::Context::OS_setKeyboard(const gale::key::Special& _special, + enum gale::key::keyboard _type, + enum gale::key::status _state, + bool _isARepeateKey, + char32_t _char) { if (_isARepeateKey == true) { - if (state == gale::key::status_down) { - state = gale::key::status_downRepeate; + if (_state == gale::key::status_down) { + _state = gale::key::status_downRepeate; } else { - state = gale::key::status_upRepeate; + _state = gale::key::status_upRepeate; } } - m_msgSystem.post(std::make_shared(_special, - gale::key::keyboard_char, - state, - _myChar)); -} - -void gale::Context::OS_SetKeyboardMove(gale::key::Special& _special, - enum gale::key::keyboard _move, - bool _isDown, - bool _isARepeateKey) { - gale::key::status state = _isDown==true?gale::key::status_down:gale::key::status_up; - if (_isARepeateKey == true) { - if (state == gale::key::status_down) { - state = gale::key::status_downRepeate; - } else { - state = gale::key::status_upRepeate; - } + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":KEYBOARD:"); + m_simulationFile.filePuts(etk::to_string(_special)); + m_simulationFile.filePuts(":"); + m_simulationFile.filePuts(etk::to_string(_type)); + m_simulationFile.filePuts(":"); + m_simulationFile.filePuts(etk::to_string(_state)); + m_simulationFile.filePuts(":"); + m_simulationFile.filePuts(etk::to_string(uint64_t(_char))); + m_simulationFile.filePuts("\n"); } - m_msgSystem.post(std::make_shared(_special, - _move, - state)); + m_msgSystem.post([_special, _type, _state, _char](gale::Context& _context){ + std::shared_ptr appl = _context.getApplication(); + if (appl == nullptr) { + return; + } + appl->onKeyboard(_special, + _type, + _char, + _state); + }); } void gale::Context::OS_Hide() { - m_msgSystem.post(std::make_shared(false)); + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":VIEW:false\n"); + } + m_msgSystem.post([](gale::Context& _context){ + /* + std::shared_ptr appl = _context.getApplication(); + if (appl == nullptr) { + return; + } + appl->onKeyboard(_special, + _type, + _char, + _state); + */ + GALE_TODO("HIDE ... "); + }); } void gale::Context::OS_Show() { - m_msgSystem.post(std::make_shared(true)); + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":VIEW:true\n"); + } + m_msgSystem.post([](gale::Context& _context){ + /* + std::shared_ptr appl = _context.getApplication(); + if (appl == nullptr) { + return; + } + appl->onKeyboard(_special, + _type, + _char, + _state); + */ + GALE_TODO("SHOW ... "); + }); } void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID) { - m_msgSystem.post(std::make_shared(_clipboardID)); + if (m_imulationActive == true) { + m_simulationFile.filePuts(etk::to_string(gale::getTime())); + m_simulationFile.filePuts(":CLIPBOARD_ARRIVE:"); + m_simulationFile.filePuts(etk::to_string(_clipboardID)); + m_simulationFile.filePuts("\n"); + } + m_msgSystem.post([_clipboardID](gale::Context& _context){ + std::shared_ptr appl = _context.getApplication(); + if (appl != nullptr) { + appl->onClipboardEvent(_clipboardID); + } + }); } void gale::Context::clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) { diff --git a/gale/context/Context.h b/gale/context/Context.h index eb36638..21c0038 100644 --- a/gale/context/Context.h +++ b/gale/context/Context.h @@ -23,14 +23,12 @@ #include #include #include -#include #include #define MAX_MANAGE_INPUT (15) namespace gale { class Context/* : private gale::object::RemoveEvent */{ - friend gale::context::LoopActionResize; private: std::shared_ptr m_application; //!< Application handle public: @@ -70,7 +68,7 @@ namespace gale { private: int64_t m_previousDisplayTime; // this is to limit framerate ... in case... // TODO : gale::context::InputManager m_input; - etk::Fifo > m_msgSystem; + etk::Fifo > m_msgSystem; bool m_displayFps; gale::context::Fps m_FpsSystemEvent; gale::context::Fps m_FpsSystemContext; @@ -84,20 +82,15 @@ namespace gale { virtual void setArchiveDir(int _mode, const char* _str); - virtual void OS_SetInputMotion(int _pointerID, const vec2& _pos); - virtual void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos); - - virtual void OS_SetMouseMotion(int _pointerID, const vec2& _pos); - virtual void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos); - - virtual void OS_SetKeyboard(gale::key::Special& _special, - char32_t _myChar, - bool _isDown, - bool _isARepeateKey=false); - virtual void OS_SetKeyboardMove(gale::key::Special& _special, - enum gale::key::keyboard _move, - bool _isDown, - bool _isARepeateKey=false); + virtual void OS_SetInput(enum gale::key::type _type, + enum gale::key::status _status, + int32_t _pointerID, + const vec2& _pos); + virtual void OS_setKeyboard(const gale::key::Special& _special, + enum gale::key::keyboard _type, + enum gale::key::status _state, + bool _isARepeateKey = false, + char32_t _char = u32char::Null); /** * @brief The current context is suspended */ @@ -285,9 +278,6 @@ namespace gale { * @return normal error int for the application error management */ static int main(int _argc, const char *_argv[]); - private: - size_t m_initStepId; - size_t m_initTotalStep; public: /** * @brief Special for init (main) set the start image when loading data diff --git a/gale/context/IOs/Context.cpp b/gale/context/IOs/Context.cpp index 813293f..4101c0b 100644 --- a/gale/context/IOs/Context.cpp +++ b/gale/context/IOs/Context.cpp @@ -76,16 +76,28 @@ public: OS_Resize(vec2(_x,_y)); } void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) { - OS_SetMouseState(_id, _isDown, vec2(_x, _y)); + OS_SetInput(gale::key::type_mouse, + (_isDown==true?gale::key::status_down:gale::key::status_up), + _id, + vec2(_x, _y)); } void MAC_SetMouseMotion(int32_t _id, float _x, float _y) { - OS_SetMouseMotion(_id, vec2(_x, _y)); + OS_SetInput(gale::key::type_mouse, + gale::key::status_move, + _id, + vec2(_x, _y)); } void MAC_SetInputState(int32_t _id, bool _isDown, float _x, float _y) { - OS_SetInputState(_id, _isDown, vec2(_x, _y)); + OS_SetInput(gale::key::type_finger, + (_isDown==true?gale::key::status_down:gale::key::status_up), + _id, + vec2(_x, _y)); } void MAC_SetInputMotion(int32_t _id, float _x, float _y) { - OS_SetInputMotion(_id, vec2(_x, _y)); + OS_SetInput(gale::key::type_finger, + gale::key::status_move, + _id, + vec2(_x, _y)); } void MAC_SetKeyboard(gale::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { if (_unichar == u32char::Delete) { @@ -113,15 +125,24 @@ public: move = gale::key::keyboardRight; break; } - OS_SetKeyboardMove(_keyboardMode, move, !_isDown, _isAReapeateKey); + OS_setKeyboard(_keyboardMode, + move, + (_isDown==false?gale::key::status_down:gale::key::status_up), + _isARepeateKey); } else { - OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey); + OS_setKeyboard(_keyboardMode, + gale::key::keyboard_char, + (_isDown==false?gale::key::status_down:gale::key::status_up), + _isARepeateKey, + _unichar); } } void MAC_SetKeyboardMove(gale::key::Special& _special, enum gale::key::keyboard _move, bool _isDown) { - OS_SetKeyboardMove(_special, _move, _isDown); + OS_setKeyboard(_keyboardMode, + _move, + (_isDown==true?gale::key::status_down:gale::key::status_up)); } void openURL(const std::string& _url) { mm_openURL(_url.c_str()); diff --git a/gale/context/LoopAction.cpp b/gale/context/LoopAction.cpp deleted file mode 100644 index 2e2e5c1..0000000 --- a/gale/context/LoopAction.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -etk::Hash(const std::string&)> >& getList() { - static etk::Hash(const std::string&)> > list; - return list; -} - -std::shared_ptr gale::context::createAction(const std::string& _lineToParse) { - // TODO: parse line ... - std::string _name = "lkjlkjlkjlk"; - std::string nameLower = etk::tolower(_name); - if (getList().exist(nameLower) == true) { - std::function(const std::string&)> func = getList()[nameLower]; - if (func != nullptr) { - return func(_lineToParse); - } - } - GALE_WARNING("try to create an UnExistant widget : " << nameLower); - return nullptr; -} - -void gale::context::addFactory(const std::string& _type, const std::function(const std::string&)>& _func) { - if (_func == nullptr) { - return; - } - //Keep name in lower case : - std::string nameLower = etk::tolower(_type); - if (true == getList().exist(nameLower)) { - GALE_WARNING("Replace Creator of a loop action : " << nameLower); - getList()[nameLower] = _func; - return; - } - GALE_INFO("Add Creator of a specify loop action : " << nameLower); - getList().add(nameLower, _func); -} - -gale::context::LoopAction::LoopAction() { - m_timestamp = gale::getTime(); -} - -gale::context::LoopAction::~LoopAction() { - -} - -///////////////////////////////////////////////////////////////////////////////////////// - -void gale::context::LoopActionInit::doAction(gale::Context& _context) { - std::shared_ptr appl = _context.getApplication(); - // this is due to the openGL context - if (appl == nullptr) { - return; - } - appl->onCreate(_context); - appl->onStart(_context); - appl->onResume(_context); -} - -std::string gale::context::LoopActionInit::createString() { - return etk::to_string(m_timestamp) + ":INIT"; -} - -///////////////////////////////////////////////////////////////////////////////////////// -gale::context::LoopActionResize::LoopActionResize(const vec2& _size) : - m_size(_size) { - -} - -void gale::context::LoopActionResize::doAction(gale::Context& _context) { - //GALE_DEBUG("Receive MSG : THREAD_RESIZE"); - _context.m_windowsSize = m_size; - gale::Dimension::setPixelWindowsSize(_context.m_windowsSize); - _context.forceRedrawAll(); -} - -std::string gale::context::LoopActionResize::createString() { - return etk::to_string(m_timestamp) + ":RESIZE:" + etk::to_string(m_size); -} - -///////////////////////////////////////////////////////////////////////////////////////// -gale::context::LoopActionView::LoopActionView(bool _show) : - m_show(_show) { - -} - -void gale::context::LoopActionView::doAction(gale::Context& _context) { - GALE_TODO("kjhkjhkhkjh"); -} - -std::string gale::context::LoopActionView::createString() { - return etk::to_string(m_timestamp) + ":VIEW:" + etk::to_string(m_show); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -void gale::context::LoopActionRecalculateSize::doAction(gale::Context& _context) { - _context.forceRedrawAll(); -} - -std::string gale::context::LoopActionRecalculateSize::createString() { - return etk::to_string(m_timestamp) + ":RECALCULATE_SIZE"; -} - -///////////////////////////////////////////////////////////////////////////////////////// -gale::context::LoopActionInput::LoopActionInput(enum gale::key::type _type, - enum gale::key::status _status, - int32_t _pointerID, - const vec2& _pos) : - m_type(_type), - m_status(_status), - m_pointerID(_pointerID), - m_pos(_pos) { - -} - -void gale::context::LoopActionInput::doAction(gale::Context& _context) { - std::shared_ptr appl = _context.getApplication(); - if (appl == nullptr) { - return; - } - appl->onPointer(m_type, - m_pointerID, - m_pos, - m_status); -} - -std::string gale::context::LoopActionInput::createString() { - return etk::to_string(m_timestamp) + ":INPUT:" + etk::to_string(m_type) + ":" + etk::to_string(m_status) + ":" + etk::to_string(m_pointerID) + ":" + etk::to_string(m_pos); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -gale::context::LoopActionKeyboard::LoopActionKeyboard(const gale::key::Special& _special, - enum gale::key::keyboard _type, - enum gale::key::status _state, - char32_t _char) : - m_special(_special), - m_type(_type), - m_state(_state), - m_char(_char) { - -} - -void gale::context::LoopActionKeyboard::doAction(gale::Context& _context) { - std::shared_ptr appl = _context.getApplication(); - if (appl == nullptr) { - return; - } - appl->onKeyboard(m_special, - m_type, - m_char, - m_state); -} - -std::string gale::context::LoopActionKeyboard::createString() { - return etk::to_string(m_timestamp) + ":KEYBOARD:" + etk::to_string(m_special) + ":" + etk::to_string(m_type) + ":" + etk::to_string(m_state) + ":" + etk::to_string(uint64_t(m_char)); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -gale::context::LoopActionClipboardArrive::LoopActionClipboardArrive(enum gale::context::clipBoard::clipboardListe _id) : - m_id(_id) { - -} - -void gale::context::LoopActionClipboardArrive::doAction(gale::Context& _context) { - std::shared_ptr appl = _context.getApplication(); - if (appl != nullptr) { - appl->onClipboardEvent(m_id); - } -} - -std::string gale::context::LoopActionClipboardArrive::createString() { - return etk::to_string(m_timestamp) + ":CLIPBOARD_ARRIVE:" + etk::to_string(m_id); -} - -///////////////////////////////////////////////////////////////////////////////////////// - - diff --git a/gale/context/LoopAction.h b/gale/context/LoopAction.h deleted file mode 100644 index 47d8b9a..0000000 --- a/gale/context/LoopAction.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __GALE_CONTEXT_LOOP_ACTION_H__ -#define __GALE_CONTEXT_LOOP_ACTION_H__ - -#include -#include -#include -#include -#include -#define MAX_MANAGE_INPUT (15) - -namespace gale { - namespace context { - - class LoopAction : public std::enable_shared_from_this { - protected: - int64_t m_timestamp; //!< time of the signal is emit (used for simulation) - public: - LoopAction(); - virtual ~LoopAction(); - virtual void doAction(gale::Context& _context) = 0; - virtual std::string createString() = 0; - }; - /** - * @brief Create action from the simulation string line - * @param[in] _lineToParse Simulation string line - * @return Created action. - */ - std::shared_ptr createAction(const std::string& _lineToParse); - /** - * @brief Add a factory to create an event from a specific type - * @param[in] _type Type of the action - * @param[in] _func function to call to create - * @return Created action. - */ - void addFactory(const std::string& _type, const std::function(const std::string&)>& _func); - - class LoopActionInit : public LoopAction { - public: - LoopActionInit() {}; - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - - class LoopActionResize : public LoopAction { - protected: - vec2 m_size; - public: - LoopActionResize(const vec2& _size); - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - - class LoopActionView : public LoopAction { - protected: - bool m_show; - public: - LoopActionView(bool _show); - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - - class LoopActionRecalculateSize : public LoopAction { - public: - LoopActionRecalculateSize() {}; - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - - class LoopActionInput : public LoopAction { - private: - enum gale::key::type m_type; - enum gale::key::status m_status; - int32_t m_pointerID; - const vec2& m_pos; - public: - LoopActionInput(enum gale::key::type _type, enum gale::key::status _status, int32_t _pointerID, const vec2& _pos); - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - - class LoopActionKeyboard : public LoopAction { - private: - gale::key::Special m_special; - enum gale::key::keyboard m_type; - enum gale::key::status m_state; - char32_t m_char; - public: - LoopActionKeyboard(const gale::key::Special& _special, enum gale::key::keyboard _type, enum gale::key::status _state, char32_t _char=u32char::Null); - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - - class LoopActionClipboardArrive : public LoopAction { - private: - enum gale::context::clipBoard::clipboardListe m_id; - public: - LoopActionClipboardArrive(enum gale::context::clipBoard::clipboardListe _id); - virtual void doAction(gale::Context& _context); - virtual std::string createString(); - }; - } -} - -#endif \ No newline at end of file diff --git a/gale/context/MacOs/Context.mm b/gale/context/MacOs/Context.mm index 0a09c28..765c3c5 100644 --- a/gale/context/MacOs/Context.mm +++ b/gale/context/MacOs/Context.mm @@ -74,12 +74,18 @@ class MacOSInterface : public ewol::Context { OS_Resize(vec2(_x,_y)); } void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) { - OS_SetMouseState(_id, _isDown, vec2(_x, _y)); + OS_SetInput(gale::key::type_mouse, + (_isDown==true?gale::key::status_down:gale::key::status_up), + _id, + vec2(_x, _y)); } void MAC_SetMouseMotion(int32_t _id, float _x, float _y) { - OS_SetMouseMotion(_id, vec2(_x, _y)); + OS_SetInput(gale::key::type_mouse, + gale::key::status_move, + _id, + vec2(_x, _y)); } - void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { + void MAC_SetKeyboard(ewol::key::Special _special, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { if (char32_t(_unichar) == u32char::Delete) { _unichar = u32char::Suppress; } else if (char32_t(_unichar) == u32char::Suppress) { @@ -105,16 +111,16 @@ class MacOSInterface : public ewol::Context { move = ewol::key::keyboardRight; break; } - OS_SetKeyboardMove(_keyboardMode, move, !_isDown, _isAReapeateKey); + OS_setKeyboard(_special, move, (_isDown==false?gale::key::status_down:gale::key::status_up), _isAReapeateKey); } else { - OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey); + OS_setKeyboard(_special, gale::key::keyboard_char, (_isDown==false?gale::key::status_down:gale::key::status_up), _isAReapeateKey, _unichar); } } void MAC_SetKeyboardMove(ewol::key::Special& _special, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey) { - OS_SetKeyboardMove(_special, _move, _isDown, _isAReapeateKey); + OS_setKeyboard(_special, _move, (_isDown==true?gale::key::status_down:gale::key::status_up), _isAReapeateKey); } void openURL(const std::string& _url) { std::string req = "open " + _url; diff --git a/gale/context/Windows/Context.cpp b/gale/context/Windows/Context.cpp index 7cabcbc..3bf2b5c 100644 --- a/gale/context/Windows/Context.cpp +++ b/gale/context/Windows/Context.cpp @@ -398,9 +398,15 @@ class WindowsContext : public gale::Context { GALE_DEBUG("kjhkjhkjhkjhkj = " << _wParam); if (tmpChar == 0) { //GALE_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) ); - OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, buttonIsDown); + OS_setKeyboard(m_guiKeyBoardMode, + move, + (buttonIsDown==true?gale::key::status_down:gale::key::status_up)); } else { - OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, buttonIsDown); + OS_setKeyboard(m_guiKeyBoardMode, + gale::key::keyboard_char, + (buttonIsDown==true?gale::key::status_down:gale::key::status_up), + false, + tmpChar); } return 0; } @@ -414,7 +420,10 @@ class WindowsContext : public gale::Context { pos.setValue(GET_X_LPARAM(_lParam), m_currentHeight-GET_Y_LPARAM(_lParam)); m_inputIsPressed[mouseButtonId] = buttonIsDown; - OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y())); + OS_SetInput(gale::key::type_mouse, + (buttonIsDown==true?gale::key::status_down:gale::key::status_up), + mouseButtonId, + vec2(pos.x(),pos.y())); return 0; case WM_MBUTTONUP: @@ -424,7 +433,10 @@ class WindowsContext : public gale::Context { pos.setValue(GET_X_LPARAM(_lParam), m_currentHeight-GET_Y_LPARAM(_lParam)); m_inputIsPressed[mouseButtonId] = buttonIsDown; - OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y())); + OS_SetInput(gale::key::type_mouse, + (buttonIsDown==true?gale::key::status_down:gale::key::status_up), + mouseButtonId, + vec2(pos.x(),pos.y())); return 0; case WM_RBUTTONUP: @@ -434,7 +446,10 @@ class WindowsContext : public gale::Context { pos.setValue(GET_X_LPARAM(_lParam), m_currentHeight-GET_Y_LPARAM(_lParam)); m_inputIsPressed[mouseButtonId] = buttonIsDown; - OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y())); + OS_SetInput(gale::key::type_mouse, + (buttonIsDown==true?gale::key::status_down:gale::key::status_up), + mouseButtonId, + vec2(pos.x(),pos.y())); return 0; case WM_MOUSEWHEEL: @@ -447,8 +462,14 @@ class WindowsContext : public gale::Context { } pos.setValue(GET_X_LPARAM(_lParam), m_currentHeight-GET_Y_LPARAM(_lParam)); - OS_SetMouseState(mouseButtonId, true, vec2(pos.x(),pos.y())); - OS_SetMouseState(mouseButtonId, false, vec2(pos.x(),pos.y())); + OS_SetInput(gale::key::type_mouse, + gale::key::status_down, + mouseButtonId, + vec2(pos.x(),pos.y())); + OS_SetInput(gale::key::type_mouse, + gale::key::status_up, + mouseButtonId, + vec2(pos.x(),pos.y())); return 0; case WM_MOUSEHOVER: @@ -458,12 +479,18 @@ class WindowsContext : public gale::Context { for (int32_t iii=0; iii