summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2019-06-24 21:25:58 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2019-06-26 16:25:01 +0900
commit26b31af60be0ddf75fba4f94b66bdfee8526c31a (patch)
tree9a0933689f1023502cf0f1ae8b9e2292e9b779aa
parent127209ce2b5ec5328b38fc114cd821f469dc755b (diff)
efl_ui_clickable: fix not to be clicked if pointer is processeddevs/jaehyun/efl_clickable_test4
-rw-r--r--src/bin/elementary/test_ui_active_view.c7
-rw-r--r--src/lib/elementary/efl_ui_active_view_view_manager_scroll.c13
-rw-r--r--src/lib/elementary/efl_ui_clickable_util.c19
3 files changed, 37 insertions, 2 deletions
diff --git a/src/bin/elementary/test_ui_active_view.c b/src/bin/elementary/test_ui_active_view.c
index 38a79ea831..b417d9b7fc 100644
--- a/src/bin/elementary/test_ui_active_view.c
+++ b/src/bin/elementary/test_ui_active_view.c
@@ -58,6 +58,12 @@ typedef struct _Size_Params
58 58
59#define PAGE_NUM 3 59#define PAGE_NUM 3
60 60
61static void
62page_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
63{
64 printf("Button Page is clicked!\n");
65}
66
61static Eo * 67static Eo *
62view_add(View_Type p, Eo *parent) 68view_add(View_Type p, Eo *parent)
63{ 69{
@@ -95,6 +101,7 @@ view_add(View_Type p, Eo *parent)
95 case BUTTON: 101 case BUTTON:
96 page = efl_add(EFL_UI_BUTTON_CLASS, parent, 102 page = efl_add(EFL_UI_BUTTON_CLASS, parent,
97 efl_text_set(efl_added, "Button Page")); 103 efl_text_set(efl_added, "Button Page"));
104 efl_event_callback_add(page, EFL_UI_EVENT_CLICKED, page_clicked_cb, NULL);
98 efl_gfx_hint_fill_set(page, EINA_TRUE, EINA_TRUE); 105 efl_gfx_hint_fill_set(page, EINA_TRUE, EINA_TRUE);
99 break; 106 break;
100 107
diff --git a/src/lib/elementary/efl_ui_active_view_view_manager_scroll.c b/src/lib/elementary/efl_ui_active_view_view_manager_scroll.c
index 6918703cf1..841fc6af80 100644
--- a/src/lib/elementary/efl_ui_active_view_view_manager_scroll.c
+++ b/src/lib/elementary/efl_ui_active_view_view_manager_scroll.c
@@ -20,6 +20,7 @@ typedef struct {
20 Eina_Bool active; 20 Eina_Bool active;
21 int from; 21 int from;
22 Eina_Position2D mouse_start; 22 Eina_Position2D mouse_start;
23 Eina_Bool moved;
23 } mouse_move; 24 } mouse_move;
24 Eina_Bool animation; 25 Eina_Bool animation;
25} Efl_Ui_Active_View_View_Manager_Scroll_Data; 26} Efl_Ui_Active_View_View_Manager_Scroll_Data;
@@ -105,6 +106,7 @@ _mouse_down_cb(void *data,
105 pd->mouse_move.active = EINA_TRUE; 106 pd->mouse_move.active = EINA_TRUE;
106 pd->mouse_move.from = efl_ui_active_view_active_index_get(pd->container); 107 pd->mouse_move.from = efl_ui_active_view_active_index_get(pd->container);
107 pd->mouse_move.mouse_start = efl_input_pointer_position_get(ev); 108 pd->mouse_move.mouse_start = efl_input_pointer_position_get(ev);
109 pd->mouse_move.moved = EINA_FALSE;
108} 110}
109 111
110static void 112static void
@@ -123,6 +125,11 @@ _mouse_move_cb(void *data,
123 pos = efl_input_pointer_position_get(ev); 125 pos = efl_input_pointer_position_get(ev);
124 pos_y_diff = pd->mouse_move.mouse_start.x - pos.x; 126 pos_y_diff = pd->mouse_move.mouse_start.x - pos.x;
125 127
128 pd->mouse_move.moved = EINA_TRUE;
129 //Set input processed not to cause clicked event to content button.
130 if (!efl_input_processed_get(ev))
131 efl_input_processed_set(ev, EINA_TRUE);
132
126 pd->transition.active = EINA_TRUE; 133 pd->transition.active = EINA_TRUE;
127 pd->transition.from = pd->mouse_move.from; 134 pd->transition.from = pd->mouse_move.from;
128 pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w; 135 pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w;
@@ -144,6 +151,12 @@ _mouse_up_cb(void *data,
144 if (efl_input_event_flags_get(ev) & EFL_INPUT_FLAGS_PROCESSED) return; 151 if (efl_input_event_flags_get(ev) & EFL_INPUT_FLAGS_PROCESSED) return;
145 if (!pd->mouse_move.active) return; 152 if (!pd->mouse_move.active) return;
146 153
154 //Set input processed not to cause clicked event to content button.
155 if (pd->mouse_move.moved && efl_input_processed_get(ev))
156 efl_input_processed_set(ev, EINA_FALSE);
157
158 pd->mouse_move.moved = EINA_FALSE;
159
147 double absolut_current_position = (double)pd->transition.from + pd->transition.progress; 160 double absolut_current_position = (double)pd->transition.from + pd->transition.progress;
148 int result = round(absolut_current_position); 161 int result = round(absolut_current_position);
149 162
diff --git a/src/lib/elementary/efl_ui_clickable_util.c b/src/lib/elementary/efl_ui_clickable_util.c
index b11e0c50e2..3243b725bb 100644
--- a/src/lib/elementary/efl_ui_clickable_util.c
+++ b/src/lib/elementary/efl_ui_clickable_util.c
@@ -38,9 +38,24 @@ _on_mouse_out(void *data,
38 efl_ui_clickable_button_state_reset(data, 1); 38 efl_ui_clickable_button_state_reset(data, 1);
39} 39}
40 40
41static void
42_theme_move_cb(void *data, const Efl_Event *ev EINA_UNUSED)
43{
44 Efl_Input_Pointer *pointer = ev->info;
45
46 if (efl_input_processed_get(pointer))
47 efl_ui_clickable_button_state_reset(data, 1);
48}
49
50EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks,
51 {EFL_EVENT_POINTER_MOVE, _theme_move_cb},
52)
53
41EOLIAN static void 54EOLIAN static void
42_efl_ui_clickable_util_bind_to_theme(Efl_Canvas_Layout *object, Efl_Ui_Clickable *clickable) 55_efl_ui_clickable_util_bind_to_theme(Efl_Canvas_Layout *object, Efl_Ui_Clickable *clickable)
43{ 56{
57 efl_event_callback_array_add(object, bind_to_theme_callbacks(), clickable);
58
44 efl_layout_signal_callback_add(object, "efl,action,press", "*", clickable, _on_press_cb, NULL); 59 efl_layout_signal_callback_add(object, "efl,action,press", "*", clickable, _on_press_cb, NULL);
45 efl_layout_signal_callback_add(object, "efl,action,unpress", "*", clickable, _on_unpress_cb, NULL); 60 efl_layout_signal_callback_add(object, "efl,action,unpress", "*", clickable, _on_unpress_cb, NULL);
46 efl_layout_signal_callback_add(object, "efl,action,mouse_out", "*", clickable, _on_mouse_out, NULL); 61 efl_layout_signal_callback_add(object, "efl,action,mouse_out", "*", clickable, _on_mouse_out, NULL);
@@ -84,7 +99,7 @@ _unpress_cb(void *data, const Efl_Event *ev EINA_UNUSED)
84 } 99 }
85} 100}
86 101
87EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks, 102EFL_CALLBACKS_ARRAY_DEFINE(bind_to_object_callbacks,
88 {EFL_EVENT_POINTER_DOWN, _press_cb}, 103 {EFL_EVENT_POINTER_DOWN, _press_cb},
89 {EFL_EVENT_POINTER_UP, _unpress_cb}, 104 {EFL_EVENT_POINTER_UP, _unpress_cb},
90) 105)
@@ -92,7 +107,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks,
92EOLIAN static void 107EOLIAN static void
93_efl_ui_clickable_util_bind_to_object(Efl_Input_Interface *object, Efl_Ui_Clickable *clickable) 108_efl_ui_clickable_util_bind_to_object(Efl_Input_Interface *object, Efl_Ui_Clickable *clickable)
94{ 109{
95 efl_event_callback_array_add(object, bind_to_theme_callbacks(), clickable); 110 efl_event_callback_array_add(object, bind_to_object_callbacks(), clickable);
96} 111}
97 112
98 113