forked from enlightenment/efl
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
This commit is contained in:
parent
5ca38bfc34
commit
8429ffba9c
|
@ -7,6 +7,7 @@
|
||||||
#define EFL_ACCESS_COMPONENT_PROTECTED
|
#define EFL_ACCESS_COMPONENT_PROTECTED
|
||||||
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
|
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
|
||||||
#define EFL_LAYOUT_CALC_PROTECTED
|
#define EFL_LAYOUT_CALC_PROTECTED
|
||||||
|
#define EFL_UI_CLICKABLE_PROTECTED
|
||||||
|
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
@ -120,10 +121,7 @@ _on_mouse_up(void *data,
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||||
if (!wd->still_in) return;
|
if (!wd->still_in) return;
|
||||||
|
|
||||||
if (elm_widget_is_legacy(obj))
|
evas_object_smart_callback_call(data, "clicked", NULL);
|
||||||
evas_object_smart_callback_call(data, "clicked", NULL);
|
|
||||||
else
|
|
||||||
efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -578,8 +576,15 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
|
||||||
evas_object_show(priv->hit_rect);
|
evas_object_show(priv->hit_rect);
|
||||||
evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
|
evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
|
||||||
|
|
||||||
evas_object_event_callback_add
|
if (elm_widget_is_legacy(obj))
|
||||||
(priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
|
{
|
||||||
|
evas_object_event_callback_add
|
||||||
|
(priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
efl_ui_clickable_util_bind_to_object(priv->hit_rect, obj);
|
||||||
|
}
|
||||||
|
|
||||||
priv->smooth = EINA_TRUE;
|
priv->smooth = EINA_TRUE;
|
||||||
priv->fill_inside = EINA_TRUE;
|
priv->fill_inside = EINA_TRUE;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
|
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
|
||||||
#define EFL_UI_SCROLL_MANAGER_PROTECTED
|
#define EFL_UI_SCROLL_MANAGER_PROTECTED
|
||||||
#define EFL_UI_SCROLLBAR_PROTECTED
|
#define EFL_UI_SCROLLBAR_PROTECTED
|
||||||
|
#define EFL_UI_CLICKABLE_PROTECTED
|
||||||
|
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
@ -830,19 +831,6 @@ _zoom_anim_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_long_press_cb(void *data)
|
|
||||||
{
|
|
||||||
EFL_UI_IMAGE_ZOOMABLE_DATA_GET(data, sd);
|
|
||||||
|
|
||||||
sd->long_timer = NULL;
|
|
||||||
sd->longpressed = EINA_TRUE;
|
|
||||||
efl_event_callback_legacy_call
|
|
||||||
(data, EFL_UI_EVENT_LONGPRESSED, NULL);
|
|
||||||
|
|
||||||
return ECORE_CALLBACK_CANCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_mouse_down_cb(void *data,
|
_mouse_down_cb(void *data,
|
||||||
Evas *evas EINA_UNUSED,
|
Evas *evas EINA_UNUSED,
|
||||||
|
@ -856,24 +844,14 @@ _mouse_down_cb(void *data,
|
||||||
if (ev->button != 1) return;
|
if (ev->button != 1) return;
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
|
||||||
else sd->on_hold = EINA_FALSE;
|
else sd->on_hold = EINA_FALSE;
|
||||||
|
|
||||||
if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
||||||
{
|
{
|
||||||
if (elm_widget_is_legacy(data))
|
if (elm_widget_is_legacy(data))
|
||||||
evas_object_smart_callback_call(data, "clicked,double", NULL);
|
evas_object_smart_callback_call(data, "clicked,double", NULL);
|
||||||
else
|
|
||||||
{
|
|
||||||
Efl_Ui_Clickable_Clicked clicked;
|
|
||||||
clicked.repeated = 1;
|
|
||||||
clicked.button = 1;
|
|
||||||
efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, &clicked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
efl_event_callback_legacy_call(data, EFL_UI_IMAGE_ZOOMABLE_EVENT_PRESS, NULL);
|
efl_event_callback_legacy_call(data, EFL_UI_IMAGE_ZOOMABLE_EVENT_PRESS, NULL);
|
||||||
sd->longpressed = EINA_FALSE;
|
|
||||||
ecore_timer_del(sd->long_timer);
|
|
||||||
sd->long_timer = ecore_timer_add
|
|
||||||
(_elm_config->longpress_timeout, _long_press_cb, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -889,13 +867,11 @@ _mouse_up_cb(void *data,
|
||||||
if (ev->button != 1) return;
|
if (ev->button != 1) return;
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
|
||||||
else sd->on_hold = EINA_FALSE;
|
else sd->on_hold = EINA_FALSE;
|
||||||
ELM_SAFE_FREE(sd->long_timer, ecore_timer_del);
|
|
||||||
if (!sd->on_hold)
|
if (!sd->on_hold)
|
||||||
{
|
{
|
||||||
if (elm_widget_is_legacy(data))
|
if (elm_widget_is_legacy(data))
|
||||||
evas_object_smart_callback_call(data, "clicked", NULL);
|
evas_object_smart_callback_call(data, "clicked", NULL);
|
||||||
else
|
|
||||||
efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, NULL);
|
|
||||||
}
|
}
|
||||||
sd->on_hold = EINA_FALSE;
|
sd->on_hold = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1889,6 +1865,7 @@ _efl_ui_image_zoomable_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Zoomable
|
||||||
(priv->img, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
|
(priv->img, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
|
||||||
evas_object_event_callback_add
|
evas_object_event_callback_add
|
||||||
(priv->img, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
|
(priv->img, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
|
||||||
|
efl_ui_clickable_util_bind_to_object(priv->img, obj);
|
||||||
evas_object_image_scale_hint_set(priv->img, EVAS_IMAGE_SCALE_HINT_STATIC);
|
evas_object_image_scale_hint_set(priv->img, EVAS_IMAGE_SCALE_HINT_STATIC);
|
||||||
|
|
||||||
/* XXX: mmm... */
|
/* XXX: mmm... */
|
||||||
|
@ -1937,7 +1914,6 @@ _efl_ui_image_zoomable_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Zoomable
|
||||||
eina_stringshare_del(sd->file);
|
eina_stringshare_del(sd->file);
|
||||||
ecore_job_del(sd->calc_job);
|
ecore_job_del(sd->calc_job);
|
||||||
ecore_timer_del(sd->scr_timer);
|
ecore_timer_del(sd->scr_timer);
|
||||||
ecore_timer_del(sd->long_timer);
|
|
||||||
efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _zoom_anim_cb, obj);
|
efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _zoom_anim_cb, obj);
|
||||||
efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _bounce_eval, obj);
|
efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _bounce_eval, obj);
|
||||||
efl_event_callback_del(obj, EFL_UI_EVENT_SCROLL, _scroll_cb, obj);
|
efl_event_callback_del(obj, EFL_UI_EVENT_SCROLL, _scroll_cb, obj);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
/* spec-meta-start
|
/* spec-meta-start
|
||||||
{"test-interface":"Efl.Ui.Clickable",
|
{"test-interface":"Efl.Ui.Clickable",
|
||||||
"test-widgets": ["Efl.Ui.Button"]
|
"test-widgets": ["Efl.Ui.Button", "Efl.Ui.Image"]
|
||||||
}
|
}
|
||||||
spec-meta-end
|
spec-meta-end
|
||||||
*/
|
*/
|
||||||
|
@ -45,6 +45,14 @@ prepare_window(void)
|
||||||
pos->x = 30;
|
pos->x = 30;
|
||||||
pos->y = 30;
|
pos->y = 30;
|
||||||
|
|
||||||
|
if (efl_isa(widget, EFL_UI_IMAGE_CLASS))
|
||||||
|
{
|
||||||
|
efl_gfx_hint_size_min_set(widget, EINA_SIZE2D(200, 200));
|
||||||
|
efl_file_simple_load(widget, ELM_IMAGE_DATA_DIR"/images/bubble.png", NULL);
|
||||||
|
pos->x = 100;
|
||||||
|
pos->y = 100;
|
||||||
|
}
|
||||||
|
|
||||||
evas_smart_objects_calculate(evas_object_evas_get(win));
|
evas_smart_objects_calculate(evas_object_evas_get(win));
|
||||||
evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, pos);
|
evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, pos);
|
||||||
efl_loop_begin(efl_app_main_get());
|
efl_loop_begin(efl_app_main_get());
|
||||||
|
|
Loading…
Reference in New Issue