* Add interceptors for color_set(), clip_set() and clip_unset()

SVN revision: 31460
This commit is contained in:
moom 2007-08-22 16:45:37 +00:00 committed by moom
parent ffb74463b2
commit c9264664d9
5 changed files with 206 additions and 1 deletions

View File

@ -801,6 +801,12 @@ extern "C" {
EAPI void *evas_object_intercept_stack_below_callback_del (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Evas_Object *below));
EAPI void evas_object_intercept_layer_set_callback_add (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, int l), const void *data);
EAPI void *evas_object_intercept_layer_set_callback_del (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, int l));
EAPI void evas_object_intercept_color_set_callback_add (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, int r, int g, int b, int a), const void *data);
EAPI void *evas_object_intercept_color_set_callback_del (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, int r, int g, int b, int a));
EAPI void evas_object_intercept_clip_set_callback_add (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Evas_Object *clip), const void *data);
EAPI void *evas_object_intercept_clip_set_callback_del (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Evas_Object *clip));
EAPI void evas_object_intercept_clip_unset_callback_add (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), const void *data);
EAPI void *evas_object_intercept_clip_unset_callback_del (Evas_Object *obj, void (*func) (void *data, Evas_Object *obj));
/* Evas utility routines for color space conversions */
/* hsv color space has h in the range 0.0 to 360.0, and s,v in the range 0.0 to 1.0 */

View File

@ -171,6 +171,7 @@ evas_object_clip_set(Evas_Object *obj, Evas_Object *clip)
MAGIC_CHECK_END();
if (obj->cur.clipper == clip) return;
if (obj == clip) return;
if (evas_object_intercept_call_clip_set(obj, clip)) return;
if (obj->smart.smart)
{
if (obj->smart.smart->smart_class->clip_set)
@ -280,6 +281,7 @@ evas_object_clip_unset(Evas_Object *obj)
MAGIC_CHECK_END();
if (!obj->cur.clipper) return;
/* unclip */
if (evas_object_intercept_call_clip_unset(obj)) return;
if (obj->smart.smart)
{
if (obj->smart.smart->smart_class->clip_unset)

View File

@ -27,7 +27,10 @@ evas_object_intercept_deinit(Evas_Object *obj)
(obj->interceptors->lower.func) ||
(obj->interceptors->stack_above.func) ||
(obj->interceptors->stack_below.func) ||
(obj->interceptors->layer_set.func))
(obj->interceptors->layer_set.func) ||
(obj->interceptors->color_set.func) ||
(obj->interceptors->clip_set.func) ||
(obj->interceptors->clip_unset.func))
return;
free(obj->interceptors);
obj->interceptors = NULL;
@ -186,6 +189,54 @@ evas_object_intercept_call_layer_set(Evas_Object *obj, int l)
return ret;
}
int
evas_object_intercept_call_color_set(Evas_Object *obj, int r, int g, int b, int a)
{
/* MEM OK */
int ret;
if (!obj->interceptors) return 0;
if (obj->intercepted) return 0;
obj->intercepted = 1;
ret = (int)obj->interceptors->color_set.func;
if (obj->interceptors->color_set.func)
obj->interceptors->color_set.func(obj->interceptors->color_set.data, obj, r, g, b, a);
obj->intercepted = 0;
return ret;
}
int
evas_object_intercept_call_clip_set(Evas_Object *obj, Evas_Object *clip)
{
/* MEM OK */
int ret;
if (!obj->interceptors) return 0;
if (obj->intercepted) return 0;
obj->intercepted = 1;
ret = (int)obj->interceptors->clip_set.func;
if (obj->interceptors->clip_set.func)
obj->interceptors->clip_set.func(obj->interceptors->clip_set.data, obj, clip);
obj->intercepted = 0;
return ret;
}
int
evas_object_intercept_call_clip_unset(Evas_Object *obj)
{
/* MEM OK */
int ret;
if (!obj->interceptors) return 0;
if (obj->intercepted) return 0;
obj->intercepted = 1;
ret = (int)obj->interceptors->clip_unset.func;
if (obj->interceptors->clip_unset.func)
obj->interceptors->clip_unset.func(obj->interceptors->clip_unset.data, obj);
obj->intercepted = 0;
return ret;
}
/* public calls */
/**
@ -584,3 +635,135 @@ evas_object_intercept_layer_set_callback_del(Evas_Object *obj, void (*func) (voi
evas_object_intercept_deinit(obj);
return data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
*
*/
EAPI void
evas_object_intercept_color_set_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, int r, int g, int b, int a), const void *data)
{
/* MEM OK */
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (!func) return;
evas_object_intercept_init(obj);
if (!obj->interceptors) return;
obj->interceptors->color_set.func = func;
obj->interceptors->color_set.data = (void *)data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
*
*/
EAPI void *
evas_object_intercept_color_set_callback_del(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, int r, int g, int b, int a))
{
/* MEM OK */
void *data;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return NULL;
MAGIC_CHECK_END();
if (!func) return NULL;
if (!obj->interceptors) return NULL;
obj->interceptors->color_set.func = NULL;
data = obj->interceptors->color_set.data;
obj->interceptors->color_set.data = NULL;
evas_object_intercept_deinit(obj);
return data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
*
*/
EAPI void
evas_object_intercept_clip_set_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Evas_Object *clip), const void *data)
{
/* MEM OK */
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (!func) return;
evas_object_intercept_init(obj);
if (!obj->interceptors) return;
obj->interceptors->clip_set.func = func;
obj->interceptors->clip_set.data = (void *)data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
*
*/
EAPI void *
evas_object_intercept_clip_set_callback_del(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, Evas_Object *clip))
{
/* MEM OK */
void *data;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return NULL;
MAGIC_CHECK_END();
if (!func) return NULL;
if (!obj->interceptors) return NULL;
obj->interceptors->clip_set.func = NULL;
data = obj->interceptors->clip_set.data;
obj->interceptors->clip_set.data = NULL;
evas_object_intercept_deinit(obj);
return data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
*
*/
EAPI void
evas_object_intercept_clip_unset_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), const void *data)
{
/* MEM OK */
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (!func) return;
evas_object_intercept_init(obj);
if (!obj->interceptors) return;
obj->interceptors->clip_unset.func = func;
obj->interceptors->clip_unset.data = (void *)data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
*
*/
EAPI void *
evas_object_intercept_clip_unset_callback_del(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj))
{
/* MEM OK */
void *data;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return NULL;
MAGIC_CHECK_END();
if (!func) return NULL;
if (!obj->interceptors) return NULL;
obj->interceptors->clip_unset.func = NULL;
data = obj->interceptors->clip_unset.data;
obj->interceptors->clip_unset.data = NULL;
evas_object_intercept_deinit(obj);
return data;
}

View File

@ -845,6 +845,7 @@ evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a)
if (g > 255) g = 255; if (g < 0) g = 0;
if (b > 255) b = 255; if (b < 0) b = 0;
if (a > 255) a = 255; if (a < 0) a = 0;
if (evas_object_intercept_call_color_set(obj, r, g, b, a)) return;
if (obj->smart.smart)
{
if (obj->smart.smart->smart_class->color_set)

View File

@ -96,6 +96,7 @@ typedef struct _Evas_Intercept_Func_Basic Evas_Intercept_Func_Basic;
typedef struct _Evas_Intercept_Func_SizePos Evas_Intercept_Func_SizePos;
typedef struct _Evas_Intercept_Func_Obj Evas_Intercept_Func_Obj;
typedef struct _Evas_Intercept_Func_Int Evas_Intercept_Func_Int;
typedef struct _Evas_Intercept_Func_Color Evas_Intercept_Func_Color;
typedef struct _Evas_Key_Grab Evas_Key_Grab;
typedef struct _Evas_Callbacks Evas_Callbacks;
typedef struct _Evas_Format Evas_Format;
@ -190,6 +191,12 @@ struct _Evas_Intercept_Func_Int
void *data;
};
struct _Evas_Intercept_Func_Color
{
void (*func) (void *data, Evas_Object *obj, int r, int g, int b, int a);
void *data;
};
struct _Evas_Key_Grab
{
char *keyname;
@ -212,6 +219,9 @@ struct _Evas_Intercept_Func
Evas_Intercept_Func_Obj stack_above;
Evas_Intercept_Func_Obj stack_below;
Evas_Intercept_Func_Int layer_set;
Evas_Intercept_Func_Color color_set;
Evas_Intercept_Func_Obj clip_set;
Evas_Intercept_Func_Basic clip_unset;
};
struct _Evas_Smart
@ -729,6 +739,9 @@ int evas_object_intercept_call_lower(Evas_Object *obj);
int evas_object_intercept_call_stack_above(Evas_Object *obj, Evas_Object *above);
int evas_object_intercept_call_stack_below(Evas_Object *obj, Evas_Object *below);
int evas_object_intercept_call_layer_set(Evas_Object *obj, int l);
int evas_object_intercept_call_color_set(Evas_Object *obj, int r, int g, int b, int a);
int evas_object_intercept_call_clip_set(Evas_Object *obj, Evas_Object *clip);
int evas_object_intercept_call_clip_unset(Evas_Object *obj);
void evas_object_grabs_cleanup(Evas_Object *obj);
void evas_key_grab_free(Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers);
void evas_font_dir_cache_free(void);