elm: Replace contents list by iterators
This introduces two new methods: - content_names_iterate - content_objects_iterate Replacing: - elm_layout_content_swallow_list_get
This commit is contained in:
parent
d2b7621907
commit
3c40ebb998
|
@ -1366,7 +1366,7 @@ _elm_popup_elm_widget_focus_next(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, Elm_Fo
|
|||
{
|
||||
Evas_Object *ao;
|
||||
Eina_List *items = NULL;
|
||||
Eina_List *base_items = NULL;
|
||||
Eina_Iterator *base_it;
|
||||
|
||||
/* access */
|
||||
if (_elm_config->access_mode)
|
||||
|
@ -1381,9 +1381,10 @@ _elm_popup_elm_widget_focus_next(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, Elm_Fo
|
|||
if (ao) items = eina_list_append(items, ao);
|
||||
}
|
||||
|
||||
base_items = elm_obj_container_content_swallow_list_get(sd->main_layout);
|
||||
|
||||
items = eina_list_merge(items, base_items);
|
||||
base_it = elm_obj_container_content_objects_iterate(sd->main_layout);
|
||||
EINA_ITERATOR_FOREACH(base_it, ao)
|
||||
if (ao) items = eina_list_append(items, ao);
|
||||
eina_iterator_free(base_it);
|
||||
|
||||
if (!elm_widget_focus_list_next_get(sd->main_layout, items, eina_list_data_get, dir, next, next_item))
|
||||
*next = sd->main_layout;
|
||||
|
@ -1403,7 +1404,7 @@ _elm_popup_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, c
|
|||
{
|
||||
Evas_Object *ao;
|
||||
Eina_List *items = NULL;
|
||||
Eina_List *base_items = NULL;
|
||||
Eina_Iterator *base_it;
|
||||
|
||||
/* access */
|
||||
if (_elm_config->access_mode)
|
||||
|
@ -1418,9 +1419,10 @@ _elm_popup_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, c
|
|||
if (ao) items = eina_list_append(items, ao);
|
||||
}
|
||||
|
||||
base_items = elm_obj_container_content_swallow_list_get(sd->main_layout);
|
||||
|
||||
items = eina_list_merge(items, base_items);
|
||||
base_it = elm_obj_container_content_objects_iterate(sd->main_layout);
|
||||
EINA_ITERATOR_FOREACH(base_it, ao)
|
||||
if (ao) items = eina_list_append(items, ao);
|
||||
eina_iterator_free(base_it);
|
||||
|
||||
elm_widget_focus_list_direction_get
|
||||
(sd->main_layout, base, items, eina_list_data_get, degree, direction, direction_item, weight);
|
||||
|
|
|
@ -4,14 +4,6 @@ class Elm.Container (Elm.Widget)
|
|||
eo_prefix: elm_obj_container;
|
||||
data: null;
|
||||
methods {
|
||||
@property content_swallow_list {
|
||||
get {
|
||||
[[Get the list of swallow parts in the object.]]
|
||||
}
|
||||
values {
|
||||
ret: free(own(list<Evas.Object *> *), eina_list_free); [[list]]
|
||||
}
|
||||
}
|
||||
@property content {
|
||||
[[Swallowed sub-object contained in this object.]]
|
||||
set {
|
||||
|
@ -32,12 +24,22 @@ class Elm.Container (Elm.Widget)
|
|||
}
|
||||
return: Evas.Object *;
|
||||
}
|
||||
content_names_iterate {
|
||||
[[Returns an iterator on all parts in this container that currently
|
||||
hold a sub-object.]]
|
||||
return: free(own(iterator<const(char)*> *), eina_iterator_free);
|
||||
}
|
||||
content_objects_iterate {
|
||||
[[Returns an iterator on all swallowed objects in this container.]]
|
||||
return: free(own(iterator<Evas.Object*> *), eina_iterator_free);
|
||||
}
|
||||
}
|
||||
implements {
|
||||
@virtual .content_unset;
|
||||
@virtual .content.get;
|
||||
@virtual .content.set;
|
||||
@virtual .content_swallow_list.get;
|
||||
@virtual .content_names_iterate;
|
||||
@virtual .content_objects_iterate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,14 @@ static const char *_elm_layout_swallow_parts[] = {
|
|||
* should not be messed up by inhering classes */
|
||||
typedef struct _Elm_Layout_Sub_Object_Data Elm_Layout_Sub_Object_Data;
|
||||
typedef struct _Elm_Layout_Sub_Object_Cursor Elm_Layout_Sub_Object_Cursor;
|
||||
typedef struct _Elm_Layout_Sub_Iterator Elm_Layout_Sub_Iterator;
|
||||
|
||||
struct _Elm_Layout_Sub_Iterator
|
||||
{
|
||||
Eina_Iterator iterator;
|
||||
Eina_Iterator *real_iterator;
|
||||
Elm_Layout *object;
|
||||
};
|
||||
|
||||
struct _Elm_Layout_Sub_Object_Data
|
||||
{
|
||||
|
@ -1115,21 +1123,14 @@ _elm_layout_elm_container_content_unset(Eo *obj, Elm_Layout_Smart_Data *sd, cons
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* legacy only - eo is iterator */
|
||||
EAPI Eina_List *
|
||||
elm_layout_content_swallow_list_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_LAYOUT_CHECK(obj) NULL;
|
||||
Eina_List *ret = NULL;
|
||||
ret = elm_obj_container_content_swallow_list_get(obj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_List*
|
||||
_elm_layout_elm_container_content_swallow_list_get(Eo *obj EINA_UNUSED, Elm_Layout_Smart_Data *sd)
|
||||
{
|
||||
Eina_List *ret = NULL;
|
||||
|
||||
Elm_Layout_Sub_Object_Data *sub_d = NULL;
|
||||
Elm_Layout_Smart_Data *sd = eo_data_scope_get(obj, MY_CLASS);
|
||||
Eina_List *l = NULL;
|
||||
|
||||
EINA_LIST_FOREACH(sd->subs, l, sub_d)
|
||||
|
@ -1141,6 +1142,78 @@ _elm_layout_elm_container_content_swallow_list_get(Eo *obj EINA_UNUSED, Elm_Layo
|
|||
return ret;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_names_iterator_next(Elm_Layout_Sub_Iterator *it, void **data)
|
||||
{
|
||||
Elm_Layout_Sub_Object_Data *sub;
|
||||
|
||||
if (!eina_iterator_next(it->real_iterator, (void **)&sub))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (data) *data = (void*) sub->part;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_objects_iterator_next(Elm_Layout_Sub_Iterator *it, void **data)
|
||||
{
|
||||
Elm_Layout_Sub_Object_Data *sub;
|
||||
|
||||
if (!eina_iterator_next(it->real_iterator, (void **)&sub))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (data) *data = sub->obj;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Elm_Layout *
|
||||
_sub_iterator_get_container(Elm_Layout_Sub_Iterator *it)
|
||||
{
|
||||
return it->object;
|
||||
}
|
||||
|
||||
static void
|
||||
_sub_iterator_free(Elm_Layout_Sub_Iterator *it)
|
||||
{
|
||||
eina_iterator_free(it->real_iterator);
|
||||
free(it);
|
||||
}
|
||||
|
||||
static Eina_Iterator *
|
||||
_sub_iterator_create(Elm_Layout_Smart_Data *sd, Eina_Bool objects)
|
||||
{
|
||||
Elm_Layout_Sub_Iterator *it;
|
||||
|
||||
it = calloc(1, sizeof(*it));
|
||||
if (!it) return NULL;
|
||||
|
||||
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
||||
|
||||
it->real_iterator = eina_list_iterator_new(sd->subs);
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_sub_iterator_get_container);
|
||||
it->iterator.free = FUNC_ITERATOR_FREE(_sub_iterator_free);
|
||||
|
||||
if (objects)
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_objects_iterator_next);
|
||||
else
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_names_iterator_next);
|
||||
|
||||
return &it->iterator;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Iterator *
|
||||
_elm_layout_elm_container_content_names_iterate(Eo *eo_obj EINA_UNUSED, Elm_Layout_Smart_Data *sd)
|
||||
{
|
||||
return _sub_iterator_create(sd, EINA_FALSE);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Iterator *
|
||||
_elm_layout_elm_container_content_objects_iterate(Eo *eo_obj EINA_UNUSED, Elm_Layout_Smart_Data *sd)
|
||||
{
|
||||
return _sub_iterator_create(sd, EINA_TRUE);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_layout_text_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, const char *text)
|
||||
{
|
||||
|
|
|
@ -490,7 +490,8 @@ class Elm.Layout (Elm.Container, Efl.File)
|
|||
Elm.Container.content.get;
|
||||
Elm.Container.content.set;
|
||||
Elm.Container.content_unset;
|
||||
Elm.Container.content_swallow_list.get;
|
||||
Elm.Container.content_names_iterate;
|
||||
Elm.Container.content_objects_iterate;
|
||||
}
|
||||
events {
|
||||
theme,changed;
|
||||
|
|
Loading…
Reference in New Issue