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.
This commit is contained in:
Jean-Philippe Andre 2018-01-15 17:27:10 +09:00
parent d133336399
commit 9e2f2970b8
6 changed files with 47 additions and 11 deletions

View File

@ -1205,14 +1205,5 @@ edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh)
EAPI Eina_Bool
edje_object_part_exists(const Eo *obj, const char *part)
{
Edje_Real_Part *rp;
Edje *ed;
if (!part) return EINA_FALSE;
ed = _edje_fetch(obj);
if (!ed) return EINA_FALSE;
rp = _edje_real_part_recursive_get(&ed, part);
if (!rp) return EINA_FALSE;
return EINA_TRUE;
return efl_layout_group_part_exist_get(obj, part);
}

View File

@ -3325,7 +3325,7 @@ _efl_canvas_layout_efl_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Edje
}
EOLIAN Eina_Size2D
_efl_canvas_layout_efl_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje *ed EINA_UNUSED)
_efl_canvas_layout_efl_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje *ed)
{
Eina_Size2D sz;
@ -3343,6 +3343,19 @@ _efl_canvas_layout_efl_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje
return sz;
}
EOLIAN Eina_Bool
_efl_canvas_layout_efl_layout_group_part_exist_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
{
Edje_Real_Part *rp;
if (!part) return EINA_FALSE;
if (ed->delete_me) return EINA_FALSE;
rp = _edje_real_part_recursive_get(&ed, part);
if (!rp) return EINA_FALSE;
return EINA_TRUE;
}
EOLIAN void
_efl_canvas_layout_efl_layout_calc_calc_force(Eo *obj EINA_UNUSED, Edje *ed)
{

View File

@ -116,6 +116,7 @@ class Efl.Canvas.Layout (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
Efl.Layout.Group.group_size_min { get; }
Efl.Layout.Group.group_size_max { get; }
Efl.Layout.Group.group_data { get; }
Efl.Layout.Group.part_exist { get; }
Efl.Layout.Signal.message_send;
Efl.Layout.Signal.signal_callback_add;
Efl.Layout.Signal.signal_callback_del;

View File

@ -98,6 +98,28 @@ interface Efl.Layout.Group
val: string; [[The data's value string.]]
}
}
@property part_exist {
[[Whether the given part exists in this group.
This is mostly equivalent to verifying the part type on the object
as would be done in C as follows:
(efl_canvas_layout_part_type_get(efl_part(obj, "partname")) !=
EFL_CANVAS_LAYOUT_PART_TYPE_NONE)
The differences are that will silently return $false if the part
does not exist, and this will return $true if the part is of type
$SPACER in the EDC file ($SPACER parts have type $NONE).
See also @Efl.Canvas.Layout.Part.part_type.
]]
get { [[Returns $true if the part exists in the EDC group.]] }
keys {
part: string @nonull; [[The part name to check.]]
}
values {
exists: bool; [[$true if the part exists, $false otherwise.]]
}
}
}
}

View File

@ -1575,6 +1575,14 @@ _efl_ui_layout_efl_layout_group_group_size_max_get(Eo *obj, Efl_Ui_Layout_Data *
return efl_layout_group_size_max_get(wd->resize_obj);
}
EOLIAN static Eina_Bool
_efl_ui_layout_efl_layout_group_part_exist_get(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, const char *part)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
return efl_layout_group_part_exist_get(wd->resize_obj, part);
}
/* layout's sizing evaluation is deferred. evaluation requests are
* queued up and only flag the object as 'changed'. when it comes to
* Evas's rendering phase, it will be addressed, finally (see

View File

@ -59,6 +59,7 @@ class Efl.Ui.Layout (Efl.Ui.Widget, Efl.Part, Efl.Container, Efl.File,
Efl.Layout.Group.group_data { get; }
Efl.Layout.Group.group_size_min { get; }
Efl.Layout.Group.group_size_max { get; }
Efl.Layout.Group.part_exist { get; }
Efl.Ui.Widget.widget_sub_object_add;
Efl.Ui.Widget.theme_apply;
Efl.Ui.Widget.on_disabled_update;