summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-05-14 15:50:39 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-05-14 15:50:39 -0400
commit8429ffba9caa43114ec82074ce26d6408e2822b7 (patch)
treef0a32567b18ba42c4517ef9a6ca5dd9573bde74e
parent5ca38bfc34b42da3947264d6fc5e6c8bbbdfbec0 (diff)
efl_ui_image: migrate to efl.ui.clickable
Summary: the mixin is now used to emit the events of the mixins. This is verified by the testsuite. The testsuite needs a special treatment for the object, because a missing image-file of the object would result in a 0x0 image size. Depends on D8822 Reviewers: zmike, segfaultxavi, cedric Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8823
-rw-r--r--src/lib/elementary/efl_ui_image.c17
-rw-r--r--src/lib/elementary/efl_ui_image_zoomable.c32
-rw-r--r--src/tests/elementary/spec/efl_test_clickable.c10
3 files changed, 24 insertions, 35 deletions
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index a0232aedeb..8fde088c88 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -7,6 +7,7 @@
7#define EFL_ACCESS_COMPONENT_PROTECTED 7#define EFL_ACCESS_COMPONENT_PROTECTED
8#define EFL_ACCESS_WIDGET_ACTION_PROTECTED 8#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
9#define EFL_LAYOUT_CALC_PROTECTED 9#define EFL_LAYOUT_CALC_PROTECTED
10#define EFL_UI_CLICKABLE_PROTECTED
10 11
11#include <Elementary.h> 12#include <Elementary.h>
12 13
@@ -120,10 +121,7 @@ _on_mouse_up(void *data,
120 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 121 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
121 if (!wd->still_in) return; 122 if (!wd->still_in) return;
122 123
123 if (elm_widget_is_legacy(obj)) 124 evas_object_smart_callback_call(data, "clicked", NULL);
124 evas_object_smart_callback_call(data, "clicked", NULL);
125 else
126 efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, NULL);
127} 125}
128 126
129static Eina_Bool 127static Eina_Bool
@@ -578,8 +576,15 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
578 evas_object_show(priv->hit_rect); 576 evas_object_show(priv->hit_rect);
579 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE); 577 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
580 578
581 evas_object_event_callback_add 579 if (elm_widget_is_legacy(obj))
582 (priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj); 580 {
581 evas_object_event_callback_add
582 (priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
583 }
584 else
585 {
586 efl_ui_clickable_util_bind_to_object(priv->hit_rect, obj);
587 }
583 588
584 priv->smooth = EINA_TRUE; 589 priv->smooth = EINA_TRUE;
585 priv->fill_inside = EINA_TRUE; 590 priv->fill_inside = EINA_TRUE;
diff --git a/src/lib/elementary/efl_ui_image_zoomable.c b/src/lib/elementary/efl_ui_image_zoomable.c
index 5f8147d777..f8c3f4ac9e 100644
--- a/src/lib/elementary/efl_ui_image_zoomable.c
+++ b/src/lib/elementary/efl_ui_image_zoomable.c
@@ -6,6 +6,7 @@
6#define EFL_ACCESS_WIDGET_ACTION_PROTECTED 6#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
7#define EFL_UI_SCROLL_MANAGER_PROTECTED 7#define EFL_UI_SCROLL_MANAGER_PROTECTED
8#define EFL_UI_SCROLLBAR_PROTECTED 8#define EFL_UI_SCROLLBAR_PROTECTED
9#define EFL_UI_CLICKABLE_PROTECTED
9 10
10#include <Elementary.h> 11#include <Elementary.h>
11 12
@@ -830,19 +831,6 @@ _zoom_anim_cb(void *data, const Efl_Event *event EINA_UNUSED)
830 } 831 }
831} 832}
832 833
833static Eina_Bool
834_long_press_cb(void *data)
835{
836 EFL_UI_IMAGE_ZOOMABLE_DATA_GET(data, sd);
837
838 sd->long_timer = NULL;
839 sd->longpressed = EINA_TRUE;
840 efl_event_callback_legacy_call
841 (data, EFL_UI_EVENT_LONGPRESSED, NULL);
842
843 return ECORE_CALLBACK_CANCEL;
844}
845
846static void 834static void
847_mouse_down_cb(void *data, 835_mouse_down_cb(void *data,
848 Evas *evas EINA_UNUSED, 836 Evas *evas EINA_UNUSED,
@@ -856,24 +844,14 @@ _mouse_down_cb(void *data,
856 if (ev->button != 1) return; 844 if (ev->button != 1) return;
857 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE; 845 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
858 else sd->on_hold = EINA_FALSE; 846 else sd->on_hold = EINA_FALSE;
847
859 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) 848 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
860 { 849 {
861 if (elm_widget_is_legacy(data)) 850 if (elm_widget_is_legacy(data))
862 evas_object_smart_callback_call(data, "clicked,double", NULL); 851 evas_object_smart_callback_call(data, "clicked,double", NULL);
863 else
864 {
865 Efl_Ui_Clickable_Clicked clicked;
866 clicked.repeated = 1;
867 clicked.button = 1;
868 efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, &clicked);
869 }
870 } 852 }
871 else 853 else
872 efl_event_callback_legacy_call(data, EFL_UI_IMAGE_ZOOMABLE_EVENT_PRESS, NULL); 854 efl_event_callback_legacy_call(data, EFL_UI_IMAGE_ZOOMABLE_EVENT_PRESS, NULL);
873 sd->longpressed = EINA_FALSE;
874 ecore_timer_del(sd->long_timer);
875 sd->long_timer = ecore_timer_add
876 (_elm_config->longpress_timeout, _long_press_cb, data);
877} 855}
878 856
879static void 857static void
@@ -889,13 +867,11 @@ _mouse_up_cb(void *data,
889 if (ev->button != 1) return; 867 if (ev->button != 1) return;
890 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE; 868 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
891 else sd->on_hold = EINA_FALSE; 869 else sd->on_hold = EINA_FALSE;
892 ELM_SAFE_FREE(sd->long_timer, ecore_timer_del); 870
893 if (!sd->on_hold) 871 if (!sd->on_hold)
894 { 872 {
895 if (elm_widget_is_legacy(data)) 873 if (elm_widget_is_legacy(data))
896 evas_object_smart_callback_call(data, "clicked", NULL); 874 evas_object_smart_callback_call(data, "clicked", NULL);
897 else
898 efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, NULL);
899 } 875 }
900 sd->on_hold = EINA_FALSE; 876 sd->on_hold = EINA_FALSE;
901} 877}
@@ -1889,6 +1865,7 @@ _efl_ui_image_zoomable_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Zoomable
1889 (priv->img, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj); 1865 (priv->img, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
1890 evas_object_event_callback_add 1866 evas_object_event_callback_add
1891 (priv->img, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj); 1867 (priv->img, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
1868 efl_ui_clickable_util_bind_to_object(priv->img, obj);
1892 evas_object_image_scale_hint_set(priv->img, EVAS_IMAGE_SCALE_HINT_STATIC); 1869 evas_object_image_scale_hint_set(priv->img, EVAS_IMAGE_SCALE_HINT_STATIC);
1893 1870
1894 /* XXX: mmm... */ 1871 /* XXX: mmm... */
@@ -1937,7 +1914,6 @@ _efl_ui_image_zoomable_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Zoomable
1937 eina_stringshare_del(sd->file); 1914 eina_stringshare_del(sd->file);
1938 ecore_job_del(sd->calc_job); 1915 ecore_job_del(sd->calc_job);
1939 ecore_timer_del(sd->scr_timer); 1916 ecore_timer_del(sd->scr_timer);
1940 ecore_timer_del(sd->long_timer);
1941 efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _zoom_anim_cb, obj); 1917 efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _zoom_anim_cb, obj);
1942 efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _bounce_eval, obj); 1918 efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _bounce_eval, obj);
1943 efl_event_callback_del(obj, EFL_UI_EVENT_SCROLL, _scroll_cb, obj); 1919 efl_event_callback_del(obj, EFL_UI_EVENT_SCROLL, _scroll_cb, obj);
diff --git a/src/tests/elementary/spec/efl_test_clickable.c b/src/tests/elementary/spec/efl_test_clickable.c
index f241deb68b..554c782d77 100644
--- a/src/tests/elementary/spec/efl_test_clickable.c
+++ b/src/tests/elementary/spec/efl_test_clickable.c
@@ -8,7 +8,7 @@
8 8
9/* spec-meta-start 9/* spec-meta-start
10 {"test-interface":"Efl.Ui.Clickable", 10 {"test-interface":"Efl.Ui.Clickable",
11 "test-widgets": ["Efl.Ui.Button"] 11 "test-widgets": ["Efl.Ui.Button", "Efl.Ui.Image"]
12 } 12 }
13 spec-meta-end 13 spec-meta-end
14 */ 14 */
@@ -45,6 +45,14 @@ prepare_window(void)
45 pos->x = 30; 45 pos->x = 30;
46 pos->y = 30; 46 pos->y = 30;
47 47
48 if (efl_isa(widget, EFL_UI_IMAGE_CLASS))
49 {
50 efl_gfx_hint_size_min_set(widget, EINA_SIZE2D(200, 200));
51 efl_file_simple_load(widget, ELM_IMAGE_DATA_DIR"/images/bubble.png", NULL);
52 pos->x = 100;
53 pos->y = 100;
54 }
55
48 evas_smart_objects_calculate(evas_object_evas_get(win)); 56 evas_smart_objects_calculate(evas_object_evas_get(win));
49 evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, pos); 57 evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, pos);
50 efl_loop_begin(efl_app_main_get()); 58 efl_loop_begin(efl_app_main_get());