summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-24 10:18:01 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-26 11:41:58 +0100
commit1763afb391f550c22969b0706b1f4bcc1ffebfc3 (patch)
tree6d00f0a97c7cdd9d6a1506fcef05b919a7faffde /src/lib/edje
parent0b0ff33f2f097fb49665ec4576ccceb8ec0c9a8e (diff)
edje: implement container api
the container api returns the number of added swallows. the content iterator returns a iterator over all swallowed objects. The reason this is only for swallows is that the interface explicitly mentions UI elements at the count. Since i am believing the the result of the count operation should mirror to the amount of elements in the iterator, the iterator only returns swallowed objects. ref T5719 Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D7748
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_util.c76
-rw-r--r--src/lib/edje/efl_canvas_layout.eo2
2 files changed, 78 insertions, 0 deletions
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index f9fac775ee..4f27839066 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3397,6 +3397,82 @@ _efl_canvas_layout_efl_container_content_remove(Eo *obj EINA_UNUSED, Edje *ed, E
3397 return EINA_TRUE; 3397 return EINA_TRUE;
3398} 3398}
3399 3399
3400typedef struct _Content_Part_Iterator Content_Part_Iterator;
3401struct _Content_Part_Iterator
3402{
3403 Eina_Iterator iterator;
3404 Eo *object;
3405 Edje *ed;
3406 unsigned index;
3407};
3408
3409static Eina_Bool
3410_content_part_iterator_next(Content_Part_Iterator *it, void **data)
3411{
3412 for (; it->index < it->ed->table_parts_size; it->index++)
3413 {
3414 Edje_Real_Part *rp = it->ed->table_parts[it->index];
3415 if (rp->part && rp->part->type == EDJE_PART_TYPE_SWALLOW)
3416 {
3417 if (data) *data = (void*) rp->typedata.swallow->swallowed_object;
3418 it->index++;
3419 return EINA_TRUE;
3420 }
3421 }
3422
3423 return EINA_FALSE;
3424}
3425
3426static Eo *
3427_content_part_iterator_get_container(Content_Part_Iterator *it)
3428{
3429 return it->object;
3430}
3431
3432static void
3433_content_part_iterator_free(Content_Part_Iterator *it)
3434{
3435 free(it);
3436}
3437
3438EOLIAN Eina_Iterator*
3439_efl_canvas_layout_efl_container_content_iterate(Eo *obj, Edje *ed)
3440{
3441 Content_Part_Iterator *it;
3442
3443 it = calloc(1, sizeof(*it));
3444 if (!it) return NULL;
3445
3446 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
3447
3448 it->iterator.version = EINA_ITERATOR_VERSION;
3449 it->iterator.next = FUNC_ITERATOR_NEXT(_content_part_iterator_next);
3450 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_content_part_iterator_get_container);
3451 it->iterator.free = FUNC_ITERATOR_FREE(_content_part_iterator_free);
3452 it->object = obj;
3453 it->ed = ed;
3454 it->index = 0;
3455
3456 return &it->iterator;
3457}
3458
3459EOLIAN int
3460_efl_canvas_layout_efl_container_content_count(Eo *obj EINA_UNUSED, Edje *pd)
3461{
3462 Edje_Real_Part *rp;
3463 int result = 0;
3464
3465 for (int i = 0; i < pd->table_parts_size; ++i)
3466 {
3467 rp = pd->table_parts[i];
3468 if (rp->part && rp->part->type == EDJE_PART_TYPE_SWALLOW)
3469 result ++;
3470 }
3471
3472 return result;
3473}
3474
3475
3400Efl_Gfx_Entity * 3476Efl_Gfx_Entity *
3401_edje_efl_content_content_get(Edje *ed, const char *part) 3477_edje_efl_content_content_get(Edje *ed, const char *part)
3402{ 3478{
diff --git a/src/lib/edje/efl_canvas_layout.eo b/src/lib/edje/efl_canvas_layout.eo
index f607e81408..e4f4f6fa8d 100644
--- a/src/lib/edje/efl_canvas_layout.eo
+++ b/src/lib/edje/efl_canvas_layout.eo
@@ -116,6 +116,8 @@ class Efl.Canvas.Layout extends Efl.Canvas.Group implements Efl.File, Efl.Contai
116 Efl.File.load_error { get; } 116 Efl.File.load_error { get; }
117 Efl.File.mmap { get; set; } 117 Efl.File.mmap { get; set; }
118 Efl.Container.content_remove; 118 Efl.Container.content_remove;
119 Efl.Container.content_iterate;
120 Efl.Container.content_count;
119 Efl.Part.part_get; [[Returns @Efl.Canvas.Layout_Part]] 121 Efl.Part.part_get; [[Returns @Efl.Canvas.Layout_Part]]
120 Efl.Observer.update; 122 Efl.Observer.update;
121 Efl.Player.playable { get; } 123 Efl.Player.playable { get; }