diff --git a/Sources/libewol/ewol/Font.h b/Sources/libewol/ewol/Font.h index 20bc9ca8..ff74d0c1 100644 --- a/Sources/libewol/ewol/Font.h +++ b/Sources/libewol/ewol/Font.h @@ -91,14 +91,14 @@ namespace ewol coord2D_ts & drawPosition, coord2D_ts & clipSize, const char * utf8String, - uint32_t & fontTextureId, + int32_t & fontTextureId, etk::VectorType & coord, etk::VectorType & coordTex); int32_t DrawText(int32_t fontID, coord2D_ts textPos, clipping_ts & drawClipping, const uniChar_t * unicodeString, - uint32_t & fontTextureId, + int32_t & fontTextureId, etk::VectorType & coord, etk::VectorType & coordTex); /* diff --git a/Sources/libewol/ewol/FontFreeType.cpp b/Sources/libewol/ewol/FontFreeType.cpp index 21e0ec2b..59186f81 100644 --- a/Sources/libewol/ewol/FontFreeType.cpp +++ b/Sources/libewol/ewol/FontFreeType.cpp @@ -437,7 +437,7 @@ class FTFont{ uint32_t GetOglId(void) { - return ewol::GetTextureGLID(m_textureId); + return m_textureId; }; int32_t GetSize(void) @@ -497,10 +497,19 @@ void ewol::UnInitFont(void) EWOL_CRITICAL(" when Un-loading FreeType Librairy ..."); } */ - /* s_currentFolderName = ""; s_currentDefaultFontName = ""; s_currentDefaultFontId = -1; + + // unload global font + for(int32_t iii=0; iii & coord, etk::VectorType & coordTex) { @@ -684,7 +692,7 @@ int32_t ewol::DrawText(int32_t fontID, coord2D_ts textPos, clipping_ts & drawClipping, const uniChar_t * unicodeString, - uint32_t & fontTextureId, + int32_t & fontTextureId, etk::VectorType & coord, etk::VectorType & coordTex) { diff --git a/Sources/libewol/ewol/OObject/2DText.cpp b/Sources/libewol/ewol/OObject/2DText.cpp index 0dda43fa..82f818eb 100644 --- a/Sources/libewol/ewol/OObject/2DText.cpp +++ b/Sources/libewol/ewol/OObject/2DText.cpp @@ -24,6 +24,7 @@ #include #include +#include #undef __class__ #define __class__ "ewol::OObject2DText" @@ -64,7 +65,7 @@ void ewol::OObject2DText::Draw(void) } glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_FontTextureId); + glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_FontTextureId)); glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] ); diff --git a/Sources/libewol/ewol/OObject/2DText.h b/Sources/libewol/ewol/OObject/2DText.h index 45846855..a959e334 100644 --- a/Sources/libewol/ewol/OObject/2DText.h +++ b/Sources/libewol/ewol/OObject/2DText.h @@ -42,7 +42,7 @@ namespace ewol { protected: int32_t m_FontId; //!< font internal ID color_ts m_textColorFg; //!< text color ... - uint32_t m_FontTextureId; //!< font internal Texture ID + int32_t m_FontTextureId; //!< font internal Texture ID etk::VectorType m_coord; //!< internal coord of the object etk::VectorType m_coordTex; //!< internal texture coordinate for every point public: diff --git a/Sources/libewol/ewol/OObject/2DTextColored.cpp b/Sources/libewol/ewol/OObject/2DTextColored.cpp index 89f8776e..225886e0 100644 --- a/Sources/libewol/ewol/OObject/2DTextColored.cpp +++ b/Sources/libewol/ewol/OObject/2DTextColored.cpp @@ -24,6 +24,7 @@ #include #include +#include #undef __class__ #define __class__ "ewol::OObject2DTextColored" @@ -80,7 +81,7 @@ void ewol::OObject2DTextColored::Draw(void) return; } glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_FontTextureId); + glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_FontTextureId)); glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays diff --git a/Sources/libewol/ewol/OObject/2DTextColored.h b/Sources/libewol/ewol/OObject/2DTextColored.h index 4bca08ba..5e516fe6 100644 --- a/Sources/libewol/ewol/OObject/2DTextColored.h +++ b/Sources/libewol/ewol/OObject/2DTextColored.h @@ -46,7 +46,7 @@ namespace ewol { protected: int32_t m_FontId; //!< font internal ID color_ts m_color; //!< tmp text color ... - uint32_t m_FontTextureId; //!< font internal Texture ID + int32_t m_FontTextureId; //!< font internal Texture ID etk::VectorType m_coord; //!< internal coord of the object etk::VectorType m_coordTex; //!< internal texture coordinate for every point etk::VectorType m_coordColor; //!< internal color of the different point diff --git a/Sources/libewol/ewol/OObject/2DTextured.cpp b/Sources/libewol/ewol/OObject/2DTextured.cpp index d3514558..6c740381 100644 --- a/Sources/libewol/ewol/OObject/2DTextured.cpp +++ b/Sources/libewol/ewol/OObject/2DTextured.cpp @@ -51,7 +51,7 @@ void ewol::OObject2DTextured::Draw(void) glColor4f(1.0, 1.0, 1.0, 1.0); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_textureId); + glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_textureId)); glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] ); diff --git a/Sources/libewol/ewol/OObject/2DTextured.h b/Sources/libewol/ewol/OObject/2DTextured.h index a2cb8e8f..6efb4478 100644 --- a/Sources/libewol/ewol/OObject/2DTextured.h +++ b/Sources/libewol/ewol/OObject/2DTextured.h @@ -37,7 +37,7 @@ namespace ewol { virtual void Draw(void); void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t texX=0.0, etkFloat_t texY=0.0, etkFloat_t texSX=1.0, etkFloat_t texSY=1.0); protected: - uint32_t m_textureId; //!< texture internal ID + int32_t m_textureId; //!< texture internal ID etk::VectorType m_coord; //!< internal coord of the object etk::VectorType m_coordTex; //!< internal texture coordinate for every point public: diff --git a/Sources/libewol/ewol/Widget.h b/Sources/libewol/ewol/Widget.h index 4ea82bbb..86950bce 100644 --- a/Sources/libewol/ewol/Widget.h +++ b/Sources/libewol/ewol/Widget.h @@ -189,12 +189,12 @@ namespace ewol { void SetOrigin(etkFloat_t x, etkFloat_t y) { m_origin.x=x; m_origin.y=y; }; coord GetOrigin(void) { return m_origin; }; virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... - //update the min Size ... and the expend parameters for the sizer + //update the min Size ... and the expend parameters for the sizer virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; return true; }; virtual void SetMinSize(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; }; coord GetMinSize(void) { return m_minSize; }; coord GetSize(void) { return m_size; }; - void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; }; + void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; MarkToReedraw();}; coord GetCurrentSize(void) { return m_size; }; virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; }; virtual bool CanExpentX(void) { return m_userExpendX; }; diff --git a/Sources/libewol/ewol/WidgetMessageMultiCast.cpp b/Sources/libewol/ewol/WidgetMessageMultiCast.cpp index 7765bb66..fdc40ec0 100644 --- a/Sources/libewol/ewol/WidgetMessageMultiCast.cpp +++ b/Sources/libewol/ewol/WidgetMessageMultiCast.cpp @@ -58,6 +58,7 @@ void ewol::widgetMessageMultiCast::Add(int32_t widgetId, const char* const messa tmpMessage.widgetId = widgetId; tmpMessage.message = message; m_messageList.PushBack(tmpMessage); + EWOL_DEBUG("SendMulticast ADD listener :" << widgetId << " on \"" << message << "\"" ); } // TODO : Do this better ... @@ -65,7 +66,8 @@ void ewol::widgetMessageMultiCast::Rm(int32_t widgetId) { // send the message at all registered widget ... for (int32_t iii=0; iiiGenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)x, (etkFloat_t)y); } } diff --git a/Sources/libewol/ewol/base/guiX11.cpp b/Sources/libewol/ewol/base/guiX11.cpp index 753ad99e..bdd83fc4 100644 --- a/Sources/libewol/ewol/base/guiX11.cpp +++ b/Sources/libewol/ewol/base/guiX11.cpp @@ -103,24 +103,24 @@ extern "C" { } // for double and triple click selection, we need to save the previous click up and down position , and the previous time ... -int32_t m_previousBouttonId; -int32_t m_previousDown_x; -int32_t m_previousDown_y; -int32_t m_previous_x; -int32_t m_previous_y; -int64_t m_previousTime; -bool m_previousDouble; +int32_t m_previousBouttonId = -1; +int32_t m_previousDown_x = 0; +int32_t m_previousDown_y = 0; +int32_t m_previous_x = 0; +int32_t m_previous_y = 0; +int64_t m_previousTime = 0; +bool m_previousDouble = 0; Atom m_delAtom; -Display * m_display; +Display * m_display = NULL;; Window WindowHandle; -int32_t m_originX; -int32_t m_originY; -int32_t m_cursorEventX; -int32_t m_cursorEventY; -XVisualInfo * m_visual; -bool m_doubleBuffered; -bool m_run; +int32_t m_originX = 0; +int32_t m_originY = 0; +int32_t m_cursorEventX = 0; +int32_t m_cursorEventY = 0; +XVisualInfo * m_visual = NULL; +bool m_doubleBuffered = 0; +bool m_run = 0; extern ewol::Windows* gui_uniqueWindows; extern etkFloat_t gui_width; extern etkFloat_t gui_height; @@ -369,9 +369,11 @@ void X11_Run(void) { // main cycle while(true == m_run) { + //EWOL_ERROR("plop1"); XEvent event; // main X boucle : while (XPending(m_display)) { + //EWOL_ERROR("plop 22222"); XNextEvent(m_display, &event); switch (event.type) @@ -427,8 +429,8 @@ void X11_Run(void) bool findOne = false; for (int32_t iii=0; iiiSetColor(1.0, 0.0, 0.0, 0.4); + myOObjectsColored->Disc(m_highSpeedStartPos.x, m_highSpeedStartPos.y, 10); + AddOObject(myOObjectsColored, "scolling object"); + } +} bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y) { if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { EWOL_INFO("mouse-event GDK_SCROLL_UP"); - m_originScrooledY -= m_pixelScrolling; - if (m_originScrooledY < 0) { - m_originScrooledY = 0; + m_originScrooled.y -= m_pixelScrolling; + if (m_originScrooled.y < 0) { + m_originScrooled.y = 0; } MarkToReedraw(); return true; } else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { EWOL_INFO("mouse-event GDK_SCROLL_DOWN"); - m_originScrooledY += m_pixelScrolling; + m_originScrooled.y += m_pixelScrolling; + if (m_maxSize.y < m_originScrooled.y) { + m_originScrooled.y = m_maxSize.y; + } + MarkToReedraw(); + return true; + }else if (2 == IdInput) { + x -= m_origin.x; + y -= m_origin.y; + if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { + m_highSpeedMode = ewol::SCROLL_INIT; + m_highSpeedStartPos.x = x; + m_highSpeedStartPos.y = y; + return true; + } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_highSpeedMode = ewol::SCROLL_DISABLE; + MarkToReedraw(); + return true; + } else if (ewol::SCROLL_INIT==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { + // wait that the cursor move more than 10 px to enable it : + if( abs(x - m_highSpeedStartPos.x) > 10 + || abs(y - m_highSpeedStartPos.y) > 10 ) { + // the scrooling can start : + // select the direction : + if (x == m_highSpeedStartPos.x) { + m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; + } else if (y == m_highSpeedStartPos.y) { + m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; + } else { + etkFloat_t coef = (y - m_highSpeedStartPos.y) / (x - m_highSpeedStartPos.x); + if (abs(coef) <= 1 ) { + m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; + } else { + m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; + } + } + if (m_highSpeedMode == ewol::SCROLL_ENABLE_HORIZONTAL) { + m_highSpeedStartPos.x = m_originScrooled.x / m_maxSize.x * m_size.x; + } else { + m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * m_size.y; + } + MarkToReedraw(); + } + return true; + } if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { + m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x); + MarkToReedraw(); + return true; + } if (ewol::SCROLL_ENABLE_VERTICAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { + m_originScrooled.y = (int32_t)(m_maxSize.y * y / m_size.y); + MarkToReedraw(); + return true; + } + } else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) { + m_highSpeedMode = ewol::SCROLL_DISABLE; MarkToReedraw(); return true; } diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.h b/Sources/libewol/ewol/widget/WidgetScrolled.h index 21d7517f..21e36884 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.h +++ b/Sources/libewol/ewol/widget/WidgetScrolled.h @@ -30,19 +30,29 @@ #include namespace ewol { + typedef enum { + SCROLL_DISABLE, + SCROLL_INIT, + SCROLL_ENABLE_HORIZONTAL, + SCROLL_ENABLE_VERTICAL, + }highSpeedMode_te; + class WidgetScrooled :public ewol::Widget { protected: - int32_t m_originScrooledX; - int32_t m_originScrooledY; + coord m_originScrooled; + coord m_maxSize; private: - uint32_t m_pixelScrolling; + etkFloat_t m_pixelScrolling; + coord m_highSpeedStartPos; + highSpeedMode_te m_highSpeedMode; public: WidgetScrooled(void); virtual ~WidgetScrooled(void); + virtual void OnRegenerateDisplay(void); virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y); protected: - void SetScrollingSize(uint32_t nbPixel) { m_pixelScrolling = nbPixel; }; + void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; }; }; };