summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2013-10-30 08:32:43 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-10-30 08:32:44 +0900
commit6ee48d9a9f3ee14c2594928b0e57c37cead27e44 (patch)
tree52c1a909cd19fe57a314a0d457fc1c00fef93e25
parent8f523ed25329b25845fc8d679dac1cd9ce2542d1 (diff)
[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
-rwxr-xr-x[-rw-r--r--]src/bin/test.c2
-rwxr-xr-x[-rw-r--r--]src/bin/test_image.c54
-rwxr-xr-x[-rw-r--r--]src/lib/elm_image.c33
3 files changed, 88 insertions, 1 deletions
diff --git a/src/bin/test.c b/src/bin/test.c
index e6c370768..963f38682 100644..100755
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -209,6 +209,7 @@ void test_popup(void *data, Evas_Object *obj, void *event_info);
209void test_dayselector(void *data, Evas_Object *obj, void *event_info); 209void test_dayselector(void *data, Evas_Object *obj, void *event_info);
210void test_image(void *data, Evas_Object *obj, void *event_info); 210void test_image(void *data, Evas_Object *obj, void *event_info);
211void test_remote_image(void *data, Evas_Object *obj, void *event_info); 211void test_remote_image(void *data, Evas_Object *obj, void *event_info);
212void test_click_image(void *data, Evas_Object *obj, void *event_info);
212void test_external_button(void *data, Evas_Object *obj, void *event_info); 213void test_external_button(void *data, Evas_Object *obj, void *event_info);
213void test_external_slider(void *data, Evas_Object *obj, void *event_info); 214void test_external_slider(void *data, Evas_Object *obj, void *event_info);
214void test_external_scroller(void *data, Evas_Object *obj, void *event_info); 215void test_external_scroller(void *data, Evas_Object *obj, void *event_info);
@@ -539,6 +540,7 @@ add_tests:
539 ADD_TEST(NULL, "Images", "Thumb", test_thumb); 540 ADD_TEST(NULL, "Images", "Thumb", test_thumb);
540 ADD_TEST(NULL, "Images", "Image", test_image); 541 ADD_TEST(NULL, "Images", "Image", test_image);
541 ADD_TEST(NULL, "Images", "Image Remote", test_remote_image); 542 ADD_TEST(NULL, "Images", "Image Remote", test_remote_image);
543 ADD_TEST(NULL, "Images", "Image Click", test_click_image);
542 ADD_TEST(NULL, "Images", "Slideshow", test_slideshow); 544 ADD_TEST(NULL, "Images", "Slideshow", test_slideshow);
543#ifdef HAVE_EMOTION 545#ifdef HAVE_EMOTION
544 ADD_TEST(NULL, "Images", "Video", test_video); 546 ADD_TEST(NULL, "Images", "Video", test_video);
diff --git a/src/bin/test_image.c b/src/bin/test_image.c
index cef56fdb6..311946231 100644..100755
--- a/src/bin/test_image.c
+++ b/src/bin/test_image.c
@@ -53,7 +53,6 @@ test_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
53 elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE); 53 elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE);
54 evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 54 evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55 evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL); 55 evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
56
57 elm_box_pack_end(box, im); 56 elm_box_pack_end(box, im);
58 evas_object_show(im); 57 evas_object_show(im);
59 58
@@ -133,4 +132,57 @@ test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
133 evas_object_resize(win, 320, 480); 132 evas_object_resize(win, 320, 480);
134 evas_object_show(win); 133 evas_object_show(win);
135} 134}
135
136static void
137_img_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
138{
139 Elm_Transit *trans;
140
141 fprintf(stderr, "%p - clicked\n", obj);
142
143 trans = elm_transit_add();
144 elm_transit_object_add(trans, data);
145 elm_transit_effect_rotation_add(trans, 0, 180);
146 elm_transit_duration_set(trans, 5.0);
147 elm_transit_go(trans);
148}
149
150void
151test_click_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
152{
153 Evas_Object *win, *box, *im, *label;
154
155 win = elm_win_util_standard_add("image test", "Image Test");
156 elm_win_autodel_set(win, EINA_TRUE);
157 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
158
159 box = elm_box_add(win);
160 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
161 elm_win_resize_object_add(win, box);
162 evas_object_show(box);
163
164 im = elm_image_add(win);
165 elm_object_focus_allow_set(im, EINA_TRUE);
166 char buf[PATH_MAX];
167 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
168 elm_image_file_set(im, buf, NULL);
169 elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE);
170 evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
171 evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
172 evas_object_smart_callback_add(im, "clicked", _img_clicked_cb, im);
173 elm_box_pack_end(box, im);
174 evas_object_show(im);
175
176 label = elm_label_add(win);
177 elm_object_text_set(label, "<b>Press Return/Space/KP_Return key on image to transit.</b>");
178 evas_object_size_hint_weight_set(label, 0.0, 0.0);
179 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
180 elm_box_pack_end(box, label);
181 evas_object_show(label);
182
183 elm_object_focus_set(im, EINA_TRUE);
184
185 evas_object_resize(win, 320, 480);
186 evas_object_show(win);
187}
136#endif 188#endif
diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c
index 517d34054..676d801ce 100644..100755
--- a/src/lib/elm_image.c
+++ b/src/lib/elm_image.c
@@ -31,6 +31,12 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
31}; 31};
32 32
33static void 33static void
34_activate(Evas_Object *obj)
35{
36 evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
37}
38
39static void
34_on_image_preloaded(void *data, 40_on_image_preloaded(void *data,
35 Evas *e __UNUSED__, 41 Evas *e __UNUSED__,
36 Evas_Object *obj, 42 Evas_Object *obj,
@@ -631,6 +637,32 @@ _elm_image_smart_theme(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
631} 637}
632 638
633static void 639static void
640_elm_image_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
641{
642 Evas_Object *src = va_arg(*list, Evas_Object *);
643 (void) src;
644 Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
645 void *event_info = va_arg(*list, void *);
646 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
647 Evas_Event_Key_Down *ev = event_info;
648 if (ret) *ret = EINA_FALSE;
649
650 if (elm_widget_disabled_get(obj)) return;
651 if (type != EVAS_CALLBACK_KEY_DOWN) return;
652 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
653
654 if ((strcmp(ev->key, "Return")) &&
655 (strcmp(ev->key, "KP_Enter")) &&
656 (strcmp(ev->key, "space")))
657 return;
658
659 _activate(obj);
660 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
661
662 if (ret) *ret = EINA_TRUE;
663}
664
665static void
634_elm_image_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 666_elm_image_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
635{ 667{
636 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; 668 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
@@ -1660,6 +1692,7 @@ _class_constructor(Eo_Class *klass)
1660 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_CLIP_UNSET), _elm_image_smart_clip_unset), 1692 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_CLIP_UNSET), _elm_image_smart_clip_unset),
1661 1693
1662 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_image_smart_theme), 1694 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_image_smart_theme),
1695 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_EVENT), _elm_image_smart_event),
1663 1696
1664 EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_SET), _elm_image_smart_aspect_fixed_set), 1697 EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_SET), _elm_image_smart_aspect_fixed_set),
1665 EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_GET), _elm_image_smart_aspect_fixed_get), 1698 EO_OP_FUNC(ELM_OBJ_IMAGE_ID(ELM_OBJ_IMAGE_SUB_ID_ASPECT_FIXED_GET), _elm_image_smart_aspect_fixed_get),