From 291da66c157e9c88483184d9fb796e2af1e002dc Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 11 Aug 2015 21:10:16 +0200 Subject: [PATCH] [DEV] continue converging --- gale/Application.cpp | 2 +- gale/Application.h | 2 +- gale/context/Context.cpp | 84 ++++++++++++++------------------------- gale/context/Context.h | 4 +- gale/resource/Texture.cpp | 2 + 5 files changed, 36 insertions(+), 58 deletions(-) diff --git a/gale/Application.cpp b/gale/Application.cpp index 192a8c4..c097789 100644 --- a/gale/Application.cpp +++ b/gale/Application.cpp @@ -85,7 +85,7 @@ void gale::Application::keyboardHide() { } -void gale::Application::onResize(const vec2& _size) { +void gale::Application::onResize(const ivec2& _size) { } diff --git a/gale/Application.h b/gale/Application.h index a7e1ef5..0581a74 100644 --- a/gale/Application.h +++ b/gale/Application.h @@ -110,7 +110,7 @@ namespace gale { * @brief Event generated when user change the size of the window. * @param[in] _size New size of the window. */ - virtual void onResize(const vec2& _size); + virtual void onResize(const ivec2& _size); /** * @brief Set the size of the window (if possible: Android and Ios does not support it) * @param[in] _size New size of the window. diff --git a/gale/context/Context.cpp b/gale/context/Context.cpp index b0b056d..505ba0a 100644 --- a/gale/context/Context.cpp +++ b/gale/context/Context.cpp @@ -176,65 +176,43 @@ void gale::Context::processEvents() { break; case eSystemMessage::msgInputMotion: //GALE_DEBUG("Receive MSG : THREAD_INPUT_MOTION"); - // TODO : m_input.motion(data->inputType, data->inputId, data->dimention); + if (m_application == nullptr) { + return; + } + m_application->onPointer(data->inputType, + data->inputId, + data->dimention, + gale::key::status_move); break; case eSystemMessage::msgInputState: //GALE_DEBUG("Receive MSG : THREAD_INPUT_STATE"); - // TODO : m_input.state(data->inputType, data->inputId, data->stateIsDown, data->dimention); + if (m_application == nullptr) { + return; + } + m_application->onPointer(data->inputType, + data->inputId, + data->dimention, + (data->stateIsDown==true?gale::key::status_down:gale::key::status_up)); break; case eSystemMessage::msgKeyboardKey: case eSystemMessage::msgKeyboardMove: //GALE_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY"); - // store the keyboard special key status for mouse event... - // TODO : m_input.setLastKeyboardSpecial(data->keyboardSpecial); - #if 0 - if (nullptr != m_windowsCurrent) { - if (false == m_windowsCurrent->onEventShortCut(data->keyboardSpecial, - data->keyboardChar, - data->keyboardMove, - data->stateIsDown) ) { - // get the current focused Widget : - std::shared_ptr tmpWidget = m_widgetManager.focusGet(); - if (nullptr != tmpWidget) { - // check if the widget allow repeating key events. - //GALE_DEBUG("repeating test :" << data->repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data->stateIsDown); - if( false == data->repeateKey - || ( true == data->repeateKey - && true == tmpWidget->getKeyboardRepeate()) ) { - // check Widget shortcut - if (false == tmpWidget->onEventShortCut(data->keyboardSpecial, - data->keyboardChar, - data->keyboardMove, - data->stateIsDown) ) { - // generate the direct event ... - if (data->TypeMessage == eSystemMessage::msgKeyboardKey) { - gale::event::EntrySystem tmpEntryEvent(gale::key::keyboardChar, - gale::key::statusUp, - data->keyboardSpecial, - data->keyboardChar); - if(true == data->stateIsDown) { - tmpEntryEvent.m_event.setStatus(gale::key::statusDown); - } - tmpWidget->systemEventEntry(tmpEntryEvent); - } else { // THREAD_KEYBORAD_MOVE - GALE_DEBUG("THREAD_KEYBORAD_MOVE" << data->keyboardMove << " " << data->stateIsDown); - gale::event::EntrySystem tmpEntryEvent(data->keyboardMove, - gale::key::statusUp, - data->keyboardSpecial, - 0); - if(true == data->stateIsDown) { - tmpEntryEvent.m_event.setStatus(gale::key::statusDown); - } - tmpWidget->systemEventEntry(tmpEntryEvent); - } - } else { - GALE_DEBUG("remove Repeate key ..."); - } - } + if (m_application == nullptr) { + return; + } else { + gale::key::status state = data->stateIsDown==true?gale::key::status_down:gale::key::status_up; + if (data->repeateKey == true) { + if (state == gale::key::status_down) { + state = gale::key::status_downRepeate; + } else { + state = gale::key::status_upRepeate; } } + m_application->onKeyboard(data->keyboardSpecial, + data->keyboardMove, + data->keyboardChar, + state); } - #endif break; case eSystemMessage::msgClipboardArrive: { @@ -304,7 +282,7 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha m_windowsSize(320,480), m_initStepId(0) { // set a basic - etk::thread::setName("gale"); + etk::thread::setName("galeThread"); if (m_application == nullptr) { GALE_CRITICAL("Can not start context with no Application ==> rtfm ..."); } @@ -673,12 +651,10 @@ void gale::Context::OS_OpenGlContextDestroy() { } void gale::Context::forceRedrawAll() { - #if 0 - if (m_windowsCurrent == nullptr) { + if (m_application == nullptr) { return; } - m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y())); - #endif + m_application->onResize(m_windowsSize); } void gale::Context::OS_Stop() { diff --git a/gale/context/Context.h b/gale/context/Context.h index 11849c5..104e2d6 100644 --- a/gale/context/Context.h +++ b/gale/context/Context.h @@ -134,13 +134,13 @@ namespace gale { */ virtual void stop(); private: - vec2 m_windowsSize; //!< current size of the system + ivec2 m_windowsSize; //!< current size of the system public: /** * @brief get the current windows size * @return the current size ... */ - const vec2& getSize() { + const ivec2& getSize() { return m_windowsSize; }; /** diff --git a/gale/resource/Texture.cpp b/gale/resource/Texture.cpp index 5d02790..40c90cd 100644 --- a/gale/resource/Texture.cpp +++ b/gale/resource/Texture.cpp @@ -112,7 +112,9 @@ void gale::resource::Texture::setTexture(const std::shared_ptr enum gale::resource::Texture::color _dataColorSpace) { m_data = _data; m_size = _size; + m_endPointSize = _size; m_dataType = _dataType; m_dataColorSpace = _dataColorSpace; // TODO : Reload ... + flush(); }