summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-09-21 12:23:29 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-09-21 12:28:20 +0900
commit419f3935c613850f0b1e61ee7246c951ccd258dc (patch)
treecf1f99c5d6c215925f20f62f02f894a006f2c7e9
parent2dbd704daee270d33dbfe6be25a5bd1ab287bf57 (diff)
edje: Add part_type_get API
For now I made this EO-only but this definitely could be expose in legacy API as well. This simply gives exact information about the type of part, after doing a recursive search. Edit Edit doesn't do a recursive search, only a direct one, which can yield invalid results (eg. RECT or NONE instead of TEXT in case of "elm.units.max" for a slider). @feature
-rw-r--r--src/lib/edje/Edje_Common.h31
-rw-r--r--src/lib/edje/Edje_Legacy.h39
-rw-r--r--src/lib/edje/edje_legacy.c15
-rw-r--r--src/lib/edje/edje_object.eo21
-rw-r--r--src/lib/edje/edje_part.c12
-rw-r--r--src/lib/edje/edje_types.eot27
-rw-r--r--src/lib/edje/edje_util.c13
-rw-r--r--src/lib/edje/efl_canvas_layout_part.eo16
8 files changed, 106 insertions, 68 deletions
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index cbc40f0..c29ccd7 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -1270,37 +1270,6 @@ EAPI Eina_Iterator *edje_mmap_color_class_iterator_new(Eina_File *f);
1270 */ 1270 */
1271 1271
1272/** 1272/**
1273 * @typedef Edje_Part_Type
1274 *
1275 * All possible "part" types in Edje.
1276 */
1277typedef enum _Edje_Part_Type
1278{
1279 EDJE_PART_TYPE_NONE = 0, /**< None type value */
1280 EDJE_PART_TYPE_RECTANGLE = 1, /**< Rectangle type value */
1281 EDJE_PART_TYPE_TEXT = 2, /**< Text type value */
1282 EDJE_PART_TYPE_IMAGE = 3, /**< Image type value */
1283 EDJE_PART_TYPE_SWALLOW = 4, /**< Swallow type value */
1284 EDJE_PART_TYPE_TEXTBLOCK = 5, /**< Text block type value */
1285 EDJE_PART_TYPE_GRADIENT = 6, /**< Gradient type value */
1286 EDJE_PART_TYPE_GROUP = 7, /**< Group type value */
1287 EDJE_PART_TYPE_BOX = 8, /**< Box type value */
1288 EDJE_PART_TYPE_TABLE = 9, /**< Table type value */
1289 EDJE_PART_TYPE_EXTERNAL = 10, /**< External type value */
1290 EDJE_PART_TYPE_PROXY = 11, /**< Proxy type value */
1291 EDJE_PART_TYPE_SPACER = 12, /**< Spacer type value @since 1.7 */
1292 EDJE_PART_TYPE_MESH_NODE = 13,
1293 EDJE_PART_TYPE_LIGHT = 14,
1294 EDJE_PART_TYPE_CAMERA = 15,
1295 EDJE_PART_TYPE_SNAPSHOT = 16, /**< Snapshot @since 1.16 */
1296 EDJE_PART_TYPE_VECTOR = 17, /**< Vector @since 1.18 */
1297 EDJE_PART_TYPE_LAST = 18 /**< Last type value */
1298} Edje_Part_Type;
1299/**
1300 * @}
1301 */
1302
1303/**
1304 * @defgroup Edje_Part_Text Edje Text Part 1273 * @defgroup Edje_Part_Text Edje Text Part
1305 * @ingroup Edje_Object_Part 1274 * @ingroup Edje_Object_Part
1306 * 1275 *
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index 7086acb..24a9136 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -2732,6 +2732,45 @@ EAPI void edje_object_size_min_get(const Edje_Object *obj, int *minw, int *minh)
2732EAPI void edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh); 2732EAPI void edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh);
2733 2733
2734/** 2734/**
2735 * @brief Checks if a part exists in a given Edje object's group definition.
2736 *
2737 * This function returns if a given part exists in the Edje group bound to this
2738 * object (with @ref edje_object_file_set()).
2739 *
2740 * This call is useful, for example, when one could expect or not a given GUI
2741 * element, depending on the theme applied to the object.
2742 *
2743 * @param[in] part The part's name to check for existence in obj's group
2744 *
2745 * @return @c true if the Edje part exists in obj's group, or @c false
2746 * otherwise (and on errors)
2747 *
2748 * @ingroup Edje_Object
2749 */
2750EAPI Eina_Bool edje_object_part_exists(const Edje_Object *obj, const char *part);
2751
2752typedef Efl_Canvas_Layout_Part_Type Edje_Part_Type;
2753#define EDJE_PART_TYPE_NONE EFL_CANVAS_LAYOUT_PART_TYPE_NONE
2754#define EDJE_PART_TYPE_RECTANGLE EFL_CANVAS_LAYOUT_PART_TYPE_RECTANGLE
2755#define EDJE_PART_TYPE_TEXT EFL_CANVAS_LAYOUT_PART_TYPE_TEXT
2756#define EDJE_PART_TYPE_IMAGE EFL_CANVAS_LAYOUT_PART_TYPE_IMAGE
2757#define EDJE_PART_TYPE_SWALLOW EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW
2758#define EDJE_PART_TYPE_TEXTBLOCK EFL_CANVAS_LAYOUT_PART_TYPE_TEXTBLOCK
2759#define EDJE_PART_TYPE_GRADIENT EFL_CANVAS_LAYOUT_PART_TYPE_GRADIENT
2760#define EDJE_PART_TYPE_GROUP EFL_CANVAS_LAYOUT_PART_TYPE_GROUP
2761#define EDJE_PART_TYPE_BOX EFL_CANVAS_LAYOUT_PART_TYPE_BOX
2762#define EDJE_PART_TYPE_TABLE EFL_CANVAS_LAYOUT_PART_TYPE_TABLE
2763#define EDJE_PART_TYPE_EXTERNAL EFL_CANVAS_LAYOUT_PART_TYPE_EXTERNAL
2764#define EDJE_PART_TYPE_PROXY EFL_CANVAS_LAYOUT_PART_TYPE_PROXY
2765#define EDJE_PART_TYPE_SPACER EFL_CANVAS_LAYOUT_PART_TYPE_SPACER
2766#define EDJE_PART_TYPE_MESH_NODE EFL_CANVAS_LAYOUT_PART_TYPE_MESH_NODE
2767#define EDJE_PART_TYPE_LIGHT EFL_CANVAS_LAYOUT_PART_TYPE_LIGHT
2768#define EDJE_PART_TYPE_CAMERA EFL_CANVAS_LAYOUT_PART_TYPE_CAMERA
2769#define EDJE_PART_TYPE_SNAPSHOT EFL_CANVAS_LAYOUT_PART_TYPE_SNAPSHOT
2770#define EDJE_PART_TYPE_VECTOR EFL_CANVAS_LAYOUT_PART_TYPE_VECTOR
2771#define EDJE_PART_TYPE_LAST EFL_CANVAS_LAYOUT_PART_TYPE_LAST
2772
2773/**
2735 * @} 2774 * @}
2736 */ 2775 */
2737#include "edje_object.eo.legacy.h" 2776#include "edje_object.eo.legacy.h"
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index dc3ab17..d3f19ea 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -1188,3 +1188,18 @@ edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh)
1188 if (maxw) *maxw = sz.w; 1188 if (maxw) *maxw = sz.w;
1189 if (maxh) *maxh = sz.h; 1189 if (maxh) *maxh = sz.h;
1190} 1190}
1191
1192EAPI Eina_Bool
1193edje_object_part_exists(const Eo *obj, const char *part)
1194{
1195 Edje_Real_Part *rp;
1196 Edje *ed;
1197
1198 if (!part) return EINA_FALSE;
1199 ed = _edje_fetch(obj);
1200 if (!ed) return EINA_FALSE;
1201 rp = _edje_real_part_recursive_get(&ed, part);
1202 if (!rp) return EINA_FALSE;
1203
1204 return EINA_TRUE;
1205}
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 9c4a84b..c898878 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -321,25 +321,6 @@ class Edje.Object (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
321 legacy: null; 321 legacy: null;
322 return: iterator<string> @owned; [[Part name iterator]] 322 return: iterator<string> @owned; [[Part name iterator]]
323 } 323 }
324 part_exists @const {
325 [[Checks if a part exists in a given Edje object's group definition.
326
327 This function returns if a given part exists in the Edje group
328 bound to this object (with @Efl.File.file.set()).
329
330 This call is useful, for example, when one could expect or not a
331 given GUI element, depending on the theme applied to the object.
332
333 Note: @Efl.Part.part() called on an Edje object will return $null
334 if it doesn't contain the given part.
335 ]]
336 return: bool; [[$true if the Edje part exists in obj's group, or
337 $false otherwise (and on errors)]]
338 params {
339 @in part: string; [[The part's name to check for existence in obj's
340 group]]
341 }
342 }
343 324
344 /* TEXT PART APIS BEGIN ---------------------------------------------- */ 325 /* TEXT PART APIS BEGIN ---------------------------------------------- */
345 @property text_change_cb { 326 @property text_change_cb {
@@ -433,7 +414,7 @@ class Edje.Object (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
433 Efl.File.file { get; set; } 414 Efl.File.file { get; set; }
434 Efl.File.mmap { get; set; } 415 Efl.File.mmap { get; set; }
435 Efl.Container.content_remove; 416 Efl.Container.content_remove;
436 Efl.Part.part; 417 Efl.Part.part; [[Returns @Efl.Canvas.Layout.Part.]]
437 Efl.Observer.update; 418 Efl.Observer.update;
438 Efl.Player.playable { get; } 419 Efl.Player.playable { get; }
439 Efl.Player.play { get; set; } 420 Efl.Player.play { get; set; }
diff --git a/src/lib/edje/edje_part.c b/src/lib/edje/edje_part.c
index f5a496d..b3f9505 100644
--- a/src/lib/edje/edje_part.c
+++ b/src/lib/edje/edje_part.c
@@ -126,6 +126,18 @@ _efl_canvas_layout_part_state_get(Eo *obj, Efl_Canvas_Layout_Part_Data *pd, cons
126 RETURN_VOID; 126 RETURN_VOID;
127} 127}
128 128
129EOLIAN static Efl_Canvas_Layout_Part_Type
130_efl_canvas_layout_part_part_type_get(Eo *obj, Efl_Canvas_Layout_Part_Data *pd)
131{
132 Edje_Real_Part *rp;
133 PROXY_CALL_BEGIN(pd);
134
135 rp = _edje_real_part_recursive_get(&pd->ed, pd->part);
136 if (!rp || !rp->part) RETURN_VAL(EFL_CANVAS_LAYOUT_PART_TYPE_NONE);
137
138 RETURN_VAL((Efl_Canvas_Layout_Part_Type) rp->part->type);
139}
140
129EOLIAN static Eina_Bool 141EOLIAN static Eina_Bool
130_efl_canvas_layout_part_efl_ui_drag_drag_value_set(Eo *obj, Efl_Canvas_Layout_Part_Data *pd, double dx, double dy) 142_efl_canvas_layout_part_efl_ui_drag_drag_value_set(Eo *obj, Efl_Canvas_Layout_Part_Data *pd, double dx, double dy)
131{ 143{
diff --git a/src/lib/edje/edje_types.eot b/src/lib/edje/edje_types.eot
index e67172b..ca09839 100644
--- a/src/lib/edje/edje_types.eot
+++ b/src/lib/edje/edje_types.eot
@@ -1,3 +1,30 @@
1enum Efl.Canvas.Layout.Part_Type
2{
3 [[Type of a part in an Efl.Canvas.Layout object (edje object).]]
4 none = 0, [[None type value, indicates invalid parts.]]
5 rectangle = 1, [[Rectangle type value.]]
6 text = 2, [[Text type value.]]
7 image = 3, [[Image type value.]]
8 swallow = 4, [[Swallow type value.]]
9 textblock = 5, [[Text block type value.]]
10 gradient = 6, [[Gradient type value.]]
11 group = 7, [[Group type value.]]
12 box = 8, [[Box type value.]]
13 table = 9, [[Table type value.]]
14 external = 10, [[External type value.]]
15 proxy = 11, [[Proxy type value.]]
16 spacer = 12, [[Spacer type value @since 1.7.]]
17 mesh_node = 13, [[Canvas 3D type: mesh node.]]
18 light = 14, [[Canvas 3D type: light.]]
19 camera = 15, [[Canvas 3D type: camera.]]
20 snapshot = 16, [[Snapshot @since 1.16.]]
21 vector = 17, [[Vector @since 1.18.]]
22 last = 18 [[Last type value.]]
23}
24
25
26/* TODO: Rename to Efl.Canvas.Layout.Blah */
27
1enum Edje.Cursor { 28enum Edje.Cursor {
2 [[All available cursor states]] 29 [[All available cursor states]]
3 main, [[Main cursor state]] 30 main, [[Main cursor state]]
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index e76eb58..36f7ce3 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -1793,19 +1793,6 @@ on_error:
1793 return NULL; 1793 return NULL;
1794} 1794}
1795 1795
1796
1797EOLIAN Eina_Bool
1798_edje_object_part_exists(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
1799{
1800 Edje_Real_Part *rp;
1801
1802 if ((!ed) || (!part)) return EINA_FALSE;
1803 rp = _edje_real_part_recursive_get(&ed, part);
1804 if (!rp) return EINA_FALSE;
1805
1806 return EINA_TRUE;
1807}
1808
1809/* Legacy API: exposes internal object. Easy to abuse. */ 1796/* Legacy API: exposes internal object. Easy to abuse. */
1810EAPI const Evas_Object * 1797EAPI const Evas_Object *
1811edje_object_part_object_get(const Eo *obj, const char *part) 1798edje_object_part_object_get(const Eo *obj, const char *part)
diff --git a/src/lib/edje/efl_canvas_layout_part.eo b/src/lib/edje/efl_canvas_layout_part.eo
index 6417b79..87cacaf 100644
--- a/src/lib/edje/efl_canvas_layout_part.eo
+++ b/src/lib/edje/efl_canvas_layout_part.eo
@@ -1,4 +1,5 @@
1/* FIXME: Rename to Efl.Canvas.Layout.Part */ 1import edje_types;
2
2class Efl.Canvas.Layout.Part (Efl.Object, Efl.Gfx, Efl.Ui.Drag) 3class Efl.Canvas.Layout.Part (Efl.Object, Efl.Gfx, Efl.Ui.Drag)
3{ 4{
4 [[Common class for part proxy objects for $Efl.Canvas.Layout. 5 [[Common class for part proxy objects for $Efl.Canvas.Layout.
@@ -24,6 +25,16 @@ class Efl.Canvas.Layout.Part (Efl.Object, Efl.Gfx, Efl.Ui.Drag)
24 val: double; [[The value of the state.]] 25 val: double; [[The value of the state.]]
25 } 26 }
26 } 27 }
28 @property part_type {
29 [[Type of this part in the layout.]]
30 get {
31 [[Returns the type of the part.]]
32 }
33 values {
34 type: Efl.Canvas.Layout.Part_Type(Efl.Canvas.Layout.Part_Type.none);
35 [[One of the types or $none if not an existing part.]]
36 }
37 }
27 } 38 }
28 implements { 39 implements {
29 Efl.Object.finalize; 40 Efl.Object.finalize;
@@ -36,7 +47,4 @@ class Efl.Canvas.Layout.Part (Efl.Object, Efl.Gfx, Efl.Ui.Drag)
36 Efl.Ui.Drag.drag_page { set; get; } 47 Efl.Ui.Drag.drag_page { set; get; }
37 Efl.Ui.Drag.drag_page_move; 48 Efl.Ui.Drag.drag_page_move;
38 } 49 }
39 events {
40 /* FIXME: Are there really no events? */
41 }
42} 50}