summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-09-01 12:30:49 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-09-13 09:57:05 +0900
commitf5a56789e062a47d0cf5141953c5d8a6071eecdf (patch)
treef6e8b548b29e29db6262a56d27913d3c039d6f11
parentc5a9e49a9bbcf2b7991b9bfbeb5041a30348bdde (diff)
evas: Add internal API to make smart obj (un)clipped
Introduction to the problem: - Efl.Canvas.Group has a method member_add() to add sub objects. - Efl.Canvas.Group (simple smart object) does NOT actually delete the objects on deletion. But: - Efl.Canvas.Group.Clipped is a direct subclass and WILL delete the sub objects on deletion. Semantically, all smart objects (at least in EO and Elementary) will own and delete sub objects automatically. Some exceptions are: - Edje object (smart clipped) does not delete swallowed objects. Edje object is a "clipped" smart object but it pops out all swallowed children before getting deleted. - Evas box/table/grid also pop out their children before deletion. Those classes are all legacy & internal only. - Elm.Widget will "manually" delete all its sub objects at deletion, as it inherits from Efl.Canvas.Group but basically takes full ownership of the sub objects. Note that member_add shouldn't be used on a widget, the widgets do it themselves. Also, smart clipped objects are much more convenient to use as they will handle some things for you: color, visibility, moving and ownership. So, the API member_add needs to be marked as own(). But right now Efl.Canvas.Group does not own. Thus, here's the plan: - Mark clipped objects as such with an internal API - Merge clipped smart object features directly inside the standard smart object. - Get rid of Efl.Canvas.Group.Clipped entirely and watch all hell break loose. Ref T5301
-rw-r--r--src/lib/elementary/elm_widget.c1
-rw-r--r--src/lib/emotion/emotion_smart.c1
-rw-r--r--src/lib/evas/Evas_Internal.h1
-rw-r--r--src/lib/evas/canvas/efl_canvas_group_clipped.eo3
-rw-r--r--src/lib/evas/canvas/efl_canvas_object_event_grabber.c1
-rw-r--r--src/lib/evas/canvas/evas_object_smart.c23
-rw-r--r--src/lib/evas/canvas/evas_object_smart_clipped.c9
7 files changed, 32 insertions, 7 deletions
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index d498319..e2947eb 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -6183,6 +6183,7 @@ _elm_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSE
6183 Eo *parent = NULL; 6183 Eo *parent = NULL;
6184 6184
6185 sd->on_create = EINA_TRUE; 6185 sd->on_create = EINA_TRUE;
6186 efl_canvas_group_unclipped_set(obj, EINA_TRUE);
6186 obj = efl_constructor(efl_super(obj, MY_CLASS)); 6187 obj = efl_constructor(efl_super(obj, MY_CLASS));
6187 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); 6188 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
6188 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 6189 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c
index 9850c80..5b2dbf2 100644
--- a/src/lib/emotion/emotion_smart.c
+++ b/src/lib/emotion/emotion_smart.c
@@ -254,6 +254,7 @@ emotion_object_add(Evas *evas)
254EOLIAN static Eo * 254EOLIAN static Eo *
255_efl_canvas_video_efl_object_constructor(Eo *obj, Efl_Canvas_Video_Data *pd EINA_UNUSED) 255_efl_canvas_video_efl_object_constructor(Eo *obj, Efl_Canvas_Video_Data *pd EINA_UNUSED)
256{ 256{
257 efl_canvas_group_unclipped_set(obj, EINA_TRUE);
257 obj = efl_constructor(efl_super(obj, MY_CLASS)); 258 obj = efl_constructor(efl_super(obj, MY_CLASS));
258 efl_canvas_object_type_set(obj, E_OBJ_NAME); 259 efl_canvas_object_type_set(obj, E_OBJ_NAME);
259 260
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index 28702ef..b4eb056 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -53,6 +53,7 @@ EOAPI void efl_canvas_object_legacy_ctor(Eo *obj);
53EOAPI void efl_canvas_object_type_set(Eo *obj, const char *type); 53EOAPI void efl_canvas_object_type_set(Eo *obj, const char *type);
54EOAPI void efl_canvas_group_add(Eo *obj); 54EOAPI void efl_canvas_group_add(Eo *obj);
55EOAPI void efl_canvas_group_del(Eo *obj); 55EOAPI void efl_canvas_group_del(Eo *obj);
56EOAPI void efl_canvas_group_unclipped_set(Eo *obj, Eina_Bool unclipped);
56 57
57EOAPI void *efl_input_legacy_info_get(const Eo *obj); 58EOAPI void *efl_input_legacy_info_get(const Eo *obj);
58EOAPI Eo *efl_input_instance_get(const Eo *obj, Efl_Object *owner, void **priv); 59EOAPI Eo *efl_input_instance_get(const Eo *obj, Efl_Object *owner, void **priv);
diff --git a/src/lib/evas/canvas/efl_canvas_group_clipped.eo b/src/lib/evas/canvas/efl_canvas_group_clipped.eo
index 39f669c..f121dce 100644
--- a/src/lib/evas/canvas/efl_canvas_group_clipped.eo
+++ b/src/lib/evas/canvas/efl_canvas_group_clipped.eo
@@ -1,8 +1,11 @@
1/* FIXME: This class needs to disappear and its functionality merged into
2 * standard smart objects (Efl.Canvas.Group). */
1abstract Efl.Canvas.Group.Clipped (Efl.Canvas.Group) 3abstract Efl.Canvas.Group.Clipped (Efl.Canvas.Group)
2{ 4{
3 [[Internal class representing a canvas object group with a clipper.]] 5 [[Internal class representing a canvas object group with a clipper.]]
4 data: Evas_Object_Smart_Clipped_Data; 6 data: Evas_Object_Smart_Clipped_Data;
5 implements { 7 implements {
8 Efl.Object.constructor;
6 Efl.Gfx.color { set; } 9 Efl.Gfx.color { set; }
7 Efl.Gfx.visible { set; } 10 Efl.Gfx.visible { set; }
8 Efl.Gfx.position { set; } 11 Efl.Gfx.position { set; }
diff --git a/src/lib/evas/canvas/efl_canvas_object_event_grabber.c b/src/lib/evas/canvas/efl_canvas_object_event_grabber.c
index 3ea7a05..18dc8c3 100644
--- a/src/lib/evas/canvas/efl_canvas_object_event_grabber.c
+++ b/src/lib/evas/canvas/efl_canvas_object_event_grabber.c
@@ -320,6 +320,7 @@ _efl_canvas_object_event_grabber_efl_object_constructor(Eo *eo_obj, Efl_Object_E
320{ 320{
321 Evas_Object_Protected_Data *obj; 321 Evas_Object_Protected_Data *obj;
322 322
323 efl_canvas_group_unclipped_set(eo_obj, EINA_TRUE);
323 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS)); 324 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
324 efl_canvas_object_type_set(eo_obj, MY_CLASS_NAME_LEGACY); 325 efl_canvas_object_type_set(eo_obj, MY_CLASS_NAME_LEGACY);
325 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 326 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c
index 760298e..4b3623e 100644
--- a/src/lib/evas/canvas/evas_object_smart.c
+++ b/src/lib/evas/canvas/evas_object_smart.c
@@ -50,6 +50,7 @@ struct _Evas_Smart_Data
50 Eina_Bool need_recalculate : 1; 50 Eina_Bool need_recalculate : 1;
51 Eina_Bool update_boundingbox_needed : 1; 51 Eina_Bool update_boundingbox_needed : 1;
52 Eina_Bool group_del_called : 1; 52 Eina_Bool group_del_called : 1;
53 Eina_Bool unclipped : 1; /* If true, NOT a smart_clipped object */
53}; 54};
54 55
55typedef struct 56typedef struct
@@ -613,13 +614,10 @@ evas_object_smart_add(Evas *eo_e, Evas_Smart *s)
613} 614}
614 615
615EOLIAN static Eo * 616EOLIAN static Eo *
616_efl_canvas_group_efl_object_constructor(Eo *eo_obj, Evas_Smart_Data *class_data EINA_UNUSED) 617_efl_canvas_group_efl_object_constructor(Eo *eo_obj, Evas_Smart_Data *sd)
617{ 618{
618 Evas_Smart_Data *smart; 619 sd->object = eo_obj;
619 620 sd->inherit_paragraph_direction = EINA_TRUE;
620 smart = class_data;
621 smart->object = eo_obj;
622 smart->inherit_paragraph_direction = EINA_TRUE;
623 621
624 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS)); 622 eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
625 evas_object_smart_init(eo_obj); 623 evas_object_smart_init(eo_obj);
@@ -1666,14 +1664,25 @@ _efl_canvas_group_efl_canvas_object_paragraph_direction_get(Eo *eo_obj EINA_UNUS
1666 return o->paragraph_direction; 1664 return o->paragraph_direction;
1667} 1665}
1668 1666
1667/* Internal EO */
1668static void
1669_efl_canvas_group_group_unclipped_set(Eo *eo_obj EINA_UNUSED, Evas_Smart_Data *sd, Eina_Bool unclipped)
1670{
1671 // We must call this function BEFORE the constructor (yes, it's hacky)
1672 EINA_SAFETY_ON_FALSE_RETURN(!sd->object);
1673 sd->unclipped = !!unclipped;
1674}
1675
1669/* Internal EO APIs */ 1676/* Internal EO APIs */
1670 1677
1671EOAPI EFL_VOID_FUNC_BODY(efl_canvas_group_add) 1678EOAPI EFL_VOID_FUNC_BODY(efl_canvas_group_add)
1672EOAPI EFL_VOID_FUNC_BODY(efl_canvas_group_del) 1679EOAPI EFL_VOID_FUNC_BODY(efl_canvas_group_del)
1680EOAPI EFL_VOID_FUNC_BODYV(efl_canvas_group_unclipped_set, EFL_FUNC_CALL(enable), Eina_Bool enable)
1673 1681
1674#define EFL_CANVAS_GROUP_EXTRA_OPS \ 1682#define EFL_CANVAS_GROUP_EXTRA_OPS \
1675 EFL_OBJECT_OP_FUNC(efl_canvas_group_add, _efl_canvas_group_group_add), \ 1683 EFL_OBJECT_OP_FUNC(efl_canvas_group_add, _efl_canvas_group_group_add), \
1676 EFL_OBJECT_OP_FUNC(efl_canvas_group_del, _efl_canvas_group_group_del) 1684 EFL_OBJECT_OP_FUNC(efl_canvas_group_del, _efl_canvas_group_group_del), \
1685 EFL_OBJECT_OP_FUNC(efl_canvas_group_unclipped_set, _efl_canvas_group_group_unclipped_set)
1677 1686
1678 1687
1679#include "canvas/efl_canvas_group.eo.c" 1688#include "canvas/efl_canvas_group.eo.c"
diff --git a/src/lib/evas/canvas/evas_object_smart_clipped.c b/src/lib/evas/canvas/evas_object_smart_clipped.c
index 23345df..2ad3597 100644
--- a/src/lib/evas/canvas/evas_object_smart_clipped.c
+++ b/src/lib/evas/canvas/evas_object_smart_clipped.c
@@ -209,6 +209,15 @@ _efl_canvas_group_clipped_efl_canvas_group_group_member_del(Eo *eo_obj, Evas_Obj
209 efl_canvas_group_member_del(efl_super(eo_obj, MY_CLASS), member); 209 efl_canvas_group_member_del(efl_super(eo_obj, MY_CLASS), member);
210} 210}
211 211
212EOLIAN static Eo *
213_efl_canvas_group_clipped_efl_object_constructor(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED)
214{
215 // Setting this flag before the parent constructor on purpose.
216 efl_canvas_group_unclipped_set(eo_obj, EINA_FALSE);
217 return efl_constructor(efl_super(eo_obj, MY_CLASS));
218}
219
220/* Legacy only */
212EAPI void 221EAPI void
213evas_object_smart_clipped_smart_set(Evas_Smart_Class *sc) 222evas_object_smart_clipped_smart_set(Evas_Smart_Class *sc)
214{ 223{