aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-09-06 10:31:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-09-13 09:57:05 +0900
commit71e122424e6ce7594fff25b27a40c92d42a11b10 (patch)
tree165e1b694a8c114d313468dfd4fc98591e6ad949
parentevas: Remove group_add from clipped smart object (diff)
downloadefl-71e122424e6ce7594fff25b27a40c92d42a11b10.tar.gz
evas: Move all overrides to std smart object
- color_set - visible_set - position_set - no_render_set - member_add, member_del - group_add, group_del - clip_set Notes: - Widget overrides color_set without calling super() which means that color_get() returns a different value. Also any subsequent child object add will not inherit the color. - Smart clipped objects also don't call super. This patch changes that, but only for smart clipped objects created through EO. This shouldn't have any side effect.
-rw-r--r--src/lib/evas/canvas/efl_canvas_group.eo5
-rw-r--r--src/lib/evas/canvas/efl_canvas_group_clipped.eo7
-rw-r--r--src/lib/evas/canvas/evas_object_smart.c173
-rw-r--r--src/lib/evas/canvas/evas_object_smart_clipped.c63
4 files changed, 138 insertions, 110 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_group.eo b/src/lib/evas/canvas/efl_canvas_group.eo
index cad0ff5bc3..583ea4fcfd 100644
--- a/src/lib/evas/canvas/efl_canvas_group.eo
+++ b/src/lib/evas/canvas/efl_canvas_group.eo
@@ -52,6 +52,7 @@ class Efl.Canvas.Group (Efl.Canvas.Object)
]]
legacy: evas_object_smart_calculate;
}
+ /* FIXME: children -> members? */
group_children_iterate @const {
[[Returns an iterator over the children of this object, that are
canvas objects.
@@ -103,6 +104,10 @@ class Efl.Canvas.Group (Efl.Canvas.Object)
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Object.debug_name_override;
+ Efl.Gfx.color { set; }
+ Efl.Gfx.visible { set; }
+ Efl.Gfx.position { set; }
+ Efl.Canvas.Object.clip { set; }
Efl.Canvas.Object.no_render { set; }
Efl.Canvas.Object.paragraph_direction { get; set; }
}
diff --git a/src/lib/evas/canvas/efl_canvas_group_clipped.eo b/src/lib/evas/canvas/efl_canvas_group_clipped.eo
index 4a7b66eb0c..2f995f9cc3 100644
--- a/src/lib/evas/canvas/efl_canvas_group_clipped.eo
+++ b/src/lib/evas/canvas/efl_canvas_group_clipped.eo
@@ -6,12 +6,5 @@ abstract Efl.Canvas.Group.Clipped (Efl.Canvas.Group)
data: null;
implements {
Efl.Object.constructor;
- Efl.Gfx.color { set; }
- Efl.Gfx.visible { set; }
- Efl.Gfx.position { set; }
- Efl.Canvas.Object.clip { set; }
- Efl.Canvas.Object.no_render { set; }
- Efl.Canvas.Group.group_member_del;
- Efl.Canvas.Group.group_member_add;
}
}
diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c
index cf6d025117..b28b25fb12 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
Eina_Bool group_del_called : 1;
Eina_Bool unclipped : 1; /* If true, NOT a smart_clipped object */
Eina_Bool data_nofree : 1; /* If true, do NOT free the data */
+ Eina_Bool constructed : 1; /* constructor finished */
};
typedef struct
@@ -78,7 +79,6 @@ _eo_evas_smart_cb(void *data, const Efl_Event *event)
}
/* private methods for smart objects */
-static inline void evas_object_smart_init(Evas_Object *eo_obj);
static void evas_object_smart_render(Evas_Object *eo_obj,
Evas_Object_Protected_Data *obj,
void *type_private_data,
@@ -125,6 +125,13 @@ static const Evas_Object_Func object_func =
NULL
};
+/* helpers */
+static inline Evas_Object *
+_smart_clipper_get(Evas_Smart_Data *o)
+{
+ Evas_Object_Smart_Clipped_Data *cso = (!o->unclipped) ? o->data : NULL;
+ return cso ? cso->clipper : NULL;
+}
/* public funcs */
EAPI void
@@ -287,6 +294,17 @@ _efl_canvas_group_group_member_add(Eo *smart_obj, Evas_Smart_Data *o, Evas_Objec
if (!smart->is_frame_top && (smart->is_frame != obj->is_frame))
efl_canvas_object_is_frame_object_set(eo_obj, smart->is_frame);
+ if (!o->unclipped && o->constructed)
+ {
+ Evas_Object *clipper = _smart_clipper_get(o);
+ Eina_Bool had_clippees = efl_canvas_object_clipees_has(clipper);
+
+ EINA_SAFETY_ON_NULL_RETURN(clipper);
+ efl_canvas_object_clip_set(eo_obj, clipper);
+ if (!had_clippees && smart->cur->visible)
+ efl_gfx_visible_set(clipper, 1);
+ }
+
evas_object_change(eo_obj, obj);
evas_object_mapped_clip_across_mark(eo_obj, obj);
if (smart->smart.smart && smart->smart.smart->smart_class->member_add)
@@ -308,16 +326,29 @@ EOLIAN static void
_efl_canvas_group_group_member_del(Eo *smart_obj, Evas_Smart_Data *_pd EINA_UNUSED, Evas_Object *eo_obj)
{
Evas_Object_Protected_Data *obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
- Evas_Smart_Data *member_o;
+ Evas_Object_Protected_Data *smart;
+ Evas_Smart_Data *member_o, *o;
if (!obj || !obj->smart.parent) return;
evas_object_async_block(obj);
- Evas_Object_Protected_Data *smart = efl_data_scope_get(smart_obj, EFL_CANVAS_OBJECT_CLASS);
+
+ smart = efl_data_scope_get(smart_obj, EFL_CANVAS_OBJECT_CLASS);
if (smart->smart.smart && smart->smart.smart->smart_class->member_del)
smart->smart.smart->smart_class->member_del(smart_obj, eo_obj);
- Evas_Smart_Data *o = efl_data_scope_get(smart_obj, MY_CLASS);
+ o = efl_data_scope_get(smart_obj, MY_CLASS);
+
+ if (!o->unclipped)
+ {
+ Evas_Object *clipper = _smart_clipper_get(o);
+
+ EINA_SAFETY_ON_NULL_RETURN(clipper);
+ efl_canvas_object_clip_set(eo_obj, NULL);
+ if (!efl_canvas_object_clipees_has(clipper))
+ efl_gfx_visible_set(clipper, 0);
+ }
+
o->contained = eina_inlist_remove(o->contained, EINA_INLIST_GET(obj));
o->member_count--;
obj->smart.parent = NULL;
@@ -526,11 +557,18 @@ evas_object_smart_members_get_direct(const Evas_Object *eo_obj)
static void
_efl_canvas_group_group_members_all_del_internal(Evas_Smart_Data *o)
-{;
+{
Evas_Object_Protected_Data *memobj;
Eina_Inlist *itrn;
+ Eo *eo_clipper;
+
+ eo_clipper = _smart_clipper_get(o);
EINA_INLIST_FOREACH_SAFE(o->contained, itrn, memobj)
- efl_del(memobj->object);
+ {
+ if (memobj->object != eo_clipper)
+ efl_del(memobj->object);
+ }
+ efl_del(eo_clipper);
o->group_del_called = EINA_TRUE;
}
@@ -625,15 +663,25 @@ evas_object_smart_add(Evas *eo_e, Evas_Smart *s)
EOLIAN static Eo *
_efl_canvas_group_efl_object_constructor(Eo *eo_obj, Evas_Smart_Data *sd)
{
+ Evas_Object_Protected_Data *obj;
+
sd->object = eo_obj;
sd->inherit_paragraph_direction = EINA_TRUE;
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
- evas_object_smart_init(eo_obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(eo_obj, NULL);
+
+ obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
+ obj->is_smart = EINA_TRUE;
+ obj->func = &object_func;
+ obj->private_data = efl_data_ref(eo_obj, MY_CLASS);
+ if (!sd->unclipped)
+ _evas_object_smart_clipped_init(eo_obj);
efl_canvas_object_type_set(eo_obj, MY_CLASS_NAME_LEGACY);
efl_canvas_group_add(eo_obj);
+ sd->constructed = EINA_TRUE;
return eo_obj;
}
@@ -743,17 +791,8 @@ _evas_object_smart_clipped_init(Evas_Object *eo_obj)
}
EOLIAN static void
-_efl_canvas_group_group_add(Eo *eo_obj, Evas_Smart_Data *o)
+_efl_canvas_group_group_add(Eo *eo_obj EINA_UNUSED, Evas_Smart_Data *o EINA_UNUSED)
{
- // We shouldn't reach this function in case of legacy API.
- Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
- EINA_SAFETY_ON_FALSE_RETURN(!obj->smart.smart);
-
- if (!o->unclipped)
- {
- if (!o->data) o->unclipped = EINA_TRUE;
- else _evas_object_smart_clipped_init(eo_obj);
- }
}
EOLIAN static void
@@ -761,31 +800,96 @@ _efl_canvas_group_group_del(Eo *eo_obj EINA_UNUSED, Evas_Smart_Data *o)
{
if (!o->unclipped)
{
- Evas_Object_Smart_Clipped_Data *cso = o->data;
- Eo *clipper;
-
- if (cso && cso->clipper)
- {
- clipper = cso->clipper;
- cso->clipper = NULL;
- evas_object_del(clipper);
- }
_efl_canvas_group_group_members_all_del_internal(o);
}
o->group_del_called = EINA_TRUE;
}
EOLIAN static void
-_efl_canvas_group_efl_canvas_object_no_render_set(Eo *eo_obj, Evas_Smart_Data *o EINA_UNUSED, Eina_Bool enable)
+_efl_canvas_group_efl_canvas_object_no_render_set(Eo *eo_obj, Evas_Smart_Data *o, Eina_Bool enable)
{
Evas_Object_Protected_Data *obj2;
+ Eo *clipper;
enable = !!enable;
if (efl_canvas_object_no_render_get(eo_obj) == enable) return;
+
efl_canvas_object_no_render_set(efl_super(eo_obj, MY_CLASS), enable);
- EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(eo_obj), obj2)
- efl_canvas_object_no_render_set(obj2->object, enable);
+ clipper = (!o->unclipped) ? _smart_clipper_get(o) : NULL;
+ EINA_INLIST_FOREACH(o->contained, obj2)
+ {
+ if (obj2->object != clipper)
+ efl_canvas_object_no_render_set(obj2->object, enable);
+ }
+}
+
+EOLIAN static void
+_efl_canvas_group_efl_gfx_color_set(Eo *eo_obj, Evas_Smart_Data *o, int r, int g, int b, int a)
+{
+ if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_COLOR_SET, 0, r, g, b, a))
+ return;
+
+ efl_gfx_color_set(efl_super(eo_obj, MY_CLASS), r, g, b, a);
+
+ if (!o->unclipped)
+ {
+ Evas_Object *clipper = _smart_clipper_get(o);
+ EINA_SAFETY_ON_NULL_RETURN(clipper);
+
+ efl_gfx_color_set(clipper, r, g, b, a);
+ // Note: Legacy impl (and Widget) didn't call super in this case...
+ }
+}
+
+EOLIAN static void
+_efl_canvas_group_efl_gfx_visible_set(Eo *eo_obj, Evas_Smart_Data *o, Eina_Bool vis)
+{
+ if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
+ return;
+
+ efl_gfx_visible_set(efl_super(eo_obj, MY_CLASS), vis);
+
+ if (!o->unclipped)
+ {
+ Evas_Object *clipper = _smart_clipper_get(o);
+ EINA_SAFETY_ON_NULL_RETURN(clipper);
+
+ // note: maybe this is not necessary with no_render set on the clipper
+ if (vis && !evas_object_clipees_has(clipper))
+ return;
+
+ efl_gfx_visible_set(clipper, vis);
+ }
+}
+
+EOLIAN static void
+_efl_canvas_group_efl_gfx_position_set(Eo *eo_obj, Evas_Smart_Data *o, Evas_Coord x, Evas_Coord y)
+{
+ if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, x, y))
+ return;
+
+ if (!o->unclipped)
+ _evas_object_smart_clipped_smart_move_internal(eo_obj, x, y);
+ efl_gfx_position_set(efl_super(eo_obj, MY_CLASS), x, y);
+}
+
+EOLIAN static void
+_efl_canvas_group_efl_canvas_object_clip_set(Eo *eo_obj, Evas_Smart_Data *o, Evas_Object *clip)
+{
+ EINA_SAFETY_ON_FALSE_RETURN(!clip || efl_isa(clip, EFL_CANVAS_OBJECT_CLASS));
+ if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_CLIP_SET, 0, clip))
+ return;
+
+ efl_canvas_object_clip_set(efl_super(eo_obj, MY_CLASS), clip);
+
+ if (!o->unclipped)
+ {
+ Evas_Object *clipper = _smart_clipper_get(o);
+ EINA_SAFETY_ON_NULL_RETURN(clipper);
+
+ efl_canvas_object_clip_set(clipper, clip);
+ }
}
void
@@ -1581,16 +1685,6 @@ evas_object_smart_bounding_box_update(Evas_Object_Protected_Data *obj)
}
/* all nice and private */
-static inline void
-evas_object_smart_init(Evas_Object *eo_obj)
-{
- Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
- obj->is_smart = EINA_TRUE;
- /* set up methods (compulsory) */
- obj->func = &object_func;
- obj->private_data = efl_data_ref(eo_obj, MY_CLASS);
-}
-
static void
evas_object_smart_render(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED, void *type_private_data EINA_UNUSED, void *engine EINA_UNUSED, void *output EINA_UNUSED, void *context EINA_UNUSED, void *surface EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, Eina_Bool do_async EINA_UNUSED)
{
@@ -1746,5 +1840,4 @@ EOAPI EFL_VOID_FUNC_BODYV(efl_canvas_group_unclipped_set, EFL_FUNC_CALL(enable),
EFL_OBJECT_OP_FUNC(efl_canvas_group_del, _efl_canvas_group_group_del), \
EFL_OBJECT_OP_FUNC(efl_canvas_group_unclipped_set, _efl_canvas_group_group_unclipped_set)
-
#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 6c2c8ea080..776c7fd68e 100644
--- a/src/lib/evas/canvas/evas_object_smart_clipped.c
+++ b/src/lib/evas/canvas/evas_object_smart_clipped.c
@@ -49,16 +49,6 @@ evas_object_smart_clipped_smart_move(Evas_Object *eo_obj, Evas_Coord x, Evas_Coo
_evas_object_smart_clipped_smart_move_internal(eo_obj, x, y);
}
-EOLIAN static void
-_efl_canvas_group_clipped_efl_gfx_position_set(Eo *eo_obj, void *_pd EINA_UNUSED, Evas_Coord x, Evas_Coord y)
-{
- if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, x, y))
- return;
-
- _evas_object_smart_clipped_smart_move_internal(eo_obj, x, y);
- efl_gfx_position_set(efl_super(eo_obj, MY_CLASS), x, y);
-}
-
static void
evas_object_smart_clipped_smart_show(Evas_Object *eo_obj)
{
@@ -74,28 +64,6 @@ evas_object_smart_clipped_smart_hide(Evas_Object *eo_obj)
evas_object_hide(cso->clipper);
}
-EOLIAN static void
-_efl_canvas_group_clipped_efl_gfx_visible_set(Eo *eo_obj, void *_pd EINA_UNUSED, Eina_Bool vis)
-{
- if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
- return;
-
- efl_gfx_visible_set(efl_super(eo_obj, MY_CLASS), vis);
-
- if (vis) evas_object_smart_clipped_smart_show(eo_obj);
- else evas_object_smart_clipped_smart_hide(eo_obj);
-}
-
-EOLIAN static void
-_efl_canvas_group_clipped_efl_canvas_object_no_render_set(Eo *eo_obj, void *_pd EINA_UNUSED, Eina_Bool enable)
-{
- CSO_DATA_GET_OR_RETURN(eo_obj, cso);
- enable = !!enable;
- if (efl_canvas_object_no_render_get(eo_obj) == enable) return;
- efl_canvas_object_no_render_set(efl_super(eo_obj, MY_CLASS), enable);
- efl_canvas_object_no_render_set(cso->clipper, 1);
-}
-
static void
evas_object_smart_clipped_smart_color_set(Evas_Object *eo_obj, int r, int g, int b, int a)
{
@@ -103,12 +71,6 @@ evas_object_smart_clipped_smart_color_set(Evas_Object *eo_obj, int r, int g, int
evas_object_color_set(cso->clipper, r, g, b, a);
}
-EOLIAN static void
-_efl_canvas_group_clipped_efl_gfx_color_set(Eo *eo_obj, void *_pd EINA_UNUSED, int r, int g, int b, int a)
-{
- evas_object_smart_clipped_smart_color_set(eo_obj, r, g, b, a);
-}
-
static void
evas_object_smart_clipped_smart_clip_set(Evas_Object *eo_obj, Evas_Object *clip)
{
@@ -123,17 +85,6 @@ evas_object_smart_clipped_smart_clip_unset(Evas_Object *eo_obj)
evas_object_clip_unset(cso->clipper);
}
-EOLIAN static void
-_efl_canvas_group_clipped_efl_canvas_object_clip_set(Eo *eo_obj, void *_pd EINA_UNUSED, Evas_Object *clip)
-{
- if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_CLIP_SET, 0, clip))
- return;
-
- efl_canvas_object_clip_set(efl_super(eo_obj, MY_CLASS), clip);
- if (clip) evas_object_smart_clipped_smart_clip_set(eo_obj, clip);
- else evas_object_smart_clipped_smart_clip_unset(eo_obj);
-}
-
static void
evas_object_smart_clipped_smart_member_add(Evas_Object *eo_obj, Evas_Object *member)
{
@@ -145,13 +96,6 @@ evas_object_smart_clipped_smart_member_add(Evas_Object *eo_obj, Evas_Object *mem
evas_object_show(cso->clipper);
}
-EOLIAN static void
-_efl_canvas_group_clipped_efl_canvas_group_group_member_add(Eo *eo_obj, void *_pd EINA_UNUSED, Evas_Object *member)
-{
- efl_canvas_group_member_add(efl_super(eo_obj, MY_CLASS), member);
- evas_object_smart_clipped_smart_member_add(eo_obj, member);
-}
-
static void
evas_object_smart_clipped_smart_member_del(Evas_Object *eo_obj, Evas_Object *member)
{
@@ -163,13 +107,6 @@ evas_object_smart_clipped_smart_member_del(Evas_Object *eo_obj, Evas_Object *mem
evas_object_hide(cso->clipper);
}
-EOLIAN static void
-_efl_canvas_group_clipped_efl_canvas_group_group_member_del(Eo *eo_obj, void *_pd EINA_UNUSED, Evas_Object *member)
-{
- evas_object_smart_clipped_smart_member_del(eo_obj, member);
- efl_canvas_group_member_del(efl_super(eo_obj, MY_CLASS), member);
-}
-
EOLIAN static Eo *
_efl_canvas_group_clipped_efl_object_constructor(Eo *eo_obj, void *_pd EINA_UNUSED)
{