} Evas_Aspect_Control;
-#define EVAS_SMART_CLASS_VERSION 2 /** the version you have to put into the version field in the smart class struct */
+#define EVAS_SMART_CLASS_VERSION 3 /** the version you have to put into the version field in the smart class struct */
struct _Evas_Smart_Class /** a smart object class */
{
const char *name; /** the string name of the class */
void (*clip_set) (Evas_Object *o, Evas_Object *clip); // FIXME: DELETE ME
void (*clip_unset) (Evas_Object *o); // FIXME: DELETE ME
void (*calculate) (Evas_Object *o);
+ void (*member_add) (Evas_Object *o, Evas_Object *child);
+ void (*member_del) (Evas_Object *o, Evas_Object *child);
const void *data;
};
EAPI Evas_Object *evas_object_smart_clipped_clipper_get(Evas_Object *obj);
EAPI void evas_object_smart_clipped_smart_set(Evas_Smart_Class *sc);
- EAPI void evas_object_smart_clipped_member_add(Evas_Object *obj, Evas_Object *member);
- EAPI void evas_object_smart_clipped_member_del(Evas_Object *member);
/* convenience */
EAPI void evas_object_smart_move_children_relative(Evas_Object *obj, Evas_Coord dx, Evas_Coord dy);
evas_object_smart_member_cache_invalidate(obj);
obj->restack = 1;
evas_object_change(obj);
+ if (smart_obj->smart.smart->smart_class->member_add)
+ smart_obj->smart.smart->smart_class->member_add(smart_obj, obj);
}
/**
evas_object_smart_member_del(Evas_Object *obj)
{
Evas_Object_Smart *o;
+ Evas_Object *smart_obj;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
if (!obj->smart.parent) return;
+ smart_obj = obj->smart.parent;
+ if (smart_obj->smart.smart->smart_class->member_del)
+ smart_obj->smart.smart->smart_class->member_del(smart_obj, obj);
+
o = (Evas_Object_Smart *)(obj->smart.parent->object_data);
o->contained = eina_inlist_remove(o->contained, EINA_INLIST_GET(obj));
obj->smart.parent = NULL;
{
Evas_Object_Smart *o;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
- return 0;
+ return;
MAGIC_CHECK_END();
o = obj->object_data;
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
- return 0;
+ return;
MAGIC_CHECK_END();
if (obj->smart.smart->smart_class->calculate)
evas_object_smart_clipped_smart_add(Evas_Object *obj)
{
Evas_Object_Smart_Clipped_Data *cso;
+ Evas_Object *clipper;
cso = evas_object_smart_data_get(obj);
if (!cso)
cso = malloc(sizeof(*cso)); /* users can provide it or realloc() later */
cso->evas = evas_object_evas_get(obj);
- cso->clipper = evas_object_rectangle_add(cso->evas);
- evas_object_smart_member_add(cso->clipper, obj);
+ clipper = evas_object_rectangle_add(cso->evas);
+ cso->clipper = NULL;
+ evas_object_smart_member_add(clipper, obj);
+ cso->clipper = clipper;
evas_object_color_set(cso->clipper, 255, 255, 255, 255);
evas_object_move(cso->clipper, -10000, -10000);
evas_object_resize(cso->clipper, 20000, 20000);
Eina_List *lst, *itr;
Evas_Object *data;
+ if (cso->clipper)
+ {
+ Evas_Object *clipper = cso->clipper;
+ cso->clipper = NULL;
+ evas_object_del(clipper);
+ }
+
lst = evas_object_smart_members_get(obj);
EINA_LIST_FOREACH(lst, itr, data)
evas_object_del(data);
evas_object_clip_unset(cso->clipper);
}
-/**
- * Add the given member to clipped smart object.
- *
- * This method is equivalent to evas_object_smart_member_add(), but
- * will do extra work required to have clipped smart object to use the
- * clipper, also shows the clipper if this is the first object and
- * object is visible.
- *
- * @warning the parameter order is different from
- * evas_object_smart_member_add()
- *
- * @param obj the smart object to use.
- * @param member the child/member to add to @a obj
- *
- * @todo add member_add() callback to Evas_Smart_Class.
- */
-EAPI void
-evas_object_smart_clipped_member_add(Evas_Object *obj, Evas_Object *member)
+static void
+evas_object_smart_clipped_smart_member_add(Evas_Object *obj, Evas_Object *member)
{
CSO_DATA_GET_OR_RETURN(obj, cso);
-
- evas_object_smart_member_add(member, obj);
- /* begin: code that should be done from inside member_add() hook */
+ if (!cso->clipper)
+ return;
evas_object_clip_set(member, cso->clipper);
if (evas_object_visible_get(obj))
evas_object_show(cso->clipper);
- /* end */
}
-/**
- * Remove the given member from clipped smart object.
- *
- * This method is equivalent to evas_object_smart_member_del(), but
- * will do extra work required to have clipped smart object to stop
- * using the clipper, also hide the clipper if this is the last
- * object.
- *
- * @param member the child/member to remove from its parent smart object.
- *
- * @todo add member_del() callback to Evas_Smart_Class.
- */
-EAPI void
-evas_object_smart_clipped_member_del(Evas_Object *member)
+static void
+evas_object_smart_clipped_smart_member_del(Evas_Object *obj, Evas_Object *member)
{
- Evas_Object *obj = evas_object_smart_parent_get(member);
CSO_DATA_GET_OR_RETURN(obj, cso);
-
- evas_object_smart_member_del(member);
- /* begin: code that should be done from inside member_del() hook */
+ if (!cso->clipper)
+ return;
evas_object_clip_unset(member);
if (!evas_object_clipees_get(cso->clipper))
evas_object_hide(cso->clipper);
- /* end */
}
/**
sc->color_set = evas_object_smart_clipped_smart_color_set;
sc->clip_set = evas_object_smart_clipped_smart_clip_set;
sc->clip_unset = evas_object_smart_clipped_smart_clip_unset;
+ sc->member_add = evas_object_smart_clipped_smart_member_add;
+ sc->member_del = evas_object_smart_clipped_smart_member_del;
}
/**