summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <singh.amitesh@gmail.com>2013-11-13 20:32:31 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-13 20:39:48 +0900
commitcf61678ea3a4dcc78fc0b86af6f118969dd4ed10 (patch)
tree8dea4ebf26151f1f5012f118a771bb208f549ec1
parent5101cb93f8e83135f9446a7f6047424881db7d5f (diff)
[hoversel] - Added focus support on hoversel items.
Summary: Focus support on hoversel items. Test Plan: elementary_test->hoversel2 Reviewers: seoz, raster, Hermet CC: nirajkr Differential Revision: https://phab.enlightenment.org/D316
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rwxr-xr-xsrc/bin/test.c2
-rw-r--r--src/bin/test_hoversel.c62
-rw-r--r--src/lib/elc_hoversel.c87
5 files changed, 156 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 4939b8134..c7c7dee47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1743,3 +1743,7 @@
17432013-11-07 ChunEon Park (Hermet) 17432013-11-07 ChunEon Park (Hermet)
1744 1744
1745 * scroller: don't focus region show if the scroller is disabled. 1745 * scroller: don't focus region show if the scroller is disabled.
1746
17472013-11-05 Amitesh Singh (_ami_)
1748
1749 * hoversel: Added focus support on hoversel items.
diff --git a/NEWS b/NEWS
index 49d973a64..a4029a966 100644
--- a/NEWS
+++ b/NEWS
@@ -156,6 +156,7 @@ Improvements:
156 layout. 156 layout.
157 * Popup: Change the behavior of adding/removing buttons dynamically. User defined button's position is kept. 157 * Popup: Change the behavior of adding/removing buttons dynamically. User defined button's position is kept.
158 * Fileselector: Monitor and update changes of selected path automatically while EIO is working. 158 * Fileselector: Monitor and update changes of selected path automatically while EIO is working.
159 * Hoversel: Added focus support on hoversel items.
159 160
160Fixes: 161Fixes:
161 * Now elm_datetime_field_limit_set() can set year limits wihtout problems. 162 * Now elm_datetime_field_limit_set() can set year limits wihtout problems.
diff --git a/src/bin/test.c b/src/bin/test.c
index 6a54dad8a..174024646 100755
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -71,6 +71,7 @@ void test_toolbar7(void *data, Evas_Object *obj, void *event_info);
71void test_toolbar8(void *data, Evas_Object *obj, void *event_info); 71void test_toolbar8(void *data, Evas_Object *obj, void *event_info);
72void test_toolbar_vertical(void *data, Evas_Object *obj, void *event_info); 72void test_toolbar_vertical(void *data, Evas_Object *obj, void *event_info);
73void test_hoversel(void *data, Evas_Object *obj, void *event_info); 73void test_hoversel(void *data, Evas_Object *obj, void *event_info);
74void test_hoversel_focus(void *data, Evas_Object *obj, void *event_info);
74void test_list(void *data, Evas_Object *obj, void *event_info); 75void test_list(void *data, Evas_Object *obj, void *event_info);
75void test_list_horizontal(void *data, Evas_Object *obj, void *event_info); 76void test_list_horizontal(void *data, Evas_Object *obj, void *event_info);
76void test_list2(void *data, Evas_Object *obj, void *event_info); 77void test_list2(void *data, Evas_Object *obj, void *event_info);
@@ -710,6 +711,7 @@ add_tests:
710 ADD_TEST(NULL, "Selectors", "ColorSelector", test_colorselector); 711 ADD_TEST(NULL, "Selectors", "ColorSelector", test_colorselector);
711 ADD_TEST(NULL, "Selectors", "SegmentControl", test_segment_control); 712 ADD_TEST(NULL, "Selectors", "SegmentControl", test_segment_control);
712 ADD_TEST(NULL, "Selectors", "Hoversel", test_hoversel); 713 ADD_TEST(NULL, "Selectors", "Hoversel", test_hoversel);
714 ADD_TEST(NULL, "Selectors", "Hoversel Focus", test_hoversel_focus);
713 ADD_TEST(NULL, "Selectors", "Radio", test_radio); 715 ADD_TEST(NULL, "Selectors", "Radio", test_radio);
714 ADD_TEST(NULL, "Selectors", "FlipSelector", test_flipselector); 716 ADD_TEST(NULL, "Selectors", "FlipSelector", test_flipselector);
715 ADD_TEST(NULL, "Selectors", "DaySelector", test_dayselector); 717 ADD_TEST(NULL, "Selectors", "DaySelector", test_dayselector);
diff --git a/src/bin/test_hoversel.c b/src/bin/test_hoversel.c
index e0417d348..25b3de094 100644
--- a/src/bin/test_hoversel.c
+++ b/src/bin/test_hoversel.c
@@ -240,3 +240,65 @@ test_hoversel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
240 240
241 evas_object_show(win); 241 evas_object_show(win);
242} 242}
243
244void
245test_hoversel_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
246{
247 Evas_Object *win, *bx, *hoversel;
248
249 win = elm_win_util_standard_add("hoversel focus", "Hoversel Focus");
250 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
251 elm_win_focus_highlight_animate_set(win, EINA_TRUE);
252 elm_win_autodel_set(win, EINA_TRUE);
253
254 bx = elm_box_add(win);
255 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
256 elm_win_resize_object_add(win, bx);
257 evas_object_show(bx);
258
259 hoversel = elm_hoversel_add(win);
260 elm_hoversel_hover_parent_set(hoversel, win);
261 elm_object_text_set(hoversel, "Vertical");
262 elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL);
263 elm_hoversel_item_add(hoversel, "Item 2", NULL, ELM_ICON_NONE, NULL, NULL);
264 elm_hoversel_item_add(hoversel, "Item 3", NULL, ELM_ICON_NONE, NULL, NULL);
265 elm_hoversel_item_add(hoversel, "Item 4 - Long Label Here", "close", ELM_ICON_STANDARD, NULL, NULL);
266 evas_object_smart_callback_add(hoversel, "clicked",
267 _hoversel_clicked_cb, NULL);
268 evas_object_smart_callback_add(hoversel, "selected",
269 _hoversel_selected_cb, NULL);
270 evas_object_smart_callback_add(hoversel, "dismissed",
271 _hoversel_dismissed_cb, NULL);
272 elm_box_pack_end(bx, hoversel);
273 evas_object_show(hoversel);
274
275 hoversel = elm_hoversel_add(win);
276 elm_hoversel_horizontal_set(hoversel, EINA_TRUE);
277 elm_hoversel_hover_parent_set(hoversel, win);
278 elm_object_text_set(hoversel, "Horizontal");
279 elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL);
280 elm_hoversel_item_add(hoversel, "Item 2", NULL, ELM_ICON_NONE, NULL, NULL);
281 elm_hoversel_item_add(hoversel, "Item 3", "home", ELM_ICON_STANDARD, NULL,
282 NULL);
283 elm_hoversel_item_add(hoversel, "Item 4", "close", ELM_ICON_STANDARD, NULL,
284 NULL);
285 elm_box_pack_end(bx, hoversel);
286 evas_object_show(hoversel);
287
288 hoversel = elm_hoversel_add(win);
289 elm_hoversel_hover_parent_set(hoversel, win);
290 elm_object_text_set(hoversel, "Icons");
291 elm_hoversel_item_add(hoversel, "Item 1", "apps", ELM_ICON_STANDARD, NULL,
292 NULL);
293 elm_hoversel_item_add(hoversel, "Item 2", "arrow_down", ELM_ICON_STANDARD,
294 NULL, NULL);
295 elm_hoversel_item_add(hoversel, "Item 3", "home", ELM_ICON_STANDARD, NULL,
296 NULL);
297 elm_hoversel_item_add(hoversel, "Item 4", "close", ELM_ICON_STANDARD, NULL,
298 NULL);
299 elm_box_pack_end(bx, hoversel);
300 evas_object_show(hoversel);
301
302 evas_object_resize(win, 320, 500);
303 evas_object_show(win);
304}
diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c
index f050e5804..2ca3465fe 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -563,6 +563,90 @@ elm_hoversel_item_icon_get(const Elm_Object_Item *it,
563} 563}
564 564
565static void 565static void
566_elm_hoversel_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
567{
568 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
569 if(ret) *ret = EINA_TRUE;
570}
571
572static void
573_elm_hoversel_smart_focus_direction(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
574{
575 Elm_Hoversel_Smart_Data *sd = _pd;
576 Evas_Object *base = va_arg(*list, Evas_Object *);
577 double degree = va_arg(*list, double);
578 Evas_Object **direction = va_arg(*list, Evas_Object **);
579 double *weight = va_arg(*list, double *);
580 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
581 if (ret) *ret = EINA_FALSE;
582 Eina_Bool int_ret;
583 Eina_List *l = NULL;
584 void *(*list_data_get)(const Eina_List *list);
585
586 if (!sd || !sd->hover) return;
587
588 list_data_get = eina_list_data_get;
589 l = eina_list_append(l, sd->hover);
590
591 int_ret = elm_widget_focus_list_direction_get
592 (obj, base, l, list_data_get, degree, direction, weight);
593 if (ret) *ret = int_ret;
594 eina_list_free(l);
595}
596
597static void
598_elm_hoversel_smart_event(Eo *obj, void *_pd, va_list *list)
599{
600 Evas_Object *src = va_arg(*list, Evas_Object *);
601 (void) src;
602 Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
603 void *event_info = va_arg(*list, void *);
604 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
605 if (ret) *ret = EINA_FALSE;
606 Evas_Event_Key_Down *ev = event_info;
607 Elm_Hoversel_Smart_Data *sd = _pd;
608
609 eo_do_super(obj, MY_CLASS, elm_wdg_event(src, type, event_info, ret));
610 if (*ret) return;
611
612 if (!sd || !sd->hover) return;
613 if (elm_widget_disabled_get(obj)) return;
614 if (type != EVAS_CALLBACK_KEY_DOWN) return;
615 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
616
617 if ((!strcmp(ev->key, "Down")) ||
618 ((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
619 {
620 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_DOWN);
621 goto success;
622 }
623 else if ((!strcmp(ev->key, "Up")) ||
624 ((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
625 {
626 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_UP);
627 goto success;
628 }
629 else if ((!strcmp(ev->key, "Left")) ||
630 ((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
631 {
632 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_LEFT);
633 goto success;
634 }
635 else if ((!strcmp(ev->key, "Right")) ||
636 ((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
637 {
638 elm_widget_focus_cycle(sd->hover, ELM_FOCUS_RIGHT);
639 goto success;
640 }
641
642 return;
643
644success:
645 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
646 if (ret) *ret = EINA_TRUE;
647}
648
649static void
566_class_constructor(Eo_Class *klass) 650_class_constructor(Eo_Class *klass)
567{ 651{
568 const Eo_Op_Func_Description func_desc[] = { 652 const Eo_Op_Func_Description func_desc[] = {
@@ -576,6 +660,9 @@ _class_constructor(Eo_Class *klass)
576 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_hoversel_smart_theme), 660 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_hoversel_smart_theme),
577 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_TRANSLATE), _elm_hoversel_smart_translate), 661 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_TRANSLATE), _elm_hoversel_smart_translate),
578 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_PARENT_SET), _elm_hoversel_smart_parent_set), 662 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_PARENT_SET), _elm_hoversel_smart_parent_set),
663 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_hoversel_smart_focus_direction_manager_is),
664 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION), _elm_hoversel_smart_focus_direction),
665 EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_EVENT), _elm_hoversel_smart_event),
579 666
580 EO_OP_FUNC(ELM_OBJ_BUTTON_ID(ELM_OBJ_BUTTON_SUB_ID_ADMITS_AUTOREPEAT_GET), _elm_hoversel_smart_admits_autorepeat_get), 667 EO_OP_FUNC(ELM_OBJ_BUTTON_ID(ELM_OBJ_BUTTON_SUB_ID_ADMITS_AUTOREPEAT_GET), _elm_hoversel_smart_admits_autorepeat_get),
581 668