summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe ANDRE <jpeg@videolan.org>2016-05-19 03:20:09 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 18:50:58 +0900
commitd0f141077ef57ecdd67106c26e3fcc778b318bff (patch)
tree50016c845b1d0e198716cb9cb16bc91a900001c7
parent93ab200d67f935041cec3126d703667abba71d18 (diff)
Efl: Add Efl.Part and switch to it
This should now fix the part API usage once and for all. EFL should have no part name in any of its APIs beyond the Efl.Part interface. Part proxy objects (may be real objects) have a lifetime of only one function call, in a fashion similar to eo_super. @feature
-rw-r--r--src/Makefile_Efl.am1
-rw-r--r--src/lib/edje/edje_containers.c43
-rw-r--r--src/lib/edje/edje_load.c1
-rw-r--r--src/lib/edje/edje_object.eo3
-rw-r--r--src/lib/edje/edje_private.h1
-rw-r--r--src/lib/edje/edje_util.c42
-rw-r--r--src/lib/efl/Efl.h1
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c1
-rw-r--r--src/lib/efl/interfaces/efl_part.eo46
9 files changed, 91 insertions, 48 deletions
diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am
index e3b3248aab..cddd82ad60 100644
--- a/src/Makefile_Efl.am
+++ b/src/Makefile_Efl.am
@@ -10,6 +10,7 @@ efl_eolian_files = \
10 lib/efl/interfaces/efl_control.eo \ 10 lib/efl/interfaces/efl_control.eo \
11 lib/efl/interfaces/efl_file.eo \ 11 lib/efl/interfaces/efl_file.eo \
12 lib/efl/interfaces/efl_image_load.eo \ 12 lib/efl/interfaces/efl_image_load.eo \
13 lib/efl/interfaces/efl_part.eo \
13 lib/efl/interfaces/efl_player.eo \ 14 lib/efl/interfaces/efl_player.eo \
14 lib/efl/interfaces/efl_text.eo \ 15 lib/efl/interfaces/efl_text.eo \
15 lib/efl/interfaces/efl_text_properties.eo \ 16 lib/efl/interfaces/efl_text_properties.eo \
diff --git a/src/lib/edje/edje_containers.c b/src/lib/edje/edje_containers.c
index 59a7399a93..87ad635883 100644
--- a/src/lib/edje/edje_containers.c
+++ b/src/lib/edje/edje_containers.c
@@ -21,6 +21,7 @@ struct _Edje_Part_Data
21 Edje *ed; 21 Edje *ed;
22 Edje_Real_Part *rp; 22 Edje_Real_Part *rp;
23 const char *part; 23 const char *part;
24 Eina_Bool temp;
24}; 25};
25 26
26struct _Part_Item_Iterator 27struct _Part_Item_Iterator
@@ -31,26 +32,12 @@ struct _Part_Item_Iterator
31 Eo *object; 32 Eo *object;
32}; 33};
33 34
34static Eina_Bool
35_del_cb(void *data, const Eo_Event *event EINA_UNUSED)
36{
37 Edje_Real_Part *rp = data;
38 rp->typedata.container->eo_proxy = NULL;
39 return EO_CALLBACK_CONTINUE;
40}
41
42Eo * 35Eo *
43_edje_box_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp) 36_edje_box_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp)
44{ 37{
45 Efl_Canvas_Layout_Internal_Box *eo = rp->typedata.container->eo_proxy; 38 // TODO: optimize (cache)
46 39 return eo_add(BOX_CLASS, obj,
47 if (eo) return eo; 40 efl_canvas_layout_internal_box_real_part_set(eo_self, ed, rp, rp->part->name));
48
49 eo = eo_add(BOX_CLASS, obj, efl_canvas_layout_internal_box_real_part_set(eo_self, ed, rp, rp->part->name));
50 eo_event_callback_add(eo, EO_EVENT_DEL, _del_cb, rp);
51
52 rp->typedata.container->eo_proxy = eo;
53 return eo;
54} 41}
55 42
56EOLIAN static void 43EOLIAN static void
@@ -59,6 +46,7 @@ _efl_canvas_layout_internal_box_real_part_set(Eo *obj EINA_UNUSED, Edje_Box_Data
59 pd->ed = ed; 46 pd->ed = ed;
60 pd->rp = rp; 47 pd->rp = rp;
61 pd->part = part; 48 pd->part = part;
49 pd->temp = EINA_TRUE;
62} 50}
63 51
64EOLIAN static Eo_Base * 52EOLIAN static Eo_Base *
@@ -261,15 +249,9 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_direction_get(Eo *obj EINA_
261Eo * 249Eo *
262_edje_table_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp) 250_edje_table_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp)
263{ 251{
264 Efl_Canvas_Layout_Internal_Box *eo = rp->typedata.container->eo_proxy; 252 // TODO: optimize (cache)
265 253 return eo_add(TABLE_CLASS, obj,
266 if (eo) return eo; 254 efl_canvas_layout_internal_table_real_part_set(eo_self, ed, rp, rp->part->name));
267
268 eo = eo_add(TABLE_CLASS, obj, efl_canvas_layout_internal_table_real_part_set(eo_self, ed, rp, rp->part->name));
269 eo_event_callback_add(eo, EO_EVENT_DEL, _del_cb, rp);
270
271 rp->typedata.container->eo_proxy = eo;
272 return eo;
273} 255}
274 256
275EOLIAN static void 257EOLIAN static void
@@ -278,6 +260,7 @@ _efl_canvas_layout_internal_table_real_part_set(Eo *obj EINA_UNUSED, Edje_Table_
278 pd->ed = ed; 260 pd->ed = ed;
279 pd->rp = rp; 261 pd->rp = rp;
280 pd->part = part; 262 pd->part = part;
263 pd->temp = EINA_TRUE;
281} 264}
282 265
283EOLIAN static Eo_Base * 266EOLIAN static Eo_Base *
@@ -453,7 +436,7 @@ _efl_canvas_layout_internal_table_efl_pack_grid_grid_position_get(Eo *obj EINA_U
453 436
454#ifdef DEGUG 437#ifdef DEGUG
455#define PART_BOX_GET(obj, part, ...) ({ \ 438#define PART_BOX_GET(obj, part, ...) ({ \
456 Eo *__box = efl_content_get(obj, part); \ 439 Eo *__box = efl_part(obj, part); \
457 if (!__box || !eo_isa(__box, EFL_CANVAS_LAYOUT_INTERNAL_BOX_CLASS)) \ 440 if (!__box || !eo_isa(__box, EFL_CANVAS_LAYOUT_INTERNAL_BOX_CLASS)) \
458 { \ 441 { \
459 ERR("No such box part '%s' in layout %p", part, obj); \ 442 ERR("No such box part '%s' in layout %p", part, obj); \
@@ -462,7 +445,7 @@ _efl_canvas_layout_internal_table_efl_pack_grid_grid_position_get(Eo *obj EINA_U
462 __box; }) 445 __box; })
463#else 446#else
464#define PART_BOX_GET(obj, part, ...) ({ \ 447#define PART_BOX_GET(obj, part, ...) ({ \
465 Eo *__box = efl_content_get(obj, part); \ 448 Eo *__box = efl_part(obj, part); \
466 if (!__box) return __VA_ARGS__; \ 449 if (!__box) return __VA_ARGS__; \
467 __box; }) 450 __box; })
468#endif 451#endif
@@ -531,7 +514,7 @@ edje_object_part_box_remove_all(Edje_Object *obj, const char *part, Eina_Bool cl
531 514
532#ifdef DEBUG 515#ifdef DEBUG
533#define PART_TABLE_GET(obj, part, ...) ({ \ 516#define PART_TABLE_GET(obj, part, ...) ({ \
534 Eo *__table = efl_content_get(obj, part); \ 517 Eo *__table = efl_part(obj, part); \
535 if (!__table || !eo_isa(__table, EFL_CANVAS_LAYOUT_INTERNAL_TABLE_CLASS)) \ 518 if (!__table || !eo_isa(__table, EFL_CANVAS_LAYOUT_INTERNAL_TABLE_CLASS)) \
536 { \ 519 { \
537 ERR("No such table part '%s' in layout %p", part, obj); \ 520 ERR("No such table part '%s' in layout %p", part, obj); \
@@ -540,7 +523,7 @@ edje_object_part_box_remove_all(Edje_Object *obj, const char *part, Eina_Bool cl
540 __table; }) 523 __table; })
541#else 524#else
542#define PART_TABLE_GET(obj, part, ...) ({ \ 525#define PART_TABLE_GET(obj, part, ...) ({ \
543 Eo *__table = efl_content_get(obj, part); \ 526 Eo *__table = efl_part(obj, part); \
544 if (!__table) return __VA_ARGS__; \ 527 if (!__table) return __VA_ARGS__; \
545 __table; }) 528 __table; })
546#endif 529#endif
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index e6bdeeae7b..1a5800365d 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1596,7 +1596,6 @@ _edje_file_del(Edje *ed)
1596 _edje_box_layout_free_data(rp->typedata.container->anim); 1596 _edje_box_layout_free_data(rp->typedata.container->anim);
1597 rp->typedata.container->anim = NULL; 1597 rp->typedata.container->anim = NULL;
1598 } 1598 }
1599 eo_unref(rp->typedata.container->eo_proxy);
1600 free(rp->typedata.container); 1599 free(rp->typedata.container);
1601 } 1600 }
1602 else if ((rp->type == EDJE_RP_TYPE_TEXT) && 1601 else if ((rp->type == EDJE_RP_TYPE_TEXT) &&
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 2ed2d882dd..d79cd9338a 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -1,6 +1,6 @@
1import edje_types; 1import edje_types;
2 2
3class Edje.Object (Evas.Smart.Clipped, Efl.File, Efl.Container) 3class Edje.Object (Evas.Smart.Clipped, Efl.File, Efl.Container, Efl.Part)
4{ 4{
5 legacy_prefix: edje_object; 5 legacy_prefix: edje_object;
6 eo_prefix: edje_obj; 6 eo_prefix: edje_obj;
@@ -2005,6 +2005,7 @@ class Edje.Object (Evas.Smart.Clipped, Efl.File, Efl.Container)
2005 Efl.Container.content_unset; 2005 Efl.Container.content_unset;
2006 Efl.Container.content_remove; 2006 Efl.Container.content_remove;
2007 Efl.Container.content_part_name.get; 2007 Efl.Container.content_part_name.get;
2008 Efl.Part.part;
2008 } 2009 }
2009 events { 2010 events {
2010 recalc; [[Edje re-calculated the object.]] 2011 recalc; [[Edje re-calculated the object.]]
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 5bfecbc845..604e7a4ca7 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1897,7 +1897,6 @@ struct _Edje_Real_Part_Container
1897{ 1897{
1898 Eina_List *items; // 4 //FIXME: only if table/box 1898 Eina_List *items; // 4 //FIXME: only if table/box
1899 Edje_Part_Box_Animation *anim; // 4 //FIXME: Used only if box 1899 Edje_Part_Box_Animation *anim; // 4 //FIXME: Used only if box
1900 Eo *eo_proxy;
1901}; 1900};
1902 1901
1903struct _Edje_Real_Part_Swallow 1902struct _Edje_Real_Part_Swallow
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 7009fda9a9..b8e4923b8e 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3897,23 +3897,15 @@ _edje_object_efl_container_content_get(Eo *obj, Edje *ed, const char *part)
3897 rp = _edje_real_part_recursive_get(&ed, part); 3897 rp = _edje_real_part_recursive_get(&ed, part);
3898 if (!rp) return NULL; 3898 if (!rp) return NULL;
3899 3899
3900 switch (rp->type) 3900 if (rp->type != EDJE_RP_TYPE_SWALLOW)
3901 { 3901 {
3902 case EDJE_RP_TYPE_SWALLOW: 3902 ERR("Edje group '%s' part '%s' is not a swallow. Did "
3903 if (!rp->typedata.swallow) return NULL; 3903 "you mean to call efl_part() instead?", ed->group, part);
3904 return rp->typedata.swallow->swallowed_object;
3905 case EDJE_RP_TYPE_CONTAINER:
3906 if (rp->part->type == EDJE_PART_TYPE_BOX)
3907 return _edje_box_internal_proxy_get(obj, ed, rp);
3908 else if (rp->part->type == EDJE_PART_TYPE_TABLE)
3909 return _edje_table_internal_proxy_get(obj, ed, rp);
3910 else return NULL;
3911 case EDJE_RP_TYPE_TEXT:
3912 WRN("not implemented yet");
3913 return NULL;
3914 default:
3915 return NULL; 3904 return NULL;
3916 } 3905 }
3906
3907 if (!rp->typedata.swallow) return NULL;
3908 return rp->typedata.swallow->swallowed_object;
3917} 3909}
3918 3910
3919/* new in eo */ 3911/* new in eo */
@@ -3943,6 +3935,26 @@ _edje_object_efl_container_content_part_name_get(Eo *obj EINA_UNUSED, Edje *ed E
3943 return rp->part->name; 3935 return rp->part->name;
3944} 3936}
3945 3937
3938EOLIAN Eo *
3939_edje_object_efl_part_part(Eo *obj, Edje *ed, const char *part)
3940{
3941 Edje_Real_Part *rp;
3942
3943 if ((!ed) || (!part)) return NULL;
3944
3945 /* Need to recalc before providing the object. */
3946 _edje_recalc_do(ed);
3947
3948 rp = _edje_real_part_recursive_get(&ed, part);
3949 if (!rp) return NULL;
3950
3951 if (rp->part->type == EDJE_PART_TYPE_BOX)
3952 return _edje_box_internal_proxy_get(obj, ed, rp);
3953 else if (rp->part->type == EDJE_PART_TYPE_TABLE)
3954 return _edje_table_internal_proxy_get(obj, ed, rp);
3955 else return NULL; /* FIXME/TODO: text & others (color, ...) */
3956}
3957
3946EOLIAN void 3958EOLIAN void
3947_edje_object_size_min_get(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *minw, Evas_Coord *minh) 3959_edje_object_size_min_get(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *minw, Evas_Coord *minh)
3948{ 3960{
diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h
index 479f7ef01f..6962c8f620 100644
--- a/src/lib/efl/Efl.h
+++ b/src/lib/efl/Efl.h
@@ -71,6 +71,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
71#include "interfaces/efl_image.eo.h" 71#include "interfaces/efl_image.eo.h"
72#include "interfaces/efl_image_animated.eo.h" 72#include "interfaces/efl_image_animated.eo.h"
73#include "interfaces/efl_image_load.eo.h" 73#include "interfaces/efl_image_load.eo.h"
74#include "interfaces/efl_part.eo.h"
74#include "interfaces/efl_player.eo.h" 75#include "interfaces/efl_player.eo.h"
75#include "interfaces/efl_text.eo.h" 76#include "interfaces/efl_text.eo.h"
76#include "interfaces/efl_text_properties.eo.h" 77#include "interfaces/efl_text_properties.eo.h"
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index 98d5096c1b..3b5ce16073 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -9,6 +9,7 @@
9#include "interfaces/efl_image.eo.c" 9#include "interfaces/efl_image.eo.c"
10#include "interfaces/efl_image_animated.eo.c" 10#include "interfaces/efl_image_animated.eo.c"
11#include "interfaces/efl_image_load.eo.c" 11#include "interfaces/efl_image_load.eo.c"
12#include "interfaces/efl_part.eo.c"
12#include "interfaces/efl_player.eo.c" 13#include "interfaces/efl_player.eo.c"
13#include "interfaces/efl_text.eo.c" 14#include "interfaces/efl_text.eo.c"
14#include "interfaces/efl_text_properties.eo.c" 15#include "interfaces/efl_text_properties.eo.c"
diff --git a/src/lib/efl/interfaces/efl_part.eo b/src/lib/efl/interfaces/efl_part.eo
new file mode 100644
index 0000000000..76ef1707c4
--- /dev/null
+++ b/src/lib/efl/interfaces/efl_part.eo
@@ -0,0 +1,46 @@
1import eo_base;
2
3interface Efl.Part
4{
5 [[Interface for objects supporting named parts.
6
7 An object implementing this interface will be able to
8 provide access to some of its sub-objects by name.
9 This gives access to parts as defined in a widget's
10 theme.
11
12 Part proxy objects have a special lifetime that
13 is limited to one and only one function call.
14
15 In other words, the caller does not hold a reference
16 to this proxy object. It may be possible, in languages
17 that allow it, to get an extra reference to this part
18 object and extend its lifetime to more than a single
19 function call.
20
21 In pseudo-code, this means only the following two
22 use cases are supported:
23
24 obj.func(part(obj, "part"), args)
25
26 And:
27
28 part = ref(part(obj, "part"))
29 func1(part, args)
30 func2(part, args)
31 func3(part, args)
32 unref(part)
33 ]]
34 methods {
35 part @const {
36 [[Get a proxy object referring to a part of an object.
37
38 The returned object is valid for only a single function call.
39 ]]
40 params {
41 name: const(char)*; [[The part name.]]
42 }
43 return: Eo.Base; [[A (proxy) object, valid for a single call.]]
44 }
45 }
46}