summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-22 17:25:27 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-28 15:25:26 +0100
commitb8639cb2a8184ef269b5e66f9f794bfab8d1308d (patch)
tree4eba9813e7708fa768c8c73d30373c26a141826d
parent84a34d2ef62832a8cddff9911821aeca71150721 (diff)
downloadefl-devs/bu5hm4n/work_spotlight_fixes.tar.gz
efl_ui_spotlight_scroll: improve scroll behaviourdevs/bu5hm4n/work_spotlight_fixes
when the mouse motion was used, we need to mark this event as processed. Otherwise a click event will be emitted which is wrong. Additionally, we should only scroll when we are definitly not clicking. Right now, the scrolling animation would dance arround on a real TS. Additionally², this commit introduces a little macro which calculates the distance of a position.
-rw-r--r--src/lib/eina/eina_rectangle.h9
-rw-r--r--src/lib/elementary/efl_ui_spotlight_scroll_manager.c21
2 files changed, 24 insertions, 6 deletions
diff --git a/src/lib/eina/eina_rectangle.h b/src/lib/eina/eina_rectangle.h
index 54cf1ccb99..40cbe62c19 100644
--- a/src/lib/eina/eina_rectangle.h
+++ b/src/lib/eina/eina_rectangle.h
@@ -82,6 +82,15 @@ typedef struct _Eina_Size2D
*/
#define EINA_POSITION2D_EQ(a, b) \
(((a).x == (b).x) && ((a).y == (b).y))
+/**
+ * @brief Convenience macro for getting the distance from one point to another
+ * @param[in] a An Eina_Position2D
+ * @param[in] b An Eina_Position2D
+ * @return The distance between the two points.
+ * @since 1.24
+ */
+#define EINA_POSITION2D_DISTANCE(a, b) \
+ sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y))
/**
* @typedef Eina_Rectangle
diff --git a/src/lib/elementary/efl_ui_spotlight_scroll_manager.c b/src/lib/elementary/efl_ui_spotlight_scroll_manager.c
index bdb6840c06..63147c1d1b 100644
--- a/src/lib/elementary/efl_ui_spotlight_scroll_manager.c
+++ b/src/lib/elementary/efl_ui_spotlight_scroll_manager.c
@@ -21,6 +21,7 @@ typedef struct {
Eina_Bool active;
int from;
Eina_Position2D mouse_start;
+ double start_time;
} mouse_move;
Eina_Bool animation;
Eina_Bool scroll_block;
@@ -98,6 +99,7 @@ _mouse_down_cb(void *data,
pd->mouse_move.active = EINA_TRUE;
pd->mouse_move.from = efl_pack_index_get(pd->container, efl_ui_spotlight_active_element_get(pd->container));
pd->mouse_move.mouse_start = efl_input_pointer_position_get(ev);
+ pd->mouse_move.start_time = ecore_time_get();
pd->transition.from = pd->mouse_move.from;
pd->transition.to = pd->transition.from + 1;
@@ -125,12 +127,15 @@ _mouse_move_cb(void *data,
if (!efl_input_processed_get(ev))
efl_input_processed_set(ev, EINA_TRUE);
- pd->transition.active = EINA_TRUE;
- pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w;
-
- _propagate_progress(data, pd->transition.from + pd->transition.progress);
-
- _apply_box_properties(obj, pd);
+ if (pd->transition.active ||
+ EINA_POSITION2D_DISTANCE(pd->mouse_move.mouse_start, efl_input_pointer_position_get(ev)) > elm_config_finger_size_get() ||
+ ecore_time_get() - pd->mouse_move.start_time > 0.1)
+ {
+ pd->transition.active = EINA_TRUE;
+ pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w;
+ _propagate_progress(data, pd->transition.from + pd->transition.progress);
+ _apply_box_properties(obj, pd);
+ }
}
static void
@@ -150,6 +155,10 @@ _mouse_up_cb(void *data,
Efl_Ui_Widget *new_content = efl_pack_content_get(pd->container, MIN(MAX(result, 0), efl_content_count(pd->container) - 1));
efl_ui_spotlight_active_element_set(pd->container, new_content);
+
+ //Set input processed not to cause clicked event to content button.
+ if (EINA_POSITION2D_DISTANCE(pd->mouse_move.mouse_start, efl_input_pointer_position_get(ev)) > elm_config_finger_size_get())
+ efl_input_processed_set(ev, EINA_TRUE);
}
EFL_CALLBACKS_ARRAY_DEFINE(mouse_listeners,