summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2018-01-15 17:27:10 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2018-01-16 18:37:04 +0900
commit9e2f2970b80157e4618a381593ef8b819f64d56f (patch)
treefaf889f2c3282e69d3296299b5ed76041114d41f
parentd13333639932beb56422b2b228607bc988ee4901 (diff)
edje: Add property "part_exist"
This allows to safely verify if a part exists, without triggering any potential call to NULL object, or even requiring the efl_part() handle to be created. This is perfectly equivalent to edje_object_part_exists(), but implemented by both edje object and elm layout.
-rw-r--r--src/lib/edje/edje_legacy.c11
-rw-r--r--src/lib/edje/edje_util.c15
-rw-r--r--src/lib/edje/efl_canvas_layout.eo1
-rw-r--r--src/lib/edje/efl_layout_group.eo22
-rw-r--r--src/lib/elementary/efl_ui_layout.c8
-rw-r--r--src/lib/elementary/efl_ui_layout.eo1
6 files changed, 47 insertions, 11 deletions
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index 6638270d57..ab8063d44d 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -1205,14 +1205,5 @@ edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh)
1205EAPI Eina_Bool 1205EAPI Eina_Bool
1206edje_object_part_exists(const Eo *obj, const char *part) 1206edje_object_part_exists(const Eo *obj, const char *part)
1207{ 1207{
1208 Edje_Real_Part *rp; 1208 return efl_layout_group_part_exist_get(obj, part);
1209 Edje *ed;
1210
1211 if (!part) return EINA_FALSE;
1212 ed = _edje_fetch(obj);
1213 if (!ed) return EINA_FALSE;
1214 rp = _edje_real_part_recursive_get(&ed, part);
1215 if (!rp) return EINA_FALSE;
1216
1217 return EINA_TRUE;
1218} 1209}
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 258a7499b0..b5638ecfc1 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3325,7 +3325,7 @@ _efl_canvas_layout_efl_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Edje
3325} 3325}
3326 3326
3327EOLIAN Eina_Size2D 3327EOLIAN Eina_Size2D
3328_efl_canvas_layout_efl_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje *ed EINA_UNUSED) 3328_efl_canvas_layout_efl_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje *ed)
3329{ 3329{
3330 Eina_Size2D sz; 3330 Eina_Size2D sz;
3331 3331
@@ -3343,6 +3343,19 @@ _efl_canvas_layout_efl_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje
3343 return sz; 3343 return sz;
3344} 3344}
3345 3345
3346EOLIAN Eina_Bool
3347_efl_canvas_layout_efl_layout_group_part_exist_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
3348{
3349 Edje_Real_Part *rp;
3350
3351 if (!part) return EINA_FALSE;
3352 if (ed->delete_me) return EINA_FALSE;
3353 rp = _edje_real_part_recursive_get(&ed, part);
3354 if (!rp) return EINA_FALSE;
3355
3356 return EINA_TRUE;
3357}
3358
3346EOLIAN void 3359EOLIAN void
3347_efl_canvas_layout_efl_layout_calc_calc_force(Eo *obj EINA_UNUSED, Edje *ed) 3360_efl_canvas_layout_efl_layout_calc_calc_force(Eo *obj EINA_UNUSED, Edje *ed)
3348{ 3361{
diff --git a/src/lib/edje/efl_canvas_layout.eo b/src/lib/edje/efl_canvas_layout.eo
index d50960a350..75fb272c49 100644
--- a/src/lib/edje/efl_canvas_layout.eo
+++ b/src/lib/edje/efl_canvas_layout.eo
@@ -116,6 +116,7 @@ class Efl.Canvas.Layout (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
116 Efl.Layout.Group.group_size_min { get; } 116 Efl.Layout.Group.group_size_min { get; }
117 Efl.Layout.Group.group_size_max { get; } 117 Efl.Layout.Group.group_size_max { get; }
118 Efl.Layout.Group.group_data { get; } 118 Efl.Layout.Group.group_data { get; }
119 Efl.Layout.Group.part_exist { get; }
119 Efl.Layout.Signal.message_send; 120 Efl.Layout.Signal.message_send;
120 Efl.Layout.Signal.signal_callback_add; 121 Efl.Layout.Signal.signal_callback_add;
121 Efl.Layout.Signal.signal_callback_del; 122 Efl.Layout.Signal.signal_callback_del;
diff --git a/src/lib/edje/efl_layout_group.eo b/src/lib/edje/efl_layout_group.eo
index bd711e97ab..bb85af9740 100644
--- a/src/lib/edje/efl_layout_group.eo
+++ b/src/lib/edje/efl_layout_group.eo
@@ -98,6 +98,28 @@ interface Efl.Layout.Group
98 val: string; [[The data's value string.]] 98 val: string; [[The data's value string.]]
99 } 99 }
100 } 100 }
101 @property part_exist {
102 [[Whether the given part exists in this group.
103
104 This is mostly equivalent to verifying the part type on the object
105 as would be done in C as follows:
106 (efl_canvas_layout_part_type_get(efl_part(obj, "partname")) !=
107 EFL_CANVAS_LAYOUT_PART_TYPE_NONE)
108
109 The differences are that will silently return $false if the part
110 does not exist, and this will return $true if the part is of type
111 $SPACER in the EDC file ($SPACER parts have type $NONE).
112
113 See also @Efl.Canvas.Layout.Part.part_type.
114 ]]
115 get { [[Returns $true if the part exists in the EDC group.]] }
116 keys {
117 part: string @nonull; [[The part name to check.]]
118 }
119 values {
120 exists: bool; [[$true if the part exists, $false otherwise.]]
121 }
122 }
101 } 123 }
102} 124}
103 125
diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index aac070e063..60c6500828 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -1575,6 +1575,14 @@ _efl_ui_layout_efl_layout_group_group_size_max_get(Eo *obj, Efl_Ui_Layout_Data *
1575 return efl_layout_group_size_max_get(wd->resize_obj); 1575 return efl_layout_group_size_max_get(wd->resize_obj);
1576} 1576}
1577 1577
1578EOLIAN static Eina_Bool
1579_efl_ui_layout_efl_layout_group_part_exist_get(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, const char *part)
1580{
1581 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
1582
1583 return efl_layout_group_part_exist_get(wd->resize_obj, part);
1584}
1585
1578/* layout's sizing evaluation is deferred. evaluation requests are 1586/* layout's sizing evaluation is deferred. evaluation requests are
1579 * queued up and only flag the object as 'changed'. when it comes to 1587 * queued up and only flag the object as 'changed'. when it comes to
1580 * Evas's rendering phase, it will be addressed, finally (see 1588 * Evas's rendering phase, it will be addressed, finally (see
diff --git a/src/lib/elementary/efl_ui_layout.eo b/src/lib/elementary/efl_ui_layout.eo
index d0d32feab0..877e3d0bcb 100644
--- a/src/lib/elementary/efl_ui_layout.eo
+++ b/src/lib/elementary/efl_ui_layout.eo
@@ -59,6 +59,7 @@ class Efl.Ui.Layout (Efl.Ui.Widget, Efl.Part, Efl.Container, Efl.File,
59 Efl.Layout.Group.group_data { get; } 59 Efl.Layout.Group.group_data { get; }
60 Efl.Layout.Group.group_size_min { get; } 60 Efl.Layout.Group.group_size_min { get; }
61 Efl.Layout.Group.group_size_max { get; } 61 Efl.Layout.Group.group_size_max { get; }
62 Efl.Layout.Group.part_exist { get; }
62 Efl.Ui.Widget.widget_sub_object_add; 63 Efl.Ui.Widget.widget_sub_object_add;
63 Efl.Ui.Widget.theme_apply; 64 Efl.Ui.Widget.theme_apply;
64 Efl.Ui.Widget.on_disabled_update; 65 Efl.Ui.Widget.on_disabled_update;