From 3d576e3a1dcf123f081a6e4da5f358f4165e8cd1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 26 Dec 2012 21:16:26 +0100 Subject: [PATCH] [DEV] Add Cursor types and display on x11 and capacity to force the cursor in ofset mode for games --- sources/ewol/cursor.cpp | 46 +++ sources/ewol/cursor.h | 49 +++ sources/ewol/renderer/os/eSystem.cpp | 10 + sources/ewol/renderer/os/eSystem.h | 31 +- sources/ewol/renderer/os/eSystemInput.cpp | 54 ++- sources/ewol/renderer/os/eSystemInput.h | 20 +- sources/ewol/renderer/os/gui.X11.cpp | 406 ++++++++++++---------- sources/ewol/renderer/os/gui.h | 15 +- sources/ewol/widget/Scene.cpp | 89 +++-- sources/ewol/widget/Scene.h | 6 +- sources/ewol/widget/Widget.cpp | 40 +++ sources/ewol/widget/Widget.h | 83 ++--- sources/file.mk | 3 +- 13 files changed, 504 insertions(+), 348 deletions(-) create mode 100644 sources/ewol/cursor.cpp create mode 100644 sources/ewol/cursor.h diff --git a/sources/ewol/cursor.cpp b/sources/ewol/cursor.cpp new file mode 100644 index 00000000..9f092f71 --- /dev/null +++ b/sources/ewol/cursor.cpp @@ -0,0 +1,46 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include + +static const char* cursorDescriptionString[ewol::cursorCount+1] = { + "cursorArrow", + "cursorLeftArrow", + "cursorInfo", + "cursorDestroy", + "cursorHelp", + "cursorCycle", + "cursorSpray", + "cursorWait", + "cursorText", + "cursorCrossHair", + "cursorSlideUpDown", + "cursorSlideLeftRight", + "cursorResizeUp", + "cursorResizeDown", + "cursorResizeLeft", + "cursorResizeRight", + "cursorCornerTopLeft", + "cursorCornerTopRight", + "cursorCornerButtomLeft", + "cursorCornerButtomRight", + "cursorNone", + "cursorCount" +}; + +etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::cursorDisplay_te obj) +{ + if (obj>=0 && obj +#include +namespace ewol +{ + typedef enum { + cursorArrow, // this is the normal arrow ... + cursorLeftArrow, + cursorInfo, + cursorDestroy, + cursorHelp, + cursorCycle, + cursorSpray, + cursorWait, + cursorText, + cursorCrossHair, + cursorSlideUpDown, //!< change the position (slide) vertical + cursorSlideLeftRight, //!< change the position (slide) horizontal + cursorResizeUp, + cursorResizeDown, + cursorResizeLeft, + cursorResizeRight, + cursorCornerTopLeft, + cursorCornerTopRight, + cursorCornerButtomLeft, + cursorCornerButtomRight, + cursorNone, + // just for the count: + cursorCount + } cursorDisplay_te; + /** + * @brief Debug operator To display the curent element in a Human readable information + */ + etk::CCout& operator <<(etk::CCout &os, const ewol::cursorDisplay_te obj); +}; + +#endif + + diff --git a/sources/ewol/renderer/os/eSystem.cpp b/sources/ewol/renderer/os/eSystem.cpp index b274987d..30d21c54 100644 --- a/sources/ewol/renderer/os/eSystem.cpp +++ b/sources/ewol/renderer/os/eSystem.cpp @@ -40,6 +40,16 @@ void eSystem::InputEventTransfertWidget(ewol::Widget* source, ewol::Widget* dest } +void eSystem::InputEventGrabPointer(ewol::Widget* widget) +{ + l_managementInput.GrabPointer(widget); +} + +void eSystem::InputEventUnGrabPointer(void) +{ + l_managementInput.UnGrabPointer(); +} + typedef enum { THREAD_NONE, THREAD_INIT, diff --git a/sources/ewol/renderer/os/eSystem.h b/sources/ewol/renderer/os/eSystem.h index be5e1f30..5df9f0c8 100644 --- a/sources/ewol/renderer/os/eSystem.h +++ b/sources/ewol/renderer/os/eSystem.h @@ -45,71 +45,58 @@ namespace eSystem // return true if a flush is needed bool Draw(bool displayEveryTime); - /** * @brief Inform object that an other object is removed ... * @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject * @note : Sub classes must call this class - * @return --- */ void OnObjectRemove(ewol::EObject * removeObject); - /** * @brief reset event management for the IO like Input ou Mouse or keyborad - * @param --- - * @return --- */ void ResetIOEvent(void); - /** * @brief Inform the system that the OpenGL constext has been destroy ==> use to automaticly reload the texture and other thinks ... - * @param --- - * @return --- */ void OpenGlContextDestroy(void); - /** * @brief Inform the system that the Application has been killed - * @param --- - * @return --- */ void OnKill(void); - /** * @brief set the current windows to display : * @param windows windows that might be displayed - * @return --- */ void SetCurrentWindows(ewol::Windows * windows); - /** * @brief Get the current windows that is displayed - * @param --- * @return the current handle on the windows (can be null) */ ewol::Windows* GetCurrentWindows(void); - /** * @brief Get the current windows size - * @param --- * @return the current size ... */ ivec2 GetSize(void); - /** * @brief Redraw all the windows - * @param --- - * @return --- */ void ForceRedrawAll(void); - /** * @brief This is to transfert the event from one widget to another one * @param source the widget where the event came from * @param destination the widget where the event mitgh be generated now - * @return --- */ void InputEventTransfertWidget(ewol::Widget* source, ewol::Widget* destination); + /** + * @brief This fonction lock the pointer properties to move in relative instead of absolute + * @param[in] widget The widget that lock the pointer events + */ + void InputEventGrabPointer(ewol::Widget* widget); + /** + * @brief This fonction un-lock the pointer properties to move in relative instead of absolute + */ + void InputEventUnGrabPointer(void); }; diff --git a/sources/ewol/renderer/os/eSystemInput.cpp b/sources/ewol/renderer/os/eSystemInput.cpp index 5ad19257..70c2d459 100644 --- a/sources/ewol/renderer/os/eSystemInput.cpp +++ b/sources/ewol/renderer/os/eSystemInput.cpp @@ -51,17 +51,13 @@ void ewol::eSystemInput::CleanElement(InputPoperty_ts *eventTable, int32_t idInp eventTable[idInput].destinationInputId = 0; eventTable[idInput].lastTimeEvent = 0; eventTable[idInput].curentWidgetEvent = NULL; - eventTable[idInput].origin.x = 0; - eventTable[idInput].origin.y = 0; - eventTable[idInput].size.x = 99999999; - eventTable[idInput].size.y = 99999999; - eventTable[idInput].downStart.x = 0; - eventTable[idInput].downStart.y = 0; + eventTable[idInput].origin = vec2(0,0); + eventTable[idInput].size = vec2(99999999,99999999); + eventTable[idInput].downStart = vec2(0,0); eventTable[idInput].isDown = false; eventTable[idInput].isInside = false; eventTable[idInput].nbClickEvent = 0; - eventTable[idInput].posEvent.x = 0; - eventTable[idInput].posEvent.y = 0; + eventTable[idInput].posEvent = vec2(0,0); } @@ -113,6 +109,21 @@ void ewol::eSystemInput::TransfertEvent(ewol::Widget* source, ewol::Widget* dest } } +void ewol::eSystemInput::GrabPointer(ewol::Widget* widget) +{ + if(NULL==widget) { + return; + } + m_grabWidget = widget; + guiInterface::GrabPointerEvents(true, widget->GetOrigin() + widget->GetSize()/2.0f); +} + +void ewol::eSystemInput::UnGrabPointer(void) +{ + m_grabWidget = NULL; + guiInterface::GrabPointerEvents(false, vec2(0,0)); +} + void ewol::eSystemInput::OnObjectRemove(ewol::EObject * removeObject) { for(int32_t iii=0; iiiGetWidgetAtPos(pos); + if (m_grabWidget != NULL) { + // grab all events ... + tmpWidget = m_grabWidget; + } else { + if (NULL != tmpWindows) { + tmpWidget = tmpWindows->GetWidgetAtPos(pos); + } } if( tmpWidget != eventTable[pointerID].curentWidgetEvent || ( true == eventTable[pointerID].isInside @@ -221,11 +238,7 @@ void ewol::eSystemInput::Motion(ewol::keyEvent::type_te type, int pointerID, vec // Set the element inside ... eventTable[pointerID].isInside = true; // get destination widget : - if(NULL != tmpWindows) { - eventTable[pointerID].curentWidgetEvent = tmpWindows->GetWidgetAtPos(pos); - } else { - eventTable[pointerID].curentWidgetEvent = NULL; - } + eventTable[pointerID].curentWidgetEvent = tmpWidget; if (NULL == eventTable[pointerID].curentWidgetEvent) { eventTable[pointerID].isInside = false; } @@ -322,7 +335,11 @@ void ewol::eSystemInput::State(ewol::keyEvent::type_te type, int pointerID, bool eventTable[pointerID].isInside = true; // get destination widget : if(NULL != tmpWindows) { - eventTable[pointerID].curentWidgetEvent = tmpWindows->GetWidgetAtPos(pos); + if (m_grabWidget != NULL && type == ewol::keyEvent::typeMouse) { + eventTable[pointerID].curentWidgetEvent = m_grabWidget; + } else { + eventTable[pointerID].curentWidgetEvent = tmpWindows->GetWidgetAtPos(pos); + } } else { eventTable[pointerID].curentWidgetEvent = NULL; } @@ -366,7 +383,10 @@ void ewol::eSystemInput::State(ewol::keyEvent::type_te type, int pointerID, bool nbClickMax = 5; } } - if(eventTable[pointerID].nbClickEvent < nbClickMax) { + // in grab mode the single to quinte event are not generated .... + if( ( m_grabWidget == NULL + || type != ewol::keyEvent::typeMouse ) + && eventTable[pointerID].nbClickEvent < nbClickMax) { // generate event SINGLE : eventTable[pointerID].nbClickEvent++; EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [" << eventTable[pointerID].nbClickEvent << "] " << pos); diff --git a/sources/ewol/renderer/os/eSystemInput.h b/sources/ewol/renderer/os/eSystemInput.h index ddd95b04..9ea7069f 100644 --- a/sources/ewol/renderer/os/eSystemInput.h +++ b/sources/ewol/renderer/os/eSystemInput.h @@ -20,10 +20,10 @@ namespace ewol int32_t destinationInputId; int64_t lastTimeEvent; ewol::Widget* curentWidgetEvent; - vec2 origin; - vec2 size; - vec2 downStart; - vec2 posEvent; + vec2 origin; + vec2 size; + vec2 downStart; + vec2 posEvent; bool isDown; bool isInside; int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3 @@ -36,6 +36,9 @@ namespace ewol class eSystemInput { + // special grab pointer mode : + private: + ewol::Widget* m_grabWidget; //!< widget that grab the curent pointer. private: int32_t m_dpi; inputLimit_ts m_eventInputLimit; @@ -100,6 +103,15 @@ namespace ewol * @return --- */ void TransfertEvent(ewol::Widget* source, ewol::Widget* destination); + /** + * @brief This fonction lock the pointer properties to move in relative instead of absolute + * @param[in] widget The widget that lock the pointer events + */ + void GrabPointer(ewol::Widget* widget); + /** + * @brief This fonction un-lock the pointer properties to move in relative instead of absolute + */ + void UnGrabPointer(void); }; }; diff --git a/sources/ewol/renderer/os/gui.X11.cpp b/sources/ewol/renderer/os/gui.X11.cpp index 064fd2a6..3d353672 100644 --- a/sources/ewol/renderer/os/gui.X11.cpp +++ b/sources/ewol/renderer/os/gui.X11.cpp @@ -34,7 +34,17 @@ */ //#define DEBUG_X11_EVENT - +#ifdef DEBUG_X11_EVENT + #define X11_DEBUG EWOL_DEBUG + #define X11_VERBOSE EWOL_VERBOSE + #define X11_INFO EWOL_INFO + #define X11_CRITICAL EWOL_CRITICAL +#else + #define X11_DEBUG EWOL_VERBOSE + #define X11_VERBOSE EWOL_VERBOSE + #define X11_INFO EWOL_VERBOSE + #define X11_CRITICAL EWOL_VERBOSE +#endif int64_t guiInterface::GetTime(void) { struct timespec now; @@ -107,7 +117,11 @@ int32_t m_currentWidth = 0; XVisualInfo * m_visual = NULL; bool m_doubleBuffered = 0; bool m_run = 0; -bool m_grabAllEvent = false; +//forcing the position +bool m_grabAllEvent = false; //!< grab mode enable... +vec2 m_forcePos = vec2(0,0); //!< position to reset the cursor +bool m_positionChangeRequested = false; //!< the position modifiquation has been requested +vec2 m_curentGrabDelta = vec2(0,0); //!< the position in X11 will arrive by pool bool inputIsPressed[20]; @@ -130,9 +144,7 @@ static Atom XAtomeDeleteWindows = 0; bool CreateX11Context(void) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11: CreateX11Context"); - #endif + X11_INFO("X11: CreateX11Context"); int x,y, attr_mask; XSizeHints hints; XWMHints *StartupState; @@ -190,12 +202,14 @@ bool CreateX11Context(void) // select internal attribute attr_mask = CWBackPixmap | CWColormap | CWBorderPixel | CWEventMask; // Create the window - int32_t tmp_width = DisplayWidth(m_display, DefaultScreen(m_display))/2; - int32_t tmp_height = DisplayHeight(m_display, DefaultScreen(m_display))/2; + int32_t tmp_width = 640;//DisplayWidth(m_display, DefaultScreen(m_display))/2; + int32_t tmp_height = 480;//DisplayHeight(m_display, DefaultScreen(m_display))/2; eSystem::Resize(tmp_width, tmp_height); - x=tmp_width/2; - y=tmp_height/4; - + x=20; + y=20; + m_originX = x; + m_originY = y; + EWOL_INFO("X11 request creating windows at pos=(" << m_originX << "," << m_originY << ") size=(" << tmp_width << "," << tmp_height << ")" ); // Real create of the window WindowHandle = XCreateWindow(m_display, Xroot, @@ -258,9 +272,7 @@ bool CreateX11Context(void) */ void guiInterface::SetTitle(etk::UString& title) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11: Set Title (START)"); - #endif + X11_INFO("X11: Set Title (START)"); XTextProperty tp; tp.value = (unsigned char *)title.c_str(); tp.encoding = XA_WM_NAME; @@ -270,9 +282,7 @@ void guiInterface::SetTitle(etk::UString& title) XStoreName(m_display, WindowHandle, (const char*)tp.value); XSetIconName(m_display, WindowHandle, (const char*)tp.value); XSetWMIconName(m_display, WindowHandle, &tp); - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11: Set Title (END)"); - #endif + X11_INFO("X11: Set Title (END)"); } /* this variable will contain the ID of the newly created pixmap. */ @@ -282,9 +292,7 @@ Pixmap icon_pixmap; void SetIcon(etk::UString inputFile) { etk::FSNode bitmapFile(inputFile); - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11: try to set icon : " << bitmapFile); - #endif + X11_INFO("X11: try to set icon : " << bitmapFile); // load bitmap if (false == bitmapFile.Exist()) { EWOL_ERROR("X11 Icon File does not Exist ... " << bitmapFile); @@ -340,9 +348,7 @@ void SetIcon(etk::UString inputFile) void RemoveDecoration(void) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11:RemoveDecoration"); - #endif + X11_INFO("X11:RemoveDecoration"); Hints hints; Atom property; hints.flags = 2;// Specify that we're changing the window decorations. @@ -358,9 +364,7 @@ void RemoveDecoration(void) void AddDecoration(void) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11:AddDecoration"); - #endif + X11_INFO("X11:AddDecoration"); Hints hints; Atom property; hints.flags = 2;// Specify that we're changing the window decorations. @@ -381,23 +385,21 @@ static void setVSync(bool sync) PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; const char *extensions = (char*)glGetString( GL_EXTENSIONS ); if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 ) { - EWOL_ERROR("Can not set the vertical synchronisation status" << sync); + EWOL_ERROR("Can not set the vertical synchronisation status" << sync << " (1)"); return; } else { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)glXGetProcAddress( (const GLubyte *)"wglSwapIntervalEXT" ); if(wglSwapIntervalEXT) { wglSwapIntervalEXT(sync); } else { - EWOL_ERROR("Can not set the vertical synchronisation status" << sync); + EWOL_ERROR("Can not set the vertical synchronisation status" << sync << " (2)"); } } } bool CreateOGlContext(void) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11:CreateOGlContext"); - #endif + X11_INFO("X11:CreateOGlContext"); /* create a GLX context */ GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE); /* connect the glx-context to the window */ @@ -416,9 +418,7 @@ bool CreateOGlContext(void) void X11_Init(void) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11:INIT"); - #endif + X11_INFO("X11:INIT"); if (m_doubleBuffered) { glXSwapBuffers(m_display, WindowHandle); XSync (m_display,0); @@ -463,17 +463,12 @@ void X11_Run(void) XEvent respond; // main X boucle : while (XPending(m_display)) { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11:Event"); - #endif XNextEvent(m_display, &event); switch (event.type) { case ClientMessage: { - #ifdef DEBUG_X11_EVENT - EWOL_INFO("Receive : ClientMessage"); - #endif + X11_INFO("Receive : ClientMessage"); if(XAtomeDeleteWindows == (int64_t)event.xclient.data.l[0]) { EWOL_INFO(" ==> Kill Requested ..."); eSystem::OnKill(); @@ -486,9 +481,7 @@ void X11_Run(void) /////////////////////////////////////////////////////////////////////////////////////////////////////////////// case SelectionClear: // Selection has been done on an other program ==> clear ours ... - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event SelectionClear"); - #endif + X11_INFO("X11 event SelectionClear"); { #ifdef DEBUG_X11_EVENT { @@ -511,9 +504,7 @@ void X11_Run(void) } break; case SelectionNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event SelectionNotify"); - #endif + X11_INFO("X11 event SelectionNotify"); if (event.xselection.property == None) { EWOL_VERBOSE(" ==> no data ..."); } else { @@ -548,9 +539,7 @@ void X11_Run(void) } break; case SelectionRequest: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event SelectionRequest"); - #endif + X11_INFO("X11 event SelectionRequest"); { XSelectionRequestEvent *req=&(event.xselectionrequest); #ifdef DEBUG_X11_EVENT @@ -631,69 +620,50 @@ void X11_Run(void) break; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// case Expose: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event Expose"); - #endif + X11_INFO("X11 event Expose"); break; case GraphicsExpose: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event GraphicsExpose"); - #endif + X11_INFO("X11 event GraphicsExpose"); break; case NoExpose: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event NoExpose"); - #endif + X11_INFO("X11 event NoExpose"); break; case CreateNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event CreateNotify"); - #endif + X11_INFO("X11 event CreateNotify"); break; case DestroyNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event DestroyNotify"); - #endif + X11_INFO("X11 event DestroyNotify"); break; case GravityNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event GravityNotify"); - #endif + X11_INFO("X11 event GravityNotify"); break; case VisibilityNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event VisibilityNotify"); - #endif + X11_INFO("X11 event VisibilityNotify"); break; case CirculateNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event CirculateNotify"); - #endif + X11_INFO("X11 event CirculateNotify"); break; case ReparentNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event ReparentNotify"); - #endif + X11_INFO("X11 event ReparentNotify"); break; case PropertyNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event PropertyNotify"); - #endif + X11_INFO("X11 event PropertyNotify"); break; case ConfigureNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event ConfigureNotify"); - #endif - m_originX = event.xconfigure.x; - m_originY = event.xconfigure.y; - m_currentHeight = event.xconfigure.height; - m_currentWidth = event.xconfigure.width; - eSystem::Resize(event.xconfigure.width, event.xconfigure.height); + X11_INFO("X11 event ConfigureNotify"); + if (m_display == event.xconfigure.display) { + //EWOL_INFO("X11 event ConfigureNotify event=" << (int32_t)event.xconfigure.event << " Window=" << (int32_t)event.xconfigure.window << " above=" << (int32_t)event.xconfigure.above << " border_width=" << (int32_t)event.xconfigure.border_width ); + m_originX = event.xconfigure.x; + m_originY = event.xconfigure.y; + X11_INFO("X11 configure windows position : (" << m_originX << "," << m_originY << ")"); + m_currentHeight = event.xconfigure.height; + m_currentWidth = event.xconfigure.width; + X11_INFO("X11 configure windows size : (" << m_currentHeight << "," << m_currentWidth << ")"); + eSystem::Resize(event.xconfigure.width, event.xconfigure.height); + } break; case ButtonPress: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event ButtonPress"); - #endif + X11_INFO("X11 event ButtonPress"); m_cursorEventX = event.xbutton.x; m_cursorEventY = (m_currentHeight-event.xbutton.y); if (event.xbutton.button < NB_MAX_INPUT) { @@ -702,9 +672,7 @@ void X11_Run(void) eSystem::SetMouseState(event.xbutton.button, true, (float)event.xbutton.x, (float)m_cursorEventY); break; case ButtonRelease: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event ButtonRelease"); - #endif + X11_INFO("X11 event ButtonRelease"); m_cursorEventX = event.xbutton.x; m_cursorEventY = (m_currentHeight-event.xbutton.y); if (event.xbutton.button < NB_MAX_INPUT) { @@ -713,69 +681,72 @@ void X11_Run(void) eSystem::SetMouseState(event.xbutton.button, false, (float)event.xbutton.x, (float)m_cursorEventY); break; case EnterNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event EnterNotify"); - #endif + X11_INFO("X11 event EnterNotify"); m_cursorEventX = event.xcrossing.x; m_cursorEventY = (m_currentHeight-event.xcrossing.y); //EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (float)event.xcrossing.x << "," << (float)event.xcrossing.y << ")"); //gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (float)event.xcrossing.x, (float)event.xcrossing.y); + m_curentGrabDelta -= vec2(m_originX, -m_originY); + EWOL_DEBUG("change grab delta of : " << vec2(m_originX, m_originY) ); break; case LeaveNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event LeaveNotify"); - #endif + X11_INFO("X11 event LeaveNotify"); m_cursorEventX = event.xcrossing.x; m_cursorEventY = (m_currentHeight-event.xcrossing.y); //EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (float)event.xcrossing.x << "," << (float)event.xcrossing.y << ")"); + m_curentGrabDelta += vec2(m_originX, -m_originY); + EWOL_DEBUG("change grab delta of : " << vec2(m_originX, m_originY) ); break; case MotionNotify: - #ifdef DEBUG_X11_EVENT - EWOL_INFO("X11 event MotionNotify"); - #endif - m_cursorEventX = event.xmotion.x; - m_cursorEventY = (m_currentHeight-event.xmotion.y); - { + X11_INFO("X11 event MotionNotify"); + if( true==m_grabAllEvent + && event.xmotion.x == (int32_t)m_forcePos.x + && event.xmotion.y == (int32_t)m_forcePos.y) { + X11_VERBOSE("X11 reject mouse move (grab mode)"); + // we get our requested position... + m_positionChangeRequested = false; + m_curentGrabDelta = vec2(0,0); + } else { + m_cursorEventX = event.xmotion.x; + m_cursorEventY = (m_currentHeight-event.xmotion.y); + if(true==m_grabAllEvent) { + m_cursorEventX -= m_forcePos.x; + m_cursorEventY -= (m_currentHeight-m_forcePos.y); + } + vec2 newDelta = vec2(m_cursorEventX, m_cursorEventY); + if(true==m_grabAllEvent) { + m_cursorEventX -= m_curentGrabDelta.x; + m_cursorEventY -= m_curentGrabDelta.y; + } + m_curentGrabDelta = newDelta; // For compatibility of the Android system : bool findOne = false; for (int32_t iii=0; iii +// select the current cursor to display : +static ewol::cursorDisplay_te l_currentCursor = ewol::cursorArrow; + +void guiInterface::SetCursor(ewol::cursorDisplay_te newCursor) { - if (false == isVisible) { - EWOL_DEBUG("Hide Cursor"); - Cursor invisibleCursor; - Pixmap bitmapNoData; - XColor black; - static char noData[] = { 0,0,0,0,0,0,0,0 }; - black.red = 0; - black.green = 0; - black.blue = 0; - bitmapNoData = XCreateBitmapFromData(m_display, WindowHandle, noData, 8, 8); - invisibleCursor = XCreatePixmapCursor(m_display, bitmapNoData, bitmapNoData, - &black, &black, 0, 0); - XDefineCursor(m_display,WindowHandle, invisibleCursor); - XFreeCursor(m_display, invisibleCursor); - } else { - EWOL_DEBUG("Show Cursor"); + if (newCursor != l_currentCursor) { + X11_DEBUG("X11-API: Set New Cursor : " << newCursor); + // undefine previous cursors ... XUndefineCursor(m_display, WindowHandle); + // set the new one : + l_currentCursor = newCursor; + Cursor myCursor = None; + switch (l_currentCursor) { + case ewol::cursorNone: + { + Pixmap bitmapNoData; + XColor black; + static char noData[] = { 0,0,0,0,0,0,0,0 }; + black.red = 0; + black.green = 0; + black.blue = 0; + bitmapNoData = XCreateBitmapFromData(m_display, WindowHandle, noData, 8, 8); + myCursor = XCreatePixmapCursor(m_display, bitmapNoData, bitmapNoData, + &black, &black, 0, 0); + } + break; + case ewol::cursorLeftArrow: + myCursor = XCreateFontCursor(m_display, XC_top_left_arrow); + break; + case ewol::cursorInfo: + myCursor = XCreateFontCursor(m_display, XC_hand1); + break; + case ewol::cursorDestroy: + myCursor = XCreateFontCursor(m_display, XC_pirate); + break; + case ewol::cursorHelp: + myCursor = XCreateFontCursor(m_display, XC_question_arrow); + break; + case ewol::cursorCycle: + myCursor = XCreateFontCursor(m_display, XC_exchange); + break; + case ewol::cursorSpray: + myCursor = XCreateFontCursor(m_display, XC_spraycan); + break; + case ewol::cursorWait: + myCursor = XCreateFontCursor(m_display, XC_watch); + break; + case ewol::cursorText: + myCursor = XCreateFontCursor(m_display, XC_xterm); + break; + case ewol::cursorCrossHair: + myCursor = XCreateFontCursor(m_display, XC_crosshair); + break; + case ewol::cursorSlideUpDown: + myCursor = XCreateFontCursor(m_display, XC_sb_v_double_arrow); + break; + case ewol::cursorSlideLeftRight: + myCursor = XCreateFontCursor(m_display, XC_sb_h_double_arrow); + break; + case ewol::cursorResizeUp: + myCursor = XCreateFontCursor(m_display, XC_top_side); + break; + case ewol::cursorResizeDown: + myCursor = XCreateFontCursor(m_display, XC_bottom_side); + break; + case ewol::cursorResizeLeft: + myCursor = XCreateFontCursor(m_display, XC_left_side); + break; + case ewol::cursorResizeRight: + myCursor = XCreateFontCursor(m_display, XC_right_side); + break; + case ewol::cursorCornerTopLeft: + myCursor = XCreateFontCursor(m_display, XC_top_left_corner); + break; + case ewol::cursorCornerTopRight: + myCursor = XCreateFontCursor(m_display, XC_top_right_corner); + break; + case ewol::cursorCornerButtomLeft: + myCursor = XCreateFontCursor(m_display, XC_bottom_right_corner); + break; + case ewol::cursorCornerButtomRight: + myCursor = XCreateFontCursor(m_display, XC_bottom_left_corner); + break; + default : + // nothing to do ... basic pointer ... + break; + } + if (myCursor != None) { + XDefineCursor(m_display,WindowHandle, myCursor); + XFreeCursor(m_display, myCursor); + } } } -void guiInterface::GrabPointerEvents(bool isGrabbed) +void guiInterface::GrabPointerEvents(bool isGrabbed, vec2 forcedPosition) { if (true == isGrabbed) { - EWOL_DEBUG("Grab Events"); - - //EWOL_DEBUG("X11 mouse move(" << (float)event.xmotion.x << "," << (float)(m_currentHeight-event.xmotion.y) << ")"); - if (BadWindow == XWarpPointer(m_display, None, WindowHandle, 0,0, 0, 0, 20, 20)) { - EWOL_WARNING("X11 mouse mouve (BadWindow)"); - } - XSync(m_display, False); - XFlush(m_display); - /* + X11_DEBUG("X11-API: Grab Events"); int32_t test = XGrabPointer(m_display,RootWindow(m_display, DefaultScreen(m_display)), True, ButtonPressMask | ButtonReleaseMask | @@ -1177,12 +1194,21 @@ void guiInterface::GrabPointerEvents(bool isGrabbed) break; } } - */ + m_forcePos = forcedPosition; + m_forcePos.y = m_currentHeight - m_forcePos.y; m_grabAllEvent = true; + // change the pointer position to generate a good mouving at the start ... + X11_DEBUG("X11-API: Set pointer position : " << m_forcePos); + XWarpPointer(m_display, None, WindowHandle, 0,0, 0, 0, m_forcePos.x, m_forcePos.y); + XFlush(m_display); + m_positionChangeRequested = true; + m_curentGrabDelta = vec2(0,0); } else { - EWOL_DEBUG("Un-Grab Events"); + X11_DEBUG("X11-API: Un-Grab Events"); XUngrabPointer(m_display, CurrentTime); m_grabAllEvent = false; + m_forcePos = vec2(0,0); + m_curentGrabDelta = vec2(0,0); } } @@ -1206,8 +1232,6 @@ int guiInterface::main(int argc, const char *argv[]) // get the icon file : etk::UString myIcon = APP_Icon(); SetIcon(myIcon); - CursorDisplay(true); - //GrabPointerEvents(true); // Run ... X11_Run(); // close X11 : diff --git a/sources/ewol/renderer/os/gui.h b/sources/ewol/renderer/os/gui.h index 4f1f1990..f7fb69dc 100644 --- a/sources/ewol/renderer/os/gui.h +++ b/sources/ewol/renderer/os/gui.h @@ -71,16 +71,17 @@ namespace guiInterface * @param orientation Selected orientation. */ void ForceOrientation(ewol::orientation_te orientation); - /** - * @brief Set the cursor visible or not. - * @param isVisible set the cursor visible of hiden (sometime neede to hide system cursor). - */ - void CursorDisplay(bool isVisible); /** * @brief Get all the event from the X system - * @param isGrabbed true if all the event will be get, false if we want only ours. + * @param[in] isGrabbed "true" if all the event will be get, false if we want only ours. + * @param[in] forcedPosition the position where the mouse might be reset at every events ... */ - void GrabPointerEvents(bool isGrabbed); + void GrabPointerEvents(bool isGrabbed, vec2 forcedPosition); + /** + * @brief Set the cursor display type. + * @param[in] newCursor selected new cursor. + */ + void SetCursor(ewol::cursorDisplay_te newCursor); }; diff --git a/sources/ewol/widget/Scene.cpp b/sources/ewol/widget/Scene.cpp index 32a0c607..c6c71f14 100644 --- a/sources/ewol/widget/Scene.cpp +++ b/sources/ewol/widget/Scene.cpp @@ -25,8 +25,7 @@ widget::Scene::Scene(game::Engine* gameEngine) : m_gameEngine(gameEngine), m_isRunning(true), m_lastCallTime(-1), - m_walk(0), - modeMoving(0) + m_walk(0) { SetCanHaveFocus(true); PeriodicCallSet(true); @@ -84,6 +83,9 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp) #define WALK_FLAG_RIGHT (1<<3) #define WALK_FLAG_CAUTION (1<<4) +static const float l_walkRatio = 6.666f; +static const float l_walkLateralRatio = 3.333f; + void widget::Scene::PeriodicCall(int64_t localTime) { double curentTime=(double)localTime/1000000.0; @@ -125,7 +127,7 @@ void widget::Scene::PeriodicCall(int64_t localTime) //EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles); vec3 pos = m_camera.GetPosition(); // walk is 6 km/h - pos += angles*3.333f*deltaTime; + pos += angles*l_walkRatio*deltaTime; m_camera.SetPosition(pos); } else if ( (m_walk&WALK_FLAG_BACK)!=0) { vec3 angles = m_camera.GetAngle(); @@ -135,7 +137,7 @@ void widget::Scene::PeriodicCall(int64_t localTime) //EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles); vec3 pos = m_camera.GetPosition(); // walk is 6 km/h - pos += angles*3.333f*deltaTime; + pos += angles*l_walkRatio*deltaTime; m_camera.SetPosition(pos); } @@ -150,7 +152,7 @@ void widget::Scene::PeriodicCall(int64_t localTime) //EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles); vec3 pos = m_camera.GetPosition(); // lateral walk is 4 km/h - pos += angles*2.2f*deltaTime; + pos += angles*l_walkLateralRatio*deltaTime; m_camera.SetPosition(pos); } else if ( (m_walk&WALK_FLAG_RIGHT)!=0) { vec3 angles = m_camera.GetAngle(); @@ -160,7 +162,7 @@ void widget::Scene::PeriodicCall(int64_t localTime) //EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles); vec3 pos = m_camera.GetPosition(); // lateral walk is 4 km/h - pos += angles*2.2f*deltaTime; + pos += angles*l_walkLateralRatio*deltaTime; m_camera.SetPosition(pos); } } @@ -227,50 +229,25 @@ vec2 widget::Scene::RelativePosition(vec2 pos) bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te statusEvent, vec2 pos) { - vec2 relativePos = RelativePosition(pos); //EWOL_DEBUG("type : " << type << " IdInput=" << IdInput << " " << "status=" << statusEvent << " RelPos=" << relativePos); - KeepFocus(); + if (type == ewol::keyEvent::typeMouse) { - if (4 == IdInput && ewol::keyEvent::statusUp == statusEvent) { - vec3 oldPos = m_camera.GetPosition(); - oldPos.z -= 0.5; - m_camera.SetPosition(oldPos); - } else if (5 == IdInput && ewol::keyEvent::statusUp == statusEvent) { - vec3 oldPos = m_camera.GetPosition(); - oldPos.z += 0.5; - m_camera.SetPosition(oldPos); - } else if (1 == IdInput) { - if(modeMoving==1 && ewol::keyEvent::statusUp == statusEvent) { - modeMoving = 0; - } else if (modeMoving==0 && ewol::keyEvent::statusDown == statusEvent) { - modeMoving = 1; - oldCursorPos = relativePos; - } else if (modeMoving==1 && ewol::keyEvent::statusMove == statusEvent) { - vec2 offset = relativePos - oldCursorPos; - vec3 oldPos = m_camera.GetPosition(); - oldPos.x += offset.x/50.0; - oldPos.y += offset.y/50.0; - m_camera.SetPosition(oldPos); - oldCursorPos = relativePos; - } - } else if (3 == IdInput) { - if(modeMoving==3 && ewol::keyEvent::statusUp == statusEvent) { - modeMoving = 0; - } else if (modeMoving==0 && ewol::keyEvent::statusDown == statusEvent) { - modeMoving = 3; - oldCursorPos = relativePos; - } else if (modeMoving==3 && ewol::keyEvent::statusMove == statusEvent) { - vec2 offset = relativePos - oldCursorPos; - offset *= M_PI/(360.0f*6); + if (0 != IdInput) { + KeepFocus(); + GrabCursor(); + SetCursor(ewol::cursorNone); + } + if (true == GetGrabStatus() ) { + if (ewol::keyEvent::statusMove == statusEvent) { + pos *= M_PI/(360.0f*6); vec3 oldAngles = m_camera.GetAngle(); - oldAngles.z -= offset.x; - oldAngles.y += offset.y; + oldAngles.z += pos.x; + oldAngles.y += pos.y; m_camera.SetAngle(oldAngles); - oldCursorPos = relativePos; } } } else if (type == ewol::keyEvent::typeFinger) { - + KeepFocus(); } // note : we did not parse the oether media ... @@ -280,12 +257,9 @@ bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData) { - /* + EWOL_DEBUG("KB EVENT : \"" << unicodeData << "\"" << "type=" << statusEvent); - if (statusEvent == ewol::ewol::keyEvent::statusDown) { - - } - */ + if( unicodeData == 'z' || unicodeData == 'Z') { if (statusEvent == ewol::keyEvent::statusDown) { @@ -330,6 +304,13 @@ bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t u } } } + // escape case : + if(unicodeData == 27) { + if (statusEvent == ewol::keyEvent::statusDown) { + UnGrabCursor(); + SetCursor(ewol::cursorArrow); + } + } EWOL_DEBUG("m_walk=" << m_walk); return false; } @@ -382,3 +363,15 @@ bool widget::Scene::OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::k return false; } + +void widget::Scene::OnGetFocus(void) +{ + //GrabCursor(); +} + +void widget::Scene::OnLostFocus(void) +{ + UnGrabCursor(); +} + + diff --git a/sources/ewol/widget/Scene.h b/sources/ewol/widget/Scene.h index d8a24c7c..fdc00f61 100644 --- a/sources/ewol/widget/Scene.h +++ b/sources/ewol/widget/Scene.h @@ -60,8 +60,6 @@ namespace widget { // camera properties : private: float m_zoom; - int32_t modeMoving; - vec2 oldCursorPos; public: /** * @brief Get the current camera reference for the scene rendering @@ -93,6 +91,10 @@ namespace widget { virtual bool OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData); // Derived function virtual bool OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey); + // Derived function + virtual void OnGetFocus(void); + // Derived function + virtual void OnLostFocus(void); }; }; diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index cf2e181b..d5034c3a 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -11,6 +11,9 @@ #include #include #include +#include +#include + #undef __class__ @@ -38,6 +41,8 @@ ewol::Widget::Widget(void) : m_hasFocus = false; m_hide = false; m_zoom = 1.0; + m_grabCursor = false; + m_cursorDisplay = ewol::cursorArrow; } @@ -456,3 +461,38 @@ bool ewol::Widget::OnEventShortCut(ewol::SpecialKey& special, uniChar_t unicodeV } +void ewol::Widget::GrabCursor(void) +{ + if (false == m_grabCursor) { + eSystem::InputEventGrabPointer(this); + m_grabCursor = true; + } +} + +void ewol::Widget::UnGrabCursor(void) +{ + if (true==m_grabCursor) { + eSystem::InputEventUnGrabPointer(); + m_grabCursor = false; + } +} + + +bool ewol::Widget::GetGrabStatus(void) +{ + return m_grabCursor; +} + + + +void ewol::Widget::SetCursor(ewol::cursorDisplay_te newCursor) +{ + EWOL_DEBUG("Change Cursor in " << newCursor); + m_cursorDisplay = newCursor; + guiInterface::SetCursor(m_cursorDisplay); +} + +ewol::cursorDisplay_te ewol::Widget::GetCursor(void) +{ + return m_cursorDisplay; +} diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index a67de4ee..7c49c89c 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -20,8 +20,10 @@ namespace ewol { #include #include #include +#include namespace ewol { + class DrawProperty{ public : ivec2 m_windowsSize; @@ -52,14 +54,11 @@ namespace ewol { public: /** * @brief Constructor of the widget classes - * @param --- * @return (no execption generated (not managed in embended platform)) */ Widget(void); /** * @brief Destructor of the widget classes - * @param --- - * @return --- */ virtual ~Widget(void); /** @@ -88,12 +87,10 @@ namespace ewol { /** * @brief Set the zoom property of the widget * @param[in] newVal newZoom value - * @return --- */ void SetZoom(float newVal); /** * @brief Get the zoom property of the widget - * @param --- * @return the current zoom value */ float GetZoom(void); @@ -102,12 +99,10 @@ namespace ewol { * This represent the absolute origin in the program windows * @param[in] x Position ot hte horizantal origin * @param[in] y Position ot hte vertical origin - * @return --- */ void SetOrigin(float x, float y); /** * @brief Get the origin (obsolute position in the windows) - * @param --- * @return coordonate of the origin requested */ vec2 GetOrigin(void); @@ -122,7 +117,6 @@ namespace ewol { * By default this save the widget availlable size in the widget size * @param[in] availlableX Availlable horisantal pixel size * @param[in] availlableY Availlable vertical pixel size - * @return --- */ // TODO : Remove bool ==> deprecated ... // TODO : Rename in SetSize() @@ -130,8 +124,6 @@ namespace ewol { //update the min Size ... and the expend parameters for the sizer /** * @brief Calculate the minimum size of the widget that is needed to display or the user requested) - * @param --- - * @return --- */ // TODO : Remove bool ==> deprecated ... virtual bool CalculateMinSize(void); @@ -139,96 +131,78 @@ namespace ewol { * @brief User set the minimum size he want to set the display * @param[in] x Set minimum horizontal size (-1 : no requested) * @param[in] y Set minimum vertical size (-1 : no requested) - * @return --- */ virtual void SetMinSize(float x=-1, float y=-1); /** * @brief Get the current calculated min size - * @param --- * @return the size requested */ vec2 GetMinSize(void); /** * @brief User set the maximum size he want to set the display * @param[in] size The new maximum size requested (vec2(-1,-1) to unset) - * @return --- */ virtual void SetMaxSize(vec2 size); /** * @brief Get the current maximum size - * @param --- * @return the size requested */ vec2 GetMaxSize(void); /** * @brief Get the widget size - * @param --- * @return Requested size */ vec2 GetSize(void); /** * @brief Set the horizontal expend capacity * @param[in] newExpend new Expend state - * @return --- */ virtual void SetExpendX(bool newExpend=false); /** * @brief Get the horizontal expend capabilities - * @param --- * @return boolean repensent the capacity to expend */ virtual bool CanExpentX(void); /** * @brief Set the vertical expend capacity * @param[in] newExpend new Expend state - * @return --- */ virtual void SetExpendY(bool newExpend=false); /** * @brief Get the vertical expend capabilities - * @param --- * @return boolean repensent the capacity to expend */ virtual bool CanExpentY(void); /** * @brief Set the horizontal filling capacity * @param[in] newFill new fill state - * @return --- */ virtual void SetFillX(bool newFill=false); /** * @brief Get the horizontal filling capabilities - * @param --- * @return boolean repensent the capacity to horizontal filling */ bool CanFillX(void); /** * @brief Set the vertical filling capacity * @param[in] newFill new fill state - * @return --- */ virtual void SetFillY(bool newFill=false); /** * @brief Get the vertical filling capabilities - * @param --- * @return boolean repensent the capacity to vertical filling */ bool CanFillY(void); /** * @brief Set the widget hidden - * @param --- - * @return --- */ void Hide(void); /** * @brief Set the widget visible - * @param --- - * @return --- */ void Show(void); /** * @brief Get the visibility of the widget - * @param --- * @return true: if the widget is hiden, false: it is visible */ bool IsHide(void) { return m_hide; }; @@ -243,51 +217,40 @@ namespace ewol { public: /** * @brief Get the focus state of the widget - * @param --- * @return Focus state */ bool GetFocus(void) { return m_hasFocus;}; /** * @brief Get the capability to have focus - * @param --- * @return State capability to have focus */ bool CanHaveFocus(void) { return m_canFocus;}; /** * @brief Set focus on this widget - * @param --- * @return return true if the widget keep the focus */ bool SetFocus(void); /** * @brief Remove the focus on this widget - * @param --- * @return return true if the widget have release his focus (if he has it) */ bool RmFocus(void); /** * @brief Set the capability to have the focus * @param[in] canFocusState new focus capability - * @return --- */ void SetCanHaveFocus(bool canFocusState); /** * @brief Keep the focus on this widget ==> this remove the previous focus on all other widget - * @param --- - * @return --- */ void KeepFocus(void); protected: /** * @brief Event of the focus has been grep by the current widget - * @param --- - * @return --- */ virtual void OnGetFocus(void) {}; /** * @brief Event of the focus has been lost by the current widget - * @param --- - * @return --- */ virtual void OnLostFocus(void) {}; @@ -299,14 +262,12 @@ namespace ewol { public: /** * @brief Get the number of mouse event supported - * @param --- * @return return the number of event that the mouse supported [0..3] */ int32_t GetMouseLimit(void) { return m_limitMouseEvent; }; /** * @brief Get the number of mouse event supported * @param[in] numberState The number of event that the mouse supported [0..3] - * @return --- */ void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; }; @@ -317,14 +278,12 @@ namespace ewol { /** * @brief Request that the current widegt have a periodic call * @param statusToSet true if the periodic call is needed - * @return --- */ void PeriodicCallSet(bool statusToSet); public: /** * @brief Periodic call of this widget * @param localTime curent system time - * @return --- */ virtual void PeriodicCall(int64_t localTime) { }; @@ -364,7 +323,6 @@ namespace ewol { * @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas * @note : need to have focus ... * @param[in] mode Mode of data requested - * @return --- */ virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID) { }; @@ -379,13 +337,10 @@ namespace ewol { * @param[in] descriptiveString Description string of the shortcut * @param[in] generateEventId Event generic of the element * @param[in] data Associate data wit the event - * @return --- */ void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false); /** * @brief Remove all curent shortCut - * @param --- - * @return --- */ void ShortCutClean(void); public: @@ -406,13 +361,10 @@ namespace ewol { bool m_needRegenerateDisplay; //!< the display might be done the next regeneration /** * @brief The widget mark itself that it need to regenerate the nest time. - * @param --- - * @return --- */ void MarkToRedraw(void); /** * @brief Get the need of the redrawing of the widget and reset it to false - * @param --- * @return true if we need to redraw * @return false if we have no need to redraw */ @@ -423,33 +375,52 @@ namespace ewol { * This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget * @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget * @param[in] displayProp properties of the current display - * @return --- */ virtual void GenDraw(DrawProperty displayProp); protected: /** * @brief Common widget drawing function (called by the drawing thread [Android, X11, ...]) * @param[in] displayProp properties of the current display - * @return --- */ virtual void OnDraw(DrawProperty& displayProp) { }; public: /** * @brief Event generated when a redraw is needed - * @param --- - * @return --- */ virtual void OnRegenerateDisplay(void) { }; // grab cursor mode private: + bool m_grabCursor; + public: /** - * @brief Grab the cursor (hide it and mouvement is now an offset) + * @brief Grab the cursor : This get all the mouvement of the mouse in PC mode, and generate an ofset instead of a position. + * @note : the generation of the offset is due to the fact the cursor position is forced at the center of the widget. + * @note This done nothing in "Finger" or "Stylet" mode. */ void GrabCursor(void); /** - * @brief Un-Grab the cursor (default mode cursor ofset) + * @brief Un-Grab the cursor (default mode cursor offset) */ void UnGrabCursor(void); + /** + * @brief Get the grabbing status of the cursor. + * @return true if the cursor is curently grabbed + */ + bool GetGrabStatus(void); + // DisplayCursorType + private: + ewol::cursorDisplay_te m_cursorDisplay; + public: + /** + * @brief Set the cursor display type. + * @param[in] newCursor selected new cursor. + */ + void SetCursor(ewol::cursorDisplay_te newCursor); + /** + * @brief Get the currrent cursor. + * @return the type of the cursor. + */ + ewol::cursorDisplay_te GetCursor(void); }; // end of the class Widget declaration diff --git a/sources/file.mk b/sources/file.mk index a156f57a..4392c6df 100644 --- a/sources/file.mk +++ b/sources/file.mk @@ -5,7 +5,8 @@ FILE_LIST:= ewol/ewol.cpp \ ewol/debug.cpp \ ewol/config.cpp \ ewol/commandLine.cpp \ - ewol/key.cpp + ewol/key.cpp \ + ewol/cursor.cpp # Basic Eobject of EWOL FILE_LIST+= ewol/eObject/EObject.cpp \