diff --git a/Sources/libewol/Linux.mk b/Sources/libewol/Linux.mk index 29317b63..fdbde8e0 100644 --- a/Sources/libewol/Linux.mk +++ b/Sources/libewol/Linux.mk @@ -16,7 +16,6 @@ LOCAL_CFLAGS := -D__PLATFORM__Linux \ -DEWOL_DEBUG_LEVEL=3 \ -DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \ -DVERSION_BUILD_TIME="\"pasd_heure\"" \ - -DEWOL_X11_MODE__XF86V \ -DEWOL_USE_FREE_TYPE \ `pkg-config --cflags freetype2` diff --git a/Sources/libewol/ewol/Texture.cpp b/Sources/libewol/ewol/Texture.cpp index a6d51401..1dc5901d 100644 --- a/Sources/libewol/ewol/Texture.cpp +++ b/Sources/libewol/ewol/Texture.cpp @@ -27,6 +27,7 @@ #include <ewol/Texture.h> #include <ewol/importgl.h> #include <ewol/ewol.h> +#include <pthread.h> extern "C" { @@ -334,6 +335,24 @@ class LoadedTexture etk::VectorType<LoadedTexture*> listLoadedTexture; +#undef __class__ +#define __class__ "ewol::texture" + +static pthread_mutex_t localMutex; + + +void ewol::texture::Init(void) +{ + // create interface mutex : + int ret = pthread_mutex_init(&localMutex, NULL); + EWOL_ASSERT(ret == 0, "Error creating Mutex ..."); +} + +void ewol::texture::UnInit(void) +{ + int ret = pthread_mutex_destroy(&localMutex); + EWOL_ASSERT(ret == 0, "Error destroying Mutex ..."); +} #undef __class__ @@ -343,6 +362,7 @@ etk::VectorType<LoadedTexture*> listLoadedTexture; void ewol::UpdateTextureContext(void) { bool needRedraw = false; + pthread_mutex_lock(&localMutex); for (int32_t iii=0; iii < listLoadedTexture.Size(); iii++) { if( NULL != listLoadedTexture[iii] && NULL != listLoadedTexture[iii]->m_data) @@ -393,6 +413,7 @@ void ewol::UpdateTextureContext(void) } } } + pthread_mutex_unlock(&localMutex); if (true == needRedraw) { ewol::ForceRedrawAll(); } @@ -439,8 +460,10 @@ int32_t ewol::LoadTexture(int32_t target, } memcpy(tmpTex->m_data, data, sizeof(char) * tmpTex->m_nbBytes); + pthread_mutex_lock(&localMutex); listLoadedTexture.PushBack(tmpTex); outTextureID = listLoadedTexture.Size()-1; + pthread_mutex_unlock(&localMutex); return outTextureID; } diff --git a/Sources/libewol/ewol/Texture.h b/Sources/libewol/ewol/Texture.h index f74d41cb..b31f2207 100644 --- a/Sources/libewol/ewol/Texture.h +++ b/Sources/libewol/ewol/Texture.h @@ -39,6 +39,10 @@ namespace ewol int32_t GetSize(uint32_t textureID); }; */ + namespace texture { + void Init(void); + void UnInit(void); + }; int32_t LoadTexture(etk::File fileName); int32_t LoadTexture(int32_t target, int32_t level, int32_t internalFormat, int32_t width, int32_t height, int32_t border, int32_t format, int32_t type, const void* data, int32_t nbBytes, etk::String filename); void UnLoadTexture(uint32_t textureID); diff --git a/Sources/libewol/ewol/Widget.cpp b/Sources/libewol/ewol/Widget.cpp index f62724c1..c3185a31 100644 --- a/Sources/libewol/ewol/Widget.cpp +++ b/Sources/libewol/ewol/Widget.cpp @@ -76,6 +76,9 @@ char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type) ewol::Widget::Widget(void) { + m_currentDrawId = 0; + m_currentCreateId = 1; + m_needFlipFlop = false; m_origin.x = 0.0; m_origin.y = 0.0; m_size.x = 10.0; @@ -337,19 +340,20 @@ void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name, int32_ newObject->UpdateSize(m_size.x, m_size.y); //EWOL_INFO("UPDATE AT origin : (" << m_origin.x << "," << m_origin.y << ")"); newObject->UpdateOrigin(m_origin.x, m_origin.y); - if (pos < 0 || pos >= m_listOObject.Size() ) { - m_listOObject.PushBack(newObject); + if (pos < 0 || pos >= m_listOObject[m_currentCreateId].Size() ) { + m_listOObject[m_currentCreateId].PushBack(newObject); } else { - m_listOObject.Insert(pos, newObject); + m_listOObject[m_currentCreateId].Insert(pos, newObject); } + m_needFlipFlop = true; } ewol::OObject* ewol::Widget::GetOObject(etk::String name) { - for (int32_t iii=0; iii<m_listOObject.Size(); iii++) { - if (m_listOObject[iii]->GetName() == name) { - return m_listOObject[iii]; + for (int32_t iii=0; iii<m_listOObject[m_currentCreateId].Size(); iii++) { + if (m_listOObject[m_currentCreateId][iii]->GetName() == name) { + return m_listOObject[m_currentCreateId][iii]; } } return NULL; @@ -357,11 +361,11 @@ ewol::OObject* ewol::Widget::GetOObject(etk::String name) void ewol::Widget::RmOObjectElem(etk::String name) { - for (int32_t iii=0; iii<m_listOObject.Size(); iii++) { - if (m_listOObject[iii]->GetName() == name) { - delete(m_listOObject[iii]); - m_listOObject[iii] = NULL; - m_listOObject.Erase(iii); + for (int32_t iii=0; iii<m_listOObject[m_currentCreateId].Size(); iii++) { + if (m_listOObject[m_currentCreateId][iii]->GetName() == name) { + delete(m_listOObject[m_currentCreateId][iii]); + m_listOObject[m_currentCreateId][iii] = NULL; + m_listOObject[m_currentCreateId].Erase(iii); return; } } @@ -369,24 +373,38 @@ void ewol::Widget::RmOObjectElem(etk::String name) void ewol::Widget::ClearOObjectList(void) { - for (int32_t iii=0; iii<m_listOObject.Size(); iii++) { - delete(m_listOObject[iii]); - m_listOObject[iii] = NULL; + for (int32_t iii=0; iii<m_listOObject[m_currentCreateId].Size(); iii++) { + delete(m_listOObject[m_currentCreateId][iii]); + m_listOObject[m_currentCreateId][iii] = NULL; } - m_listOObject.Clear(); + m_listOObject[m_currentCreateId].Clear(); } bool ewol::Widget::GenericDraw(void) { - for (int32_t iii=0; iii<m_listOObject.Size(); iii++) { - if (NULL != m_listOObject[iii]) { - m_listOObject[iii]->Draw(); + for (int32_t iii=0; iii<m_listOObject[m_currentDrawId].Size(); iii++) { + if (NULL != m_listOObject[m_currentDrawId][iii]) { + m_listOObject[m_currentDrawId][iii]->Draw(); } } return true; } -//} // ??? +void ewol::Widget::DoubleBufferFlipFlop(void) +{ + if (true == m_needFlipFlop) { + m_currentDrawId++; + if (NB_BOUBLE_BUFFER<=m_currentDrawId) { + m_currentDrawId = 0; + } + m_currentCreateId++; + if (NB_BOUBLE_BUFFER<=m_currentCreateId) { + m_currentCreateId = 0; + } + m_needFlipFlop = false; + } +} + diff --git a/Sources/libewol/ewol/Widget.h b/Sources/libewol/ewol/Widget.h index 01969672..bfaa7a3e 100644 --- a/Sources/libewol/ewol/Widget.h +++ b/Sources/libewol/ewol/Widget.h @@ -25,6 +25,7 @@ #ifndef __EWOL_WIDGET_H__ #define __EWOL_WIDGET_H__ +#define NB_BOUBLE_BUFFER (2) namespace ewol { class Widget; @@ -291,8 +292,13 @@ namespace ewol { private: bool m_genericDraw; bool m_specificDraw; - etk::VectorType<ewol::OObject*> m_listOObject; //!< generic element to display... + int32_t m_currentDrawId; + int32_t m_currentCreateId; + bool m_needFlipFlop; + etk::VectorType<ewol::OObject*> m_listOObject[NB_BOUBLE_BUFFER]; //!< generic element to display... bool GenericDraw(void); + public: + void DoubleBufferFlipFlop(void); protected: void AddOObject(ewol::OObject* newObject, etk::String name = "", int32_t pos=-1); ewol::OObject* GetOObject(etk::String name); diff --git a/Sources/libewol/ewol/WidgetManager.cpp b/Sources/libewol/ewol/WidgetManager.cpp index 0ca804fa..a6c626a8 100644 --- a/Sources/libewol/ewol/WidgetManager.cpp +++ b/Sources/libewol/ewol/WidgetManager.cpp @@ -34,6 +34,9 @@ extern "C" { } widgetList_ts; }; +static pthread_mutex_t localMutex; + + // internal element of the widget manager : static etk::VectorType<widgetList_ts> m_widgetList; // all widget allocated ==> all time increment ... never removed ... // For the focus Management @@ -42,11 +45,15 @@ static ewol::Widget * m_focusWidgetCurrent = NULL; void ewol::widgetManager::Init(void) { - EWOL_INFO("user widget manager"); + EWOL_DEBUG("Init Widget manager"); + // create interface mutex : + int ret = pthread_mutex_init(&localMutex, NULL); + EWOL_ASSERT(ret == 0, "Error creating Mutex ..."); } void ewol::widgetManager::UnInit(void) { + EWOL_DEBUG("Un-Init Widget manager"); EWOL_INFO("Realease all FOCUS"); ewol::widgetManager::FocusSetDefault(NULL); ewol::widgetManager::FocusRelease(); @@ -61,6 +68,8 @@ void ewol::widgetManager::UnInit(void) } } m_widgetList.Clear(); + int ret = pthread_mutex_destroy(&localMutex); + EWOL_ASSERT(ret == 0, "Error destroying Mutex ..."); } void ewol::widgetManager::Add(ewol::Widget * newWidget) @@ -208,3 +217,25 @@ void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget) } + +void ewol::widgetManager::GetDoubleBufferFlipFlop(void) +{ + pthread_mutex_lock(&localMutex); + // flip/Flop all the widget registered : + for(int32_t iii=0; iii<m_widgetList.Size(); iii++) { + if (NULL != m_widgetList[iii].widgetPointer) { + m_widgetList[iii].widgetPointer->DoubleBufferFlipFlop(); + } + } + pthread_mutex_unlock(&localMutex); +} + +void ewol::widgetManager::GetDoubleBufferStartDraw(void) +{ + pthread_mutex_lock(&localMutex); +} + +void ewol::widgetManager::GetDoubleBufferStopDraw(void) +{ + pthread_mutex_unlock(&localMutex); +} diff --git a/Sources/libewol/ewol/WidgetManager.h b/Sources/libewol/ewol/WidgetManager.h index 2631d351..a45d9c42 100644 --- a/Sources/libewol/ewol/WidgetManager.h +++ b/Sources/libewol/ewol/WidgetManager.h @@ -45,6 +45,13 @@ namespace ewol { void FocusRelease( void); // Release focus from the current widget to the default ewol::Widget * FocusGet( void); void FocusRemoveIfRemove(ewol::Widget * newWidget); + + + int32_t GetDoubleBufferCreate(void); + int32_t GetDoubleBufferDraw(void); + void GetDoubleBufferFlipFlop(void); + void GetDoubleBufferStartDraw(void); + void GetDoubleBufferStopDraw(void); }; }; diff --git a/Sources/libewol/ewol/base/MainThread.cpp b/Sources/libewol/ewol/base/MainThread.cpp index 2f77789f..a867b5d9 100644 --- a/Sources/libewol/ewol/base/MainThread.cpp +++ b/Sources/libewol/ewol/base/MainThread.cpp @@ -28,6 +28,9 @@ #include <ewol/threadMsg.h> #include <ewol/base/MainThread.h> #include <ewol/base/gui.h> +#include <ewol/Texture.h> +#include <ewol/WidgetManager.h> +#include <ewol/themeManager.h> @@ -47,6 +50,9 @@ enum { JNI_APP_INIT, JNI_APP_UN_INIT, JNI_APP_RENDERER, + + THREAD_KEYBORAD_KEY, + THREAD_KEYBORAD_MOVE, }; @@ -70,6 +76,15 @@ typedef struct { float y; } eventInputState_ts; +typedef struct { + bool isDown; + uniChar_t myChar; +} eventKeyboardKey_ts; + +typedef struct { + bool isDown; + ewol::eventKbMoveType_te move; +} eventKeyboardMove_ts; extern int EWOL_appArgC; extern char *EWOL_appArgV[]; @@ -78,12 +93,19 @@ void EWOL_NativeEventInputMotion(int pointerID, float x, float y ); void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y ); void EWOL_NativeResize(int w, int h ); + + static void* BaseAppEntry(void* param) { bool requestEndProcessing = false; EWOL_DEBUG("BThread Init (START)"); - ewol::Init(EWOL_appArgC, EWOL_appArgV); + EWOL_INFO("v" EWOL_VERSION_TAG_NAME); + EWOL_INFO("Build Date: " VERSION_BUILD_TIME); + ewol::texture::Init(); + ewol::theme::Init(); + ewol::widgetManager::Init(); + ewol::InitFont(); APP_Init(EWOL_appArgC, EWOL_appArgV); EWOL_DEBUG("BThread Init (END)"); while(false == requestEndProcessing) { @@ -112,14 +134,14 @@ static void* BaseAppEntry(void* param) } break; case JNI_INPUT_MOTION: - EWOL_DEBUG("Receive MSG : JNI_INPUT_MOTION"); + //EWOL_DEBUG("Receive MSG : JNI_INPUT_MOTION"); { eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data; EWOL_NativeEventInputMotion(tmpData->pointerID, tmpData->x, tmpData->y); } break; case JNI_INPUT_STATE: - EWOL_DEBUG("Receive MSG : JNI_INPUT_STATE"); + //EWOL_DEBUG("Receive MSG : JNI_INPUT_STATE"); { eventInputState_ts * tmpData = (eventInputState_ts*)data.data; EWOL_NativeEventInputState(tmpData->pointerID, tmpData->state, tmpData->x, tmpData->y); @@ -137,10 +159,30 @@ static void* BaseAppEntry(void* param) case JNI_APP_RENDERER: EWOL_DEBUG("Receive MSG : JNI_APP_RENDERER"); break; + case THREAD_KEYBORAD_KEY: + EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY"); + { + eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data; + etk::String keyInput = "a"; + keyInput.c_str()[0] = tmpData->myChar; + guiAbstraction::SendKeyboardEvent(tmpData->isDown, keyInput); + } + break; + case THREAD_KEYBORAD_MOVE: + EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE"); + { + eventKeyboardMove_ts * tmpData = (eventKeyboardMove_ts*)data.data; + guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); + } + break; default: EWOL_DEBUG("Receive MSG : UNKNOW"); break; } + // TODO : when no message in the pipe : generate the display, and after, request the flip flop + if (0 == ewol::threadMsg::WaitingMessage(androidJniMsg)) { + ewol::widgetManager::GetDoubleBufferFlipFlop(); + } } EWOL_DEBUG("BThread Un-Init (START)"); @@ -148,8 +190,11 @@ static void* BaseAppEntry(void* param) ewol::DisplayWindows(NULL); // call application to uninit APP_UnInit(); - // uninit Ewol - ewol::UnInit(); + + ewol::texture::UnInit(); + ewol::UnInitFont(); + ewol::widgetManager::UnInit(); + ewol::theme::UnInit(); EWOL_DEBUG("BThread Un-Init (END)"); pthread_exit(NULL); } @@ -161,24 +206,15 @@ void EWOL_ThreadSetArchiveDir(int mode, const char* str) { case 0: EWOL_DEBUG("Directory APK : path=" << str); - //if (firstInitDone == false) - { - etk::SetBaseFolderData(str); - } + etk::SetBaseFolderData(str); break; case 1: EWOL_DEBUG("Directory mode=FILE path=" << str); - //if (firstInitDone == false) - { - etk::SetBaseFolderDataUser(str); - } + etk::SetBaseFolderDataUser(str); break; case 2: EWOL_DEBUG("Directory mode=CACHE path=" << str); - //if (firstInitDone == false) - { - etk::SetBaseFolderCache(str); - } + etk::SetBaseFolderCache(str); break; case 3: EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << str); @@ -247,3 +283,20 @@ void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y ) ewol::threadMsg::SendMessage(androidJniMsg, JNI_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) ); } +void EWOL_ThreadKeyboardEvent(bool isDown, etk::String &keyInput) +{ + eventKeyboardKey_ts tmpData; + tmpData.isDown = isDown; + tmpData.myChar = keyInput.c_str()[0]; + ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventKeyboardKey_ts) ); +} + +void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput) +{ + eventKeyboardMove_ts tmpData; + tmpData.isDown = isDown; + tmpData.move = keyInput; + ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventKeyboardMove_ts) ); +} + + diff --git a/Sources/libewol/ewol/base/MainThread.h b/Sources/libewol/ewol/base/MainThread.h index 8e5b8e43..1ba60bd7 100644 --- a/Sources/libewol/ewol/base/MainThread.h +++ b/Sources/libewol/ewol/base/MainThread.h @@ -37,6 +37,8 @@ void EWOL_ThreadSetArchiveDir(int mode, const char* str); void EWOL_ThreadResize(int w, int h ); void EWOL_ThreadEventInputMotion(int pointerID, float x, float y); void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y); +void EWOL_ThreadKeyboardEvent(bool isDown, etk::String &keyInput); +void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput); diff --git a/Sources/libewol/ewol/base/gui.cpp b/Sources/libewol/ewol/base/gui.cpp new file mode 100644 index 00000000..90d35660 --- /dev/null +++ b/Sources/libewol/ewol/base/gui.cpp @@ -0,0 +1,257 @@ +/** + ******************************************************************************* + * @file gui.cpp + * @brief Gui abstraction layer common part (Sources) + * @author Edouard DUPIN + * @date 01/02/2012 + * @par Project + * ewol + * + * @par Copyright + * Copyright 2011 Edouard DUPIN, all right reserved + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY. + * + * Licence summary : + * You can modify and redistribute the sources code and binaries. + * You can send me the bug-fix + * + * Term of the licence in in the file licence.txt. + * + ******************************************************************************* + */ + + + +#include <ewol/Debug.h> +#include <etk/String.h> +#include <ewol/WidgetManager.h> +#include <ewol/base/gui.h> + +#include <ewol/Texture.h> +#include <ewol/base/MainThread.h> + +ewol::Windows* gui_uniqueWindows = NULL; +etkFloat_t gui_width = 320; +etkFloat_t gui_height = 480; + +void EWOL_NativeResize(int w, int h ) +{ + gui_width = w; + gui_height = h; + //EWOL_INFO("Resize w=" << w << " h=" << h); + if (NULL != gui_uniqueWindows) { + gui_uniqueWindows->CalculateSize((etkFloat_t)gui_width, (etkFloat_t)gui_height); + gui_uniqueWindows->SetOrigin(0.0, 0.0); + } +} + + +void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newWindows) +{ + gui_uniqueWindows = newWindows; + if (NULL != gui_uniqueWindows) { + gui_uniqueWindows->CalculateSize((etkFloat_t)gui_width, (etkFloat_t)gui_height); + } +} + +void guiAbstraction::ForceRedrawAll(void) +{ + if (NULL != gui_uniqueWindows) { + gui_uniqueWindows->CalculateSize((etkFloat_t)gui_width, (etkFloat_t)gui_height); + } +} + + +void guiAbstraction::SendKeyboardEvent(bool isDown, etk::String &keyInput) +{ + // Get the current Focused Widget : + ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); + if (NULL != tmpWidget) { + if(true == isDown) { + EWOL_DEBUG("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size()); + tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str()); + } else { + EWOL_DEBUG("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size()); + tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str()); + } + } +} + +void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput) +{ + // Get the current Focused Widget : + ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); + if (NULL != tmpWidget) { + if(true == isDown) { + tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, keyInput); + } else { + tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, keyInput); + } + } +} + + + +void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode) +{ + if (NULL != gui_uniqueWindows) { + gui_uniqueWindows->KeyboardShow(mode); + } +} + +void guiAbstraction::KeyboardHide(void) +{ + if (NULL != gui_uniqueWindows) { + gui_uniqueWindows->KeyboardHide(); + } + ForceRedrawAll(); +} + + +// defined by the platform specific file : +extern int32_t separateClickTime; +extern int32_t offsetMoveClicked; +extern int32_t offsetMoveClickedDouble; + + +static int32_t m_previousBouttonId = -1; +static int32_t m_previousDown_x = -1; +static int32_t m_previousDown_y = -1; +static int32_t m_previous_x = -1; +static int32_t m_previous_y = -1; +static int64_t m_previousTime = 0; +static bool m_previousDouble = false; + +void EWOL_NativeEventInputMotion(int pointerID, float x, float y ) +{ + //EWOL_INFO("Event : Input Motion ID=" << pointerID << " x=" << x << " y=" << y); + if(0<=pointerID && pointerID < NB_MAX_INPUT ) { + if(NULL != gui_uniqueWindows) { + //EWOL_DEBUG("ANDROID event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); + gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)x, (etkFloat_t)y); + } + } +} + +void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y ) +{ + //EWOL_INFO("Event : Input ID=" << pointerID << " [" << isUp << "] x=" << x << " y=" << y); + if (isUp) { + //EWOL_INFO("Event : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y); + if(0<=pointerID && pointerID < NB_MAX_INPUT ) { + // Send Down message + if (NULL != gui_uniqueWindows) { + EWOL_DEBUG("ANDROID bt=" << pointerID+1 << " event : **=\"ButtonPress\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); + gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y); + } + // Check double or triple click event ... + m_previousDown_x = x; + m_previousDown_y = y; + if (m_previousBouttonId != pointerID+1) { + m_previousBouttonId = pointerID+1; + m_previous_x = -1; + m_previous_y = -1; + m_previousTime = 0; + m_previousDouble = false; + } else { + if( abs(m_previous_x - x) < offsetMoveClicked + && abs(m_previous_y - y) < offsetMoveClicked ) + { + // nothink to do ... wait up ... + } else { + m_previous_x = -1; + m_previous_y = -1; + m_previousTime = 0; + m_previousDouble = false; + } + } + } + } else { + //EWOL_INFO("Event : Input ID=" << pointerID << " [UP] x=" << x << " y=" << y); + if(0<=pointerID && pointerID < NB_MAX_INPUT ) { + // Send Down message + if (NULL != gui_uniqueWindows) { + EWOL_DEBUG("ANDROID bt=" << pointerID+1 << " event : **=\"ButtonRelease\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); + gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y); + } + if (m_previousBouttonId != pointerID+1) { + m_previousDown_x = -1; + m_previousDown_y = -1; + m_previousBouttonId = 0; + m_previous_x = -1; + m_previous_y = -1; + m_previousTime = 0; + m_previousDouble = false; + } else { + int64_t currentTime = GetCurrentTime(); // return the tic in 10ms + //EWOL_DEBUG("time is : " << (int)currentTime << " "<< (int)(currentTime/100) <<"s " << (int)((currentTime%100)*10) << "ms"); + if (currentTime - m_previousTime >= separateClickTime) { + //check if the same area click : + if( abs(m_previousDown_x - x) < offsetMoveClicked + && abs(m_previousDown_y - y) < offsetMoveClicked ) + { + // might generate an sigle event : + EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedSingle\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); + gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y); + m_previous_x = m_previousDown_x; + m_previous_y = m_previousDown_y; + m_previousTime = currentTime; + } else { + // reset values ... + m_previousDown_x = -1; + m_previousDown_y = -1; + m_previousBouttonId = 0; + m_previous_x = -1; + m_previous_y = -1; + m_previousTime = 0; + } + m_previousDouble = false; + } else { + // TODO : the double ckick does not work, I need to check this later ... if needed + //check if the same area click : + if( abs(m_previous_x - x) < offsetMoveClickedDouble + && abs(m_previous_y - y) < offsetMoveClickedDouble ) + { + // might generate an sigle event : + if (false == m_previousDouble) { + EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedDouble\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); + gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)x, (etkFloat_t)y); + m_previousTime = currentTime; + m_previousDouble = true; + } else { + EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedTriple\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); + gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)x, (etkFloat_t)y); + // reset values ... + m_previousDown_x = -1; + m_previousDown_y = -1; + m_previousBouttonId = 0; + m_previous_x = -1; + m_previous_y = -1; + m_previousTime = 0; + m_previousDouble = false; + } + } else { + // reset values ... + m_previousDown_x = -1; + m_previousDown_y = -1; + m_previousBouttonId = 0; + m_previous_x = -1; + m_previous_y = -1; + m_previousTime = 0; + m_previousDouble = false; + } + } + } + } + } +} + + +void EWOL_GenericDraw(void) +{ + ewol::widgetManager::GetDoubleBufferStartDraw(); + gui_uniqueWindows->SysDraw(); + ewol::widgetManager::GetDoubleBufferStopDraw(); +} \ No newline at end of file diff --git a/Sources/libewol/ewol/base/gui.h b/Sources/libewol/ewol/base/gui.h index e24c2de3..59f83aea 100644 --- a/Sources/libewol/ewol/base/gui.h +++ b/Sources/libewol/ewol/base/gui.h @@ -29,14 +29,13 @@ #include <etk/Types.h> #include <etk/String.h> #include <ewol/Windows.h> -#include <ewol/ewolInterne.h> + +void EWOL_NativeResize(int w, int h ); +void EWOL_GenericDraw(void); namespace guiAbstraction { - void Init(int32_t argc, char *argv[]); - void Run(void); void Stop(void); - void UnInit(void); void SetDisplayOnWindows(ewol::Windows * newOne); void ChangeSize(int32_t w, int32_t h); void ChangePos(int32_t x, int32_t y); @@ -56,6 +55,5 @@ void APP_Init(int argc, char *argv[]); void APP_UnInit(void); #define NB_MAX_INPUT (20) -#define SEPARATED_CLICK_TIME (30) #endif diff --git a/Sources/libewol/ewol/base/guiAndroid.cpp b/Sources/libewol/ewol/base/guiAndroid.cpp index 9a4a715a..7b10df60 100644 --- a/Sources/libewol/ewol/base/guiAndroid.cpp +++ b/Sources/libewol/ewol/base/guiAndroid.cpp @@ -43,11 +43,14 @@ #define __class__ "AndroidJNI" int EWOL_appArgC = 0; char **EWOL_appArgV = NULL; +int32_t separateClickTime = 20; +int32_t offsetMoveClicked = 40; +int32_t offsetMoveClickedDouble = 300; -static etkFloat_t m_width = 320; -static etkFloat_t m_height = 480; +extern etkFloat_t gui_width; +extern etkFloat_t gui_height; +extern ewol::Windows* gui_uniqueWindows; -ewol::Windows* m_uniqueWindows = NULL; int64_t GetCurrentTime(void) { struct timeval now; @@ -63,7 +66,7 @@ void Draw(void); #undef SEPARATED_CLICK_TIME #define SEPARATED_CLICK_TIME (300) -bool inputIsPressed[NB_MAX_INPUT];// = {false, false, false}; +//bool inputIsPressed[NB_MAX_INPUT];// = {false, false, false}; int32_t m_previousBouttonId = -1; int32_t m_previousDown_x = -1; int32_t m_previousDown_y = -1; @@ -74,175 +77,18 @@ bool m_previousDouble = false; -void EWOL_NativeResize(int w, int h ) -{ - m_width = w; - m_height = h; - EWOL_INFO("Resize w=" << w << " h=" << h); - if (NULL != m_uniqueWindows) { - m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height); - m_uniqueWindows->SetOrigin(0.0, 0.0); - } -} - -void EWOL_NativeEventInputMotion(int pointerID, float x, float y ) -{ - //EWOL_INFO("Event : Input Motion ID=" << pointerID << " x=" << x << " y=" << y); - if(0<=pointerID && pointerID < NB_MAX_INPUT ) { - if (true == inputIsPressed[pointerID]) { - if(NULL != m_uniqueWindows) { - //EWOL_DEBUG("ANDROID event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); - m_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)x, (etkFloat_t)y); - } - } - } -} - -void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y ) -{ - //EWOL_INFO("Event : Input ID=" << pointerID << " [" << isUp << "] x=" << x << " y=" << y); - if (isUp) { - //EWOL_INFO("Event : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y); - if(0<=pointerID && pointerID < NB_MAX_INPUT ) { - // Send Down message - if (NULL != m_uniqueWindows) { - EWOL_DEBUG("ANDROID bt=" << pointerID+1 << " event : **=\"ButtonPress\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); - m_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y); - } - // Check double or triple click event ... - m_previousDown_x = x; - m_previousDown_y = y; - if (m_previousBouttonId != pointerID+1) { - m_previousBouttonId = pointerID+1; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } else { - if( abs(m_previous_x - x) < OFFSET_MOVE_CLICKED - && abs(m_previous_y - y) < OFFSET_MOVE_CLICKED ) - { - // nothink to do ... wait up ... - } else { - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } - } - } - } else { - //EWOL_INFO("Event : Input ID=" << pointerID << " [UP] x=" << x << " y=" << y); - if(0<=pointerID && pointerID < NB_MAX_INPUT ) { - // Send Down message - if (NULL != m_uniqueWindows) { - EWOL_DEBUG("ANDROID bt=" << pointerID+1 << " event : **=\"ButtonRelease\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); - m_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y); - } - if (m_previousBouttonId != pointerID+1) { - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } else { - int64_t currentTime = GetCurrentTime(); // return the tic in 10ms - //EWOL_DEBUG("time is : " << (int)currentTime << " "<< (int)(currentTime/100) <<"s " << (int)((currentTime%100)*10) << "ms"); - if (currentTime - m_previousTime >= SEPARATED_CLICK_TIME) { - //check if the same area click : - if( abs(m_previousDown_x - x) < OFFSET_MOVE_CLICKED - && abs(m_previousDown_y - y) < OFFSET_MOVE_CLICKED ) - { - // might generate an sigle event : - EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedSingle\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); - m_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y); - m_previous_x = m_previousDown_x; - m_previous_y = m_previousDown_y; - m_previousTime = currentTime; - } else { - // reset values ... - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - } - m_previousDouble = false; - } else { - // TODO : the double ckick does not work, I need to check this later ... if needed - //check if the same area click : - if( abs(m_previous_x - x) < OFFSET_MOVE_CLICKED_DOUBLE - && abs(m_previous_y - y) < OFFSET_MOVE_CLICKED_DOUBLE ) - { - // might generate an sigle event : - if (false == m_previousDouble) { - EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedDouble\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); - m_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)x, (etkFloat_t)y); - m_previousTime = currentTime; - m_previousDouble = true; - } else { - EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedTriple\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); - m_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)x, (etkFloat_t)y); - // reset values ... - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } - } else { - // reset values ... - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } - } - } - } - } -} - - -/* Call to render the next GL frame */ -void EWOL_NativeRender(void) -{ - Draw(); -} - - - - - -static void Setwindow(ewol::Windows* newWindows) -{ - m_uniqueWindows = newWindows; - if (NULL != m_uniqueWindows) { - m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height); - } -} - - static etkFloat_t gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f }; static etkFloat_t gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f }; -void Draw(void) +void EWOL_NativeRender(void) { ewol::UpdateTextureContext(); - //EWOL_DEBUG("redraw (" << m_width << "," << m_height << ")"); - if(NULL == m_uniqueWindows) { + //EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")"); + if(NULL == gui_uniqueWindows) { // set the size of the open GL system - glViewport(0,0,m_width,m_height); + glViewport(0,0,gui_width,gui_height); // Clear the screen with transparency ... glClearColor(0.0,0.0,0.0, 1.0); @@ -251,12 +97,12 @@ void Draw(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); //glOrtho(0., width, 0., -height, 1., 20.); - glOrtho(-m_width/2, m_width/2, m_height/2, -m_height/2, -1, 1); + glOrtho(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //glTranslatef(0, -height/2, -5); - glTranslatef(-m_width/2, -m_height/2, -1.0); + glTranslatef(-gui_width/2, -gui_height/2, -1.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -334,7 +180,7 @@ void Draw(void) glDisable(GL_BLEND); } else { - m_uniqueWindows->SysDraw(); + EWOL_GenericDraw(); } glFlush(); } @@ -345,46 +191,20 @@ void Draw(void) #undef __class__ #define __class__ "guiAbstraction" -void guiAbstraction::Run(void) -{ -} - void guiAbstraction::Stop(void) { + // TODo : send a message to the android system to stop ... } -void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newOne) -{ - Setwindow(newOne); -} - -void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode) -{ - if (NULL != m_uniqueWindows) { - m_uniqueWindows->KeyboardShow(mode); - } -} - -void guiAbstraction::KeyboardHide(void) -{ - if (NULL != m_uniqueWindows) { - m_uniqueWindows->KeyboardHide(); - } -} - -void guiAbstraction::ForceRedrawAll(void) -{ - if (NULL != m_uniqueWindows) { - m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height); - } -} void guiAbstraction::ChangeSize(int32_t w, int32_t h) { + // nothing to do with Android } void guiAbstraction::ChangePos(int32_t x, int32_t y) { + // nothing to do with Android } void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y) @@ -402,21 +222,6 @@ bool guiAbstraction::IsPressedInput(int32_t inputID) } -void guiAbstraction::SendKeyboardEvent(bool isDown, etk::String &keyInput) -{ - // Get the current Focused Widget : - ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); - if (NULL != tmpWidget) { - if(true == isDown) { - EWOL_DEBUG("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size()); - tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str()); - } else { - EWOL_DEBUG("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size()); - tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str()); - } - } -} - void glOrtho(GLfloat left, GLfloat right, diff --git a/Sources/libewol/ewol/base/guiX11.cpp b/Sources/libewol/ewol/base/guiX11.cpp index 4b0e2f1e..b3497b37 100644 --- a/Sources/libewol/ewol/base/guiX11.cpp +++ b/Sources/libewol/ewol/base/guiX11.cpp @@ -40,14 +40,7 @@ #include <GL/glut.h> #include <GL/glx.h> #include <X11/Xatom.h> -#if defined(EWOL_X11_MODE__XF86V) -# include <X11/extensions/xf86vmode.h> -#elif defined(EWOL_X11_MODE__XRENDER) -# include <X11/extensions/Xrender.h> -#else -# error you might define an EWOL_X11_MODE in EWOL_X11_XF86V / EWOL_X11_XRENDER -#endif - +#include <X11/extensions/xf86vmode.h> #include <sys/times.h> @@ -59,7 +52,6 @@ int64_t GetCurrentTime(void) #undef __class__ #define __class__ "guiAbstraction" -#if defined(EWOL_X11_MODE__XF86V) // attributes for a single buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer static int attrListSgl[] = { GLX_RGBA, @@ -80,20 +72,6 @@ static int attrListDbl[] = { GLX_DEPTH_SIZE, 16, None }; -#elif defined(EWOL_X11_MODE__XRENDER) -static int VisualData[] = { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_DOUBLEBUFFER, True, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, - GLX_DEPTH_SIZE, 1, - None -}; -#endif - extern bool guiKeyBoardMode_CapLock; extern bool guiKeyBoardMode_Shift; @@ -128,12 +106,6 @@ bool m_previousDouble; Atom m_delAtom; Display * m_display; Window WindowHandle; -#if defined(EWOL_X11_MODE__XRENDER) -GLXFBConfig m_fbConfig; -Window m_GLXWindowHandle; -#endif -int32_t m_width; -int32_t m_height; int32_t m_originX; int32_t m_originY; int32_t m_cursorEventX; @@ -141,19 +113,21 @@ int32_t m_cursorEventY; XVisualInfo * m_visual; bool m_doubleBuffered; bool m_run; -ewol::Windows* m_uniqueWindows; +extern ewol::Windows* gui_uniqueWindows; +extern etkFloat_t gui_width; +extern etkFloat_t gui_height; + +int32_t separateClickTime = 30; +int32_t offsetMoveClicked = 10; +int32_t offsetMoveClickedDouble = 20; + bool inputIsPressed[20]; -static void X11_Stop(void); static void X11_ChangeSize(int32_t w, int32_t h); static void X11_ChangePos(int32_t x, int32_t y); static void X11_GetAbsPos(int32_t & x, int32_t & y); -static void X11_KeyboardShow(ewol::keyboardMode_te mode); -static void X11_KeyboardHide(void); -static void X11_ForceRedrawAll(void); -static bool X11_IsPressedInput(int32_t inputID); bool CreateX11Context(void) { @@ -164,11 +138,7 @@ bool CreateX11Context(void) XSetWindowAttributes attr; static char *title = (char*)"APPLICATION Title ... (todo)"; - #if defined(EWOL_X11_MODE__XF86V) - EWOL_INFO("X11 Mode XF86 Video"); - #elif defined(EWOL_X11_MODE__XRENDER) - EWOL_INFO("X11 Mode XRendrer Video"); - #endif + EWOL_INFO("X11 Mode XF86 Video"); // Connect to the X server m_display = XOpenDisplay(NULL); @@ -179,43 +149,21 @@ bool CreateX11Context(void) EWOL_INFO("Display opened."); } int Xscreen = DefaultScreen(m_display); - #if defined(EWOL_X11_MODE__XF86V) - { - int32_t vmMajor, vmMinor; - XF86VidModeQueryVersion(m_display, &vmMajor, &vmMinor); - EWOL_INFO("XF86 VideoMode extension version " << vmMajor << "." << vmMinor); - } - // get an appropriate visual - m_visual = glXChooseVisual(m_display, Xscreen, attrListDbl); - if (NULL == m_visual) { - m_visual = glXChooseVisual(m_display, Xscreen, attrListSgl); - m_doubleBuffered = false; - EWOL_INFO("XF86 singlebuffered rendering will be used, no doublebuffering available"); - } else { - m_doubleBuffered = true; - EWOL_INFO("XF86 doublebuffered rendering available"); - } - #elif defined(EWOL_X11_MODE__XRENDER) - int numfbconfigs; + { + int32_t vmMajor, vmMinor; + XF86VidModeQueryVersion(m_display, &vmMajor, &vmMinor); + EWOL_INFO("XF86 VideoMode extension version " << vmMajor << "." << vmMinor); + } + // get an appropriate visual + m_visual = glXChooseVisual(m_display, Xscreen, attrListDbl); + if (NULL == m_visual) { + m_visual = glXChooseVisual(m_display, Xscreen, attrListSgl); + m_doubleBuffered = false; + EWOL_INFO("XF86 singlebuffered rendering will be used, no doublebuffering available"); + } else { m_doubleBuffered = true; - GLXFBConfig *fbconfigs = glXChooseFBConfig(m_display, Xscreen, VisualData, &numfbconfigs); - EWOL_DEBUG("get glx format config =" << numfbconfigs); - for(int i = 0; i<numfbconfigs; i++) { - m_visual = glXGetVisualFromFBConfig(m_display, fbconfigs[i]); - if(!m_visual) { - continue; - } - XRenderPictFormat * pictFormat = XRenderFindVisualFormat(m_display, m_visual->visual); - if(!pictFormat) { - continue; - } - if(pictFormat->direct.alphaMask > 0) { - m_fbConfig = fbconfigs[i]; - EWOL_DEBUG("SELECT fbconfig id=" << i); - break; - } - } - #endif + EWOL_INFO("XF86 doublebuffered rendering available"); + } { int32_t glxMajor, glxMinor; glXQueryVersion(m_display, &glxMajor, &glxMinor); @@ -246,15 +194,16 @@ bool CreateX11Context(void) // select internal attribute attr_mask = CWBackPixmap | CWColormap | CWBorderPixel | CWEventMask; // Create the window - m_width = DisplayWidth(m_display, DefaultScreen(m_display))/2; - m_height = DisplayHeight(m_display, DefaultScreen(m_display))/2; - x=m_width/2; - y=m_height/4; + int32_t tmp_width = DisplayWidth(m_display, DefaultScreen(m_display))/2; + int32_t tmp_height = DisplayHeight(m_display, DefaultScreen(m_display))/2; + EWOL_NativeResize(tmp_width, tmp_height); + x=tmp_width/2; + y=tmp_height/4; // Real create of the window WindowHandle = XCreateWindow(m_display, Xroot, - x, y, m_width, m_height, + x, y, tmp_width, tmp_height, 1, m_visual->depth, InputOutput, @@ -274,8 +223,8 @@ bool CreateX11Context(void) hints.x = x; hints.y = y; - hints.width = m_width; - hints.height = m_height; + hints.width = tmp_width; + hints.height = tmp_height; hints.flags = USPosition|USSize; StartupState = XAllocWMHints(); @@ -336,49 +285,27 @@ void AddDecoration(void) bool CreateOGlContext(void) { - #if defined(EWOL_X11_MODE__XRENDER) - /* See if we can do OpenGL on this visual */ - int dummy; - if (!glXQueryExtension(m_display, &dummy, &dummy)) { - EWOL_CRITICAL("OpenGL not supported by X server"); - exit(-1); - } - - /* Create the OpenGL rendering context */ - GLXContext RenderContext = glXCreateNewContext(m_display, m_fbConfig, GLX_RGBA_TYPE, 0, GL_TRUE); - if (!RenderContext) { - EWOL_CRITICAL("Failed to create a GL context"); - exit(-1); - } - m_GLXWindowHandle = glXCreateWindow(m_display, m_fbConfig, WindowHandle, NULL); - /* Make it current */ - if (!glXMakeContextCurrent(m_display, m_GLXWindowHandle, m_GLXWindowHandle, RenderContext)) { - EWOL_CRITICAL("glXMakeCurrent failed for window"); - exit(-1); - } - #elif defined(EWOL_X11_MODE__XF86V) - /* create a GLX context */ - GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE); - /* connect the glx-context to the window */ - glXMakeCurrent(m_display, WindowHandle, RenderContext); - if (glXIsDirect(m_display, RenderContext)) { - EWOL_INFO("XF86 DRI enabled\n"); - } else { - EWOL_INFO("XF86 DRI NOT available\n"); - } - #endif + /* create a GLX context */ + GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE); + /* connect the glx-context to the window */ + glXMakeCurrent(m_display, WindowHandle, RenderContext); + if (glXIsDirect(m_display, RenderContext)) { + EWOL_INFO("XF86 DRI enabled\n"); + } else { + EWOL_INFO("XF86 DRI NOT available\n"); + } return true; } -void Draw(void) +void EWOL_NativeRender(void) { ewol::UpdateTextureContext(); - //EWOL_DEBUG("redraw (" << m_width << "," << m_height << ")"); - if(NULL == m_uniqueWindows) { + //EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")"); + if(NULL == gui_uniqueWindows) { //EWOL_DEBUG("Has No Windows set..."); // set the size of the open GL system - glViewport(0,0,m_width,m_height); + glViewport(0,0,gui_width,gui_height); // Clear the screen with transparency ... glClearColor(0.750, 0.750, 0.750, 0.5); @@ -386,30 +313,26 @@ void Draw(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0., (etkFloat_t)m_width, 0., (etkFloat_t)m_height, 1., 20.); + glOrtho(0., (etkFloat_t)gui_width, 0., (etkFloat_t)gui_height, 1., 20.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -5); glBegin(GL_QUADS); - glColor3f(1., 0., 0.); glVertex3f( .25*(etkFloat_t)m_width, .25*(etkFloat_t)m_height, 0.); - glColor3f(0., 1., 0.); glVertex3f( .75*(etkFloat_t)m_width, .25*(etkFloat_t)m_height, 0.); - glColor3f(0., 0., 1.); glVertex3f( .75*(etkFloat_t)m_width, .75*(etkFloat_t)m_height, 0.); - glColor3f(1., 1., 0.); glVertex3f( .25*(etkFloat_t)m_width, .75*(etkFloat_t)m_height, 0.); + glColor3f(1., 0., 0.); glVertex3f( .25*(etkFloat_t)gui_width, .25*(etkFloat_t)gui_height, 0.); + glColor3f(0., 1., 0.); glVertex3f( .75*(etkFloat_t)gui_width, .25*(etkFloat_t)gui_height, 0.); + glColor3f(0., 0., 1.); glVertex3f( .75*(etkFloat_t)gui_width, .75*(etkFloat_t)gui_height, 0.); + glColor3f(1., 1., 0.); glVertex3f( .25*(etkFloat_t)gui_width, .75*(etkFloat_t)gui_height, 0.); glEnd(); } else { - m_uniqueWindows->SysDraw(); + EWOL_GenericDraw(); } // swap the buffers if we have doublebuffered - #if defined(EWOL_X11_MODE__XRENDER) - glXSwapBuffers(m_display, m_GLXWindowHandle); - #elif defined(EWOL_X11_MODE__XF86V) - glFlush(); - if (m_doubleBuffered) { - glXSwapBuffers(m_display, WindowHandle); - } - #endif + glFlush(); + if (m_doubleBuffered) { + glXSwapBuffers(m_display, WindowHandle); + } } void X11_Init(void) @@ -435,14 +358,6 @@ void X11_Init(void) } -void X11_Setwindow(ewol::Windows* newWindows) -{ - m_uniqueWindows = newWindows; - if (NULL != m_uniqueWindows) { - m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height); - } -} - void X11_Run(void) { // main cycle @@ -458,16 +373,15 @@ void X11_Run(void) { Atom atom = XInternAtom(m_display, "WM_DELETE_WINDOW", false); if((int64_t)atom == (int64_t)event.xclient.data.l[0]) { - if (NULL != m_uniqueWindows) { - m_uniqueWindows->SysOnKill(); + if (NULL != gui_uniqueWindows) { + gui_uniqueWindows->SysOnKill(); } - X11_Stop(); + m_run = false; } } break; case ConfigureNotify: - m_width = event.xconfigure.width; - m_height = event.xconfigure.height; + EWOL_NativeResize(event.xconfigure.width, event.xconfigure.height); m_originX = event.xconfigure.x; m_originY = event.xconfigure.y; break; @@ -496,130 +410,29 @@ void X11_Run(void) break; } // parse event - if(NULL == m_uniqueWindows) { + if(NULL == gui_uniqueWindows) { EWOL_DEBUG("Has No Windows set..."); } else { switch (event.type) { case ConfigureNotify: - EWOL_VERBOSE("X11 event : " << event.type << " = \"ConfigureNotify\" Origin(" << event.xconfigure.x << "," << event.xconfigure.y << ") Size(" << event.xconfigure.width << "," << event.xconfigure.height << ")"); - m_uniqueWindows->CalculateSize((etkFloat_t)event.xconfigure.width, (etkFloat_t)event.xconfigure.height); - m_uniqueWindows->SetOrigin(event.xconfigure.x, event.xconfigure.y); + //EWOL_VERBOSE("X11 event : " << event.type << " = \"ConfigureNotify\" Origin(" << event.xconfigure.x << "," << event.xconfigure.y << ") Size(" << event.xconfigure.width << "," << event.xconfigure.height << ")"); + //gui_uniqueWindows->CalculateSize((etkFloat_t)event.xconfigure.width, (etkFloat_t)event.xconfigure.height); + //gui_uniqueWindows->SetOrigin(event.xconfigure.x, event.xconfigure.y); break; case Expose: EWOL_VERBOSE("X11 event : " << event.type << " = \"Expose\""); - m_uniqueWindows->SysOnExpose(); + gui_uniqueWindows->SysOnExpose(); break; case ButtonPress: - { - int32_t btId = event.xbutton.button; - EWOL_VERBOSE("X11 bt=" << btId << " event : " << event.type << "=\"ButtonPress\" (" << (etkFloat_t)event.xbutton.x << "," << (etkFloat_t)event.xbutton.y << ")"); - // Send Down message - m_uniqueWindows->GenEventInput(btId, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)event.xbutton.x, (etkFloat_t)event.xbutton.y); - // Check double or triple click event ... - m_previousDown_x = event.xbutton.x; - m_previousDown_y = event.xbutton.y; - if (m_previousBouttonId != btId) { - m_previousBouttonId = btId; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } else { - if( abs(m_previous_x - event.xbutton.x) < 5 - && abs(m_previous_y - event.xbutton.y) < 5 ) - { - // nothink to do ... wait up ... - } else { - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } - } - } + EWOL_ThreadEventInputState(event.xbutton.button-1, true, (float)event.xbutton.x, (float)event.xbutton.y); break; case ButtonRelease: - { - int32_t btId = event.xbutton.button; - EWOL_VERBOSE("X11 bt=" << btId << " event : " << event.type << "=\"ButtonRelease\" (" << (etkFloat_t)event.xbutton.x << "," << (etkFloat_t)event.xbutton.y << ")"); - // send Up event ... - m_uniqueWindows->GenEventInput(btId, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)event.xbutton.x, (etkFloat_t)event.xbutton.y); - - if (m_previousBouttonId != btId) { - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } else { - int64_t currentTime = GetCurrentTime(); // return the tic in 10ms - //EWOL_DEBUG("time is : " << currentTime << " "<< currentTime/100 <<"s " << (currentTime%100)*10 << "ms"); - if (currentTime - m_previousTime >= SEPARATED_CLICK_TIME) { - //check if the same area click : - if( abs(m_previousDown_x - event.xbutton.x) < 5 - && abs(m_previousDown_y - event.xbutton.y) < 5 ) - { - // might generate an sigle event : - //EWOL_DEBUG("X11 event : " << event.type << " = \"ButtonClickedSingle\" (" << (etkFloat_t)event.xbutton.x << "," << (etkFloat_t)event.xbutton.y << ")"); - m_uniqueWindows->GenEventInput(btId, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)event.xbutton.x, (etkFloat_t)event.xbutton.y); - m_previous_x = m_previousDown_x; - m_previous_y = m_previousDown_y; - m_previousTime = currentTime; - } else { - // reset values ... - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - } - m_previousDouble = false; - } else { - //check if the same area click : - if( abs(m_previous_x - event.xbutton.x) < 5 - && abs(m_previous_y - event.xbutton.y) < 5 ) - { - // might generate an sigle event : - if (false == m_previousDouble) { - //EWOL_DEBUG("X11 event : " << event.type << " = \"ButtonClickedDouble\" (" << (etkFloat_t)event.xbutton.x << "," << (etkFloat_t)event.xbutton.y << ")"); - m_uniqueWindows->GenEventInput(btId, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)event.xbutton.x, (etkFloat_t)event.xbutton.y); - m_previousTime = currentTime; - m_previousDouble = true; - } else { - //EWOL_DEBUG("X11 event : " << event.type << " = \"ButtonClickedTriple\" (" << (etkFloat_t)event.xbutton.x << "," << (etkFloat_t)event.xbutton.y << ")"); - m_uniqueWindows->GenEventInput(btId, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)event.xbutton.x, (etkFloat_t)event.xbutton.y); - // reset values ... - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } - } else { - // reset values ... - m_previousDown_x = -1; - m_previousDown_y = -1; - m_previousBouttonId = 0; - m_previous_x = -1; - m_previous_y = -1; - m_previousTime = 0; - m_previousDouble = false; - } - } - - //int64_t currentTime = - } - } + EWOL_ThreadEventInputState(event.xbutton.button-1, false, (float)event.xbutton.x, (float)event.xbutton.y); break; case EnterNotify: //EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")"); - m_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y); + //gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y); break; case MotionNotify: { @@ -628,27 +441,29 @@ void X11_Run(void) for (int32_t iii=0; iii<NB_MAX_INPUT ; iii++) { if (true == inputIsPressed[iii]) { EWOL_VERBOSE("X11 event: bt=" << iii+1 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")"); - m_uniqueWindows->GenEventInput(iii+1, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)event.xmotion.x, (etkFloat_t)event.xmotion.y); + //gui_uniqueWindows->GenEventInput(iii+1, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)event.xmotion.x, (etkFloat_t)event.xmotion.y); + EWOL_ThreadEventInputMotion(iii+1, (float)event.xmotion.x, (float)event.xmotion.y); findOne = true; } } if (false == findOne) { EWOL_VERBOSE("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")"); - m_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)event.xmotion.x, (etkFloat_t)event.xmotion.y); + //gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)event.xmotion.x, (etkFloat_t)event.xmotion.y); + EWOL_ThreadEventInputMotion(0, (float)event.xmotion.x, (float)event.xmotion.y); } } break; case LeaveNotify: //EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")"); - m_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_LEAVE, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y); + //gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_LEAVE, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y); break; case FocusIn: EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusIn\""); - m_uniqueWindows->SetFocus(); + //gui_uniqueWindows->SetFocus(); break; case FocusOut: EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusOut\""); - m_uniqueWindows->RmFocus(); + //gui_uniqueWindows->RmFocus(); break; case KeyPress: case KeyRelease: @@ -764,9 +579,9 @@ void X11_Run(void) buf[1] = 0x00; etk::String tmpData = buf; if(event.type == KeyPress) { - guiAbstraction::SendKeyboardEvent(true, tmpData); + EWOL_ThreadKeyboardEvent(true, tmpData); } else { - guiAbstraction::SendKeyboardEvent(false, tmpData); + EWOL_ThreadKeyboardEvent(false, tmpData); } } default: @@ -785,9 +600,9 @@ void X11_Run(void) if (count>0) { etk::String tmpData = buf; if(event.type == KeyPress) { - guiAbstraction::SendKeyboardEvent(true, tmpData); + EWOL_ThreadKeyboardEvent(true, tmpData); } else { - guiAbstraction::SendKeyboardEvent(false, tmpData); + EWOL_ThreadKeyboardEvent(false, tmpData); } } else { EWOL_WARNING("Unknow event Key : " << event.xkey.keycode); @@ -798,9 +613,9 @@ void X11_Run(void) if (true == find) { EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) ); if(event.type == KeyPress) { - guiAbstraction::SendKeyboardEventMove(true, keyInput); + EWOL_ThreadKeyboardEventMove(true, keyInput); } else { - guiAbstraction::SendKeyboardEventMove(false, keyInput); + EWOL_ThreadKeyboardEventMove(false, keyInput); } } break; @@ -809,27 +624,22 @@ void X11_Run(void) // break; case MapNotify: EWOL_VERBOSE("X11 event : " << event.type << " = \"MapNotify\""); - m_uniqueWindows->SysOnShow(); + gui_uniqueWindows->SysOnShow(); break; case UnmapNotify: EWOL_VERBOSE("X11 event : " << event.type << " = \"UnmapNotify\""); - m_uniqueWindows->SysOnHide(); + gui_uniqueWindows->SysOnHide(); break; default: EWOL_DEBUG("X11 event : " << event.type << " = \"???\""); } } } - Draw(); + EWOL_NativeRender(); //usleep( 100000 ); } }; -void X11_Stop(void) -{ - m_run = false; -}; - void X11_ChangeSize(int32_t w, int32_t h) { XResizeWindow(m_display, WindowHandle, w, h); @@ -848,27 +658,38 @@ void X11_GetAbsPos(int32_t & x, int32_t & y) XQueryPointer(m_display, WindowHandle, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2); }; -void X11_KeyboardShow(ewol::keyboardMode_te mode) + + + + +#undef __class__ +#define __class__ "guiAbstraction" + + +void guiAbstraction::Stop(void) { - if (NULL != m_uniqueWindows) { - m_uniqueWindows->KeyboardShow(mode); - } -} -void X11_KeyboardHide(void) -{ - if (NULL != m_uniqueWindows) { - m_uniqueWindows->KeyboardHide(); - } - X11_ForceRedrawAll(); + m_run = false; } -void X11_ForceRedrawAll(void) + + + +void guiAbstraction::ChangeSize(int32_t w, int32_t h) { - if (NULL != m_uniqueWindows) { - m_uniqueWindows->CalculateSize((etkFloat_t)m_width, (etkFloat_t)m_height); - } -}; -bool X11_IsPressedInput(int32_t inputID) + X11_ChangeSize(w, h); +} + +void guiAbstraction::ChangePos(int32_t x, int32_t y) +{ + X11_ChangePos(x, y); +} + +void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y) +{ + X11_GetAbsPos(x, y); +} + +bool guiAbstraction::IsPressedInput(int32_t inputID) { if( NB_MAX_INPUT > inputID && 0 <= inputID) @@ -880,148 +701,6 @@ bool X11_IsPressedInput(int32_t inputID) } } - - - -#undef __class__ -#define __class__ "guiAbstraction" - -static bool guiAbstractionIsInit = false; - -void guiAbstraction::Init(int32_t argc, char *argv[]) -{ - if (false == guiAbstractionIsInit) { - // set the gui is init : - guiAbstractionIsInit = true; - EWOL_INFO("INIT for X11 environement"); - X11_Init(); - } else { - EWOL_CRITICAL("Can not INIT X11 ==> already init before"); - } -} - -void guiAbstraction::Stop(void) -{ - if (true == guiAbstractionIsInit) { - X11_Stop(); - } else { - EWOL_CRITICAL("Can not Stop X11 ==> not init ... "); - } -} - -void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newOne) -{ - if (true == guiAbstractionIsInit) { - X11_Setwindow(newOne); - } else { - EWOL_CRITICAL("Can not set Windows X11 ==> not init ... "); - } -} - -void guiAbstraction::UnInit(void) -{ - if (true == guiAbstractionIsInit) { - EWOL_INFO("UN-INIT for X11 environement"); - guiAbstractionIsInit = false; - } else { - EWOL_CRITICAL("Can not Un-Init X11 ==> not init ... "); - } -} - - -void guiAbstraction::ChangeSize(int32_t w, int32_t h) -{ - if (true == guiAbstractionIsInit) { - X11_ChangeSize(w, h); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - } -} - -void guiAbstraction::ChangePos(int32_t x, int32_t y) -{ - if (true == guiAbstractionIsInit) { - X11_ChangePos(x, y); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - } -} - -void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y) -{ - if (true == guiAbstractionIsInit) { - X11_GetAbsPos(x, y); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - } -} - -bool guiAbstraction::IsPressedInput(int32_t inputID) -{ - if (true == guiAbstractionIsInit) { - return X11_IsPressedInput(inputID); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - return false; - } -} - -void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode) -{ - if (true == guiAbstractionIsInit) { - X11_KeyboardShow(mode); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - } -} - -void guiAbstraction::KeyboardHide(void) -{ - if (true == guiAbstractionIsInit) { - X11_KeyboardHide(); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - } -} - -void guiAbstraction::ForceRedrawAll(void) -{ - if (true == guiAbstractionIsInit) { - X11_ForceRedrawAll(); - } else { - EWOL_CRITICAL("X11 ==> not init ... "); - } -} - -void guiAbstraction::SendKeyboardEvent(bool isDown, etk::String &keyInput) -{ - // Get the current Focused Widget : - ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); - if (NULL != tmpWidget) { - if(true == isDown) { - EWOL_DEBUG("X11 PRESSED : \"" << keyInput << "\" size=" << keyInput.Size()); - tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput.c_str()); - } else { - EWOL_DEBUG("X11 Release : \"" << keyInput << "\" size=" << keyInput.Size()); - tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput.c_str()); - } - } -} - - -void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput) -{ - // Get the current Focused Widget : - ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); - if (NULL != tmpWidget) { - if(true == isDown) { - tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, keyInput); - } else { - tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, keyInput); - } - } -} - #include <ewol/ewol.h> @@ -1034,20 +713,16 @@ int main(int argc, char *argv[]) //EWOL_appArgC = argc; //EWOL_appArgV = argv; // start X11 thread ... - guiAbstraction::Init(argc, argv); - + X11_Init(); //start the basic thread : EWOL_SystemStart(); // Run ... X11_Run(); // close X11 : - X11_Stop(); + guiAbstraction::Stop(); // uninit ALL : EWOL_SystemStop(); - // basic abstraction un-init - guiAbstraction::UnInit(); - return 0; } diff --git a/Sources/libewol/ewol/ewolInterne.cpp b/Sources/libewol/ewol/ewolInterne.cpp deleted file mode 100644 index 87af5e33..00000000 --- a/Sources/libewol/ewol/ewolInterne.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** - ******************************************************************************* - * @file ewol/ewolInterne.cpp - * @brief Main code of ewol interne interaction (sources) - * @author Edouard DUPIN - * @date 07/01/2012 - * @par Project - * ewol - * - * @par Copyright - * Copyright 2011 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - - -#include <ewol/ewolInterne.h> -#include <ewol/Font.h> -#include <ewol/WidgetManager.h> -#include <ewol/themeManager.h> - -#include <ewol/base/gui.h> - -#undef __class__ -#define __class__ "ewol" - -void ewol::Init(int argc, char *argv[]) -{ - EWOL_INFO("v" EWOL_VERSION_TAG_NAME); - EWOL_INFO("Build Date: " VERSION_BUILD_TIME); - ewol::theme::Init(); - ewol::widgetManager::Init(); - ewol::InitFont(); -} - -void ewol::UnInit(void) -{ - ewol::UnInitFont(); - ewol::widgetManager::UnInit(); - ewol::theme::UnInit(); -} - diff --git a/Sources/libewol/ewol/ewolInterne.h b/Sources/libewol/ewol/ewolInterne.h deleted file mode 100644 index a0d8d575..00000000 --- a/Sources/libewol/ewol/ewolInterne.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - ******************************************************************************* - * @file ewol/ewolInterne.h - * @brief Main include of ewol internal interation(header) - * @author Edouard DUPIN - * @date 07/01/2012 - * @par Project - * ewol - * - * @par Copyright - * Copyright 2011 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - - -#ifndef __EWOL_INTERNE_H__ -#define __EWOL_INTERNE_H__ - -#include <etk/Types.h> -#include <etk/String.h> -#include <ewol/Widget.h> -#include <ewol/Windows.h> - - - -namespace ewol { - void Init(int32_t argc, char *argv[]); - void UnInit(void); -}; - - - -#endif \ No newline at end of file diff --git a/Sources/libewol/ewol/threadMsg.cpp b/Sources/libewol/ewol/threadMsg.cpp index 410b2f02..de60cdee 100644 --- a/Sources/libewol/ewol/threadMsg.cpp +++ b/Sources/libewol/ewol/threadMsg.cpp @@ -152,3 +152,16 @@ bool ewol::threadMsg::SendMessage(ewol::threadMsg::threadMsg_ts& messageData, ui return returnValue; } +int32_t ewol::threadMsg::WaitingMessage(threadMsg_ts& messageData) +{ + if (false == messageData.isInit) { + return false; + } + pthread_mutex_lock(&messageData.mutex); + int32_t nbMessage = 0; + for (int32_t iii=0; MSG_PRIO_NUMBER>iii; iii++) { + nbMessage += messageData.nbMessages[iii]; + } + pthread_mutex_unlock(&messageData.mutex); + return nbMessage; +} diff --git a/Sources/libewol/ewol/threadMsg.h b/Sources/libewol/ewol/threadMsg.h index a738bd83..1c4dbc1c 100644 --- a/Sources/libewol/ewol/threadMsg.h +++ b/Sources/libewol/ewol/threadMsg.h @@ -60,6 +60,7 @@ namespace ewol { void Init(threadMsg_ts& messageData); void UnInit(threadMsg_ts& messageData); bool WaitMessage(threadMsg_ts& messageData, threadMsgContent_ts &data); + int32_t WaitingMessage(threadMsg_ts& messageData); bool SendMessage(threadMsg_ts& messageData, uint32_t type, msgPriority_te prio = MSG_PRIO_NONE, void * data = NULL, uint32_t size = 0); }; }; diff --git a/Sources/libewol/ewol/widget/CheckBox.cpp b/Sources/libewol/ewol/widget/CheckBox.cpp index 6e724e00..34e16b55 100644 --- a/Sources/libewol/ewol/widget/CheckBox.cpp +++ b/Sources/libewol/ewol/widget/CheckBox.cpp @@ -29,7 +29,7 @@ #include <ewol/WidgetManager.h> -extern const char * ewolEventCheckBoxClicked = "ewol CheckBox Clicked"; +extern const char * const ewolEventCheckBoxClicked = "ewol CheckBox Clicked"; #undef __class__ #define __class__ "ewol::CheckBox" diff --git a/Sources/libewol/ewol/widget/CheckBox.h b/Sources/libewol/ewol/widget/CheckBox.h index 3e44fda1..83e459b7 100644 --- a/Sources/libewol/ewol/widget/CheckBox.h +++ b/Sources/libewol/ewol/widget/CheckBox.h @@ -29,7 +29,7 @@ #include <ewol/Debug.h> #include <ewol/Widget.h> -extern const char * ewolEventCheckBoxClicked; +extern const char* const ewolEventCheckBoxClicked; namespace ewol { class CheckBox :public ewol::Widget diff --git a/Sources/libewol/file.mk b/Sources/libewol/file.mk index 6288ed3c..42f70cc0 100644 --- a/Sources/libewol/file.mk +++ b/Sources/libewol/file.mk @@ -1,9 +1,9 @@ FILE_LIST = ewol/ewol.cpp \ - ewol/ewolInterne.cpp \ ewol/threadMsg.cpp \ ewol/base/MainThread.cpp \ + ewol/base/gui.cpp \ ewol/Debug.cpp \ ewol/OObject.cpp \ ewol/OObject/2DText.cpp \