summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-05-26 11:33:58 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-05-29 10:49:17 +0900
commitda2a7e65879de8de51ce8a5b999a1d544abc8938 (patch)
treeaf127f7351255eee5c00c0d223e1a57bd7e6ffdb
parent42403cd3df85101daedf69f4d782d21855bd50e0 (diff)
edje: Implement part_geometry_get with Efl.Part
This refactors even more the edje part eo internals. But now common part APIs can easily be implemented in edje_part.c The API now looks like: efl_gfx_geometry_get(efl_part(edje, "part"), &x, &y, &w, &h)
-rw-r--r--src/Makefile_Edje.am1
-rw-r--r--src/lib/edje/Edje_Legacy.h26
-rw-r--r--src/lib/edje/edje_legacy.c41
-rw-r--r--src/lib/edje/edje_object.eo26
-rw-r--r--src/lib/edje/edje_part.c41
-rw-r--r--src/lib/edje/edje_part_box.c5
-rw-r--r--src/lib/edje/edje_part_helper.h35
-rw-r--r--src/lib/edje/edje_part_swallow.c5
-rw-r--r--src/lib/edje/edje_part_table.c5
-rw-r--r--src/lib/edje/edje_util.c34
-rw-r--r--src/lib/edje/efl_canvas_layout_internal.eo3
-rw-r--r--src/lib/edje/efl_canvas_layout_internal_box.eo1
-rw-r--r--src/lib/edje/efl_canvas_layout_internal_swallow.eo1
-rw-r--r--src/lib/edje/efl_canvas_layout_internal_table.eo1
14 files changed, 116 insertions, 109 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index 34a2cb7549..c2a85499ae 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -90,6 +90,7 @@ lib/edje/edje_smart.c \
90lib/edje/edje_text.c \ 90lib/edje/edje_text.c \
91lib/edje/edje_textblock_styles.c \ 91lib/edje/edje_textblock_styles.c \
92lib/edje/edje_util.c \ 92lib/edje/edje_util.c \
93lib/edje/edje_legacy.c \
93lib/edje/edje_var.c \ 94lib/edje/edje_var.c \
94lib/edje/edje_signal.c \ 95lib/edje/edje_signal.c \
95lib/edje/edje_part.c \ 96lib/edje/edje_part.c \
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index 26a871fe40..7a7b46da45 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -150,6 +150,32 @@ EAPI Edje_Load_Error edje_object_load_error_get(const Evas_Object *obj);
150EAPI const char *edje_load_error_str (Edje_Load_Error error); 150EAPI const char *edje_load_error_str (Edje_Load_Error error);
151 151
152/** 152/**
153 * @brief Retrieves the geometry of a given Edje part, in a given Edje object's
154 * group definition, relative to the object's area.
155 *
156 * This function gets the geometry of an Edje part within its group. The x and
157 * y coordinates are relative to the top left corner of the whole obj object's
158 * area.
159 *
160 * @note Use @c null pointers on the geometry components you're not interested
161 * in: they'll be ignored by the function.
162 *
163 * @note On failure, this function will make all non-$null geometry pointers'
164 * pointed variables be set to zero.
165 *
166 * @param[in] part The Edje part's name
167 * @param[out] x A pointer to a variable where to store the part's x coordinate
168 * @param[out] y A pointer to a variable where to store the part's y coordinate
169 * @param[out] w A pointer to a variable where to store the part's width
170 * @param[out] h A pointer to a variable where to store the part's height
171 *
172 * @return @c true on success, @c false otherwise
173 *
174 * @ingroup Edje_Object
175 */
176EAPI Eina_Bool edje_object_part_geometry_get(const Edje_Object *obj, const char * part, int *x, int *y, int *w, int *h);
177
178/**
153 * @brief Gets a handle to the Evas object implementing a given Edje part, in 179 * @brief Gets a handle to the Evas object implementing a given Edje part, in
154 * an Edje object. 180 * an Edje object.
155 * 181 *
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
new file mode 100644
index 0000000000..693fd316d5
--- /dev/null
+++ b/src/lib/edje/edje_legacy.c
@@ -0,0 +1,41 @@
1/* Legacy API implementations based on internal EO calls */
2
3#include "edje_private.h"
4
5EAPI Eina_Bool
6edje_object_part_geometry_get(const Edje_Object *obj, const char *part, int *x, int *y, int *w, int *h)
7{
8 Edje_Real_Part *rp;
9 Edje *ed;
10
11 // Similar to geometry_get(efl_part(obj, part), x, y, w, h) but the bool
12 // return value matters here.
13
14 ed = _edje_fetch(obj);
15 if ((!ed) || (!part))
16 {
17 if (x) *x = 0;
18 if (y) *y = 0;
19 if (w) *w = 0;
20 if (h) *h = 0;
21 return EINA_FALSE;
22 }
23
24 /* Need to recalc before providing the object. */
25 _edje_recalc_do(ed);
26
27 rp = _edje_real_part_recursive_get(&ed, part);
28 if (!rp)
29 {
30 if (x) *x = 0;
31 if (y) *y = 0;
32 if (w) *w = 0;
33 if (h) *h = 0;
34 return EINA_FALSE;
35 }
36 if (x) *x = rp->x;
37 if (y) *y = rp->y;
38 if (w) *w = rp->w;
39 if (h) *h = rp->h;
40 return EINA_TRUE;
41}
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index c6105ab6fd..69b2ce7d12 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -837,32 +837,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
837 val_ret: double; [[Part state value]] 837 val_ret: double; [[Part state value]]
838 } 838 }
839 } 839 }
840 @property part_geometry {
841 get {
842 [[Retrieves the geometry of a given Edje part, in a given Edje
843 object's group definition, relative to the object's area.
844
845 This function gets the geometry of an Edje part within its
846 group. The x and y coordinates are relative to the top left
847 corner of the whole obj object's area.
848
849 Note: Use $null pointers on the geometry components you're not
850 interested in: they'll be ignored by the function.
851
852 Note: On failure, this function will make all non-$null geometry
853 pointers' pointed variables be set to zero.]]
854 return: bool; [[$true on success, $false otherwise]]
855 }
856 keys {
857 part: string; [[The Edje part's name]]
858 }
859 values {
860 x: int; [[A pointer to a variable where to store the part's x coordinate]]
861 y: int; [[A pointer to a variable where to store the part's y coordinate]]
862 w: int; [[A pointer to a variable where to store the part's width]]
863 h: int; [[A pointer to a variable where to store the part's height]]
864 }
865 }
866 @property part_drag_value { 840 @property part_drag_value {
867 set { 841 set {
868 [[Sets the dragable object location. 842 [[Sets the dragable object location.
diff --git a/src/lib/edje/edje_part.c b/src/lib/edje/edje_part.c
index ab8b532f67..5f7c314048 100644
--- a/src/lib/edje/edje_part.c
+++ b/src/lib/edje/edje_part.c
@@ -1,5 +1,6 @@
1#include "edje_private.h" 1#include "edje_private.h"
2#include "edje_part_helper.h" 2#include "edje_part_helper.h"
3#define MY_CLASS EFL_CANVAS_LAYOUT_INTERNAL_CLASS
3 4
4PROXY_INIT(box) 5PROXY_INIT(box)
5PROXY_INIT(table) 6PROXY_INIT(table)
@@ -13,11 +14,43 @@ _edje_internal_proxy_shutdown(void)
13 _swallow_shutdown(); 14 _swallow_shutdown();
14} 15}
15 16
16/* Internal EO API */ 17void
18_edje_real_part_set(Eo *obj, void *ed, void *rp, const char *part)
19{
20 PROXY_DATA_GET(obj, pd);
21 pd->ed = ed;
22 pd->rp = rp;
23 pd->part = part;
24 pd->temp = 1;
25 efl_parent_set(obj, pd->ed->obj);
26}
17 27
18EOAPI EFL_VOID_FUNC_BODYV(_efl_canvas_layout_internal_real_part_set, EFL_FUNC_CALL(ed, rp, part), void *ed, void *rp, const char *part) 28EOLIAN static Efl_Object *
29_efl_canvas_layout_internal_efl_object_finalize(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd)
30{
31 EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->rp && pd->ed && pd->part, NULL);
32 return efl_finalize(efl_super(obj, MY_CLASS));
33}
19 34
20#define EFL_CANVAS_LAYOUT_INTERNAL_EXTRA_OPS \ 35EOLIAN void
21 EFL_OBJECT_OP_FUNC(_efl_canvas_layout_internal_real_part_set, NULL) 36_efl_canvas_layout_internal_efl_gfx_geometry_get(Eo *obj EINA_UNUSED, Efl_Canvas_Layout_Internal_Data *pd, int *x, int *y, int *w, int *h)
37{
38 Edje_Real_Part *rp = pd->rp;
39
40 _edje_recalc_do(pd->ed);
41 if (!rp)
42 {
43 if (x) *x = 0;
44 if (y) *y = 0;
45 if (w) *w = 0;
46 if (h) *h = 0;
47 }
48
49 if (x) *x = rp->x;
50 if (y) *y = rp->y;
51 if (w) *w = rp->w;
52 if (h) *h = rp->h;
53 RETURN_VOID;
54}
22 55
23#include "efl_canvas_layout_internal.eo.c" 56#include "efl_canvas_layout_internal.eo.c"
diff --git a/src/lib/edje/edje_part_box.c b/src/lib/edje/edje_part_box.c
index 701971d144..75bb2687d5 100644
--- a/src/lib/edje/edje_part_box.c
+++ b/src/lib/edje/edje_part_box.c
@@ -214,9 +214,4 @@ _efl_canvas_layout_internal_box_efl_orientation_orientation_get(Eo *obj, void *_
214 RETURN_VAL(EFL_ORIENT_NONE); 214 RETURN_VAL(EFL_ORIENT_NONE);
215} 215}
216 216
217/* Internal EO API */
218
219#define EFL_CANVAS_LAYOUT_INTERNAL_BOX_EXTRA_OPS \
220 EFL_OBJECT_OP_FUNC(_efl_canvas_layout_internal_real_part_set, _efl_canvas_layout_internal_box_efl_canvas_layout_internal_real_part_set)
221
222#include "efl_canvas_layout_internal_box.eo.c" 217#include "efl_canvas_layout_internal_box.eo.c"
diff --git a/src/lib/edje/edje_part_helper.h b/src/lib/edje/edje_part_helper.h
index 385dcec12d..136e09244b 100644
--- a/src/lib/edje/edje_part_helper.h
+++ b/src/lib/edje/edje_part_helper.h
@@ -1,8 +1,6 @@
1#include "edje_private.h" 1#include "edje_private.h"
2#include "efl_canvas_layout_internal.eo.h" 2#include "efl_canvas_layout_internal.eo.h"
3 3
4EOAPI void _efl_canvas_layout_internal_real_part_set(Eo *obj, void *ed, void *rp, const char *part);
5
6typedef struct _Efl_Canvas_Layout_Internal_Data Efl_Canvas_Layout_Internal_Data; 4typedef struct _Efl_Canvas_Layout_Internal_Data Efl_Canvas_Layout_Internal_Data;
7 5
8struct _Efl_Canvas_Layout_Internal_Data 6struct _Efl_Canvas_Layout_Internal_Data
@@ -27,6 +25,8 @@ struct _Part_Item_Iterator
27#define RETURN_VOID do { PROXY_UNREF(obj, pd); return; } while(0) 25#define RETURN_VOID do { PROXY_UNREF(obj, pd); return; } while(0)
28#define PROXY_CALL(a) ({ PROXY_REF(obj, pd); a; }) 26#define PROXY_CALL(a) ({ PROXY_REF(obj, pd); a; })
29 27
28void _edje_real_part_set(Eo *obj, void *ed, void *rp, const char *part);
29
30/* ugly macros to avoid code duplication */ 30/* ugly macros to avoid code duplication */
31 31
32#define PROXY_RESET(type) \ 32#define PROXY_RESET(type) \
@@ -48,7 +48,7 @@ _ ## type ## _shutdown(void); \
48static Eo * _ ## type ## _proxy = NULL; \ 48static Eo * _ ## type ## _proxy = NULL; \
49\ 49\
50static void \ 50static void \
51type ## _del_cb(Eo *proxy) \ 51_ ## type ## _del_cb(Eo *proxy) \
52{ \ 52{ \
53 if (_ ## type ## _proxy) \ 53 if (_ ## type ## _proxy) \
54 { \ 54 { \
@@ -85,8 +85,10 @@ _edje_ ## type ## _internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Ed
85 ERR("Found invalid handle for efl_part. Reset."); \ 85 ERR("Found invalid handle for efl_part. Reset."); \
86 _ ## type ## _proxy = NULL; \ 86 _ ## type ## _proxy = NULL; \
87 } \ 87 } \
88 return efl_add(MY_CLASS, ed->obj, \ 88 proxy = efl_add(MY_CLASS, ed->obj, \
89 _efl_canvas_layout_internal_real_part_set(efl_added, ed, rp, rp->part->name)); \ 89 _edje_real_part_set(efl_added, ed, rp, rp->part->name)); \
90 efl_del_intercept_set(proxy, _ ## type ## _del_cb); \
91 return proxy; \
90 } \ 92 } \
91 \ 93 \
92 if (EINA_UNLIKELY(pd->temp)) \ 94 if (EINA_UNLIKELY(pd->temp)) \
@@ -99,28 +101,9 @@ _edje_ ## type ## _internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Ed
99 } \ 101 } \
100 proxy = _ ## type ## _proxy; \ 102 proxy = _ ## type ## _proxy; \
101 _ ## type ## _proxy = NULL; \ 103 _ ## type ## _proxy = NULL; \
102 _efl_canvas_layout_internal_real_part_set(proxy, ed, rp, rp->part->name); \ 104 _edje_real_part_set(proxy, ed, rp, rp->part->name); \
105 efl_del_intercept_set(proxy, _ ## type ## _del_cb); \
103 return proxy; \ 106 return proxy; \
104} \
105\
106EOLIAN static void \
107_efl_canvas_layout_internal_ ## type ## _efl_canvas_layout_internal_real_part_set(Eo *obj, void *_pd EINA_UNUSED, void *ed, void *rp, const char *part) \
108{ \
109 PROXY_DATA_GET(obj, pd); \
110 pd->ed = ed; \
111 pd->rp = rp; \
112 pd->part = part; \
113 pd->temp = 1; \
114 efl_del_intercept_set(obj, type ## _del_cb); \
115 efl_parent_set(obj, pd->ed->obj); \
116} \
117\
118EOLIAN static Efl_Object * \
119_efl_canvas_layout_internal_ ## type ## _efl_object_finalize(Eo *obj, void *_pd EINA_UNUSED) \
120{ \
121 PROXY_DATA_GET(obj, pd); \
122 EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->rp && pd->ed && pd->part, NULL); \
123 return efl_finalize(efl_super(obj, MY_CLASS)); \
124} 107}
125 108
126#ifdef DEBUG 109#ifdef DEBUG
diff --git a/src/lib/edje/edje_part_swallow.c b/src/lib/edje/edje_part_swallow.c
index 7eab4bc31e..db24d49f70 100644
--- a/src/lib/edje/edje_part_swallow.c
+++ b/src/lib/edje/edje_part_swallow.c
@@ -31,9 +31,4 @@ _efl_canvas_layout_internal_swallow_efl_container_content_unset(Eo *obj, void *_
31 RETURN_VAL(content); 31 RETURN_VAL(content);
32} 32}
33 33
34/* Internal EO APIs */
35
36#define EFL_CANVAS_LAYOUT_INTERNAL_SWALLOW_EXTRA_OPS \
37 EFL_OBJECT_OP_FUNC(_efl_canvas_layout_internal_real_part_set, _efl_canvas_layout_internal_swallow_efl_canvas_layout_internal_real_part_set),
38
39#include "efl_canvas_layout_internal_swallow.eo.c" 34#include "efl_canvas_layout_internal_swallow.eo.c"
diff --git a/src/lib/edje/edje_part_table.c b/src/lib/edje/edje_part_table.c
index 2abd03fdec..58305bfbd0 100644
--- a/src/lib/edje/edje_part_table.c
+++ b/src/lib/edje/edje_part_table.c
@@ -352,9 +352,4 @@ edje_object_part_table_clear(Edje_Object *obj, const char *part, Eina_Bool clear
352 return efl_pack_unpack_all(table); 352 return efl_pack_unpack_all(table);
353} 353}
354 354
355/* Internal EO APIs */
356
357#define EFL_CANVAS_LAYOUT_INTERNAL_TABLE_EXTRA_OPS \
358 EFL_OBJECT_OP_FUNC(_efl_canvas_layout_internal_real_part_set, _efl_canvas_layout_internal_table_efl_canvas_layout_internal_real_part_set),
359
360#include "efl_canvas_layout_internal_table.eo.c" 355#include "efl_canvas_layout_internal_table.eo.c"
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 8740fea09e..17c9a064a1 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -1822,40 +1822,6 @@ edje_object_part_object_get(const Eo *obj, const char *part)
1822 return rp->object; 1822 return rp->object;
1823} 1823}
1824 1824
1825EOLIAN Eina_Bool
1826_edje_object_part_geometry_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1827{
1828 Edje_Real_Part *rp;
1829
1830 if ((!ed) || (!part))
1831 {
1832 if (x) *x = 0;
1833 if (y) *y = 0;
1834 if (w) *w = 0;
1835 if (h) *h = 0;
1836 return EINA_FALSE;
1837 }
1838
1839 /* Need to recalc before providing the object. */
1840 _edje_recalc_do(ed);
1841
1842 rp = _edje_real_part_recursive_get(&ed, part);
1843 if (!rp)
1844 {
1845 if (x) *x = 0;
1846 if (y) *y = 0;
1847 if (w) *w = 0;
1848 if (h) *h = 0;
1849 return EINA_FALSE;
1850 }
1851 if (x) *x = rp->x;
1852 if (y) *y = rp->y;
1853 if (w) *w = rp->w;
1854 if (h) *h = rp->h;
1855
1856 return EINA_TRUE;
1857}
1858
1859EOLIAN void 1825EOLIAN void
1860_edje_object_item_provider_set(Eo *obj EINA_UNUSED, Edje *ed, Edje_Item_Provider_Cb func, void *data) 1826_edje_object_item_provider_set(Eo *obj EINA_UNUSED, Edje *ed, Edje_Item_Provider_Cb func, void *data)
1861{ 1827{
diff --git a/src/lib/edje/efl_canvas_layout_internal.eo b/src/lib/edje/efl_canvas_layout_internal.eo
index 67e09278a0..0a523f3b8d 100644
--- a/src/lib/edje/efl_canvas_layout_internal.eo
+++ b/src/lib/edje/efl_canvas_layout_internal.eo
@@ -2,7 +2,8 @@ class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx)
2{ 2{
3 [[Common class for part proxy objects for $Efl.Canvas.Layout.]] 3 [[Common class for part proxy objects for $Efl.Canvas.Layout.]]
4 implements { 4 implements {
5 //Efl.Gfx.Size.geometry { get; } 5 Efl.Object.finalize;
6 Efl.Gfx.geometry { get; }
6 //Efl.Gfx.Size.size { get; } 7 //Efl.Gfx.Size.size { get; }
7 } 8 }
8} 9}
diff --git a/src/lib/edje/efl_canvas_layout_internal_box.eo b/src/lib/edje/efl_canvas_layout_internal_box.eo
index 1db1f5522a..4e96a61ccf 100644
--- a/src/lib/edje/efl_canvas_layout_internal_box.eo
+++ b/src/lib/edje/efl_canvas_layout_internal_box.eo
@@ -8,7 +8,6 @@ class Efl.Canvas.Layout_Internal.Box (Efl.Canvas.Layout_Internal, Efl.Pack.Linea
8 ]] 8 ]]
9 data: null; 9 data: null;
10 implements { 10 implements {
11 Efl.Object.finalize;
12 Efl.Container.content_iterate; 11 Efl.Container.content_iterate;
13 Efl.Container.content_count; 12 Efl.Container.content_count;
14 Efl.Container.content_remove; 13 Efl.Container.content_remove;
diff --git a/src/lib/edje/efl_canvas_layout_internal_swallow.eo b/src/lib/edje/efl_canvas_layout_internal_swallow.eo
index d3e19b3e26..a5e9098b6a 100644
--- a/src/lib/edje/efl_canvas_layout_internal_swallow.eo
+++ b/src/lib/edje/efl_canvas_layout_internal_swallow.eo
@@ -7,7 +7,6 @@ class Efl.Canvas.Layout_Internal.Swallow (Efl.Canvas.Layout_Internal, Efl.Contai
7 ]] 7 ]]
8 data: null; 8 data: null;
9 implements { 9 implements {
10 Efl.Object.finalize;
11 Efl.Container.content { get; set; } 10 Efl.Container.content { get; set; }
12 Efl.Container.content_unset; 11 Efl.Container.content_unset;
13 } 12 }
diff --git a/src/lib/edje/efl_canvas_layout_internal_table.eo b/src/lib/edje/efl_canvas_layout_internal_table.eo
index 53258c0298..1bc84f2816 100644
--- a/src/lib/edje/efl_canvas_layout_internal_table.eo
+++ b/src/lib/edje/efl_canvas_layout_internal_table.eo
@@ -7,7 +7,6 @@ class Efl.Canvas.Layout_Internal.Table (Efl.Canvas.Layout_Internal, Efl.Pack.Gri
7 ]] 7 ]]
8 data: null; 8 data: null;
9 implements { 9 implements {
10 Efl.Object.finalize;
11 Efl.Container.content_iterate; 10 Efl.Container.content_iterate;
12 Efl.Container.content_count; 11 Efl.Container.content_count;
13 Efl.Container.content_remove; 12 Efl.Container.content_remove;