From 2f34ae3f87cb20f1c4c86f26d47b33f64c8970ad Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Tue, 22 May 2012 09:49:55 +0200 Subject: [PATCH] [BREAK compatibility] Change the input event call function and manage touch without flag --- Sources/libewol/ewol/Widget.h | 6 +- .../ewol/base/eventInputManagement.cpp | 45 ++- .../libewol/ewol/base/eventInputManagement.h | 25 +- Sources/libewol/ewol/widget/Button.cpp | 3 +- Sources/libewol/ewol/widget/Button.h | 3 +- Sources/libewol/ewol/widget/ButtonColor.cpp | 3 +- Sources/libewol/ewol/widget/ButtonColor.h | 3 +- Sources/libewol/ewol/widget/CheckBox.cpp | 3 +- Sources/libewol/ewol/widget/CheckBox.h | 3 +- Sources/libewol/ewol/widget/ColorBar.cpp | 3 +- Sources/libewol/ewol/widget/ColorBar.h | 3 +- Sources/libewol/ewol/widget/ContextMenu.cpp | 3 +- Sources/libewol/ewol/widget/ContextMenu.h | 3 +- Sources/libewol/ewol/widget/Entry.cpp | 3 +- Sources/libewol/ewol/widget/Entry.h | 3 +- Sources/libewol/ewol/widget/Image.cpp | 3 +- Sources/libewol/ewol/widget/Image.h | 3 +- Sources/libewol/ewol/widget/Joystick.cpp | 3 +- Sources/libewol/ewol/widget/Joystick.h | 3 +- Sources/libewol/ewol/widget/Label.cpp | 3 +- Sources/libewol/ewol/widget/Label.h | 3 +- Sources/libewol/ewol/widget/List.cpp | 5 +- Sources/libewol/ewol/widget/List.h | 3 +- Sources/libewol/ewol/widget/Slider.cpp | 3 +- Sources/libewol/ewol/widget/Slider.h | 3 +- .../libewol/ewol/widget/WidgetScrolled.cpp | 327 +++++++++--------- Sources/libewol/ewol/widget/WidgetScrolled.h | 29 +- 27 files changed, 286 insertions(+), 214 deletions(-) diff --git a/Sources/libewol/ewol/Widget.h b/Sources/libewol/ewol/Widget.h index ebd43a69..7d33267d 100644 --- a/Sources/libewol/ewol/Widget.h +++ b/Sources/libewol/ewol/Widget.h @@ -34,9 +34,10 @@ namespace ewol { }; #include +#include #include #include -#include +#include namespace ewol { typedef enum { @@ -342,13 +343,14 @@ namespace ewol { virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos) { return this; }; /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) { return false; }; + virtual bool OnEventInput(ewol::inputType_te type, 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) diff --git a/Sources/libewol/ewol/base/eventInputManagement.cpp b/Sources/libewol/ewol/base/eventInputManagement.cpp index d8074a5f..13459003 100644 --- a/Sources/libewol/ewol/base/eventInputManagement.cpp +++ b/Sources/libewol/ewol/base/eventInputManagement.cpp @@ -1,3 +1,27 @@ +/** + ******************************************************************************* + * @file eventInputManagement.cpp + * @brief Input (mouse,finger) abstraction layer (Sources) + * @author Edouard DUPIN + * @date 00/04/2011 + * @par Project + * ewol + * + * @par Copyright + * Copyright 2011 Edouard DUPIN, all right reserved + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY. + * + * Licence summary : + * You can modify and redistribute the sources code and binaries. + * You can send me the bug-fix + * + * Term of the licence in in the file licence.txt. + * + ******************************************************************************* + */ + #include #include @@ -112,29 +136,32 @@ void ewol::eventInput::UnInit(void) extern ewol::Windows* gui_uniqueWindows; +/** + * @brief generate the event on the destinated widger + * @param[in] type Type of the event that might be sended + * @param[in] destWidget Pointer on the requested widget that element might be sended + * @param[in] IdInput Id of the event (PC : [0..9] and touch : [1..9]) + * @param[in] typeEvent type of the eventg generated + * @param[in] pos position of the event + * @return true if event has been greped + */ static bool localEventInput(ewol::inputType_te type, ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos) { if (NULL != destWidget) { - if (type == ewol::INPUT_TYPE_MOUSE) { - return destWidget->OnEventInput(IdInput, typeEvent, pos); - } else if (type == ewol::INPUT_TYPE_FINGER) { - return destWidget->OnEventInput(-1*IdInput, typeEvent, pos); + if (type == ewol::INPUT_TYPE_MOUSE || type == ewol::INPUT_TYPE_FINGER) { + return destWidget->OnEventInput(type, IdInput, typeEvent, pos); } else { return false; } - } return false; } /** * @brief Convert the system event id in the correct EWOL id depending of the system management mode - * * This function find the next input id unused on the specifiic widget ==> on PC, the ID does not change (IHM is not the same - * * @param[in] destWidget Pointer of the widget destination * @param[in] realInputId System Id - * * @return the ewol input id */ static int32_t localGetDestinationId(ewol::inputType_te type, ewol::Widget* destWidget, int32_t realInputId) @@ -187,7 +214,7 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, coord2D_ts destWidget = gui_uniqueWindows->GetWidgetAtPos(pos); } if (NULL != destWidget) { - destWidget->OnEventInput(0, ewol::EVENT_INPUT_TYPE_MOVE, pos); + destWidget->OnEventInput(type, 0, ewol::EVENT_INPUT_TYPE_MOVE, pos); } return; } diff --git a/Sources/libewol/ewol/base/eventInputManagement.h b/Sources/libewol/ewol/base/eventInputManagement.h index 86528e2b..2c4a1436 100644 --- a/Sources/libewol/ewol/base/eventInputManagement.h +++ b/Sources/libewol/ewol/base/eventInputManagement.h @@ -1,4 +1,26 @@ - +/** + ******************************************************************************* + * @file eventInputManagement.h + * @brief Input (mouse,finger) abstraction layer (header) + * @author Edouard DUPIN + * @date 00/04/2011 + * @par Project + * ewol + * + * @par Copyright + * Copyright 2011 Edouard DUPIN, all right reserved + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY. + * + * Licence summary : + * You can modify and redistribute the sources code and binaries. + * You can send me the bug-fix + * + * Term of the licence in in the file licence.txt. + * + ******************************************************************************* + */ @@ -8,6 +30,7 @@ namespace ewol { typedef enum { + INPUT_TYPE_UNKNOW, INPUT_TYPE_MOUSE, INPUT_TYPE_FINGER, } inputType_te; diff --git a/Sources/libewol/ewol/widget/Button.cpp b/Sources/libewol/ewol/widget/Button.cpp index 2a7dc78e..63af1c10 100644 --- a/Sources/libewol/ewol/widget/Button.cpp +++ b/Sources/libewol/ewol/widget/Button.cpp @@ -268,13 +268,14 @@ void ewol::Button::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::Button::OnEventInput(ewol::inputType_te type, 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 b6eb3ed7..9658dfa3 100644 --- a/Sources/libewol/ewol/widget/Button.h +++ b/Sources/libewol/ewol/widget/Button.h @@ -83,13 +83,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, 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 eebf1d10..25781389 100644 --- a/Sources/libewol/ewol/widget/ButtonColor.cpp +++ b/Sources/libewol/ewol/widget/ButtonColor.cpp @@ -239,13 +239,14 @@ void ewol::ButtonColor::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::ButtonColor::OnEventInput(ewol::inputType_te type, 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 d1995633..6f3aa054 100644 --- a/Sources/libewol/ewol/widget/ButtonColor.h +++ b/Sources/libewol/ewol/widget/ButtonColor.h @@ -76,13 +76,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, 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 ca7a41b0..31eef537 100644 --- a/Sources/libewol/ewol/widget/CheckBox.cpp +++ b/Sources/libewol/ewol/widget/CheckBox.cpp @@ -182,13 +182,14 @@ void ewol::CheckBox::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::CheckBox::OnEventInput(ewol::inputType_te type, 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 93e10625..26e56372 100644 --- a/Sources/libewol/ewol/widget/CheckBox.h +++ b/Sources/libewol/ewol/widget/CheckBox.h @@ -68,13 +68,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, 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 eaa3ea5d..f9b0a0b8 100644 --- a/Sources/libewol/ewol/widget/ColorBar.cpp +++ b/Sources/libewol/ewol/widget/ColorBar.cpp @@ -250,13 +250,14 @@ void ewol::ColorBar::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::ColorBar::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { coord2D_ts relativePos = RelativePosition(pos); //EWOL_DEBUG("Event on BT ..."); diff --git a/Sources/libewol/ewol/widget/ColorBar.h b/Sources/libewol/ewol/widget/ColorBar.h index 1fc8cafa..eba74749 100644 --- a/Sources/libewol/ewol/widget/ColorBar.h +++ b/Sources/libewol/ewol/widget/ColorBar.h @@ -64,13 +64,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; extern const char * const TYPE_EOBJECT_WIDGET_COLOR_BAR; diff --git a/Sources/libewol/ewol/widget/ContextMenu.cpp b/Sources/libewol/ewol/widget/ContextMenu.cpp index 3add9bbb..511beddf 100644 --- a/Sources/libewol/ewol/widget/ContextMenu.cpp +++ b/Sources/libewol/ewol/widget/ContextMenu.cpp @@ -316,13 +316,14 @@ ewol::Widget * ewol::ContextMenu::GetWidgetAtPos(coord2D_ts pos) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) +bool ewol::ContextMenu::OnEventInput(ewol::inputType_te type, 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 3d5da23a..bfe3e8a9 100644 --- a/Sources/libewol/ewol/widget/ContextMenu.h +++ b/Sources/libewol/ewol/widget/ContextMenu.h @@ -90,13 +90,14 @@ namespace ewol { virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos); /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, 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/Entry.cpp b/Sources/libewol/ewol/widget/Entry.cpp index 6ff46adc..52b54c7d 100644 --- a/Sources/libewol/ewol/widget/Entry.cpp +++ b/Sources/libewol/ewol/widget/Entry.cpp @@ -209,13 +209,14 @@ void ewol::Entry::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::Entry::OnEventInput(ewol::inputType_te type, 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 ac7af0f3..e75f9516 100644 --- a/Sources/libewol/ewol/widget/Entry.h +++ b/Sources/libewol/ewol/widget/Entry.h @@ -79,13 +79,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); /** * @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) diff --git a/Sources/libewol/ewol/widget/Image.cpp b/Sources/libewol/ewol/widget/Image.cpp index 54b060c9..5237da40 100644 --- a/Sources/libewol/ewol/widget/Image.cpp +++ b/Sources/libewol/ewol/widget/Image.cpp @@ -184,13 +184,14 @@ void ewol::Image::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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::Image::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) +bool ewol::Image::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { //EWOL_DEBUG("Event on BT ..."); if (1 == IdInput) { diff --git a/Sources/libewol/ewol/widget/Image.h b/Sources/libewol/ewol/widget/Image.h index 0407672e..b0966951 100644 --- a/Sources/libewol/ewol/widget/Image.h +++ b/Sources/libewol/ewol/widget/Image.h @@ -66,13 +66,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; /** diff --git a/Sources/libewol/ewol/widget/Joystick.cpp b/Sources/libewol/ewol/widget/Joystick.cpp index 64439184..0f56a94f 100644 --- a/Sources/libewol/ewol/widget/Joystick.cpp +++ b/Sources/libewol/ewol/widget/Joystick.cpp @@ -236,13 +236,14 @@ Tangent Function: tan(teta) = Opposite / Adjacent /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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::Joystick::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) +bool ewol::Joystick::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { if (1 == IdInput) { if( ewol::EVENT_INPUT_TYPE_DOWN == typeEvent diff --git a/Sources/libewol/ewol/widget/Joystick.h b/Sources/libewol/ewol/widget/Joystick.h index df08e516..6ae74cf6 100644 --- a/Sources/libewol/ewol/widget/Joystick.h +++ b/Sources/libewol/ewol/widget/Joystick.h @@ -83,13 +83,14 @@ namespace ewol { virtual void OnRegenerateDisplay(void); /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); void SetLockMode(bool lockWhenOut) { m_lock = lockWhenOut; }; void SetDisplayMode(joystickMode_te newMode) { m_displayMode = newMode; }; /** diff --git a/Sources/libewol/ewol/widget/Label.cpp b/Sources/libewol/ewol/widget/Label.cpp index 3e43de6d..8a318c84 100644 --- a/Sources/libewol/ewol/widget/Label.cpp +++ b/Sources/libewol/ewol/widget/Label.cpp @@ -157,13 +157,14 @@ void ewol::Label::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::Label::OnEventInput(ewol::inputType_te type, 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 a5b6fa4b..0bab3573 100644 --- a/Sources/libewol/ewol/widget/Label.h +++ b/Sources/libewol/ewol/widget/Label.h @@ -64,13 +64,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; extern const char * const TYPE_EOBJECT_WIDGET_LABEL; diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 50386a85..5b3ac4e1 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -239,16 +239,17 @@ void ewol::List::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::List::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { coord2D_ts relativePos = RelativePosition(pos); - if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, pos)) { + if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) { ewol::widgetManager::FocusKeep(this); // nothing to do ... done on upper widet ... return true; diff --git a/Sources/libewol/ewol/widget/List.h b/Sources/libewol/ewol/widget/List.h index aedde127..70343309 100644 --- a/Sources/libewol/ewol/widget/List.h +++ b/Sources/libewol/ewol/widget/List.h @@ -72,13 +72,14 @@ namespace ewol { virtual void OnRegenerateDisplay(void); /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, 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/Slider.cpp b/Sources/libewol/ewol/widget/Slider.cpp index a4b612ae..528eae65 100644 --- a/Sources/libewol/ewol/widget/Slider.cpp +++ b/Sources/libewol/ewol/widget/Slider.cpp @@ -164,13 +164,14 @@ void ewol::Slider::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::Slider::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { coord2D_ts relativePos = RelativePosition(pos); //EWOL_DEBUG("Event on Slider ..."); diff --git a/Sources/libewol/ewol/widget/Slider.h b/Sources/libewol/ewol/widget/Slider.h index 4cedfb49..a493a9a7 100644 --- a/Sources/libewol/ewol/widget/Slider.h +++ b/Sources/libewol/ewol/widget/Slider.h @@ -69,13 +69,14 @@ namespace ewol { public: /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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 OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; extern const char * const TYPE_EOBJECT_WIDGET_SLIDER; diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.cpp b/Sources/libewol/ewol/widget/WidgetScrolled.cpp index fc3c3120..0ba63d44 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.cpp +++ b/Sources/libewol/ewol/widget/WidgetScrolled.cpp @@ -145,201 +145,200 @@ void ewol::WidgetScrooled::OnRegenerateDisplay(void) /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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) +bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos) { coord2D_ts relativePos = RelativePosition(pos); if (SCROLL_MODE_NORMAL == m_scroollingMode) { - #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 = relativePos.x; - m_highSpeedStartPos.y = relativePos.y; - EWOL_VERBOSE("SCROOL ==> INIT"); - return true; - } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { - m_highSpeedMode = ewol::SCROLL_DISABLE; - EWOL_VERBOSE("SCROOL ==> DISABLE"); + if (ewol::INPUT_TYPE_MOUSE==type && ( ewol::INPUT_TYPE_UNKNOW==m_highSpeedType || ewol::INPUT_TYPE_MOUSE==m_highSpeedType )) { + if (1 == IdInput && ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { + // check if selected the scrolling position whth the scrolling bar ... + if (relativePos.x >= (m_size.x-SCROLL_BAR_SPACE)) { + if(m_size.y < m_maxSize.y) { + m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; + m_highSpeedType = ewol::INPUT_TYPE_MOUSE; + m_highSpeedStartPos.x = relativePos.x; + m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * (m_size.y-SCROLL_BAR_SPACE*2); + m_highSpeedButton = 1; + // force direct scrolling in this case + m_originScrooled.y = (int32_t)(m_maxSize.y * (relativePos.y-SCROLL_BAR_SPACE) / (m_size.y-SCROLL_BAR_SPACE*2)); + m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); + MarkToReedraw(); + return true; + } + } else if (relativePos.y >= (m_size.y-SCROLL_BAR_SPACE)) { + if(m_size.x < m_maxSize.x) { + m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; + m_highSpeedType = ewol::INPUT_TYPE_MOUSE; + m_highSpeedStartPos.x = m_originScrooled.x / m_maxSize.x * (m_size.x-SCROLL_BAR_SPACE*2); + m_highSpeedStartPos.y = relativePos.y; + m_highSpeedButton = 1; + // force direct scrolling in this case + m_originScrooled.x = (int32_t)(m_maxSize.x * (relativePos.x-SCROLL_BAR_SPACE) / (m_size.x-SCROLL_BAR_SPACE*2)); + m_originScrooled.x = etk_avg(0, m_originScrooled.x, m_maxSize.x); + MarkToReedraw(); + return true; + } + } + return false; + } else if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_originScrooled.y -= m_pixelScrolling; + m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); 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(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; - EWOL_VERBOSE("SCROOL ==> ENABLE"); - MarkToReedraw(); - } + } else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_originScrooled.y += m_pixelScrolling; + m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); + MarkToReedraw(); 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 -= 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 = relativePos.x; - m_highSpeedStartPos.y = relativePos.y; - EWOL_VERBOSE("SCROOL ==> MOVE (" << m_originScrooled.x << "," << m_originScrooled.y << ")"); + }else if (2 == IdInput) { + if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { + m_highSpeedMode = ewol::SCROLL_INIT; + m_highSpeedType = ewol::INPUT_TYPE_MOUSE; + m_highSpeedStartPos.x = relativePos.x; + m_highSpeedStartPos.y = relativePos.y; + m_highSpeedButton = 2; + return true; + } + } else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) { + m_highSpeedMode = ewol::SCROLL_DISABLE; + m_highSpeedType = ewol::INPUT_TYPE_UNKNOW; MarkToReedraw(); return true; } - } else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) { - m_highSpeedMode = ewol::SCROLL_DISABLE; - EWOL_VERBOSE("SCROOL ==> DISABLE"); - MarkToReedraw(); - return true; - } - #else - if (1 == IdInput && ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { - // check if selected the scrolling position whth the scrolling bar ... - if (relativePos.x >= (m_size.x-SCROLL_BAR_SPACE)) { - if(m_size.y < m_maxSize.y) { - m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; - m_highSpeedStartPos.x = relativePos.x; - m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * (m_size.y-SCROLL_BAR_SPACE*2); - m_highSpeedButton = 1; - // force direct scrolling in this case + if (IdInput==m_highSpeedButton && ewol::SCROLL_DISABLE!=m_highSpeedMode) { + if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_highSpeedMode = ewol::SCROLL_GREP_END_EVENT; + MarkToReedraw(); + return true; + } else if (ewol::SCROLL_GREP_END_EVENT == m_highSpeedMode) { + if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { + m_highSpeedMode = ewol::SCROLL_DISABLE; + m_highSpeedType = ewol::INPUT_TYPE_UNKNOW; + m_highSpeedButton = -1; + 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(relativePos.x - m_highSpeedStartPos.x) > 10 + || abs(relativePos.y - m_highSpeedStartPos.y) > 10 ) { + // the scrooling can start : + // select the direction : + if (relativePos.x == m_highSpeedStartPos.x) { + m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; + } else if (relativePos.y == m_highSpeedStartPos.y) { + m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; + } else { + etkFloat_t coef = (relativePos.y - m_highSpeedStartPos.y) / (relativePos.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-SCROLL_BAR_SPACE*2); + } else { + m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * (m_size.y-SCROLL_BAR_SPACE*2); + } + MarkToReedraw(); + } + m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); + return true; + } if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { + m_originScrooled.x = (int32_t)(m_maxSize.x * (relativePos.x-SCROLL_BAR_SPACE) / (m_size.x-SCROLL_BAR_SPACE*2)); + m_originScrooled.x = etk_avg(0, m_originScrooled.x, m_maxSize.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 * (relativePos.y-SCROLL_BAR_SPACE) / (m_size.y-SCROLL_BAR_SPACE*2)); m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); MarkToReedraw(); return true; } - } else if (relativePos.y >= (m_size.y-SCROLL_BAR_SPACE)) { - if(m_size.x < m_maxSize.x) { - m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; - m_highSpeedStartPos.x = m_originScrooled.x / m_maxSize.x * (m_size.x-SCROLL_BAR_SPACE*2); + } + } else if (ewol::INPUT_TYPE_FINGER==type && ( ewol::INPUT_TYPE_UNKNOW==m_highSpeedType || ewol::INPUT_TYPE_FINGER==m_highSpeedType )) { + 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_highSpeedType = ewol::INPUT_TYPE_FINGER; + m_highSpeedStartPos.x = relativePos.x; m_highSpeedStartPos.y = relativePos.y; - m_highSpeedButton = 1; - // force direct scrolling in this case - m_originScrooled.x = (int32_t)(m_maxSize.x * (relativePos.x-SCROLL_BAR_SPACE) / (m_size.x-SCROLL_BAR_SPACE*2)); - m_originScrooled.x = etk_avg(0, m_originScrooled.x, m_maxSize.x); + EWOL_VERBOSE("SCROOL ==> INIT"); + return true; + } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_highSpeedMode = ewol::SCROLL_DISABLE; + m_highSpeedType = ewol::INPUT_TYPE_UNKNOW; + EWOL_VERBOSE("SCROOL ==> 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(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_FINGER; + EWOL_VERBOSE("SCROOL ==> ENABLE"); + MarkToReedraw(); + } + return true; + } if (ewol::SCROLL_ENABLE_FINGER==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { + //m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x); + 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 = relativePos.x; + m_highSpeedStartPos.y = relativePos.y; + EWOL_VERBOSE("SCROOL ==> MOVE (" << m_originScrooled.x << "," << m_originScrooled.y << ")"); MarkToReedraw(); return true; } - } - return false; - } else if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { - m_originScrooled.y -= m_pixelScrolling; - m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); - MarkToReedraw(); - return true; - } else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { - m_originScrooled.y += m_pixelScrolling; - m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); - MarkToReedraw(); - return true; - }else if (2 == IdInput) { - if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { - m_highSpeedMode = ewol::SCROLL_INIT; - m_highSpeedStartPos.x = relativePos.x; - m_highSpeedStartPos.y = relativePos.y; - m_highSpeedButton = 2; - return true; - } - } else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) { - m_highSpeedMode = ewol::SCROLL_DISABLE; - MarkToReedraw(); - return true; - } - if (IdInput==m_highSpeedButton && ewol::SCROLL_DISABLE!=m_highSpeedMode) { - if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { - m_highSpeedMode = ewol::SCROLL_GREP_END_EVENT; - MarkToReedraw(); - return true; - } else if (ewol::SCROLL_GREP_END_EVENT == m_highSpeedMode) { - if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { - m_highSpeedMode = ewol::SCROLL_DISABLE; - m_highSpeedButton = -1; - MarkToReedraw(); - } else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) { - m_highSpeedMode = ewol::SCROLL_DISABLE; - m_highSpeedButton = -1; - MarkToReedraw(); - } else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) { - m_highSpeedMode = ewol::SCROLL_DISABLE; - m_highSpeedButton = -1; - 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(relativePos.x - m_highSpeedStartPos.x) > 10 - || abs(relativePos.y - m_highSpeedStartPos.y) > 10 ) { - // the scrooling can start : - // select the direction : - if (relativePos.x == m_highSpeedStartPos.x) { - m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL; - } else if (relativePos.y == m_highSpeedStartPos.y) { - m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL; - } else { - etkFloat_t coef = (relativePos.y - m_highSpeedStartPos.y) / (relativePos.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-SCROLL_BAR_SPACE*2); - } else { - m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * (m_size.y-SCROLL_BAR_SPACE*2); - } - MarkToReedraw(); - } - m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); - return true; - } if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { - m_originScrooled.x = (int32_t)(m_maxSize.x * (relativePos.x-SCROLL_BAR_SPACE) / (m_size.x-SCROLL_BAR_SPACE*2)); - m_originScrooled.x = etk_avg(0, m_originScrooled.x, m_maxSize.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 * (relativePos.y-SCROLL_BAR_SPACE) / (m_size.y-SCROLL_BAR_SPACE*2)); - m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y); + } else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) { + m_highSpeedMode = ewol::SCROLL_DISABLE; + m_highSpeedType = ewol::INPUT_TYPE_UNKNOW; + EWOL_VERBOSE("SCROOL ==> DISABLE"); MarkToReedraw(); return true; } } - #endif } else if (SCROLL_MODE_CENTER == m_scroollingMode) { - #ifdef __MODE__Touch - // TODO ... - #else - etkFloat_t tmp1=ewol::GetCurrentHeight() / m_maxSize.y; - etkFloat_t tmp2=ewol::GetCurrentWidth() / m_maxSize.x; - //EWOL_INFO(" elements Zoom : " << tmp1 << " " << tmp2); - tmp1 = etk_min(tmp1, tmp2); - if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { - m_zoom -= 0.1; - if (tmp1 < 1.0) { - m_zoom = etk_max(tmp1, m_zoom); - } else { - m_zoom = etk_max(1.0, m_zoom); + if (ewol::INPUT_TYPE_MOUSE==type) { + etkFloat_t tmp1=ewol::GetCurrentHeight() / m_maxSize.y; + etkFloat_t tmp2=ewol::GetCurrentWidth() / m_maxSize.x; + //EWOL_INFO(" elements Zoom : " << tmp1 << " " << tmp2); + tmp1 = etk_min(tmp1, tmp2); + if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_zoom -= 0.1; + if (tmp1 < 1.0) { + m_zoom = etk_max(tmp1, m_zoom); + } else { + m_zoom = etk_max(1.0, m_zoom); + } + MarkToReedraw(); + return true; + } else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { + m_zoom += 0.1; + if (tmp1 > 1.0) { + m_zoom = etk_min(tmp1, m_zoom); + } else { + m_zoom = etk_min(1.0, m_zoom); + } + MarkToReedraw(); + return true; } - MarkToReedraw(); - return true; - } else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { - m_zoom += 0.1; - if (tmp1 > 1.0) { - m_zoom = etk_min(tmp1, m_zoom); - } else { - m_zoom = etk_min(1.0, m_zoom); - } - MarkToReedraw(); - return true; } - #endif } else { EWOL_ERROR("Scrolling mode unknow ... " << m_scroollingMode ); } diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.h b/Sources/libewol/ewol/widget/WidgetScrolled.h index fc108927..5763e09f 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.h +++ b/Sources/libewol/ewol/widget/WidgetScrolled.h @@ -33,12 +33,9 @@ namespace ewol { typedef enum { SCROLL_DISABLE, SCROLL_INIT, - #ifdef __MODE__Touch - SCROLL_ENABLE, - #else - SCROLL_ENABLE_HORIZONTAL, - SCROLL_ENABLE_VERTICAL, - #endif + SCROLL_ENABLE_FINGER, // Specific for touchpad + SCROLL_ENABLE_HORIZONTAL, // Specific for mouse + SCROLL_ENABLE_VERTICAL, // Specific for mouse SCROLL_GREP_END_EVENT, }highSpeedMode_te; @@ -53,15 +50,16 @@ namespace ewol { void AddOObject(ewol::OObject* newObject, int32_t pos=-1); void ClearOObjectList(void); protected: - coord2D_ts m_originScrooled; - coord2D_ts m_maxSize; - etkFloat_t m_zoom; //!< current zoom on the display + coord2D_ts m_originScrooled; + coord2D_ts m_maxSize; + etkFloat_t m_zoom; //!< current zoom on the display private: - scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling - etkFloat_t m_pixelScrolling; - coord2D_ts m_highSpeedStartPos; - highSpeedMode_te m_highSpeedMode; - int32_t m_highSpeedButton; + scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling + etkFloat_t m_pixelScrolling; + coord2D_ts m_highSpeedStartPos; + highSpeedMode_te m_highSpeedMode; + int32_t m_highSpeedButton; + ewol::inputType_te m_highSpeedType; public: WidgetScrooled(void); virtual ~WidgetScrooled(void); @@ -84,13 +82,14 @@ namespace ewol { virtual void OnDraw(void); /** * @brief Event on an input of this Widget + * @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @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); + virtual bool OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos); /** * @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