diff options
author | Daniel Hirt <daniel.hirt@samsung.com> | 2016-11-03 17:45:42 +0200 |
---|---|---|
committer | Daniel Hirt <daniel.hirt@samsung.com> | 2016-11-09 16:10:31 +0200 |
commit | 70cd22bf0760ccaedfb074c1b0ca0ed248307edf (patch) | |
tree | 31ec4c0f49739f210bd4aa1cc030a76c092245af | |
parent | 17af933ae750a3090fba94b804e114001a4181a2 (diff) | |
download | efl-70cd22bf0760ccaedfb074c1b0ca0ed248307edf.tar.gz |
Edje containers: split logic
-rw-r--r-- | src/Makefile_Edje.am | 4 | ||||
-rw-r--r-- | src/lib/edje/edje_containers.c | 155 | ||||
-rw-r--r-- | src/lib/edje/edje_part.c | 14 | ||||
-rw-r--r-- | src/lib/edje/edje_part_helper.h | 120 | ||||
-rw-r--r-- | src/lib/edje/edje_part_swallow.c | 34 |
5 files changed, 172 insertions, 155 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am index 907c927b5e..84453ff802 100644 --- a/src/Makefile_Edje.am +++ b/src/Makefile_Edje.am @@ -92,7 +92,9 @@ lib/edje/edje_textblock_styles.c \ lib/edje/edje_util.c \ lib/edje/edje_var.c \ lib/edje/edje_signal.c \ -lib/edje/edje_containers.c +lib/edje/edje_part.c \ +lib/edje/edje_containers.c \ +lib/edje/edje_part_swallow.c lib_edje_libedje_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl $(EDJE_COMMON_CPPFLAGS) diff --git a/src/lib/edje/edje_containers.c b/src/lib/edje/edje_containers.c index 6aae0adc2e..27f490b8c0 100644 --- a/src/lib/edje/edje_containers.c +++ b/src/lib/edje/edje_containers.c @@ -1,153 +1,25 @@ #include "edje_private.h" - +#include "edje_part_helper.h" #define EFL_CANVAS_LAYOUT_INTERNAL_PROTECTED #define EFL_CANVAS_LAYOUT_INTERNAL_BOX_PROTECTED #define EFL_CANVAS_LAYOUT_INTERNAL_TABLE_PROTECTED -#define EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_PROTECTED -#include "efl_canvas_layout_internal.eo.h" #include "efl_canvas_layout_internal_box.eo.h" #include "efl_canvas_layout_internal_table.eo.h" -#include "efl_canvas_layout_internal_swallow.eo.h" #include "../evas/canvas/evas_box.eo.h" #include "../evas/canvas/evas_table.eo.h" #define BOX_CLASS EFL_CANVAS_LAYOUT_INTERNAL_BOX_CLASS #define TABLE_CLASS EFL_CANVAS_LAYOUT_INTERNAL_TABLE_CLASS -#define SWALLOW_CLASS EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_CLASS -typedef struct _Edje_Part_Data Edje_Box_Data; -typedef struct _Edje_Part_Data Edje_Table_Data; -typedef struct _Edje_Part_Data Edje_Swallow_Data; typedef struct _Part_Item_Iterator Part_Item_Iterator; -struct _Edje_Part_Data -{ - Edje *ed; - Edje_Real_Part *rp; - const char *part; - unsigned char temp; -}; - -struct _Part_Item_Iterator -{ - Eina_Iterator iterator; - Eina_List *list; - Eina_Iterator *real_iterator; - Eo *object; -}; - -#define PROXY_REF(obj, pd) do { if (!(pd->temp++)) efl_ref(obj); } while(0) -#define PROXY_UNREF(obj, pd) do { if (pd->temp) { if (!(--pd->temp)) efl_del(obj); } } while(0) -#define RETURN_VAL(a) do { typeof(a) _ret = a; PROXY_UNREF(obj, pd); return _ret; } while(0) -#define RETURN_VOID do { PROXY_UNREF(obj, pd); return; } while(0) -#define PROXY_CALL(a) ({ PROXY_REF(obj, pd); a; }) - -/* ugly macros to avoid code duplication */ - -#define PROXY_RESET(type) \ - do { if (_ ## type ## _proxy) \ - { \ - efl_del_intercept_set(_ ## type ## _proxy, NULL); \ - efl_del(_ ## type ## _proxy); \ - _ ## type ## _proxy = NULL; \ - } } while (0) - -#define PROXY_DEL_CB(type) \ -static void \ -type ## _del_cb(Eo *proxy) \ -{ \ - if (_ ## type ## _proxy) \ - { \ - efl_del_intercept_set(proxy, NULL); \ - efl_del(proxy); \ - return; \ - } \ - if (efl_parent_get(proxy)) \ - { \ - efl_ref(proxy); \ - efl_parent_set(proxy, NULL); \ - } \ - _ ## type ## _proxy = proxy; \ -} - -#define PROXY_IMPLEMENTATION(type, TYPE, datatype) \ -Eo * \ -_edje_ ## type ## _internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Edje_Real_Part *rp) \ -{ \ - Edje_Box_Data *pd; \ - Eo *proxy; \ - \ - pd = efl_data_scope_get(_ ## type ## _proxy, TYPE ## _CLASS); \ - if (!pd) \ - { \ - if (_ ## type ## _proxy) \ - { \ - ERR("Found invalid handle for efl_part. Reset."); \ - _ ## type ## _proxy = NULL; \ - } \ - return efl_add(TYPE ## _CLASS, ed->obj, \ - _edje_real_part_set(efl_added, ed, rp, rp->part->name)); \ - } \ - \ - if (EINA_UNLIKELY(pd->temp)) \ - { \ - /* warn about misuse, since non-implemented functions may trigger this \ - * misuse by accident. */ \ - ERR("Misuse of efl_part detected. Handles returned by efl_part() are " \ - "valid for a single function call! Did you call a non implemented " \ - "function?"); \ - } \ - proxy = _ ## type ## _proxy; \ - _ ## type ## _proxy = NULL; \ - _edje_real_part_set(proxy, ed, rp, rp->part->name); \ - return proxy; \ -} \ -\ -EOLIAN static void \ -_efl_canvas_layout_internal_ ## type ## _efl_canvas_layout_internal_real_part_set(Eo *obj, datatype *pd, void *ed, void *rp, const char *part) \ -{ \ - pd->ed = ed; \ - pd->rp = rp; \ - pd->part = part; \ - pd->temp = 1; \ - efl_del_intercept_set(obj, type ## _del_cb); \ - efl_parent_set(obj, pd->ed->obj); \ -} \ -\ -EOLIAN static Efl_Object * \ -_efl_canvas_layout_internal_ ## type ## _efl_object_finalize(Eo *obj, datatype *pd) \ -{ \ - EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->rp && pd->ed && pd->part, NULL); \ - return efl_finalize(efl_super(obj, TYPE ## _CLASS)); \ -} - -static Eo *_box_proxy = NULL; -static Eo *_table_proxy = NULL; -static Eo *_swallow_proxy = NULL; - -void -_edje_internal_proxy_shutdown(void) -{ - PROXY_RESET(box); - PROXY_RESET(table); - PROXY_RESET(swallow); -} - -PROXY_DEL_CB(box) -PROXY_DEL_CB(table) -PROXY_DEL_CB(swallow) - PROXY_IMPLEMENTATION(box, BOX, Edje_Box_Data) PROXY_IMPLEMENTATION(table, TABLE, Edje_Table_Data) -PROXY_IMPLEMENTATION(swallow, SWALLOW, Edje_Swallow_Data) -#undef PROXY_RESET -#undef PROXY_DEL_CB #undef PROXY_IMPLEMENTATION - /* Legacy features */ EOLIAN static Eina_Bool @@ -499,29 +371,6 @@ _efl_canvas_layout_internal_table_efl_pack_grid_grid_position_get(Eo *obj, Edje_ RETURN_VAL(ret); } -/* Swallow parts */ -EOLIAN static Efl_Gfx * -_efl_canvas_layout_internal_swallow_efl_container_content_get(Eo *obj, Edje_Swallow_Data *pd) -{ - RETURN_VAL(_edje_efl_container_content_get(pd->ed, pd->part)); -} - -EOLIAN static Eina_Bool -_efl_canvas_layout_internal_swallow_efl_container_content_set(Eo *obj, Edje_Swallow_Data *pd, Efl_Gfx *content) -{ - RETURN_VAL(_edje_efl_container_content_set(pd->ed, pd->part, content)); -} - -EOLIAN static Efl_Gfx * -_efl_canvas_layout_internal_swallow_efl_container_content_unset(Eo *obj, Edje_Swallow_Data *pd) -{ - Efl_Gfx *content = _edje_efl_container_content_get(pd->ed, pd->part); - if (!content) RETURN_VAL(NULL); - PROXY_CALL(efl_content_remove(obj, content)); - RETURN_VAL(content); -} - - /* Legacy API implementation */ #ifdef DEGUG @@ -656,7 +505,5 @@ edje_object_part_table_clear(Edje_Object *obj, const char *part, Eina_Bool clear return efl_pack_unpack_all(table); } -#include "efl_canvas_layout_internal.eo.c" #include "efl_canvas_layout_internal_box.eo.c" #include "efl_canvas_layout_internal_table.eo.c" -#include "efl_canvas_layout_internal_swallow.eo.c" diff --git a/src/lib/edje/edje_part.c b/src/lib/edje/edje_part.c new file mode 100644 index 0000000000..505afa66ab --- /dev/null +++ b/src/lib/edje/edje_part.c @@ -0,0 +1,14 @@ +#include "edje_private.h" +#include "edje_part_helper.h" + +PROXY_INIT(box) +PROXY_INIT(table) +PROXY_INIT(swallow) + +void +_edje_internal_proxy_shutdown(void) +{ + _box_shutdown(); + _table_shutdown(); + _swallow_shutdown(); +} diff --git a/src/lib/edje/edje_part_helper.h b/src/lib/edje/edje_part_helper.h new file mode 100644 index 0000000000..8dfb12df5b --- /dev/null +++ b/src/lib/edje/edje_part_helper.h @@ -0,0 +1,120 @@ +#include "edje_private.h" +#include "efl_canvas_layout_internal.eo.h" + +struct _Edje_Part_Data +{ + Edje *ed; + Edje_Real_Part *rp; + const char *part; + unsigned char temp; +}; + +typedef struct _Edje_Part_Data Edje_Part_Data; + +struct _Part_Item_Iterator +{ + Eina_Iterator iterator; + Eina_List *list; + Eina_Iterator *real_iterator; + Eo *object; +}; + +#define PROXY_REF(obj, pd) do { if (!(pd->temp++)) efl_ref(obj); } while(0) +#define PROXY_UNREF(obj, pd) do { if (pd->temp) { if (!(--pd->temp)) efl_del(obj); } } while(0) +#define RETURN_VAL(a) do { typeof(a) _ret = a; PROXY_UNREF(obj, pd); return _ret; } while(0) +#define RETURN_VOID do { PROXY_UNREF(obj, pd); return; } while(0) +#define PROXY_CALL(a) ({ PROXY_REF(obj, pd); a; }) + +/* ugly macros to avoid code duplication */ + +#define PROXY_RESET(type) \ + do { if (_ ## type ## _proxy) \ + { \ + efl_del_intercept_set(_ ## type ## _proxy, NULL); \ + efl_del(_ ## type ## _proxy); \ + _ ## type ## _proxy = NULL; \ + } } while (0) + +#define PROXY_INIT(type) \ +void \ +_ ## type ## _shutdown(void); \ + +#define PROXY_IMPLEMENTATION(type, TYPE, datatype) \ +typedef struct _Edje_Part_Data datatype; \ +\ +static Eo * _ ## type ## _proxy = NULL; \ +\ +static void \ +type ## _del_cb(Eo *proxy) \ +{ \ + if (_ ## type ## _proxy) \ + { \ + efl_del_intercept_set(proxy, NULL); \ + efl_del(proxy); \ + return; \ + } \ + if (efl_parent_get(proxy)) \ + { \ + efl_ref(proxy); \ + efl_parent_set(proxy, NULL); \ + } \ + _ ## type ## _proxy = proxy; \ +} \ +\ +void \ +_ ## type ## _shutdown(void) \ +{ \ + PROXY_RESET(type); \ +} \ +\ +Eo * \ +_edje_ ## type ## _internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Edje_Real_Part *rp) \ +{ \ + Edje_Part_Data *pd; \ + Eo *proxy; \ + \ + pd = efl_data_scope_get(_ ## type ## _proxy, TYPE ## _CLASS); \ + if (!pd) \ + { \ + if (_ ## type ## _proxy) \ + { \ + ERR("Found invalid handle for efl_part. Reset."); \ + _ ## type ## _proxy = NULL; \ + } \ + return efl_add(TYPE ## _CLASS, ed->obj, \ + _edje_real_part_set(efl_added, ed, rp, rp->part->name)); \ + } \ + \ + if (EINA_UNLIKELY(pd->temp)) \ + { \ + /* warn about misuse, since non-implemented functions may trigger this \ + * misuse by accident. */ \ + ERR("Misuse of efl_part detected. Handles returned by efl_part() are " \ + "valid for a single function call! Did you call a non implemented " \ + "function?"); \ + } \ + proxy = _ ## type ## _proxy; \ + _ ## type ## _proxy = NULL; \ + _edje_real_part_set(proxy, ed, rp, rp->part->name); \ + return proxy; \ +} \ +\ +EOLIAN static void \ +_efl_canvas_layout_internal_ ## type ## _efl_canvas_layout_internal_real_part_set(Eo *obj, datatype *pd, void *ed, void *rp, const char *part) \ +{ \ + pd->ed = ed; \ + pd->rp = rp; \ + pd->part = part; \ + pd->temp = 1; \ + efl_del_intercept_set(obj, type ## _del_cb); \ + efl_parent_set(obj, pd->ed->obj); \ +} \ +\ +EOLIAN static Efl_Object * \ +_efl_canvas_layout_internal_ ## type ## _efl_object_finalize(Eo *obj, datatype *pd) \ +{ \ + EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->rp && pd->ed && pd->part, NULL); \ + return efl_finalize(efl_super(obj, TYPE ## _CLASS)); \ +} + +#include "efl_canvas_layout_internal.eo.c" diff --git a/src/lib/edje/edje_part_swallow.c b/src/lib/edje/edje_part_swallow.c new file mode 100644 index 0000000000..e655d374d9 --- /dev/null +++ b/src/lib/edje/edje_part_swallow.c @@ -0,0 +1,34 @@ +#include "edje_private.h" +#include "edje_part_helper.h" + +#define EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_PROTECTED +#define MY_CLASS EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_CLASS +#define SWALLOW_CLASS EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_CLASS + +#include "efl_canvas_layout_internal_swallow.eo.h" + +PROXY_IMPLEMENTATION(swallow, SWALLOW, Edje_Swallow_Data) + +/* Swallow parts */ +EOLIAN static Efl_Gfx * +_efl_canvas_layout_internal_swallow_efl_container_content_get(Eo *obj, Edje_Swallow_Data *pd) +{ + RETURN_VAL(_edje_efl_container_content_get(pd->ed, pd->part)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_swallow_efl_container_content_set(Eo *obj, Edje_Swallow_Data *pd, Efl_Gfx *content) +{ + RETURN_VAL(_edje_efl_container_content_set(pd->ed, pd->part, content)); +} + +EOLIAN static Efl_Gfx * +_efl_canvas_layout_internal_swallow_efl_container_content_unset(Eo *obj, Edje_Swallow_Data *pd) +{ + Efl_Gfx *content = _edje_efl_container_content_get(pd->ed, pd->part); + if (!content) RETURN_VAL(NULL); + PROXY_CALL(efl_content_remove(obj, content)); + RETURN_VAL(content); +} + +#include "efl_canvas_layout_internal_swallow.eo.c" |