forked from enlightenment/efl
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
This commit is contained in:
parent
2dbd704dae
commit
419f3935c6
|
@ -1269,37 +1269,6 @@ EAPI Eina_Iterator *edje_mmap_color_class_iterator_new(Eina_File *f);
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Edje_Part_Type
|
||||
*
|
||||
* All possible "part" types in Edje.
|
||||
*/
|
||||
typedef enum _Edje_Part_Type
|
||||
{
|
||||
EDJE_PART_TYPE_NONE = 0, /**< None type value */
|
||||
EDJE_PART_TYPE_RECTANGLE = 1, /**< Rectangle type value */
|
||||
EDJE_PART_TYPE_TEXT = 2, /**< Text type value */
|
||||
EDJE_PART_TYPE_IMAGE = 3, /**< Image type value */
|
||||
EDJE_PART_TYPE_SWALLOW = 4, /**< Swallow type value */
|
||||
EDJE_PART_TYPE_TEXTBLOCK = 5, /**< Text block type value */
|
||||
EDJE_PART_TYPE_GRADIENT = 6, /**< Gradient type value */
|
||||
EDJE_PART_TYPE_GROUP = 7, /**< Group type value */
|
||||
EDJE_PART_TYPE_BOX = 8, /**< Box type value */
|
||||
EDJE_PART_TYPE_TABLE = 9, /**< Table type value */
|
||||
EDJE_PART_TYPE_EXTERNAL = 10, /**< External type value */
|
||||
EDJE_PART_TYPE_PROXY = 11, /**< Proxy type value */
|
||||
EDJE_PART_TYPE_SPACER = 12, /**< Spacer type value @since 1.7 */
|
||||
EDJE_PART_TYPE_MESH_NODE = 13,
|
||||
EDJE_PART_TYPE_LIGHT = 14,
|
||||
EDJE_PART_TYPE_CAMERA = 15,
|
||||
EDJE_PART_TYPE_SNAPSHOT = 16, /**< Snapshot @since 1.16 */
|
||||
EDJE_PART_TYPE_VECTOR = 17, /**< Vector @since 1.18 */
|
||||
EDJE_PART_TYPE_LAST = 18 /**< Last type value */
|
||||
} Edje_Part_Type;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Edje_Part_Text Edje Text Part
|
||||
* @ingroup Edje_Object_Part
|
||||
|
|
|
@ -2731,6 +2731,45 @@ EAPI void edje_object_size_min_get(const Edje_Object *obj, int *minw, int *minh)
|
|||
*/
|
||||
EAPI void edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh);
|
||||
|
||||
/**
|
||||
* @brief Checks if a part exists in a given Edje object's group definition.
|
||||
*
|
||||
* This function returns if a given part exists in the Edje group bound to this
|
||||
* object (with @ref edje_object_file_set()).
|
||||
*
|
||||
* This call is useful, for example, when one could expect or not a given GUI
|
||||
* element, depending on the theme applied to the object.
|
||||
*
|
||||
* @param[in] part The part's name to check for existence in obj's group
|
||||
*
|
||||
* @return @c true if the Edje part exists in obj's group, or @c false
|
||||
* otherwise (and on errors)
|
||||
*
|
||||
* @ingroup Edje_Object
|
||||
*/
|
||||
EAPI Eina_Bool edje_object_part_exists(const Edje_Object *obj, const char *part);
|
||||
|
||||
typedef Efl_Canvas_Layout_Part_Type Edje_Part_Type;
|
||||
#define EDJE_PART_TYPE_NONE EFL_CANVAS_LAYOUT_PART_TYPE_NONE
|
||||
#define EDJE_PART_TYPE_RECTANGLE EFL_CANVAS_LAYOUT_PART_TYPE_RECTANGLE
|
||||
#define EDJE_PART_TYPE_TEXT EFL_CANVAS_LAYOUT_PART_TYPE_TEXT
|
||||
#define EDJE_PART_TYPE_IMAGE EFL_CANVAS_LAYOUT_PART_TYPE_IMAGE
|
||||
#define EDJE_PART_TYPE_SWALLOW EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW
|
||||
#define EDJE_PART_TYPE_TEXTBLOCK EFL_CANVAS_LAYOUT_PART_TYPE_TEXTBLOCK
|
||||
#define EDJE_PART_TYPE_GRADIENT EFL_CANVAS_LAYOUT_PART_TYPE_GRADIENT
|
||||
#define EDJE_PART_TYPE_GROUP EFL_CANVAS_LAYOUT_PART_TYPE_GROUP
|
||||
#define EDJE_PART_TYPE_BOX EFL_CANVAS_LAYOUT_PART_TYPE_BOX
|
||||
#define EDJE_PART_TYPE_TABLE EFL_CANVAS_LAYOUT_PART_TYPE_TABLE
|
||||
#define EDJE_PART_TYPE_EXTERNAL EFL_CANVAS_LAYOUT_PART_TYPE_EXTERNAL
|
||||
#define EDJE_PART_TYPE_PROXY EFL_CANVAS_LAYOUT_PART_TYPE_PROXY
|
||||
#define EDJE_PART_TYPE_SPACER EFL_CANVAS_LAYOUT_PART_TYPE_SPACER
|
||||
#define EDJE_PART_TYPE_MESH_NODE EFL_CANVAS_LAYOUT_PART_TYPE_MESH_NODE
|
||||
#define EDJE_PART_TYPE_LIGHT EFL_CANVAS_LAYOUT_PART_TYPE_LIGHT
|
||||
#define EDJE_PART_TYPE_CAMERA EFL_CANVAS_LAYOUT_PART_TYPE_CAMERA
|
||||
#define EDJE_PART_TYPE_SNAPSHOT EFL_CANVAS_LAYOUT_PART_TYPE_SNAPSHOT
|
||||
#define EDJE_PART_TYPE_VECTOR EFL_CANVAS_LAYOUT_PART_TYPE_VECTOR
|
||||
#define EDJE_PART_TYPE_LAST EFL_CANVAS_LAYOUT_PART_TYPE_LAST
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -1188,3 +1188,18 @@ edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh)
|
|||
if (maxw) *maxw = sz.w;
|
||||
if (maxh) *maxh = sz.h;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -321,25 +321,6 @@ class Edje.Object (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
|
|||
legacy: null;
|
||||
return: iterator<string> @owned; [[Part name iterator]]
|
||||
}
|
||||
part_exists @const {
|
||||
[[Checks if a part exists in a given Edje object's group definition.
|
||||
|
||||
This function returns if a given part exists in the Edje group
|
||||
bound to this object (with @Efl.File.file.set()).
|
||||
|
||||
This call is useful, for example, when one could expect or not a
|
||||
given GUI element, depending on the theme applied to the object.
|
||||
|
||||
Note: @Efl.Part.part() called on an Edje object will return $null
|
||||
if it doesn't contain the given part.
|
||||
]]
|
||||
return: bool; [[$true if the Edje part exists in obj's group, or
|
||||
$false otherwise (and on errors)]]
|
||||
params {
|
||||
@in part: string; [[The part's name to check for existence in obj's
|
||||
group]]
|
||||
}
|
||||
}
|
||||
|
||||
/* TEXT PART APIS BEGIN ---------------------------------------------- */
|
||||
@property text_change_cb {
|
||||
|
@ -433,7 +414,7 @@ class Edje.Object (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
|
|||
Efl.File.file { get; set; }
|
||||
Efl.File.mmap { get; set; }
|
||||
Efl.Container.content_remove;
|
||||
Efl.Part.part;
|
||||
Efl.Part.part; [[Returns @Efl.Canvas.Layout.Part.]]
|
||||
Efl.Observer.update;
|
||||
Efl.Player.playable { get; }
|
||||
Efl.Player.play { get; set; }
|
||||
|
|
|
@ -126,6 +126,18 @@ _efl_canvas_layout_part_state_get(Eo *obj, Efl_Canvas_Layout_Part_Data *pd, cons
|
|||
RETURN_VOID;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Canvas_Layout_Part_Type
|
||||
_efl_canvas_layout_part_part_type_get(Eo *obj, Efl_Canvas_Layout_Part_Data *pd)
|
||||
{
|
||||
Edje_Real_Part *rp;
|
||||
PROXY_CALL_BEGIN(pd);
|
||||
|
||||
rp = _edje_real_part_recursive_get(&pd->ed, pd->part);
|
||||
if (!rp || !rp->part) RETURN_VAL(EFL_CANVAS_LAYOUT_PART_TYPE_NONE);
|
||||
|
||||
RETURN_VAL((Efl_Canvas_Layout_Part_Type) rp->part->type);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_canvas_layout_part_efl_ui_drag_drag_value_set(Eo *obj, Efl_Canvas_Layout_Part_Data *pd, double dx, double dy)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
enum Efl.Canvas.Layout.Part_Type
|
||||
{
|
||||
[[Type of a part in an Efl.Canvas.Layout object (edje object).]]
|
||||
none = 0, [[None type value, indicates invalid parts.]]
|
||||
rectangle = 1, [[Rectangle type value.]]
|
||||
text = 2, [[Text type value.]]
|
||||
image = 3, [[Image type value.]]
|
||||
swallow = 4, [[Swallow type value.]]
|
||||
textblock = 5, [[Text block type value.]]
|
||||
gradient = 6, [[Gradient type value.]]
|
||||
group = 7, [[Group type value.]]
|
||||
box = 8, [[Box type value.]]
|
||||
table = 9, [[Table type value.]]
|
||||
external = 10, [[External type value.]]
|
||||
proxy = 11, [[Proxy type value.]]
|
||||
spacer = 12, [[Spacer type value @since 1.7.]]
|
||||
mesh_node = 13, [[Canvas 3D type: mesh node.]]
|
||||
light = 14, [[Canvas 3D type: light.]]
|
||||
camera = 15, [[Canvas 3D type: camera.]]
|
||||
snapshot = 16, [[Snapshot @since 1.16.]]
|
||||
vector = 17, [[Vector @since 1.18.]]
|
||||
last = 18 [[Last type value.]]
|
||||
}
|
||||
|
||||
|
||||
/* TODO: Rename to Efl.Canvas.Layout.Blah */
|
||||
|
||||
enum Edje.Cursor {
|
||||
[[All available cursor states]]
|
||||
main, [[Main cursor state]]
|
||||
|
|
|
@ -1793,19 +1793,6 @@ on_error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
EOLIAN Eina_Bool
|
||||
_edje_object_part_exists(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
|
||||
{
|
||||
Edje_Real_Part *rp;
|
||||
|
||||
if ((!ed) || (!part)) return EINA_FALSE;
|
||||
rp = _edje_real_part_recursive_get(&ed, part);
|
||||
if (!rp) return EINA_FALSE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
/* Legacy API: exposes internal object. Easy to abuse. */
|
||||
EAPI const Evas_Object *
|
||||
edje_object_part_object_get(const Eo *obj, const char *part)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* FIXME: Rename to Efl.Canvas.Layout.Part */
|
||||
import edje_types;
|
||||
|
||||
class Efl.Canvas.Layout.Part (Efl.Object, Efl.Gfx, Efl.Ui.Drag)
|
||||
{
|
||||
[[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)
|
|||
val: double; [[The value of the state.]]
|
||||
}
|
||||
}
|
||||
@property part_type {
|
||||
[[Type of this part in the layout.]]
|
||||
get {
|
||||
[[Returns the type of the part.]]
|
||||
}
|
||||
values {
|
||||
type: Efl.Canvas.Layout.Part_Type(Efl.Canvas.Layout.Part_Type.none);
|
||||
[[One of the types or $none if not an existing part.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Efl.Object.finalize;
|
||||
|
@ -36,7 +47,4 @@ class Efl.Canvas.Layout.Part (Efl.Object, Efl.Gfx, Efl.Ui.Drag)
|
|||
Efl.Ui.Drag.drag_page { set; get; }
|
||||
Efl.Ui.Drag.drag_page_move;
|
||||
}
|
||||
events {
|
||||
/* FIXME: Are there really no events? */
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue