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)
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
82 */ 82 */
83#define EINA_POSITION2D_EQ(a, b) \ 83#define EINA_POSITION2D_EQ(a, b) \
84 (((a).x == (b).x) && ((a).y == (b).y)) 84 (((a).x == (b).x) && ((a).y == (b).y))
85/**
86 * @brief Convenience macro for getting the distance from one point to another
87 * @param[in] a An Eina_Position2D
88 * @param[in] b An Eina_Position2D
89 * @return The distance between the two points.
90 * @since 1.24
91 */
92#define EINA_POSITION2D_DISTANCE(a, b) \
93 sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y))
85 94
86/** 95/**
87 * @typedef Eina_Rectangle 96 * @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 {
21 Eina_Bool active; 21 Eina_Bool active;
22 int from; 22 int from;
23 Eina_Position2D mouse_start; 23 Eina_Position2D mouse_start;
24 double start_time;
24 } mouse_move; 25 } mouse_move;
25 Eina_Bool animation; 26 Eina_Bool animation;
26 Eina_Bool scroll_block; 27 Eina_Bool scroll_block;
@@ -98,6 +99,7 @@ _mouse_down_cb(void *data,
98 pd->mouse_move.active = EINA_TRUE; 99 pd->mouse_move.active = EINA_TRUE;
99 pd->mouse_move.from = efl_pack_index_get(pd->container, efl_ui_spotlight_active_element_get(pd->container)); 100 pd->mouse_move.from = efl_pack_index_get(pd->container, efl_ui_spotlight_active_element_get(pd->container));
100 pd->mouse_move.mouse_start = efl_input_pointer_position_get(ev); 101 pd->mouse_move.mouse_start = efl_input_pointer_position_get(ev);
102 pd->mouse_move.start_time = ecore_time_get();
101 103
102 pd->transition.from = pd->mouse_move.from; 104 pd->transition.from = pd->mouse_move.from;
103 pd->transition.to = pd->transition.from + 1; 105 pd->transition.to = pd->transition.from + 1;
@@ -125,12 +127,15 @@ _mouse_move_cb(void *data,
125 if (!efl_input_processed_get(ev)) 127 if (!efl_input_processed_get(ev))
126 efl_input_processed_set(ev, EINA_TRUE); 128 efl_input_processed_set(ev, EINA_TRUE);
127 129
128 pd->transition.active = EINA_TRUE; 130 if (pd->transition.active ||
129 pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w; 131 EINA_POSITION2D_DISTANCE(pd->mouse_move.mouse_start, efl_input_pointer_position_get(ev)) > elm_config_finger_size_get() ||
130 132 ecore_time_get() - pd->mouse_move.start_time > 0.1)
131 _propagate_progress(data, pd->transition.from + pd->transition.progress); 133 {
132 134 pd->transition.active = EINA_TRUE;
133 _apply_box_properties(obj, pd); 135 pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w;
136 _propagate_progress(data, pd->transition.from + pd->transition.progress);
137 _apply_box_properties(obj, pd);
138 }
134} 139}
135 140
136static void 141static void
@@ -150,6 +155,10 @@ _mouse_up_cb(void *data,
150 155
151 Efl_Ui_Widget *new_content = efl_pack_content_get(pd->container, MIN(MAX(result, 0), efl_content_count(pd->container) - 1)); 156 Efl_Ui_Widget *new_content = efl_pack_content_get(pd->container, MIN(MAX(result, 0), efl_content_count(pd->container) - 1));
152 efl_ui_spotlight_active_element_set(pd->container, new_content); 157 efl_ui_spotlight_active_element_set(pd->container, new_content);
158
159 //Set input processed not to cause clicked event to content button.
160 if (EINA_POSITION2D_DISTANCE(pd->mouse_move.mouse_start, efl_input_pointer_position_get(ev)) > elm_config_finger_size_get())
161 efl_input_processed_set(ev, EINA_TRUE);
153} 162}
154 163
155EFL_CALLBACKS_ARRAY_DEFINE(mouse_listeners, 164EFL_CALLBACKS_ARRAY_DEFINE(mouse_listeners,