edje_part: move part_type to common interface

In EFL we have multiple hirachies of parts. One in Efl.Layout namespace
(alias edje) and one in Efl.Ui namespace. The seperation of these two
makes sense from the perspective of hiding functionality. However, a
functionality that we want to have on both is: we want to be able to
check which type of part this is. In order to do so, this commit
introduces a common interface, which allows that.

This is required because eo is currently undergoing some works, where
only APIs on a object are allowed, that are also inheriting its type,
which is normal in OOP, but sometimes, due to the lack of limitation, we
did that. This commit resolves one more case of that.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D11516
This commit is contained in:
Marcel Hollerbach 2020-03-16 13:53:03 +01:00
parent 1e91674acd
commit 654b05b76f
11 changed files with 33 additions and 19 deletions

View File

@ -8,6 +8,7 @@
#include <efl_canvas_layout_types.eot.h>
#include "efl_canvas_layout_part_type_provider.eo.h"
#include "efl_canvas_layout_part.eo.h"
#include "efl_canvas_layout_part_box.eo.h"
#include "efl_canvas_layout_part_table.eo.h"

View File

@ -48,6 +48,7 @@ extern "C" {
#include <efl_canvas_layout_types.eot.h>
#include <efl_canvas_layout_part_type_provider.eo.h>
#include <efl_canvas_layout_part.eo.h>
#include <efl_canvas_layout_part_box.eo.h>
#include <efl_canvas_layout_part_table.eo.h>

View File

@ -121,7 +121,7 @@ _efl_canvas_layout_part_state_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Layout_P
}
EOLIAN static Efl_Canvas_Layout_Part_Type
_efl_canvas_layout_part_part_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Layout_Part_Data *pd)
_efl_canvas_layout_part_efl_canvas_layout_part_type_provider_part_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Layout_Part_Data *pd)
{
Edje_Real_Part *rp;
@ -204,4 +204,5 @@ _efl_canvas_layout_part_efl_object_debug_name_override(Eo *obj, Efl_Canvas_Layou
eina_strbuf_append_printf(sb, "%s : %s : %s", pd->part, _part_type_to_string(pd->rp->type), pd->ed->group);
}
#include "efl_canvas_layout_part_type_provider.eo.c"
#include "efl_canvas_layout_part.eo.c"

View File

@ -38,7 +38,7 @@ _efl_canvas_layout_part_invalid_efl_canvas_layout_part_state_get(const Eo *proxy
}
EOLIAN static Efl_Canvas_Layout_Part_Type
_efl_canvas_layout_part_invalid_efl_canvas_layout_part_part_type_get(const Eo *proxy EINA_UNUSED, void *_pd EINA_UNUSED)
_efl_canvas_layout_part_invalid_efl_canvas_layout_part_type_provider_part_type_get(const Eo *proxy EINA_UNUSED, void *_pd EINA_UNUSED)
{
return EFL_CANVAS_LAYOUT_PART_TYPE_NONE;
}

View File

@ -1,6 +1,6 @@
import efl_canvas_layout_types;
class @beta Efl.Canvas.Layout_Part extends Efl.Object implements Efl.Gfx.Entity, Efl.Ui.Drag
class @beta Efl.Canvas.Layout_Part extends Efl.Object implements Efl.Gfx.Entity, Efl.Ui.Drag, Efl.Canvas.Layout_Part_Type_Provider
{
[[Common class for part proxy objects for @Efl.Canvas.Layout.
@ -24,15 +24,6 @@ class @beta Efl.Canvas.Layout_Part extends Efl.Object implements Efl.Gfx.Entity,
val: double(0.0); [[The value of the state.]]
}
}
@property part_type {
[[Type of this part in the layout.]]
get {
}
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;
@ -45,5 +36,6 @@ class @beta Efl.Canvas.Layout_Part extends Efl.Object implements Efl.Gfx.Entity,
Efl.Ui.Drag.drag_step_move;
Efl.Ui.Drag.drag_page { set; get; }
Efl.Ui.Drag.drag_page_move;
Efl.Canvas.Layout_Part_Type_Provider.part_type { get; }
}
}

View File

@ -14,7 +14,7 @@ class @beta Efl.Canvas.Layout_Part_Invalid extends Efl.Canvas.Layout_Part implem
implements {
// Efl.Canvas.Layout.Part
Efl.Canvas.Layout_Part.state { get; }
Efl.Canvas.Layout_Part.part_type { get; }
Efl.Canvas.Layout_Part_Type_Provider.part_type { get; }
Efl.Gfx.Entity.geometry { get; }
Efl.Ui.Drag.drag_value { set; get; }
Efl.Ui.Drag.drag_size { set; get; }

View File

@ -0,0 +1,20 @@
import efl_canvas_layout_types;
interface @beta Efl.Canvas.Layout_Part_Type_Provider
{
[[Common Interface for the Part Type
The getter for the part type is usefull for different types of part hirachies. This interface can be used to support all the different kinds of part types that are available in EFL.
]]
c_prefix: efl_canvas_layout;
methods {
@property part_type {
[[Type of this part in the layout.]]
get {
}
values {
type: Efl.Canvas.Layout_Part_Type(Efl.Canvas.Layout_Part_Type.none); [[One of the types or $none if not an existing part.]]
}
}
}
}

View File

@ -109,7 +109,7 @@ interface Efl.Layout.Group
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.
See also @Efl.Canvas.Layout_Part_Type_Provider.part_type.
]]
get {}
keys {

View File

@ -32,6 +32,7 @@ pub_legacy_eo_files = [
'efl_canvas_layout_part_swallow.eo',
'efl_canvas_layout_part_table.eo',
'efl_canvas_layout_part_text.eo',
'efl_canvas_layout_part_type_provider.eo',
]
pub_eo_files = pub_legacy_eo_files

View File

@ -5644,7 +5644,7 @@ _efl_ui_widget_part_efl_object_destructor(Eo *obj, Elm_Part_Data *pd)
}
static Efl_Canvas_Layout_Part_Type
_efl_ui_widget_part_efl_canvas_layout_part_type_get(const Eo *obj EINA_UNUSED, Elm_Part_Data *pd)
_efl_ui_widget_part_efl_canvas_layout_part_type_provider_part_type_get(const Eo *obj EINA_UNUSED, Elm_Part_Data *pd)
{
Elm_Widget_Smart_Data *sd = efl_data_scope_safe_get(pd->obj, MY_CLASS);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EFL_CANVAS_LAYOUT_PART_TYPE_NONE);
@ -5672,9 +5672,6 @@ _efl_ui_widget_part_efl_ui_property_bind_property_bind(Eo *obj, Elm_Part_Data *p
return _efl_ui_property_bind(widget, obj, pd, ppd->part, key, property);
}
#define EFL_UI_WIDGET_PART_EXTRA_OPS \
EFL_OBJECT_OP_FUNC(efl_canvas_layout_part_type_get, _efl_ui_widget_part_efl_canvas_layout_part_type_get)
#include "efl_ui_widget_part.eo.c"
/* Efl.Part end */

View File

@ -1,4 +1,4 @@
class Efl.Ui.Widget_Part extends Efl.Object implements Efl.Ui.Property_Bind, Efl.Gfx.Entity
class Efl.Ui.Widget_Part extends Efl.Object implements Efl.Ui.Property_Bind, Efl.Gfx.Entity, Efl.Canvas.Layout_Part_Type_Provider
{
[[This is the base class for all "Part" handles in Efl.Ui widgets.
@ -17,5 +17,6 @@ class Efl.Ui.Widget_Part extends Efl.Object implements Efl.Ui.Property_Bind, Efl
@empty Efl.Gfx.Entity.position { get; set; }
@empty Efl.Gfx.Entity.size { get; set; }
@empty Efl.Gfx.Entity.scale { set; get; }
Efl.Canvas.Layout_Part_Type_Provider.part_type { get; }
}
}