diff --git a/Sources/libewol/ewol/Widget.cpp b/Sources/libewol/ewol/Widget.cpp index 7e30e395..938c8d19 100644 --- a/Sources/libewol/ewol/Widget.cpp +++ b/Sources/libewol/ewol/Widget.cpp @@ -75,6 +75,11 @@ char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type) #undef __class__ #define __class__ "Widget" +/** + * @brief Constructor of the widget classes + * @param --- + * @return (no execption generated (not managed in embended platform)) + */ ewol::Widget::Widget(void) { m_needRegenerateDisplay = true; @@ -98,12 +103,14 @@ ewol::Widget::Widget(void) m_hasFocus = false; } -ewol::Widget::~Widget(void) -{ - //ewol::widgetMessageMultiCast::Rm(GetWidgetId()); -} - +/** + * @brief This will be equivalent at the destructor @ref ~Widget + * @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user. + * @note All the EObject are inform that an other EObject is removed ... @ref ewol::EObject + * @param --- + * @return --- + */ void ewol::Widget::MarkToRemove(void) { // Remove his own focus... @@ -113,6 +120,13 @@ void ewol::Widget::MarkToRemove(void) } +/** + * @brief Parrent set the possible diplay size of the current widget whith his own possibilities + * 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 --- + */ bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) { m_size.x = availlableX; @@ -122,23 +136,6 @@ bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) } -/** - * @brief Get the widget at the specific windows absolute position - * @param[in] pos gAbsolute position of the requested widget knowledge - * @return NULL No widget found - * @return pointer on the widget found - */ -ewol::Widget * ewol::Widget::GetWidgetAtPos(coord2D_ts pos) -{ - return this; -} - - -bool ewol::Widget::GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue) -{ - return false; -} - /** * @brief Event generated to inform a flip-flop has occured on the current widget * @param --- @@ -160,8 +157,11 @@ void ewol::Widget::OnFlipFlopEvent(void) } - - +/** + * @brief Set focus on this widget + * @param --- + * @return return true if the widget keep the focus + */ bool ewol::Widget::SetFocus(void) { if (true == m_canFocus) { @@ -172,6 +172,12 @@ bool ewol::Widget::SetFocus(void) return false; } + +/** + * @brief Remove the focus on this widget + * @param --- + * @return return true if the widget have release his focus (if he has it) + */ bool ewol::Widget::RmFocus(void) { if (true == m_canFocus) { @@ -182,6 +188,12 @@ bool ewol::Widget::RmFocus(void) return false; } + +/** + * @brief Set the capability to have the focus + * @param[in] canFocusState new focus capability + * @return --- + */ void ewol::Widget::SetCanHaveFocus(bool canFocusState) { m_canFocus = canFocusState; @@ -190,30 +202,31 @@ void ewol::Widget::SetCanHaveFocus(bool canFocusState) } } -//#define TEST_CLIPPING_SIZE (10) -//#define TEST_CLIPPING_SIZE (3) -#define TEST_CLIPPING_SIZE (0) -bool ewol::Widget::GenDraw(void) +/** + * @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...]) + * This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget + * @param --- + * @return --- + */ +void ewol::Widget::GenDraw(void) { glPushMatrix(); - etkFloat_t testSizeX = m_size.x-TEST_CLIPPING_SIZE*2; - etkFloat_t testSizeY = m_size.y-TEST_CLIPPING_SIZE*2; // here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left - glViewport( m_origin.x + TEST_CLIPPING_SIZE, - ewol::GetCurrentHeight() - m_size.y - m_origin.y + TEST_CLIPPING_SIZE, - testSizeX, - testSizeY); + glViewport( m_origin.x, + ewol::GetCurrentHeight() - m_size.y - m_origin.y, + m_size.x, + m_size.y); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrthoEwol(-testSizeX/2, testSizeX/2, testSizeY/2, -testSizeY/2, -1, 1); + glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1); //glOrthoEwol(0., m_size.x, 0., -m_size.y, 1., 20.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(-testSizeX/2, -testSizeY/2, -1.0); - - bool valRet = OnDraw(); + glTranslatef(-m_size.x/2, -m_size.y/2, -1.0); + // Call the widget drawing methode + OnDraw(); glPopMatrix(); - return valRet; + return; } diff --git a/Sources/libewol/ewol/Widget.h b/Sources/libewol/ewol/Widget.h index af285e78..6c786433 100644 --- a/Sources/libewol/ewol/Widget.h +++ b/Sources/libewol/ewol/Widget.h @@ -96,21 +96,35 @@ namespace ewol { char* GetCharTypeMoveEvent(eventKbMoveType_te type); - typedef struct { - coord2D_ts abs; - coord2D_ts local; - } eventPosition_ts; - - class Widget : public EObject { 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 + * @note Use must never call this directly, when he will remove a widget he must call @ref MarkToRemove. This restriction is due to + * the internal system (one thread processing data, maybe one to regenerate the display(later) and one tha drawing on openGL) + * then when user want to remove a widget, it must be stored in the current pipe-line of ewol ... + * @param --- + * @return --- + */ // TODO : Set this in private if possible ... - virtual ~Widget(void); - void MarkToRemove(void); + virtual ~Widget(void) { }; + /** + * @brief This will be equivalent at the destructor @ref ~Widget + * @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user. + * @note All the EObject are inform that an other EObject is removed ... @ref ewol::EObject + * @param --- + * @return --- + */ + void MarkToRemove(void); // ---------------------------------------------------------------------------------------------------------------- // -- Widget Size: // ---------------------------------------------------------------------------------------------------------------- @@ -126,25 +140,111 @@ namespace ewol { bool m_userFillX; bool m_userFillY; public: - void SetOrigin(etkFloat_t x, etkFloat_t y) { m_origin.x=x; m_origin.y=y;}; - coord2D_ts GetOrigin(void) { return m_origin; }; - coord2D_ts RelativePosition(coord2D_ts pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; }; - virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... + /** + * @brief Set origin at the widget (must be an parrent widget that set this parameter). + * 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(etkFloat_t x, etkFloat_t y) { m_origin.x=x; m_origin.y=y;}; + /** + * @brief Get the origin (obsolute position in the windows) + * @param --- + * @return coordonate of the origin requested + */ + coord2D_ts GetOrigin(void) { return m_origin; }; + /** + * @brief Convert the absolute position in the local Position (Relative) + * @param[in] pos Absolute position that you request convertion + * @return the relative position + */ + coord2D_ts RelativePosition(coord2D_ts pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; }; + /** + * @brief Parrent set the possible diplay size of the current widget whith his own possibilities + * 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() + 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 - virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; MarkToReedraw(); return true; }; - virtual void SetMinSize(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; }; - coord2D_ts GetMinSize(void) { return m_minSize; }; - coord2D_ts GetSize(void) { return m_size; }; - void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; MarkToReedraw();}; - coord2D_ts GetCurrentSize(void) { return m_size; }; - virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; }; - virtual bool CanExpentX(void) { return m_userExpendX; }; - virtual void SetExpendY(bool newExpend=false) { m_userExpendY = newExpend; }; - virtual bool CanExpentY(void) { return m_userExpendY; }; - virtual void SetFillX(bool newFill=false) { m_userFillX = newFill; }; - bool CanFillX(void) { return m_userFillX; }; - virtual void SetFillY(bool newFill=false) { m_userFillY = newFill; }; - bool CanFillY(void) { return m_userFillY; }; + /** + * @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) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; MarkToReedraw(); return true; }; + /** + * @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(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; }; + /** + * @brief Get the current calculated min size + * @param --- + * @return re size requested + */ + coord2D_ts GetMinSize(void) { return m_minSize; }; + /** + * @brief Get the widget size + * @param --- + * @return Requested size + */ + coord2D_ts GetSize(void) { return m_size; }; + /** + * @brief Set the horizontal expend capacity + * @param[in] newExpend new Expend state + * @return --- + */ + virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; }; + /** + * @brief Get the horizontal expend capabilities + * @param --- + * @return boolean repensent the capacity to expend + */ + virtual bool CanExpentX(void) { return m_userExpendX; }; + /** + * @brief Set the vertical expend capacity + * @param[in] newExpend new Expend state + * @return --- + */ + virtual void SetExpendY(bool newExpend=false) { m_userExpendY = newExpend; }; + /** + * @brief Get the vertical expend capabilities + * @param --- + * @return boolean repensent the capacity to expend + */ + virtual bool CanExpentY(void) { return m_userExpendY; }; + /** + * @brief Set the horizontal filling capacity + * @param[in] newFill new fill state + * @return --- + */ + virtual void SetFillX(bool newFill=false) { m_userFillX = newFill; }; + /** + * @brief Get the horizontal filling capabilities + * @param --- + * @return boolean repensent the capacity to horizontal filling + */ + bool CanFillX(void) { return m_userFillX; }; + /** + * @brief Set the vertical filling capacity + * @param[in] newFill new fill state + * @return --- + */ + virtual void SetFillY(bool newFill=false) { m_userFillY = newFill; }; + /** + * @brief Get the vertical filling capabilities + * @param --- + * @return boolean repensent the capacity to vertical filling + */ + bool CanFillY(void) { return m_userFillY; }; // ---------------------------------------------------------------------------------------------------------------- // -- Focus Area @@ -153,13 +253,48 @@ namespace ewol { bool m_hasFocus; //!< set the focus on this widget bool m_canFocus; //!< the focus can be done on this widget public: - bool GetFocus(void) { return m_hasFocus;}; - bool CanHaveFocus(void) { return m_canFocus;}; - bool SetFocus(void); - bool RmFocus(void); - void SetCanHaveFocus(bool canFocusState); + /** + * @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); 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) {}; public: @@ -169,22 +304,40 @@ namespace ewol { * @return NULL No widget found * @return pointer on the widget found */ - virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos); - virtual bool GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue); + virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos) { return this; }; /** - * @brief Manage input event of this Widget + * @brief Event on an input of this Widget * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... - * @param[in] pos Relative and absolute position + * @param[in] pos Absolute position of the event * @return true the event is used * @return false the event is not used */ - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) { return false; }; - // ---------------------------------------------------------------------------------------------------------------- - // -- Keboard event (when one is present or when a graphical is present - // ---------------------------------------------------------------------------------------------------------------- - public: + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { return false; }; + /** + * @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb) + * @param[in] shift The key Shift (left or/and right) is pressed (if true) + * @param[in] control The key control (left or/and right) is pressed (if true) + * @param[in] alt The key Alt is pressed (if true) + * @param[in] meta The key Meta (windows key/Apple key) (left or/and right) is pressed (if true) + * @param[in] unicodeValue key pressed by the user + * @return true if the event has been used + * @return false if the event has not been used + */ + virtual bool OnEventShortCut(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue) { return false; }; + /** + * @brief Event on the keybord (if no shortcut has been detected before). + * @param[in] type of the event (ewol::EVENT_KB_TYPE_DOWN or ewol::EVENT_KB_TYPE_UP) + * @param[in] unicodeValue key pressed by the user + * @return true if the event has been used + * @return false if the event has not been used + */ virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData) { return false; }; + /** + * @brief Event on the keyboard that is not a printable key (if no shortcut has been detected before). + * @return true if the event has been used + * @return false if the event has not been used + */ virtual bool OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te moveTypeEvent) { return false; }; // ---------------------------------------------------------------------------------------------------------------- @@ -195,8 +348,19 @@ namespace ewol { int8_t m_currentCreateId; //!< Id of the element might be modify bool m_needFlipFlop; //!< A flip flop need to be done bool m_needRegenerateDisplay; //!< the display might be done the next regeneration - void MarkToReedraw(void) { m_needRegenerateDisplay = true; }; - bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; }; + /** + * @brief The widget mark itself that it need to regenerate the nest time. + * @param --- + * @return --- + */ + void MarkToReedraw(void) { m_needRegenerateDisplay = true; }; + /** + * @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 + */ + bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; }; public: /** * @brief Event generated to inform a flip-flop has occured on the current widget @@ -205,13 +369,29 @@ namespace ewol { */ virtual void OnFlipFlopEvent(void); public: - bool GenDraw(void); + /** + * @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...]) + * This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget + * @param --- + * @return --- + */ + void GenDraw(void); protected: - virtual bool OnDraw(void) { return true; }; + /** + * @brief Common widget drawing function (called by the drawing thread [Android, X11, ...]) + * @param --- + * @return --- + */ + virtual void OnDraw(void) { }; public: - virtual void OnRegenerateDisplay(void) { /* nothing to do */ }; + /** + * @brief Event generated when a redraw is needed + * @param --- + * @return --- + */ + virtual void OnRegenerateDisplay(void) { }; }; // end of the class Widget declaration -};// end of nameSpace +};// end of namespace #endif diff --git a/Sources/libewol/ewol/Windows.cpp b/Sources/libewol/ewol/Windows.cpp index f545ce8d..b551f932 100644 --- a/Sources/libewol/ewol/Windows.cpp +++ b/Sources/libewol/ewol/Windows.cpp @@ -135,30 +135,6 @@ ewol::Widget * ewol::Windows::GetWidgetAtPos(coord2D_ts pos) return this; } -bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) -{ -/* - if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) { - coord2D_ts tmpSize = m_keyBoardwidget->GetMinSize(); - if (pos.local.y > m_size.y - tmpSize.y) { - m_keyBoardwidget->GenEventInput(IdInput, typeEvent, pos.abs); - return true; - } - } - // event go directly on the pop-up - if (0 < m_popUpWidgetList[m_currentCreateId].Size()) { - if (NULL == m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]) { - m_popUpWidgetList[m_currentCreateId].PopBack(); - } else { - m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]->GenEventInput(IdInput, typeEvent, pos.abs); - } - // otherwise in the normal windows - } else if (NULL != m_subWidget[m_currentCreateId]) { - m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, pos.abs); - } -*/ - return true; -} void ewol::Windows::SysDraw(void) { @@ -208,7 +184,7 @@ void ewol::Windows::OnRegenerateDisplay(void) } -bool ewol::Windows::OnDraw(void) +void ewol::Windows::OnDraw(void) { // Clear the screen with transparency ... @@ -232,7 +208,6 @@ bool ewol::Windows::OnDraw(void) m_keyBoardwidget->GenDraw(); //EWOL_DEBUG("Draw kewboard"); } - return true; } diff --git a/Sources/libewol/ewol/Windows.h b/Sources/libewol/ewol/Windows.h index 933105ef..f26d8325 100644 --- a/Sources/libewol/ewol/Windows.h +++ b/Sources/libewol/ewol/Windows.h @@ -59,7 +59,6 @@ namespace ewol { * @return pointer on the widget found */ virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos); - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); private: bool m_hasDecoration; public: @@ -81,7 +80,7 @@ namespace ewol { void SetSubWidget(ewol::Widget * widget); void PopUpWidgetPush(ewol::Widget * widget); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); public: virtual void OnRegenerateDisplay(void); public: diff --git a/Sources/libewol/ewol/base/eventInputManagement.cpp b/Sources/libewol/ewol/base/eventInputManagement.cpp index 1ceea2f4..74c8b82e 100644 --- a/Sources/libewol/ewol/base/eventInputManagement.cpp +++ b/Sources/libewol/ewol/base/eventInputManagement.cpp @@ -100,10 +100,7 @@ extern ewol::Windows* gui_uniqueWindows; static bool localEventInput(ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos) { if (NULL != destWidget) { - ewol::eventPosition_ts tmpEventPosition; - tmpEventPosition.abs = pos; - tmpEventPosition.local = destWidget->RelativePosition(pos); - return destWidget->OnEventInput(IdInput, typeEvent, tmpEventPosition); + return destWidget->OnEventInput(IdInput, typeEvent, pos); } return false; } diff --git a/Sources/libewol/ewol/widget/Button.cpp b/Sources/libewol/ewol/widget/Button.cpp index faa40805..33e63e3b 100644 --- a/Sources/libewol/ewol/widget/Button.cpp +++ b/Sources/libewol/ewol/widget/Button.cpp @@ -183,8 +183,15 @@ void ewol::Button::OnRegenerateDisplay(void) } } - -bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_DEBUG("Event on BT ..."); if (1 == IdInput) { diff --git a/Sources/libewol/ewol/widget/Button.h b/Sources/libewol/ewol/widget/Button.h index fbb4ccc1..b8443d8a 100644 --- a/Sources/libewol/ewol/widget/Button.h +++ b/Sources/libewol/ewol/widget/Button.h @@ -61,7 +61,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData); }; }; diff --git a/Sources/libewol/ewol/widget/ButtonColor.cpp b/Sources/libewol/ewol/widget/ButtonColor.cpp index 1a349708..f21348fc 100644 --- a/Sources/libewol/ewol/widget/ButtonColor.cpp +++ b/Sources/libewol/ewol/widget/ButtonColor.cpp @@ -190,8 +190,15 @@ void ewol::ButtonColor::OnRegenerateDisplay(void) } } - -bool ewol::ButtonColor::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::ButtonColor::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_DEBUG("Event on BT ..."); if (1 == IdInput) { diff --git a/Sources/libewol/ewol/widget/ButtonColor.h b/Sources/libewol/ewol/widget/ButtonColor.h index 63475317..2c1f0997 100644 --- a/Sources/libewol/ewol/widget/ButtonColor.h +++ b/Sources/libewol/ewol/widget/ButtonColor.h @@ -59,7 +59,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); color_ts GetCurrentColor(void) { return m_selectedColor; }; void SetCurrentColor(color_ts color); /** diff --git a/Sources/libewol/ewol/widget/CheckBox.cpp b/Sources/libewol/ewol/widget/CheckBox.cpp index cd1faeac..1e2ff3cf 100644 --- a/Sources/libewol/ewol/widget/CheckBox.cpp +++ b/Sources/libewol/ewol/widget/CheckBox.cpp @@ -147,8 +147,15 @@ void ewol::CheckBox::OnRegenerateDisplay(void) } } - -bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_DEBUG("Event on checkbox ..."); if (1 == IdInput) { diff --git a/Sources/libewol/ewol/widget/CheckBox.h b/Sources/libewol/ewol/widget/CheckBox.h index 2db35059..2f1d0d5c 100644 --- a/Sources/libewol/ewol/widget/CheckBox.h +++ b/Sources/libewol/ewol/widget/CheckBox.h @@ -51,7 +51,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData); }; }; diff --git a/Sources/libewol/ewol/widget/ColorBar.cpp b/Sources/libewol/ewol/widget/ColorBar.cpp index c3997d8e..59d5c589 100644 --- a/Sources/libewol/ewol/widget/ColorBar.cpp +++ b/Sources/libewol/ewol/widget/ColorBar.cpp @@ -210,27 +210,35 @@ void ewol::ColorBar::OnRegenerateDisplay(void) } } - -bool ewol::ColorBar::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::ColorBar::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { + coord2D_ts relativePos = RelativePosition(pos); //EWOL_DEBUG("Event on BT ..."); if (1 == IdInput) { - pos.local.x = etk_max(etk_min(pos.local.x, m_size.x),0); - pos.local.y = etk_max(etk_min(pos.local.y, m_size.y),0); + relativePos.x = etk_max(etk_min(relativePos.x, m_size.x),0); + relativePos.y = etk_max(etk_min(relativePos.y, m_size.y),0); if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent || ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent || ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent || ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { // nothing to do ... - m_currentUserPos.x=pos.local.x/m_size.x; - m_currentUserPos.y=pos.local.y/m_size.y; + m_currentUserPos.x=relativePos.x/m_size.x; + m_currentUserPos.y=relativePos.y/m_size.y; MarkToReedraw(); //==> try to estimate color - EWOL_VERBOSE("event on (" << pos.local.x << "," << pos.local.y << ")"); - int32_t bandID = (int32_t)(pos.local.x/(m_size.x/6)); - etkFloat_t relativePos = pos.local.x - (m_size.x/6) * bandID; - etkFloat_t poroportionnalPos = relativePos/(m_size.x/6); - EWOL_VERBOSE("bandId=" << bandID << " relative pos=" << relativePos); + EWOL_VERBOSE("event on (" << relativePos.x << "," << relativePos.y << ")"); + int32_t bandID = (int32_t)(relativePos.x/(m_size.x/6)); + etkFloat_t localPos = relativePos.x - (m_size.x/6) * bandID; + etkFloat_t poroportionnalPos = localPos/(m_size.x/6); + EWOL_VERBOSE("bandId=" << bandID << " relative pos=" << localPos); color_ts estimateColor; estimateColor.alpha = 1.0; if (s_listColor[bandID].red == s_listColor[bandID+1].red) { @@ -255,15 +263,15 @@ bool ewol::ColorBar::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, estimateColor.blue = s_listColor[bandID+1].blue + (s_listColor[bandID].blue-s_listColor[bandID+1].blue)*(1-poroportionnalPos); } // step 2 generate the white and black ... - if (pos.local.y == (m_size.y/2)) { + if (relativePos.y == (m_size.y/2)) { // nothing to do ... just get the current color ... - } else if (pos.local.y < (m_size.y/2)) { - etkFloat_t poroportionnalWhite = 1.0-pos.local.y/(m_size.y/2); + } else if (relativePos.y < (m_size.y/2)) { + etkFloat_t poroportionnalWhite = 1.0-relativePos.y/(m_size.y/2); estimateColor.red = estimateColor.red + (1.0 - estimateColor.red )*poroportionnalWhite; estimateColor.green = estimateColor.green + (1.0 - estimateColor.green)*poroportionnalWhite; estimateColor.blue = estimateColor.blue + (1.0 - estimateColor.blue )*poroportionnalWhite; } else { - etkFloat_t poroportionnalBlack = (pos.local.y-(m_size.y/2))/(m_size.y/2); + etkFloat_t poroportionnalBlack = (relativePos.y-(m_size.y/2))/(m_size.y/2); estimateColor.red = estimateColor.red - (estimateColor.red )*poroportionnalBlack; estimateColor.green = estimateColor.green - (estimateColor.green)*poroportionnalBlack; estimateColor.blue = estimateColor.blue - (estimateColor.blue )*poroportionnalBlack; diff --git a/Sources/libewol/ewol/widget/ColorBar.h b/Sources/libewol/ewol/widget/ColorBar.h index a4f8e404..9977c3cf 100644 --- a/Sources/libewol/ewol/widget/ColorBar.h +++ b/Sources/libewol/ewol/widget/ColorBar.h @@ -47,7 +47,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; }; diff --git a/Sources/libewol/ewol/widget/ContextMenu.cpp b/Sources/libewol/ewol/widget/ContextMenu.cpp index 6da21c89..e04b7a71 100644 --- a/Sources/libewol/ewol/widget/ContextMenu.cpp +++ b/Sources/libewol/ewol/widget/ContextMenu.cpp @@ -187,14 +187,13 @@ void ewol::ContextMenu::SubWidgetRemove(void) } } -bool ewol::ContextMenu::OnDraw(void) +void ewol::ContextMenu::OnDraw(void) { //EWOL_DEBUG("On Draw " << m_currentDrawId); ewol::Drawable::OnDraw(); if (NULL != m_subWidget[m_currentDrawId]) { m_subWidget[m_currentDrawId]->GenDraw(); } - return true; } @@ -282,14 +281,14 @@ ewol::Widget * ewol::ContextMenu::GetWidgetAtPos(coord2D_ts pos) } /** - * @brief Manage input event of this Widget + * @brief Event on an input of this Widget * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... - * @param[in] pos Relative and absolute position + * @param[in] pos Absolute position of the event * @return true the event is used * @return false the event is not used */ -bool ewol::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +bool ewol::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_INFO("Event ouside the context menu"); if (IdInput > 0) { diff --git a/Sources/libewol/ewol/widget/ContextMenu.h b/Sources/libewol/ewol/widget/ContextMenu.h index 99c2ad2b..2fc400e9 100644 --- a/Sources/libewol/ewol/widget/ContextMenu.h +++ b/Sources/libewol/ewol/widget/ContextMenu.h @@ -62,7 +62,7 @@ namespace ewol { void SubWidgetRemove(void); void SetPositionMark(markPosition_te position, coord2D_ts arrowPos); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); public: virtual void OnRegenerateDisplay(void); public: @@ -73,7 +73,15 @@ namespace ewol { * @return pointer on the widget found */ virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos); - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); /** * @brief Event generated to inform a flip-flop has occured on the current widget * @param --- diff --git a/Sources/libewol/ewol/widget/Drawable.cpp b/Sources/libewol/ewol/widget/Drawable.cpp index ea2d8373..6ad7c407 100644 --- a/Sources/libewol/ewol/widget/Drawable.cpp +++ b/Sources/libewol/ewol/widget/Drawable.cpp @@ -67,14 +67,13 @@ void ewol::Drawable::ClearOObjectList(void) m_listOObject[m_currentCreateId].Clear(); } -bool ewol::Drawable::OnDraw(void) +void ewol::Drawable::OnDraw(void) { for (int32_t iii=0; iiiDraw(); } } - return true; } diff --git a/Sources/libewol/ewol/widget/Drawable.h b/Sources/libewol/ewol/widget/Drawable.h index d36ee0f8..fcd43127 100644 --- a/Sources/libewol/ewol/widget/Drawable.h +++ b/Sources/libewol/ewol/widget/Drawable.h @@ -41,7 +41,7 @@ namespace ewol { void AddOObject(ewol::OObject* newObject, int32_t pos=-1); void ClearOObjectList(void); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); }; }; diff --git a/Sources/libewol/ewol/widget/Entry.cpp b/Sources/libewol/ewol/widget/Entry.cpp index 8d255eb8..c7f15d8b 100644 --- a/Sources/libewol/ewol/widget/Entry.cpp +++ b/Sources/libewol/ewol/widget/Entry.cpp @@ -170,8 +170,15 @@ void ewol::Entry::OnRegenerateDisplay(void) } } - -bool ewol::Entry::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::Entry::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_DEBUG("Event on Entry ..."); if (1 == IdInput) { diff --git a/Sources/libewol/ewol/widget/Entry.h b/Sources/libewol/ewol/widget/Entry.h index f3b47090..c739f3aa 100644 --- a/Sources/libewol/ewol/widget/Entry.h +++ b/Sources/libewol/ewol/widget/Entry.h @@ -62,7 +62,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData); protected: virtual void OnGetFocus(void); diff --git a/Sources/libewol/ewol/widget/Label.cpp b/Sources/libewol/ewol/widget/Label.cpp index 34460f40..175dd377 100644 --- a/Sources/libewol/ewol/widget/Label.cpp +++ b/Sources/libewol/ewol/widget/Label.cpp @@ -119,8 +119,15 @@ void ewol::Label::OnRegenerateDisplay(void) } } - -bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_DEBUG("Event on Label ..."); if (1 == IdInput) { diff --git a/Sources/libewol/ewol/widget/Label.h b/Sources/libewol/ewol/widget/Label.h index 21af5c0d..22b11569 100644 --- a/Sources/libewol/ewol/widget/Label.h +++ b/Sources/libewol/ewol/widget/Label.h @@ -47,7 +47,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; }; diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 00451929..2587f6fa 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -98,14 +98,13 @@ void ewol::List::ClearOObjectList(void) m_listOObject[m_currentCreateId].Clear(); } -bool ewol::List::OnDraw(void) +void ewol::List::OnDraw(void) { for (int32_t iii=0; iiiDraw(); } } - return true; } @@ -197,9 +196,17 @@ void ewol::List::OnRegenerateDisplay(void) } } - -bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { + coord2D_ts relativePos = RelativePosition(pos); if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, pos)) { ewol::widgetManager::FocusKeep(this); // nothing to do ... done on upper widet ... @@ -209,9 +216,9 @@ bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, even //int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str()); int32_t minHeight = ewol::GetHeight(fontId); - int32_t rawID = (pos.local.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY); + int32_t rawID = (relativePos.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY); //EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");"); - bool isUsed = OnItemEvent(IdInput, typeEvent, 0, rawID, pos.local.x, pos.local.y); + bool isUsed = OnItemEvent(IdInput, typeEvent, 0, rawID, pos.x, pos.y); if (true == isUsed) { // TODO : this generate bugs ... I did not understand why .. //ewol::widgetManager::FocusKeep(this); diff --git a/Sources/libewol/ewol/widget/List.h b/Sources/libewol/ewol/widget/List.h index 69fd293d..f782a0e2 100644 --- a/Sources/libewol/ewol/widget/List.h +++ b/Sources/libewol/ewol/widget/List.h @@ -46,7 +46,7 @@ namespace ewol { void AddOObject(ewol::OObject* newObject, int32_t pos=-1); void ClearOObjectList(void); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); // list properties ... private: int32_t m_paddingSizeX; @@ -55,7 +55,15 @@ namespace ewol { int32_t m_displayCurrentNbLine; //!< Number of line in the display public: virtual void OnRegenerateDisplay(void); - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); protected: // function call to display the list : virtual color_ts GetBasicBG(void) { diff --git a/Sources/libewol/ewol/widget/PopUp.cpp b/Sources/libewol/ewol/widget/PopUp.cpp index 41084172..ac2f189d 100644 --- a/Sources/libewol/ewol/widget/PopUp.cpp +++ b/Sources/libewol/ewol/widget/PopUp.cpp @@ -144,14 +144,13 @@ void ewol::PopUp::SubWidgetRemove(void) MarkToReedraw(); } -bool ewol::PopUp::OnDraw(void) +void ewol::PopUp::OnDraw(void) { // draw upper classes ewol::Drawable::OnDraw(); if (NULL != m_subWidget[m_currentDrawId]) { m_subWidget[m_currentDrawId]->GenDraw(); } - return true; } diff --git a/Sources/libewol/ewol/widget/PopUp.h b/Sources/libewol/ewol/widget/PopUp.h index 082dfffc..0f316dcc 100644 --- a/Sources/libewol/ewol/widget/PopUp.h +++ b/Sources/libewol/ewol/widget/PopUp.h @@ -52,7 +52,7 @@ namespace ewol { void SubWidgetSet(ewol::Widget* newWidget); void SubWidgetRemove(void); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); public: virtual void OnRegenerateDisplay(void); public: diff --git a/Sources/libewol/ewol/widget/SizerHori.cpp b/Sources/libewol/ewol/widget/SizerHori.cpp index 1dfb3c98..6720c942 100644 --- a/Sources/libewol/ewol/widget/SizerHori.cpp +++ b/Sources/libewol/ewol/widget/SizerHori.cpp @@ -213,14 +213,13 @@ void ewol::SizerHori::SubWidgetUnLink(ewol::Widget* newWidget) } -bool ewol::SizerHori::OnDraw(void) +void ewol::SizerHori::OnDraw(void) { for (int32_t iii=0; iiiGenDraw(); } } - return true; } diff --git a/Sources/libewol/ewol/widget/SizerHori.h b/Sources/libewol/ewol/widget/SizerHori.h index d72a3d14..9479f903 100644 --- a/Sources/libewol/ewol/widget/SizerHori.h +++ b/Sources/libewol/ewol/widget/SizerHori.h @@ -53,7 +53,7 @@ namespace ewol { virtual void SubWidgetRemove(ewol::Widget* newWidget); virtual void SubWidgetUnLink(ewol::Widget* newWidget); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); public: virtual void OnRegenerateDisplay(void); /** diff --git a/Sources/libewol/ewol/widget/SizerVert.cpp b/Sources/libewol/ewol/widget/SizerVert.cpp index 11ec7168..2bbee237 100644 --- a/Sources/libewol/ewol/widget/SizerVert.cpp +++ b/Sources/libewol/ewol/widget/SizerVert.cpp @@ -212,14 +212,13 @@ void ewol::SizerVert::SubWidgetUnLink(ewol::Widget* newWidget) } -bool ewol::SizerVert::OnDraw(void) +void ewol::SizerVert::OnDraw(void) { for (int32_t iii=0; iiiGenDraw(); } } - return true; } diff --git a/Sources/libewol/ewol/widget/SizerVert.h b/Sources/libewol/ewol/widget/SizerVert.h index 04de0b1d..f4f2df84 100644 --- a/Sources/libewol/ewol/widget/SizerVert.h +++ b/Sources/libewol/ewol/widget/SizerVert.h @@ -53,7 +53,7 @@ namespace ewol { virtual void SubWidgetRemove(ewol::Widget* newWidget); virtual void SubWidgetUnLink(ewol::Widget* newWidget); protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); public: virtual void OnRegenerateDisplay(void); public: diff --git a/Sources/libewol/ewol/widget/Slider.cpp b/Sources/libewol/ewol/widget/Slider.cpp index 318e00cf..c2d71a6a 100644 --- a/Sources/libewol/ewol/widget/Slider.cpp +++ b/Sources/libewol/ewol/widget/Slider.cpp @@ -121,8 +121,17 @@ void ewol::Slider::OnRegenerateDisplay(void) } -bool ewol::Slider::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::Slider::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { + coord2D_ts relativePos = RelativePosition(pos); //EWOL_DEBUG("Event on Slider ..."); if (1 == IdInput) { if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent @@ -130,8 +139,8 @@ bool ewol::Slider::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, ev || ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent || ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { // get the new position : - EWOL_DEBUG("Event on Slider (" << pos.local.x << "," << pos.local.y << ")"); - m_value = m_min + (etkFloat_t)(pos.local.x - dotRadius) / (etkFloat_t)(m_size.x-2*dotRadius) * (etkFloat_t)(m_max-m_min); + EWOL_DEBUG("Event on Slider (" << relativePos.x << "," << relativePos.y << ")"); + m_value = m_min + (etkFloat_t)(relativePos.x - dotRadius) / (etkFloat_t)(m_size.x-2*dotRadius) * (etkFloat_t)(m_max-m_min); m_value = etk_max(etk_min(m_value, m_max), m_min); EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]"); GenerateEventId(ewolEventSliderChange); diff --git a/Sources/libewol/ewol/widget/Slider.h b/Sources/libewol/ewol/widget/Slider.h index c60f4f24..6197ced4 100644 --- a/Sources/libewol/ewol/widget/Slider.h +++ b/Sources/libewol/ewol/widget/Slider.h @@ -52,7 +52,15 @@ namespace ewol { public: virtual void OnRegenerateDisplay(void); public: - virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; }; diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.cpp b/Sources/libewol/ewol/widget/WidgetScrolled.cpp index 412e1951..5515fd7f 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.cpp +++ b/Sources/libewol/ewol/widget/WidgetScrolled.cpp @@ -65,16 +65,24 @@ void ewol::WidgetScrooled::OnRegenerateDisplay(void) */ #endif } - -bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, eventPosition_ts pos) +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos) { + coord2D_ts relativePos = RelativePosition(pos); #ifdef __MODE__Touch if (1 == IdInput) { EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")"); if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { m_highSpeedMode = ewol::SCROLL_INIT; - m_highSpeedStartPos.x = pos.local.x; - m_highSpeedStartPos.y = pos.local.y; + m_highSpeedStartPos.x = relativePos.x; + m_highSpeedStartPos.y = relativePos.y; EWOL_VERBOSE("SCROOL ==> INIT"); return true; } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { @@ -84,8 +92,8 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te 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(pos.local.x - m_highSpeedStartPos.x) > 10 - || abs(pos.local.y - m_highSpeedStartPos.y) > 10 ) { + if( abs(relativePos.x - m_highSpeedStartPos.x) > 10 + || abs(relativePos.y - m_highSpeedStartPos.y) > 10 ) { // the scrooling can start : // select the direction : m_highSpeedMode = ewol::SCROLL_ENABLE; @@ -95,14 +103,14 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te return true; } if (ewol::SCROLL_ENABLE==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { //m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x); - m_originScrooled.x -= pos.local.x - m_highSpeedStartPos.x; - m_originScrooled.y -= pos.local.y - m_highSpeedStartPos.y; + m_originScrooled.x -= relativePos.x - m_highSpeedStartPos.x; + m_originScrooled.y -= relativePos.y - m_highSpeedStartPos.y; m_originScrooled.x = etk_max(m_originScrooled.x, 0); m_originScrooled.y = etk_max(m_originScrooled.y, 0); m_originScrooled.x = etk_min(m_originScrooled.x, m_maxSize.x); m_originScrooled.y = etk_min(m_originScrooled.y, m_maxSize.y); - m_highSpeedStartPos.x = pos.local.x; - m_highSpeedStartPos.y = pos.local.y; + m_highSpeedStartPos.x = relativePos.x; + m_highSpeedStartPos.y = relativePos.y; EWOL_VERBOSE("SCROOL ==> MOVE (" << m_originScrooled.x << "," << m_originScrooled.y << ")"); MarkToReedraw(); return true; @@ -133,8 +141,8 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te }else if (2 == IdInput) { if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { m_highSpeedMode = ewol::SCROLL_INIT; - m_highSpeedStartPos.x = pos.local.x; - m_highSpeedStartPos.y = pos.local.y; + m_highSpeedStartPos.x = relativePos.x; + m_highSpeedStartPos.y = relativePos.y; return true; } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { m_highSpeedMode = ewol::SCROLL_DISABLE; @@ -142,16 +150,16 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te 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(pos.local.x - m_highSpeedStartPos.x) > 10 - || abs(pos.local.y - m_highSpeedStartPos.y) > 10 ) { + if( abs(relativePos.x - m_highSpeedStartPos.x) > 10 + || abs(relativePos.y - m_highSpeedStartPos.y) > 10 ) { // the scrooling can start : // select the direction : - if (pos.local.x == m_highSpeedStartPos.x) { + if (relativePos.x == m_highSpeedStartPos.x) { m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; - } else if (pos.local.y == m_highSpeedStartPos.y) { + } else if (relativePos.y == m_highSpeedStartPos.y) { m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; } else { - etkFloat_t coef = (pos.local.y - m_highSpeedStartPos.y) / (pos.local.x - m_highSpeedStartPos.x); + etkFloat_t coef = (relativePos.y - m_highSpeedStartPos.y) / (relativePos.x - m_highSpeedStartPos.x); if (abs(coef) <= 1 ) { m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; } else { @@ -167,11 +175,11 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te } return true; } if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { - m_originScrooled.x = (int32_t)(m_maxSize.x * pos.local.x / m_size.x); + m_originScrooled.x = (int32_t)(m_maxSize.x * relativePos.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 * pos.local.y / m_size.y); + m_originScrooled.y = (int32_t)(m_maxSize.y * relativePos.y / m_size.y); MarkToReedraw(); return true; } diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.h b/Sources/libewol/ewol/widget/WidgetScrolled.h index 34c67d45..4c9f4286 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.h +++ b/Sources/libewol/ewol/widget/WidgetScrolled.h @@ -54,7 +54,15 @@ namespace ewol { WidgetScrooled(void); virtual ~WidgetScrooled(void); virtual void OnRegenerateDisplay(void); - virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, eventPosition_ts pos); + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos); protected: void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; }; }; diff --git a/Sources/libewol/ewol/widgetMeta/Keyboard.cpp b/Sources/libewol/ewol/widgetMeta/Keyboard.cpp index f430749d..be215756 100644 --- a/Sources/libewol/ewol/widgetMeta/Keyboard.cpp +++ b/Sources/libewol/ewol/widgetMeta/Keyboard.cpp @@ -284,12 +284,11 @@ bool ewol::Keyboard::CalculateMinSize(void) -bool ewol::Keyboard::OnDraw(void) +void ewol::Keyboard::OnDraw(void) { if (NULL != m_subWidget[m_currentDrawId]) { m_subWidget[m_currentDrawId]->GenDraw(); } - return true; } diff --git a/Sources/libewol/ewol/widgetMeta/Keyboard.h b/Sources/libewol/ewol/widgetMeta/Keyboard.h index bf63b95d..8f76fe08 100644 --- a/Sources/libewol/ewol/widgetMeta/Keyboard.h +++ b/Sources/libewol/ewol/widgetMeta/Keyboard.h @@ -83,7 +83,7 @@ namespace ewol { virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer protected: - virtual bool OnDraw(void); + virtual void OnDraw(void); public: virtual void OnRegenerateDisplay(void); virtual void SetMinSise(etkFloat_t x=-1, etkFloat_t y=-1);