summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2017-11-11 18:26:53 +0100
committerMarcel Hollerbach <marcel@osg.samsung.com>2017-11-12 12:04:11 +0100
commitb364293b0c2238c74a8450c4d27787ebe027b483 (patch)
treeb3b5d6a9f89bb021499351550cf82e94f9cfcfb8 /src
parentd30985b4e21b136483c4ffafa2fd42c7281e175b (diff)
genlist: implement item focus
this implements item-content focus for genlist. feel free to notify me if there are any crashes or something simular. ref T6181
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/elm_genlist.c105
-rw-r--r--src/lib/elementary/elm_genlist.eo13
-rw-r--r--src/lib/elementary/elm_genlist_item.eo5
-rw-r--r--src/lib/elementary/elm_widget_genlist.h3
4 files changed, 108 insertions, 18 deletions
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index 6c77edff13..25aa0b1bd5 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -8,6 +8,7 @@
8#define EFL_ACCESS_SELECTION_PROTECTED 8#define EFL_ACCESS_SELECTION_PROTECTED
9#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED 9#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
10#define ELM_WIDGET_ITEM_PROTECTED 10#define ELM_WIDGET_ITEM_PROTECTED
11#define EFL_UI_FOCUS_COMPOSITION_PROTECTED
11 12
12#include <Elementary.h> 13#include <Elementary.h>
13#include <Elementary_Cursor.h> 14#include <Elementary_Cursor.h>
@@ -15,6 +16,8 @@
15#include "elm_priv.h" 16#include "elm_priv.h"
16#include "elm_widget_genlist.h" 17#include "elm_widget_genlist.h"
17#include "elm_interface_scrollable.h" 18#include "elm_interface_scrollable.h"
19#include "efl_ui_focus_parent_provider_gen.eo.h"
20#include "efl_ui_focus_composition_adapter.eo.h"
18#include "elm_genlist_item.eo.h" 21#include "elm_genlist_item.eo.h"
19#include "elm_genlist_pan.eo.h" 22#include "elm_genlist_pan.eo.h"
20#include "elm_genlist.eo.h" 23#include "elm_genlist.eo.h"
@@ -403,6 +406,8 @@ _item_content_realize(Elm_Gen_Item *it,
403 Eina_List *source; 406 Eina_List *source;
404 const char *key; 407 const char *key;
405 408
409 ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
410
406 if (!parts) 411 if (!parts)
407 { 412 {
408 EINA_LIST_FREE(*contents, content) 413 EINA_LIST_FREE(*contents, content)
@@ -437,6 +442,7 @@ _item_content_realize(Elm_Gen_Item *it,
437 442
438 if (content != old) 443 if (content != old)
439 { 444 {
445 eina_hash_add(sd->content_item_map, &content, it->base->eo_obj);
440 // FIXME: Genlist item doesn't update its size when the size of 446 // FIXME: Genlist item doesn't update its size when the size of
441 // content is changed, so deferred calculation for content should 447 // content is changed, so deferred calculation for content should
442 // be performed before realization. 448 // be performed before realization.
@@ -472,6 +478,7 @@ out:
472 { 478 {
473 *contents = eina_list_remove(*contents, old); 479 *contents = eina_list_remove(*contents, old);
474 evas_object_del(old); 480 evas_object_del(old);
481 eina_hash_del_by_key(sd->content_item_map, &old);
475 } 482 }
476 } 483 }
477} 484}
@@ -1684,6 +1691,7 @@ _item_cache_find(Elm_Gen_Item *it)
1684static Eina_List * 1691static Eina_List *
1685_content_cache_add(Elm_Gen_Item *it, Eina_List **cache) 1692_content_cache_add(Elm_Gen_Item *it, Eina_List **cache)
1686{ 1693{
1694 ELM_GENLIST_DATA_GET_FROM_ITEM(it, pd);
1687 Evas_Object *content = NULL; 1695 Evas_Object *content = NULL;
1688 EINA_LIST_FREE(it->contents, content) 1696 EINA_LIST_FREE(it->contents, content)
1689 { 1697 {
@@ -1691,6 +1699,7 @@ _content_cache_add(Elm_Gen_Item *it, Eina_List **cache)
1691 elm_widget_disabled_set(content, EINA_FALSE); 1699 elm_widget_disabled_set(content, EINA_FALSE);
1692 1700
1693 *cache = eina_list_append(*cache, content); 1701 *cache = eina_list_append(*cache, content);
1702 eina_hash_del_by_key(pd->content_item_map, &content);
1694 } 1703 }
1695 1704
1696 return *cache; 1705 return *cache;
@@ -5786,16 +5795,50 @@ elm_genlist_add(Evas_Object *parent)
5786 return elm_legacy_add(MY_CLASS, parent); 5795 return elm_legacy_add(MY_CLASS, parent);
5787} 5796}
5788 5797
5798static void
5799_genlist_element_focused(void *data, const Efl_Event *ev)
5800{
5801 ELM_GENLIST_DATA_GET(data, pd);
5802 Elm_Widget *focused = efl_ui_focus_manager_focus_get(ev->object);
5803 Elm_Widget_Item *item;
5804
5805 if (!focused) return;
5806
5807 if (efl_isa(focused, EFL_UI_FOCUS_COMPOSITION_ADAPTER_CLASS))
5808 item = efl_parent_get(focused);
5809 else
5810 item = efl_ui_focus_parent_provider_find_logical_parent(pd->provider, focused);
5811
5812 if (efl_isa(item, ELM_GENLIST_ITEM_CLASS))
5813 {
5814 _elm_genlist_item_focused(item);
5815 _all_items_deselect(pd);
5816 elm_genlist_item_selected_set(item, EINA_TRUE);
5817 elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
5818 }
5819}
5820
5789EOLIAN static Eo * 5821EOLIAN static Eo *
5790_elm_genlist_efl_object_constructor(Eo *obj, Elm_Genlist_Data *sd) 5822_elm_genlist_efl_object_constructor(Eo *obj, Elm_Genlist_Data *sd)
5791{ 5823{
5792 obj = efl_constructor(efl_super(obj, MY_CLASS)); 5824 obj = efl_constructor(efl_super(obj, MY_CLASS));
5825
5826 sd->content_item_map = eina_hash_pointer_new(NULL);
5827 sd->provider = efl_add(EFL_UI_FOCUS_PARENT_PROVIDER_GEN_CLASS, obj,
5828 efl_ui_focus_parent_provider_gen_container_set(efl_added, obj),
5829 efl_ui_focus_parent_provider_gen_content_item_map_set(efl_added, sd->content_item_map));
5830
5831 efl_ui_focus_composition_custom_manager_set(obj, obj);
5832 efl_ui_focus_composition_logical_mode_set(obj, EINA_TRUE);
5833
5793 sd->obj = obj; 5834 sd->obj = obj;
5794 5835
5795 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); 5836 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
5796 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 5837 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
5797 efl_access_role_set(obj, EFL_ACCESS_ROLE_LIST); 5838 efl_access_role_set(obj, EFL_ACCESS_ROLE_LIST);
5798 5839
5840 efl_event_callback_add(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, _genlist_element_focused, obj);
5841
5799 return obj; 5842 return obj;
5800} 5843}
5801 5844
@@ -5924,17 +5967,7 @@ _item_select(Elm_Gen_Item *it)
5924 5967
5925 if (!(sd->focus_on_selection_enabled || _elm_config->item_select_on_focus_disable)) 5968 if (!(sd->focus_on_selection_enabled || _elm_config->item_select_on_focus_disable))
5926 { 5969 {
5927 Evas_Object *swallow_obj; 5970 efl_ui_focus_manager_focus_set(obj, it->base->eo_obj);
5928 Eina_List *l;
5929 EINA_LIST_FOREACH(it->contents, l, swallow_obj)
5930 {
5931 if (elm_widget_is(swallow_obj) && elm_object_focus_get(swallow_obj))
5932 {
5933 elm_object_focus_set(obj, EINA_FALSE);
5934 elm_object_focus_set(obj, EINA_TRUE);
5935 break;
5936 }
5937 }
5938 } 5971 }
5939 5972
5940 evas_object_unref(obj); 5973 evas_object_unref(obj);
@@ -6191,6 +6224,8 @@ _elm_genlist_item_new(Elm_Genlist_Data *sd,
6191 it->item->expanded_depth = depth; 6224 it->item->expanded_depth = depth;
6192 sd->item_count++; 6225 sd->item_count++;
6193 6226
6227 efl_ui_focus_composition_dirty(sd->obj);
6228
6194 return it; 6229 return it;
6195} 6230}
6196 6231
@@ -8702,6 +8737,54 @@ _elm_genlist_efl_access_selection_child_deselect(Eo *obj EINA_UNUSED, Elm_Genlis
8702 return EINA_FALSE; 8737 return EINA_FALSE;
8703} 8738}
8704 8739
8740EOLIAN static Efl_Object*
8741_elm_genlist_efl_object_provider_find(Eo *obj, Elm_Genlist_Data *pd, const Efl_Object *klass)
8742{
8743 if (klass == EFL_UI_FOCUS_PARENT_PROVIDER_INTERFACE)
8744 return pd->provider;
8745 return efl_provider_find(efl_super(obj, ELM_GENLIST_CLASS), klass);
8746}
8747
8748EOLIAN static void
8749_elm_genlist_efl_ui_focus_composition_prepare(Eo *obj, Elm_Genlist_Data *pd)
8750{
8751 Elm_Gen_Item *item;
8752 Eina_List *order = NULL;
8753
8754 EINA_INLIST_FOREACH(pd->items, item)
8755 {
8756 if (item->base->disabled)
8757 continue;
8758
8759 order = eina_list_append(order, item->base->eo_obj);
8760 }
8761
8762 efl_ui_focus_composition_elements_set(obj, order);
8763}
8764
8765EOLIAN static void
8766_elm_genlist_item_efl_ui_focus_object_prepare_logical(Eo *obj, Elm_Gen_Item *pd)
8767{
8768 Eina_List *n;
8769 Elm_Widget *wid;
8770
8771 _item_realize(pd, pd->item->order_num_in, EINA_FALSE);
8772
8773 EINA_LIST_FOREACH(pd->contents, n, wid)
8774 {
8775 if (efl_isa(wid, ELM_WIDGET_CLASS))
8776 _elm_widget_full_eval(wid);
8777 }
8778
8779 efl_ui_focus_object_prepare_logical(efl_super(obj, ELM_GENLIST_ITEM_CLASS));
8780}
8781
8782EOLIAN static Eina_Bool
8783_elm_genlist_elm_widget_focus_state_apply(Eo *obj, Elm_Genlist_Data *pd EINA_UNUSED, Elm_Widget_Focus_State current_state, Elm_Widget_Focus_State *configured_state, Elm_Widget *redirect EINA_UNUSED)
8784{
8785 return efl_ui_widget_focus_state_apply(efl_super(obj, MY_CLASS), current_state, configured_state, obj);
8786}
8787
8705/* Standard widget overrides */ 8788/* Standard widget overrides */
8706 8789
8707ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(elm_genlist, Elm_Genlist_Data) 8790ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(elm_genlist, Elm_Genlist_Data)
diff --git a/src/lib/elementary/elm_genlist.eo b/src/lib/elementary/elm_genlist.eo
index 52cb44908c..c0460b12ef 100644
--- a/src/lib/elementary/elm_genlist.eo
+++ b/src/lib/elementary/elm_genlist.eo
@@ -2,7 +2,7 @@ import elm_general;
2import elm_list; 2import elm_list;
3import elm_genlist_item; 3import elm_genlist_item;
4 4
5class Elm.Genlist (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable, 5class Elm.Genlist (Efl.Ui.Layout, Efl.Ui.Focus.Composition, Elm.Interface_Scrollable, Efl.Ui.Clickable,
6 Elm.Interface.Atspi_Widget_Action, Efl.Access.Selection, 6 Elm.Interface.Atspi_Widget_Action, Efl.Access.Selection,
7 Efl.Ui.Selectable) 7 Efl.Ui.Selectable)
8{ 8{
@@ -301,7 +301,7 @@ class Elm.Genlist (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
301 301
302 This returns a list of the realized items in the genlist. 302 This returns a list of the realized items in the genlist.
303 The list contains genlist item pointers. The list must be 303 The list contains genlist item pointers. The list must be
304 freed by the caller when done with \@ref eina_list_free. The 304 freed by the caller when done with \@ref eina_list_free. The
305 item pointers in the list are only valid so long as those 305 item pointers in the list are only valid so long as those
306 items are not deleted or the genlist is not deleted. 306 items are not deleted or the genlist is not deleted.
307 ]] 307 ]]
@@ -331,7 +331,7 @@ class Elm.Genlist (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
331 [[Get the last item in the genlist 331 [[Get the last item in the genlist
332 332
333 This returns the last item in the list. 333 This returns the last item in the list.
334 334
335 If filter is set to genlist, it returns 335 If filter is set to genlist, it returns
336 last filtered item in the list. 336 last filtered item in the list.
337 ]] 337 ]]
@@ -532,6 +532,7 @@ class Elm.Genlist (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
532 Efl.Gfx.position { set; } 532 Efl.Gfx.position { set; }
533 Efl.Gfx.size { set; } 533 Efl.Gfx.size { set; }
534 Efl.Canvas.Group.group_member_add; 534 Efl.Canvas.Group.group_member_add;
535 Efl.Object.provider_find;
535 Elm.Widget.theme_apply; 536 Elm.Widget.theme_apply;
536 Elm.Widget.widget_sub_object_add; 537 Elm.Widget.widget_sub_object_add;
537 Elm.Widget.on_access_update; 538 Elm.Widget.on_access_update;
@@ -554,6 +555,8 @@ class Elm.Genlist (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
554 Efl.Access.Selection.is_child_selected; 555 Efl.Access.Selection.is_child_selected;
555 Efl.Access.Selection.all_children_select; 556 Efl.Access.Selection.all_children_select;
556 Efl.Access.Selection.clear; 557 Efl.Access.Selection.clear;
558 Efl.Ui.Focus.Composition.prepare;
559 Elm.Widget.focus_state_apply;
557 } 560 }
558 events { 561 events {
559 item,focused; [[Called when genlist item got focus]] 562 item,focused; [[Called when genlist item got focus]]
@@ -568,11 +571,11 @@ class Elm.Genlist (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
568 edge,bottom; [[Called when bottom edge is reached]] 571 edge,bottom; [[Called when bottom edge is reached]]
569 edge,left; [[Called when left edge is reached]] 572 edge,left; [[Called when left edge is reached]]
570 edge,right; [[Called when right edge is reached]] 573 edge,right; [[Called when right edge is reached]]
571 moved; [[Called when genlist item moved]] 574 moved; [[Called when genlist item moved]]
572 moved,before; [[Called when genlist item moved before]] 575 moved,before; [[Called when genlist item moved before]]
573 moved,after; [[Called when genlist item moved after]] 576 moved,after; [[Called when genlist item moved after]]
574 swipe; [[Called when swipe is detected]] 577 swipe; [[Called when swipe is detected]]
575 multi,pinch,in; [[Called when multitouch pinch in detected]] 578 multi,pinch,in; [[Called when multitouch pinch in detected]]
576 multi,pinch,out; [[Called when multitouch pinch out detected]] 579 multi,pinch,out; [[Called when multitouch pinch out detected]]
577 multi,swipe,down; [[Called when multitouch swipe down detected]] 580 multi,swipe,down; [[Called when multitouch swipe down detected]]
578 multi,swipe,up; [[Called when multitouch swipe up detected]] 581 multi,swipe,up; [[Called when multitouch swipe up detected]]
diff --git a/src/lib/elementary/elm_genlist_item.eo b/src/lib/elementary/elm_genlist_item.eo
index 87bc3bcff8..64fb0982a6 100644
--- a/src/lib/elementary/elm_genlist_item.eo
+++ b/src/lib/elementary/elm_genlist_item.eo
@@ -38,7 +38,7 @@ enum Elm.Genlist.Item.Scrollto_Type
38 bottom = (1 << 3) [[To the bottom of viewport.]] 38 bottom = (1 << 3) [[To the bottom of viewport.]]
39} 39}
40 40
41class Elm.Genlist.Item(Elm.Widget.Item) 41class Elm.Genlist.Item(Elm.Widget.Item.Static_Focus)
42{ 42{
43 [[Elementary genlist item class]] 43 [[Elementary genlist item class]]
44 legacy_prefix: elm_genlist_item; 44 legacy_prefix: elm_genlist_item;
@@ -223,7 +223,7 @@ class Elm.Genlist.Item(Elm.Widget.Item)
223 @property select_mode { 223 @property select_mode {
224 get { 224 get {
225 [[Get the genlist item's select mode. 225 [[Get the genlist item's select mode.
226 226
227 It's ELM_OBJECT_SELECT_MODE_MAX on failure. 227 It's ELM_OBJECT_SELECT_MODE_MAX on failure.
228 ]] 228 ]]
229 } 229 }
@@ -461,5 +461,6 @@ class Elm.Genlist.Item(Elm.Widget.Item)
461 Elm.Widget.Item.cursor_unset; 461 Elm.Widget.Item.cursor_unset;
462 Efl.Access.name { get; } 462 Efl.Access.name { get; }
463 Efl.Access.state_set { get; } 463 Efl.Access.state_set { get; }
464 Efl.Ui.Focus.Object.prepare_logical;
464 } 465 }
465} 466}
diff --git a/src/lib/elementary/elm_widget_genlist.h b/src/lib/elementary/elm_widget_genlist.h
index 5e81cbe8ac..69c0cb530a 100644
--- a/src/lib/elementary/elm_widget_genlist.h
+++ b/src/lib/elementary/elm_widget_genlist.h
@@ -149,6 +149,9 @@ struct _Elm_Genlist_Data
149 Ecore_Idle_Enterer *queue_filter_enterer; 149 Ecore_Idle_Enterer *queue_filter_enterer;
150 Eina_Hash *size_caches; 150 Eina_Hash *size_caches;
151 151
152 Eina_Hash *content_item_map;
153 Eo *provider;
154
152 Eina_Bool filter; 155 Eina_Bool filter;
153 Eina_Bool focus_on_selection_enabled : 1; 156 Eina_Bool focus_on_selection_enabled : 1;
154 Eina_Bool tree_effect_enabled : 1; 157 Eina_Bool tree_effect_enabled : 1;