forked from enlightenment/efl
[image] - Added support for "clicked" callback on Return/space/KP_Enter key press.
Summary: [image] - Added support for "clicked" callback on Return/space/KP_Enter key press. Reviewers: seoz, Hermet Differential Revision: https://phab.enlightenment.org/D278
This commit is contained in:
parent
a437e66219
commit
72c30bb3e2
|
@ -209,6 +209,7 @@ void test_popup(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_dayselector(void *data, Evas_Object *obj, void *event_info);
|
void test_dayselector(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_image(void *data, Evas_Object *obj, void *event_info);
|
void test_image(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_remote_image(void *data, Evas_Object *obj, void *event_info);
|
void test_remote_image(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
void test_click_image(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_external_button(void *data, Evas_Object *obj, void *event_info);
|
void test_external_button(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_external_slider(void *data, Evas_Object *obj, void *event_info);
|
void test_external_slider(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_external_scroller(void *data, Evas_Object *obj, void *event_info);
|
void test_external_scroller(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
@ -539,6 +540,7 @@ add_tests:
|
||||||
ADD_TEST(NULL, "Images", "Thumb", test_thumb);
|
ADD_TEST(NULL, "Images", "Thumb", test_thumb);
|
||||||
ADD_TEST(NULL, "Images", "Image", test_image);
|
ADD_TEST(NULL, "Images", "Image", test_image);
|
||||||
ADD_TEST(NULL, "Images", "Image Remote", test_remote_image);
|
ADD_TEST(NULL, "Images", "Image Remote", test_remote_image);
|
||||||
|
ADD_TEST(NULL, "Images", "Image Click", test_click_image);
|
||||||
ADD_TEST(NULL, "Images", "Slideshow", test_slideshow);
|
ADD_TEST(NULL, "Images", "Slideshow", test_slideshow);
|
||||||
#ifdef HAVE_EMOTION
|
#ifdef HAVE_EMOTION
|
||||||
ADD_TEST(NULL, "Images", "Video", test_video);
|
ADD_TEST(NULL, "Images", "Video", test_video);
|
||||||
|
|
|
@ -53,7 +53,6 @@ test_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
||||||
elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE);
|
elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE);
|
||||||
evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
|
||||||
elm_box_pack_end(box, im);
|
elm_box_pack_end(box, im);
|
||||||
evas_object_show(im);
|
evas_object_show(im);
|
||||||
|
|
||||||
|
@ -133,4 +132,57 @@ test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
||||||
evas_object_resize(win, 320, 480);
|
evas_object_resize(win, 320, 480);
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_img_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Elm_Transit *trans;
|
||||||
|
|
||||||
|
fprintf(stderr, "%p - clicked\n", obj);
|
||||||
|
|
||||||
|
trans = elm_transit_add();
|
||||||
|
elm_transit_object_add(trans, data);
|
||||||
|
elm_transit_effect_rotation_add(trans, 0, 180);
|
||||||
|
elm_transit_duration_set(trans, 5.0);
|
||||||
|
elm_transit_go(trans);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_click_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Evas_Object *win, *box, *im, *label;
|
||||||
|
|
||||||
|
win = elm_win_util_standard_add("image test", "Image Test");
|
||||||
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
||||||
|
|
||||||
|
box = elm_box_add(win);
|
||||||
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
elm_win_resize_object_add(win, box);
|
||||||
|
evas_object_show(box);
|
||||||
|
|
||||||
|
im = elm_image_add(win);
|
||||||
|
elm_object_focus_allow_set(im, EINA_TRUE);
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
|
||||||
|
elm_image_file_set(im, buf, NULL);
|
||||||
|
elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE);
|
||||||
|
evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
evas_object_smart_callback_add(im, "clicked", _img_clicked_cb, im);
|
||||||
|
elm_box_pack_end(box, im);
|
||||||
|
evas_object_show(im);
|
||||||
|
|
||||||
|
label = elm_label_add(win);
|
||||||
|
elm_object_text_set(label, "<b>Press Return/Space/KP_Return key on image to transit.</b>");
|
||||||
|
evas_object_size_hint_weight_set(label, 0.0, 0.0);
|
||||||
|
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
elm_box_pack_end(box, label);
|
||||||
|
evas_object_show(label);
|
||||||
|
|
||||||
|
elm_object_focus_set(im, EINA_TRUE);
|
||||||
|
|
||||||
|
evas_object_resize(win, 320, 480);
|
||||||
|
evas_object_show(win);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,12 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_activate(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_on_image_preloaded(void *data,
|
_on_image_preloaded(void *data,
|
||||||
Evas *e __UNUSED__,
|
Evas *e __UNUSED__,
|
||||||
|
@ -630,6 +636,32 @@ _elm_image_smart_theme(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
||||||
if (ret) *ret = EINA_TRUE;
|
if (ret) *ret = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_elm_image_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
||||||
|
{
|
||||||
|
Evas_Object *src = va_arg(*list, Evas_Object *);
|
||||||
|
(void) src;
|
||||||
|
Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
|
||||||
|
void *event_info = va_arg(*list, void *);
|
||||||
|
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
|
||||||
|
Evas_Event_Key_Down *ev = event_info;
|
||||||
|
if (ret) *ret = EINA_FALSE;
|
||||||
|
|
||||||
|
if (elm_widget_disabled_get(obj)) return;
|
||||||
|
if (type != EVAS_CALLBACK_KEY_DOWN) return;
|
||||||
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||||
|
|
||||||
|
if ((strcmp(ev->key, "Return")) &&
|
||||||
|
(strcmp(ev->key, "KP_Enter")) &&
|
||||||
|
(strcmp(ev->key, "space")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_activate(obj);
|
||||||
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||||
|
|
||||||
|
if (ret) *ret = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_elm_image_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
_elm_image_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -1660,6 +1692,7 @@ _class_constructor(Eo_Class *klass)
|
||||||
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_CLIP_UNSET), _elm_image_smart_clip_unset),
|
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_CLIP_UNSET), _elm_image_smart_clip_unset),
|
||||||
|
|
||||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_image_smart_theme),
|
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_image_smart_theme),
|
||||||
|
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_EVENT), _elm_image_smart_event),
|
||||||
|
|
||||||
EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_SET), _elm_image_smart_aspect_fixed_set),
|
EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_SET), _elm_image_smart_aspect_fixed_set),
|
||||||
EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_GET), _elm_image_smart_aspect_fixed_get),
|
EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_GET), _elm_image_smart_aspect_fixed_get),
|
||||||
|
|
Loading…
Reference in New Issue