2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
|
|
|
typedef struct _Evas_Object_Smart Evas_Object_Smart;
|
|
|
|
typedef struct _Evas_Smart_Callback Evas_Smart_Callback;
|
|
|
|
|
|
|
|
struct _Evas_Object_Smart
|
|
|
|
{
|
|
|
|
DATA32 magic;
|
|
|
|
void *engine_data;
|
2008-04-30 22:48:03 -07:00
|
|
|
void *data;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *callbacks;
|
2008-10-17 04:23:18 -07:00
|
|
|
Eina_Inlist *contained;
|
2010-01-11 06:24:41 -08:00
|
|
|
Evas_Smart_Cb_Description_Array callbacks_descriptions;
|
2008-04-30 22:48:03 -07:00
|
|
|
int walking_list;
|
2009-06-17 03:01:52 -07:00
|
|
|
Eina_Bool deletions_waiting : 1;
|
|
|
|
Eina_Bool need_recalculate : 1;
|
2002-11-08 00:02:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Evas_Smart_Callback
|
|
|
|
{
|
2006-05-31 11:33:46 -07:00
|
|
|
const char *event;
|
2011-04-12 02:23:57 -07:00
|
|
|
Evas_Smart_Cb func;
|
2002-11-08 00:02:15 -08:00
|
|
|
void *func_data;
|
2011-08-17 04:55:29 -07:00
|
|
|
Evas_Callback_Priority priority;
|
2007-06-28 16:22:20 -07:00
|
|
|
char delete_me : 1;
|
2002-11-08 00:02:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* private methods for smart objects */
|
2003-01-19 20:36:17 -08:00
|
|
|
static void evas_object_smart_callbacks_clear(Evas_Object *obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
static void evas_object_smart_init(Evas_Object *obj);
|
|
|
|
static void *evas_object_smart_new(void);
|
|
|
|
static void evas_object_smart_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y);
|
|
|
|
static void evas_object_smart_free(Evas_Object *obj);
|
|
|
|
static void evas_object_smart_render_pre(Evas_Object *obj);
|
|
|
|
static void evas_object_smart_render_post(Evas_Object *obj);
|
|
|
|
|
2008-08-30 19:04:31 -07:00
|
|
|
static unsigned int evas_object_smart_id_get(Evas_Object *obj);
|
|
|
|
static unsigned int evas_object_smart_visual_id_get(Evas_Object *obj);
|
2008-08-25 22:45:04 -07:00
|
|
|
static void *evas_object_smart_engine_data_get(Evas_Object *obj);
|
|
|
|
|
2007-05-06 04:29:37 -07:00
|
|
|
static const Evas_Object_Func object_func =
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
/* methods (compulsory) */
|
|
|
|
evas_object_smart_free,
|
2011-05-07 01:01:42 -07:00
|
|
|
evas_object_smart_render,
|
|
|
|
evas_object_smart_render_pre,
|
|
|
|
evas_object_smart_render_post,
|
|
|
|
evas_object_smart_id_get,
|
|
|
|
evas_object_smart_visual_id_get,
|
|
|
|
evas_object_smart_engine_data_get,
|
|
|
|
/* these are optional. NULL = nothing */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
2002-11-08 00:02:15 -08:00
|
|
|
};
|
|
|
|
|
2010-11-26 02:01:18 -08:00
|
|
|
EVAS_MEMPOOL(_mp_obj);
|
|
|
|
EVAS_MEMPOOL(_mp_cb);
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* public funcs */
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_data_set(Evas_Object *obj, void *data)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2008-04-30 22:48:03 -07:00
|
|
|
o->data = data;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void *
|
2008-02-08 14:35:19 -08:00
|
|
|
evas_object_smart_data_get(const Evas_Object *obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
2011-07-29 04:44:03 -07:00
|
|
|
if (!o) return NULL;
|
2008-04-30 22:48:03 -07:00
|
|
|
return o->data;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Smart *
|
2008-02-08 14:35:19 -08:00
|
|
|
evas_object_smart_smart_get(const Evas_Object *obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return obj->smart.smart;
|
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_member_add(Evas_Object *obj, Evas_Object *smart_obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
MAGIC_CHECK(smart_obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(smart_obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2006-07-30 07:30:24 -07:00
|
|
|
if (obj->delete_me)
|
|
|
|
{
|
2009-10-22 08:22:22 -07:00
|
|
|
CRIT("Adding deleted object %p to smart obj %p", obj, smart_obj);
|
2011-05-07 01:01:42 -07:00
|
|
|
abort();
|
|
|
|
return;
|
2006-07-30 07:30:24 -07:00
|
|
|
}
|
|
|
|
if (smart_obj->delete_me)
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
CRIT("Adding object %p to deleted smart obj %p", obj, smart_obj);
|
|
|
|
abort();
|
|
|
|
return;
|
2006-07-30 07:30:24 -07:00
|
|
|
}
|
2009-10-07 05:47:01 -07:00
|
|
|
if (!smart_obj->layer)
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
CRIT("No evas surface associated with smart object (%p)", smart_obj);
|
|
|
|
abort();
|
|
|
|
return;
|
2009-10-07 05:47:01 -07:00
|
|
|
}
|
2009-03-17 10:45:37 -07:00
|
|
|
if (obj->layer && smart_obj->layer
|
2009-03-17 10:56:06 -07:00
|
|
|
&& obj->layer->evas != smart_obj->layer->evas)
|
2009-03-17 10:45:37 -07:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
CRIT("Adding object %p from Evas (%p) from another Evas (%p)", obj, obj->layer->evas, smart_obj->layer->evas);
|
|
|
|
abort();
|
|
|
|
return;
|
2009-03-17 10:45:37 -07:00
|
|
|
}
|
|
|
|
|
2006-07-30 07:30:24 -07:00
|
|
|
if (obj->smart.parent == smart_obj) return;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
if (obj->smart.parent) evas_object_smart_member_del(obj);
|
2009-03-17 10:45:37 -07:00
|
|
|
|
2005-10-26 19:44:36 -07:00
|
|
|
evas_object_release(obj, 1);
|
|
|
|
obj->layer = smart_obj->layer;
|
|
|
|
obj->cur.layer = obj->layer->layer;
|
2005-11-08 03:59:21 -08:00
|
|
|
obj->layer->usage++;
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->smart.parent = smart_obj;
|
2008-10-17 04:23:18 -07:00
|
|
|
o->contained = eina_inlist_append(o->contained, EINA_INLIST_GET(obj));
|
2005-07-22 03:28:11 -07:00
|
|
|
evas_object_smart_member_cache_invalidate(obj);
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->restack = 1;
|
|
|
|
evas_object_change(obj);
|
2010-09-01 14:37:10 -07:00
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
2008-10-24 19:49:19 -07:00
|
|
|
if (smart_obj->smart.smart->smart_class->member_add)
|
|
|
|
smart_obj->smart.smart->smart_class->member_add(smart_obj, obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_member_del(Evas_Object *obj)
|
|
|
|
{
|
2008-04-30 22:48:03 -07:00
|
|
|
Evas_Object_Smart *o;
|
2008-10-24 19:49:19 -07:00
|
|
|
Evas_Object *smart_obj;
|
2008-04-30 22:48:03 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!obj->smart.parent) return;
|
2008-04-30 22:48:03 -07:00
|
|
|
|
2008-10-24 19:49:19 -07:00
|
|
|
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);
|
|
|
|
|
2008-04-30 22:48:03 -07:00
|
|
|
o = (Evas_Object_Smart *)(obj->smart.parent->object_data);
|
2008-10-17 04:23:18 -07:00
|
|
|
o->contained = eina_inlist_remove(o->contained, EINA_INLIST_GET(obj));
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->smart.parent = NULL;
|
2005-07-22 03:28:11 -07:00
|
|
|
evas_object_smart_member_cache_invalidate(obj);
|
2005-11-08 03:59:21 -08:00
|
|
|
obj->layer->usage--;
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->cur.layer = obj->layer->layer;
|
|
|
|
evas_object_inject(obj, obj->layer->evas);
|
|
|
|
obj->restack = 1;
|
|
|
|
evas_object_change(obj);
|
2010-09-01 14:37:10 -07:00
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-08-02 19:14:53 -07:00
|
|
|
EAPI Evas_Object *
|
2008-02-08 14:35:19 -08:00
|
|
|
evas_object_smart_parent_get(const Evas_Object *obj)
|
2006-08-02 19:14:53 -07:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2006-08-02 19:14:53 -07:00
|
|
|
return obj->smart.parent;
|
|
|
|
}
|
|
|
|
|
2010-03-22 18:22:20 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_object_smart_type_check(const Evas_Object *obj, const char *type)
|
|
|
|
{
|
|
|
|
const Evas_Smart_Class *sc;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return EINA_FALSE;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!obj->smart.smart)
|
|
|
|
return EINA_FALSE;
|
|
|
|
sc = obj->smart.smart->smart_class;
|
|
|
|
while (sc)
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
if (!strcmp(sc->name, type))
|
|
|
|
return EINA_TRUE;
|
|
|
|
sc = sc->parent;
|
2010-03-22 18:22:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-03-24 01:43:39 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_object_smart_type_check_ptr(const Evas_Object *obj, const char *type)
|
|
|
|
{
|
|
|
|
const Evas_Smart_Class *sc;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return EINA_FALSE;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!obj->smart.smart)
|
|
|
|
return EINA_FALSE;
|
|
|
|
sc = obj->smart.smart->smart_class;
|
|
|
|
while (sc)
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
if (sc->name == type)
|
|
|
|
return EINA_TRUE;
|
|
|
|
sc = sc->parent;
|
2010-03-24 01:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-21 09:31:05 -07:00
|
|
|
EAPI Eina_List *
|
2008-02-08 14:35:19 -08:00
|
|
|
evas_object_smart_members_get(const Evas_Object *obj)
|
2006-08-02 19:14:53 -07:00
|
|
|
{
|
2008-04-30 22:48:03 -07:00
|
|
|
Evas_Object_Smart *o;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *members;
|
2008-10-17 04:23:18 -07:00
|
|
|
Eina_Inlist *member;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2006-08-02 19:14:53 -07:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2008-04-30 22:48:03 -07:00
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2006-08-02 19:14:53 -07:00
|
|
|
members = NULL;
|
2008-04-30 22:48:03 -07:00
|
|
|
for (member = o->contained; member; member = member->next)
|
2011-05-07 01:01:42 -07:00
|
|
|
members = eina_list_append(members, member);
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2006-08-02 19:14:53 -07:00
|
|
|
return members;
|
|
|
|
}
|
|
|
|
|
2008-10-17 04:23:18 -07:00
|
|
|
const Eina_Inlist *
|
2008-04-30 22:48:03 -07:00
|
|
|
evas_object_smart_members_get_direct(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
2009-12-09 18:26:50 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2008-04-30 22:48:03 -07:00
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
2009-12-09 18:26:50 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2008-04-30 22:48:03 -07:00
|
|
|
return o->contained;
|
|
|
|
}
|
|
|
|
|
2010-10-06 20:54:51 -07:00
|
|
|
void
|
|
|
|
_evas_object_smart_members_all_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
while (o->contained)
|
2011-05-07 01:01:42 -07:00
|
|
|
evas_object_del((Evas_Object *)(o->contained));
|
2010-10-06 20:54:51 -07:00
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Object *
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_add(Evas *e, Evas_Smart *s)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
MAGIC_CHECK(s, Evas_Smart, MAGIC_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2010-04-29 10:35:47 -07:00
|
|
|
obj = evas_object_new(e);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!obj) return NULL;
|
|
|
|
obj->smart.smart = s;
|
2003-10-08 20:05:17 -07:00
|
|
|
obj->type = s->smart_class->name;
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_init(obj);
|
|
|
|
evas_object_inject(obj, e);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_use(s);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
if (s->smart_class->add) s->smart_class->add(obj);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
|
|
|
return obj;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2011-08-17 04:55:29 -07:00
|
|
|
static int
|
|
|
|
_callback_priority_cmp(const void *_a, const void *_b)
|
|
|
|
{
|
|
|
|
const Evas_Smart_Callback *a, *b;
|
|
|
|
a = (const Evas_Smart_Callback *) _a;
|
|
|
|
b = (const Evas_Smart_Callback *) _b;
|
|
|
|
if (a->priority < b->priority)
|
|
|
|
return -1;
|
|
|
|
else if (a->priority == b->priority)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2011-04-12 02:23:57 -07:00
|
|
|
evas_object_smart_callback_add(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data)
|
2011-08-17 04:55:29 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_callback_priority_add(obj, event,
|
|
|
|
EVAS_CALLBACK_PRIORITY_DEFAULT, func, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_object_smart_callback_priority_add(Evas_Object *obj, const char *event, Evas_Callback_Priority priority, Evas_Smart_Cb func, const void *data)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (!event) return;
|
|
|
|
if (!func) return;
|
2010-11-26 02:01:18 -08:00
|
|
|
EVAS_MEMPOOL_INIT(_mp_cb, "evas_smart_callback", Evas_Smart_Callback, 512, );
|
|
|
|
cb = EVAS_MEMPOOL_ALLOC(_mp_cb, Evas_Smart_Callback);
|
|
|
|
if (!cb) return;
|
|
|
|
EVAS_MEMPOOL_PREP(_mp_cb, cb, Evas_Smart_Callback);
|
2008-10-15 07:38:34 -07:00
|
|
|
cb->event = eina_stringshare_add(event);
|
2002-11-08 00:02:15 -08:00
|
|
|
cb->func = func;
|
2003-01-09 20:58:51 -08:00
|
|
|
cb->func_data = (void *)data;
|
2011-08-17 04:55:29 -07:00
|
|
|
cb->priority = priority;
|
|
|
|
o->callbacks = eina_list_sorted_insert(o->callbacks, _callback_priority_cmp,
|
|
|
|
cb);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void *
|
2011-04-12 02:23:57 -07:00
|
|
|
evas_object_smart_callback_del(Evas_Object *obj, const char *event, Evas_Smart_Cb func)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2003-10-17 20:34:00 -07:00
|
|
|
return NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
2003-10-17 20:34:00 -07:00
|
|
|
return NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK_END();
|
2003-10-17 20:34:00 -07:00
|
|
|
if (!event) return NULL;
|
2008-10-21 09:31:05 -07:00
|
|
|
EINA_LIST_FOREACH(o->callbacks, l, cb)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
if ((!strcmp(cb->event, event)) && (cb->func == func))
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
data = cb->func_data;
|
|
|
|
cb->delete_me = 1;
|
|
|
|
o->deletions_waiting = 1;
|
|
|
|
evas_object_smart_callbacks_clear(obj);
|
|
|
|
return data;
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2003-01-09 20:58:51 -08:00
|
|
|
evas_object_smart_callback_call(Evas_Object *obj, const char *event, void *event_info)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evas_Smart_Callback *cb;
|
2009-09-03 20:53:18 -07:00
|
|
|
const char *strshare;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (!event) return;
|
2003-01-19 20:36:17 -08:00
|
|
|
if (obj->delete_me) return;
|
2008-04-30 22:48:03 -07:00
|
|
|
o->walking_list++;
|
2009-09-03 20:53:18 -07:00
|
|
|
strshare = eina_stringshare_add(event);
|
2008-10-21 09:31:05 -07:00
|
|
|
EINA_LIST_FOREACH(o->callbacks, l, cb)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
if (!cb->delete_me)
|
|
|
|
{
|
|
|
|
if (cb->event == strshare)
|
|
|
|
cb->func(cb->func_data, obj, event_info);
|
|
|
|
}
|
|
|
|
if (obj->delete_me)
|
|
|
|
break;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2009-09-03 20:53:18 -07:00
|
|
|
eina_stringshare_del(strshare);
|
2008-04-30 22:48:03 -07:00
|
|
|
o->walking_list--;
|
2003-01-19 20:36:17 -08:00
|
|
|
evas_object_smart_callbacks_clear(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2010-01-11 06:24:41 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_object_smart_callbacks_descriptions_set(Evas_Object *obj, const Evas_Smart_Cb_Description *descriptions)
|
|
|
|
{
|
|
|
|
const Evas_Smart_Cb_Description *d;
|
|
|
|
Evas_Object_Smart *o;
|
2010-03-01 18:25:33 -08:00
|
|
|
unsigned int i, count = 0;
|
2010-01-11 06:24:41 -08:00
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2011-07-28 23:49:25 -07:00
|
|
|
return EINA_FALSE;
|
2010-01-11 06:24:41 -08:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
2011-07-28 23:49:25 -07:00
|
|
|
return EINA_FALSE;
|
2010-01-11 06:24:41 -08:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if ((!descriptions) || (!descriptions->name))
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
evas_smart_cb_descriptions_resize(&o->callbacks_descriptions, 0);
|
2011-07-28 23:49:25 -07:00
|
|
|
return EINA_TRUE;
|
2010-01-11 06:24:41 -08:00
|
|
|
}
|
|
|
|
|
2010-08-21 06:52:25 -07:00
|
|
|
for (count = 0, d = descriptions; d->name; d++)
|
2010-01-11 06:24:41 -08:00
|
|
|
count++;
|
|
|
|
|
|
|
|
evas_smart_cb_descriptions_resize(&o->callbacks_descriptions, count);
|
2011-07-28 23:49:25 -07:00
|
|
|
if (count == 0) return EINA_TRUE;
|
2010-04-01 08:56:06 -07:00
|
|
|
|
2010-01-11 06:24:41 -08:00
|
|
|
for (i = 0, d = descriptions; i < count; d++, i++)
|
|
|
|
o->callbacks_descriptions.array[i] = d;
|
|
|
|
|
|
|
|
evas_smart_cb_descriptions_fix(&o->callbacks_descriptions);
|
|
|
|
|
2011-07-28 23:49:25 -07:00
|
|
|
return EINA_TRUE;
|
2010-01-11 06:24:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_object_smart_callbacks_descriptions_get(const Evas_Object *obj, const Evas_Smart_Cb_Description ***class_descriptions, unsigned int *class_count, const Evas_Smart_Cb_Description ***instance_descriptions, unsigned int *instance_count)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
if (class_descriptions) *class_descriptions = NULL;
|
|
|
|
if (class_count) *class_count = 0;
|
|
|
|
if (instance_descriptions) *instance_descriptions = NULL;
|
|
|
|
if (instance_count) *instance_count = 0;
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
if (class_descriptions) *class_descriptions = NULL;
|
|
|
|
if (class_count) *class_count = 0;
|
|
|
|
if (instance_descriptions) *instance_descriptions = NULL;
|
|
|
|
if (instance_count) *instance_count = 0;
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (class_descriptions)
|
|
|
|
*class_descriptions = obj->smart.smart->callbacks.array;
|
|
|
|
if (class_count)
|
|
|
|
*class_count = obj->smart.smart->callbacks.size;
|
|
|
|
|
|
|
|
if (instance_descriptions)
|
|
|
|
*instance_descriptions = o->callbacks_descriptions.array;
|
|
|
|
if (instance_count)
|
|
|
|
*instance_count = o->callbacks_descriptions.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_object_smart_callback_description_find(const Evas_Object *obj, const char *name, const Evas_Smart_Cb_Description **class_description, const Evas_Smart_Cb_Description **instance_description)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
if (class_description) *class_description = NULL;
|
|
|
|
if (instance_description) *instance_description = NULL;
|
|
|
|
return;
|
2010-01-11 06:24:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
if (class_description) *class_description = NULL;
|
|
|
|
if (instance_description) *instance_description = NULL;
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
if (class_description) *class_description = NULL;
|
|
|
|
if (instance_description) *instance_description = NULL;
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (class_description)
|
|
|
|
*class_description = evas_smart_cb_description_find
|
2011-05-07 01:01:42 -07:00
|
|
|
(&obj->smart.smart->callbacks, name);
|
2010-01-11 06:24:41 -08:00
|
|
|
|
|
|
|
if (instance_description)
|
|
|
|
*instance_description = evas_smart_cb_description_find
|
2011-05-07 01:01:42 -07:00
|
|
|
(&o->callbacks_descriptions, name);
|
2010-01-11 06:24:41 -08:00
|
|
|
}
|
|
|
|
|
2008-09-06 18:25:49 -07:00
|
|
|
EAPI void
|
2009-06-17 03:01:52 -07:00
|
|
|
evas_object_smart_need_recalculate_set(Evas_Object *obj, Eina_Bool value)
|
2008-09-06 18:25:49 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = obj->object_data;
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
value = !!value;
|
|
|
|
if (o->need_recalculate == value)
|
|
|
|
return;
|
2011-07-20 02:14:41 -07:00
|
|
|
|
|
|
|
if (obj->recalculate_cycle > 64)
|
|
|
|
{
|
|
|
|
ERR("Object %p is not stable during recalc loop", obj);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
if (obj->layer->evas->in_smart_calc)
|
|
|
|
obj->recalculate_cycle++;
|
2008-09-06 18:25:49 -07:00
|
|
|
o->need_recalculate = value;
|
|
|
|
|
2011-02-22 04:12:37 -08:00
|
|
|
if (!obj->smart.smart->smart_class->calculate) return;
|
2008-09-06 18:25:49 -07:00
|
|
|
|
|
|
|
/* XXX: objects can be present multiple times in calculate_objects()
|
|
|
|
* XXX: after a set-unset-set cycle, but it's not a problem since
|
|
|
|
* XXX: on _evas_render_call_smart_calculate() will check for the flag
|
|
|
|
* XXX: and it will be unset after the first.
|
|
|
|
*/
|
|
|
|
if (o->need_recalculate)
|
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
Evas *e = obj->layer->evas;
|
|
|
|
eina_array_push(&e->calculate_objects, obj);
|
2008-09-06 18:25:49 -07:00
|
|
|
}
|
|
|
|
/* TODO: else, remove from array */
|
|
|
|
}
|
|
|
|
|
2009-06-17 03:01:52 -07:00
|
|
|
EAPI Eina_Bool
|
2008-10-31 10:42:47 -07:00
|
|
|
evas_object_smart_need_recalculate_get(const Evas_Object *obj)
|
2008-09-06 18:25:49 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2011-07-28 23:49:25 -07:00
|
|
|
return EINA_FALSE;
|
2008-09-06 18:25:49 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = obj->object_data;
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
2011-07-28 23:49:25 -07:00
|
|
|
return EINA_FALSE;
|
2008-09-06 18:25:49 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
return o->need_recalculate;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_object_smart_calculate(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2008-10-24 19:49:19 -07:00
|
|
|
return;
|
2008-09-06 18:25:49 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = obj->object_data;
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
2008-10-24 19:49:19 -07:00
|
|
|
return;
|
2008-09-06 18:25:49 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2008-12-11 13:55:22 -08:00
|
|
|
if (!obj->smart.smart->smart_class->calculate)
|
|
|
|
return;
|
|
|
|
|
2011-07-07 08:24:16 -07:00
|
|
|
o->need_recalculate = 0;
|
2011-07-20 02:20:53 -07:00
|
|
|
obj->smart.smart->smart_class->calculate(obj);
|
2008-09-06 18:25:49 -07:00
|
|
|
}
|
|
|
|
|
2009-10-08 07:28:21 -07:00
|
|
|
EAPI void
|
|
|
|
evas_smart_objects_calculate(Evas *e)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
2009-10-08 21:31:13 -07:00
|
|
|
return;
|
2009-10-08 07:28:21 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
evas_call_smarts_calculate(e);
|
|
|
|
}
|
|
|
|
|
2008-09-06 18:25:49 -07:00
|
|
|
/**
|
|
|
|
* Call calculate() on all smart objects that need_recalculate.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
evas_call_smarts_calculate(Evas *e)
|
|
|
|
{
|
2008-10-16 05:27:07 -07:00
|
|
|
Eina_Array *calculate;
|
2011-07-20 02:14:41 -07:00
|
|
|
Evas_Object *obj;
|
|
|
|
Eina_Array_Iterator it;
|
2008-09-06 18:25:49 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
2011-07-20 02:14:41 -07:00
|
|
|
e->in_smart_calc++;
|
2008-09-06 18:25:49 -07:00
|
|
|
calculate = &e->calculate_objects;
|
2011-07-20 04:22:01 -07:00
|
|
|
for (i = 0; i < eina_array_count_get(calculate); ++i)
|
2008-09-06 18:25:49 -07:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
Evas_Object_Smart *o;
|
2008-09-06 18:25:49 -07:00
|
|
|
|
2011-07-28 23:49:25 -07:00
|
|
|
obj = eina_array_data_get(calculate, i);
|
2011-05-07 01:01:42 -07:00
|
|
|
if (obj->delete_me)
|
|
|
|
continue;
|
2008-09-06 18:25:49 -07:00
|
|
|
|
2011-05-07 01:01:42 -07:00
|
|
|
o = obj->object_data;
|
|
|
|
if (o->need_recalculate)
|
|
|
|
{
|
2011-07-07 08:24:16 -07:00
|
|
|
o->need_recalculate = 0;
|
2011-07-20 02:14:41 -07:00
|
|
|
obj->smart.smart->smart_class->calculate(obj);
|
2011-05-07 01:01:42 -07:00
|
|
|
}
|
2008-09-06 18:25:49 -07:00
|
|
|
}
|
2011-07-20 02:14:41 -07:00
|
|
|
EINA_ARRAY_ITER_NEXT(calculate, i, obj, it)
|
|
|
|
{
|
|
|
|
obj->recalculate_cycle = 0;
|
|
|
|
}
|
|
|
|
e->in_smart_calc--;
|
|
|
|
if (e->in_smart_calc == 0) eina_array_clean(calculate);
|
2008-09-06 18:25:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_object_smart_changed(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
evas_object_change(obj);
|
|
|
|
evas_object_smart_need_recalculate_set(obj, 1);
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* internal calls */
|
2003-01-19 20:36:17 -08:00
|
|
|
static void
|
|
|
|
evas_object_smart_callbacks_clear(Evas_Object *obj)
|
|
|
|
{
|
2008-04-30 22:48:03 -07:00
|
|
|
Evas_Object_Smart *o;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-04-30 22:48:03 -07:00
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
|
|
|
|
if (o->walking_list) return;
|
|
|
|
if (!o->deletions_waiting) return;
|
|
|
|
for (l = o->callbacks; l;)
|
2003-01-19 20:36:17 -08:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
cb = eina_list_data_get(l);
|
|
|
|
l = eina_list_next(l);
|
|
|
|
if (cb->delete_me)
|
|
|
|
{
|
|
|
|
o->callbacks = eina_list_remove(o->callbacks, cb);
|
|
|
|
if (cb->event) eina_stringshare_del(cb->event);
|
2010-11-26 02:01:18 -08:00
|
|
|
EVAS_MEMPOOL_FREE(_mp_cb, cb);
|
2011-05-07 01:01:42 -07:00
|
|
|
}
|
2003-01-19 20:36:17 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
void
|
|
|
|
evas_object_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Smart *s;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-10-15 05:15:36 -07:00
|
|
|
if (obj->delete_me) return;
|
2011-07-28 23:49:25 -07:00
|
|
|
s = obj->smart.smart;
|
2003-10-08 20:05:17 -07:00
|
|
|
if ((s) && (s->smart_class->del)) s->smart_class->del(obj);
|
2003-01-09 21:38:47 -08:00
|
|
|
if (obj->smart.parent) evas_object_smart_member_del(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (s) evas_object_smart_unuse(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_smart_cleanup(Evas_Object *obj)
|
|
|
|
{
|
2008-04-30 22:48:03 -07:00
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-04-26 19:35:48 -07:00
|
|
|
if (obj->smart.parent)
|
|
|
|
evas_object_smart_member_del(obj);
|
2008-04-30 22:48:03 -07:00
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
if (o->magic == MAGIC_OBJ_SMART)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
while (o->contained)
|
|
|
|
evas_object_smart_member_del((Evas_Object *)o->contained);
|
2008-04-30 22:48:03 -07:00
|
|
|
|
2011-05-07 01:01:42 -07:00
|
|
|
while (o->callbacks)
|
|
|
|
{
|
|
|
|
Evas_Smart_Callback *cb;
|
2008-04-30 22:48:03 -07:00
|
|
|
|
2011-05-07 01:01:42 -07:00
|
|
|
cb = o->callbacks->data;
|
|
|
|
o->callbacks = eina_list_remove(o->callbacks, cb);
|
|
|
|
if (cb->event) eina_stringshare_del(cb->event);
|
2010-11-26 02:01:18 -08:00
|
|
|
EVAS_MEMPOOL_FREE(_mp_cb, cb);
|
2011-05-07 01:01:42 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-05-07 01:01:42 -07:00
|
|
|
evas_smart_cb_descriptions_resize(&o->callbacks_descriptions, 0);
|
|
|
|
o->data = NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2008-04-30 22:48:03 -07:00
|
|
|
|
2003-10-17 20:34:00 -07:00
|
|
|
obj->smart.parent = NULL;
|
2003-01-19 19:54:00 -08:00
|
|
|
obj->smart.smart = NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2005-07-22 03:28:11 -07:00
|
|
|
void
|
|
|
|
evas_object_smart_member_cache_invalidate(Evas_Object *obj)
|
|
|
|
{
|
2008-04-30 22:48:03 -07:00
|
|
|
Evas_Object_Smart *o;
|
2008-10-17 04:23:18 -07:00
|
|
|
Eina_Inlist *l;
|
2008-04-30 22:48:03 -07:00
|
|
|
|
2011-05-06 03:55:24 -07:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2011-05-06 04:04:32 -07:00
|
|
|
return;
|
2011-05-06 03:55:24 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2011-05-06 04:04:32 -07:00
|
|
|
obj->parent_cache_valid = 0;
|
|
|
|
|
2008-04-30 22:48:03 -07:00
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
if (o->magic != MAGIC_OBJ_SMART)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (l = o->contained; l; l = l->next)
|
2005-07-22 03:28:11 -07:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
Evas_Object *obj2;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2011-05-07 01:01:42 -07:00
|
|
|
obj2 = (Evas_Object *)l;
|
|
|
|
evas_object_smart_member_cache_invalidate(obj2);
|
2005-07-22 03:28:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-30 22:48:03 -07:00
|
|
|
void
|
|
|
|
evas_object_smart_member_raise(Evas_Object *member)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(member->smart.parent->object_data);
|
2008-10-17 04:23:18 -07:00
|
|
|
o->contained = eina_inlist_demote(o->contained, EINA_INLIST_GET(member));
|
2008-04-30 22:48:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_smart_member_lower(Evas_Object *member)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(member->smart.parent->object_data);
|
2008-10-17 04:23:18 -07:00
|
|
|
o->contained = eina_inlist_promote(o->contained, EINA_INLIST_GET(member));
|
2008-04-30 22:48:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_smart_member_stack_above(Evas_Object *member, Evas_Object *other)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(member->smart.parent->object_data);
|
2008-10-17 04:23:18 -07:00
|
|
|
o->contained = eina_inlist_remove(o->contained, EINA_INLIST_GET(member));
|
|
|
|
o->contained = eina_inlist_append_relative(o->contained, EINA_INLIST_GET(member), EINA_INLIST_GET(other));
|
2008-04-30 22:48:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_smart_member_stack_below(Evas_Object *member, Evas_Object *other)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(member->smart.parent->object_data);
|
2008-10-17 04:23:18 -07:00
|
|
|
o->contained = eina_inlist_remove(o->contained, EINA_INLIST_GET(member));
|
|
|
|
o->contained = eina_inlist_prepend_relative(o->contained, EINA_INLIST_GET(member), EINA_INLIST_GET(other));
|
2008-04-30 22:48:03 -07:00
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* all nice and private */
|
|
|
|
static void
|
|
|
|
evas_object_smart_init(Evas_Object *obj)
|
|
|
|
{
|
2006-12-07 23:51:48 -08:00
|
|
|
/* alloc smart obj, setup methods and default values */
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->object_data = evas_object_smart_new();
|
|
|
|
/* set up default settings for this kind of object */
|
|
|
|
obj->cur.color.r = 255;
|
|
|
|
obj->cur.color.g = 255;
|
|
|
|
obj->cur.color.b = 255;
|
|
|
|
obj->cur.color.a = 255;
|
2007-10-04 21:52:10 -07:00
|
|
|
obj->cur.geometry.x = 0;
|
|
|
|
obj->cur.geometry.y = 0;
|
|
|
|
obj->cur.geometry.w = 0;
|
|
|
|
obj->cur.geometry.h = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->cur.layer = 0;
|
|
|
|
/* set up object-specific settings */
|
|
|
|
obj->prev = obj->cur;
|
|
|
|
/* set up methods (compulsory) */
|
|
|
|
obj->func = &object_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
evas_object_smart_new(void)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* alloc obj private data */
|
2010-11-26 02:01:18 -08:00
|
|
|
EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_smart", Evas_Object_Smart, 256, NULL);
|
|
|
|
o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Smart);
|
|
|
|
if (!o) return NULL;
|
|
|
|
EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Smart);
|
2002-11-08 00:02:15 -08:00
|
|
|
o->magic = MAGIC_OBJ_SMART;
|
|
|
|
return o;
|
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
static void
|
|
|
|
evas_object_smart_free(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* frees private object data. very simple here */
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
/* free obj */
|
|
|
|
o->magic = 0;
|
2010-11-26 02:01:18 -08:00
|
|
|
EVAS_MEMPOOL_FREE(_mp_obj, o);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2005-05-21 19:49:50 -07:00
|
|
|
static void
|
2009-02-24 00:31:31 -08:00
|
|
|
evas_object_smart_render(Evas_Object *obj __UNUSED__, void *output __UNUSED__, void *context __UNUSED__, void *surface __UNUSED__, int x __UNUSED__, int y __UNUSED__)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2003-10-17 20:34:00 -07:00
|
|
|
return;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_render_pre(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
if (obj->pre_render_done) return;
|
2009-11-09 07:18:37 -08:00
|
|
|
if ((obj->cur.map != obj->prev.map) ||
|
|
|
|
(obj->cur.usemap != obj->prev.usemap))
|
2009-11-06 00:44:49 -08:00
|
|
|
{
|
2011-05-07 01:01:42 -07:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, obj);
|
2009-11-06 00:44:49 -08:00
|
|
|
goto done;
|
|
|
|
}
|
2011-05-07 01:01:42 -07:00
|
|
|
done:
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->pre_render_done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_render_post(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
obj->prev = obj->cur;
|
|
|
|
}
|
2008-08-25 22:45:04 -07:00
|
|
|
|
2008-08-30 19:04:31 -07:00
|
|
|
static unsigned int evas_object_smart_id_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
if (!o) return 0;
|
|
|
|
return MAGIC_OBJ_SMART;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int evas_object_smart_visual_id_get(Evas_Object *obj)
|
2008-08-25 22:45:04 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
if (!o) return 0;
|
|
|
|
return MAGIC_OBJ_CONTAINER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *evas_object_smart_engine_data_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
if (!o) return NULL;
|
|
|
|
return o->engine_data;
|
|
|
|
}
|