2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
|
|
|
void
|
2005-04-03 07:22:17 -07:00
|
|
|
evas_object_clip_dirty(Evas_Object *obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-04-03 07:22:17 -07:00
|
|
|
obj->cur.cache.clip.dirty = 1;
|
2008-10-21 09:31:05 -07:00
|
|
|
EINA_LIST_FOREACH(obj->clip.clipees, l, data)
|
|
|
|
evas_object_clip_dirty(data);
|
2005-04-03 07:22:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_recalc_clippees(Evas_Object *obj)
|
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-07-30 02:52:53 -07:00
|
|
|
if (obj->cur.cache.clip.dirty)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-07-30 02:52:53 -07:00
|
|
|
evas_object_clip_recalc(obj);
|
2008-10-21 09:31:05 -07:00
|
|
|
EINA_LIST_FOREACH(obj->clip.clipees, l, data)
|
|
|
|
evas_object_recalc_clippees(data);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_object_clippers_was_visible(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
if (obj->prev.visible)
|
|
|
|
{
|
|
|
|
if (obj->prev.clipper)
|
|
|
|
return evas_object_clippers_is_visible(obj->prev.clipper);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2004-08-15 22:13:25 -07:00
|
|
|
/**
|
2010-03-17 21:57:40 -07:00
|
|
|
* @addtogroup Evas_Object_Group_Basic
|
2008-11-01 14:50:36 -07:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2002-12-09 15:00:10 -08:00
|
|
|
/**
|
2003-03-04 18:30:20 -08:00
|
|
|
* Clip one object to another.
|
2002-12-09 15:00:10 -08:00
|
|
|
* @param obj The object to be clipped
|
|
|
|
* @param clip The object to clip @p obj by
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-12-09 15:00:10 -08:00
|
|
|
* This function will clip the object @p obj to the area occupied by the
|
2003-10-17 20:34:00 -07:00
|
|
|
* object @p clipper. This means the object @p obj will only be visible within
|
|
|
|
* the area occupied by the clipping object (@p clip). The color of the object
|
|
|
|
* being clipped will be multiplied by the color of the clipping object, so
|
|
|
|
* the resulting color for the clipped object is
|
|
|
|
* RESULT = (OBJ * CLIP) / (255 * 255) per color element (red, green, blue and
|
|
|
|
* alpha). Clipping is recursive, so clip objects may be clipped by other
|
|
|
|
* objects, and their color will in tern be multiplied. You may NOT set up
|
2004-02-16 11:22:48 -08:00
|
|
|
* circular clipping lists (i.e. object 1 clips object 2 which clips object 1).
|
2003-10-17 20:34:00 -07:00
|
|
|
* The behavior of Evas is undefined in this case. Objects which do not clip
|
|
|
|
* others are visible as normal, those that clip 1 or more objects become
|
|
|
|
* invisible themselves, only affecting what they clip. If an object ceases to
|
|
|
|
* have other objects being clipped by it, it will become visible again. The
|
|
|
|
* visibility of an object affects the objects that are clipped by it, so if
|
2004-02-16 11:22:48 -08:00
|
|
|
* the object clipping others is not shown, the objects clipped will not be
|
2003-10-17 20:34:00 -07:00
|
|
|
* shown either. If the object was being clipped by another object when this
|
|
|
|
* function is called, it is implicitly removed from the clipper it is being
|
|
|
|
* clipped to, and now is made to clip its new clipper.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* At the moment the only objects that can validly be used to clip other
|
2004-02-16 11:22:48 -08:00
|
|
|
* objects are rectangle objects. All other object types are invalid and the
|
|
|
|
* result of using them is undefined.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* The clip object @p clip must be a valid object, but may also be NULL in
|
|
|
|
* which case the effect of this function is the same as calling
|
|
|
|
* evas_object_clip_unset() on the @p obj object.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-12-09 15:00:10 -08:00
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas *evas;
|
|
|
|
* extern Evas_Object *obj;
|
|
|
|
* Evas_Object *clipper;
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-12-09 15:00:10 -08:00
|
|
|
* clipper = evas_object_rectangle_add(evas);
|
2004-02-16 11:22:48 -08:00
|
|
|
* evas_object_color_set(clipper, 255, 255, 255, 255);
|
2002-12-09 15:00:10 -08:00
|
|
|
* evas_object_move(clipper, 10, 10);
|
|
|
|
* evas_object_resize(clipper, 20, 50);
|
|
|
|
* evas_object_clip_set(obj, clipper);
|
|
|
|
* evas_object_show(clipper);
|
|
|
|
* @endcode
|
2004-08-15 22:13:25 -07:00
|
|
|
*
|
2002-12-09 15:00:10 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_clip_set(Evas_Object *obj, Evas_Object *clip)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-05-21 19:49:50 -07:00
|
|
|
if (!clip)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
evas_object_clip_unset(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MAGIC_CHECK(clip, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (obj->cur.clipper == clip) return;
|
2007-04-12 04:17:40 -07:00
|
|
|
if (obj == clip) return;
|
2007-08-22 09:45:37 -07:00
|
|
|
if (evas_object_intercept_call_clip_set(obj, clip)) return;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (obj->smart.smart)
|
|
|
|
{
|
2003-10-08 20:05:17 -07:00
|
|
|
if (obj->smart.smart->smart_class->clip_set)
|
|
|
|
obj->smart.smart->smart_class->clip_set(obj, clip);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
if (obj->cur.clipper)
|
|
|
|
{
|
|
|
|
/* unclip */
|
2008-10-21 09:31:05 -07:00
|
|
|
obj->cur.clipper->clip.clipees = eina_list_remove(obj->cur.clipper->clip.clipees, obj);
|
2010-02-01 11:50:01 -08:00
|
|
|
if (!obj->cur.clipper->clip.clipees)
|
|
|
|
{
|
|
|
|
obj->cur.clipper->cur.have_clipees = 0;
|
|
|
|
if (obj->cur.clipper->cur.visible)
|
|
|
|
evas_damage_rectangle_add(obj->cur.clipper->layer->evas,
|
|
|
|
obj->cur.clipper->cur.geometry.x,
|
|
|
|
obj->cur.clipper->cur.geometry.y,
|
|
|
|
obj->cur.clipper->cur.geometry.w,
|
|
|
|
obj->cur.clipper->cur.geometry.h);
|
|
|
|
}
|
2005-11-01 20:03:55 -08:00
|
|
|
evas_object_change(obj->cur.clipper);
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_change(obj);
|
2005-05-21 19:49:50 -07:00
|
|
|
obj->cur.clipper = NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
/* clip me */
|
2010-08-21 06:52:25 -07:00
|
|
|
if ((!clip->clip.clipees) && (clip->cur.visible))
|
2004-09-21 21:37:51 -07:00
|
|
|
{
|
2005-01-19 22:54:45 -08:00
|
|
|
/* Basically it just went invisible */
|
|
|
|
clip->changed = 1;
|
|
|
|
clip->layer->evas->changed = 1;
|
|
|
|
evas_damage_rectangle_add(clip->layer->evas,
|
|
|
|
clip->cur.geometry.x, clip->cur.geometry.y,
|
|
|
|
clip->cur.geometry.w, clip->cur.geometry.h);
|
2004-09-21 21:37:51 -07:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->cur.clipper = clip;
|
2008-10-21 09:31:05 -07:00
|
|
|
clip->clip.clipees = eina_list_append(clip->clip.clipees, obj);
|
2005-11-01 20:03:55 -08:00
|
|
|
if (clip->clip.clipees) clip->cur.have_clipees = 1;
|
|
|
|
evas_object_change(clip);
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_change(obj);
|
2005-04-03 07:22:17 -07:00
|
|
|
evas_object_clip_dirty(obj);
|
2005-07-30 02:52:53 -07:00
|
|
|
evas_object_recalc_clippees(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!obj->smart.smart)
|
|
|
|
{
|
2005-05-21 19:49:50 -07:00
|
|
|
if (evas_object_is_in_output_rect(obj,
|
|
|
|
obj->layer->evas->pointer.x,
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->layer->evas->pointer.y, 1, 1))
|
2004-12-13 19:21:32 -08:00
|
|
|
evas_event_feed_mouse_move(obj->layer->evas,
|
2005-05-21 19:49:50 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
2004-12-13 19:21:32 -08:00
|
|
|
obj->layer->evas->pointer.y,
|
2005-07-25 02:55:47 -07:00
|
|
|
obj->layer->evas->last_timestamp,
|
2004-12-13 19:21:32 -08:00
|
|
|
NULL);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2003-10-17 20:34:00 -07:00
|
|
|
* Get the object clipping this one (if any).
|
|
|
|
* @param obj The object to get the clipper from
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2004-02-16 11:22:48 -08:00
|
|
|
* This function returns the the object clipping @p obj. If @p obj not being
|
2003-10-17 20:34:00 -07:00
|
|
|
* clipped, NULL is returned. The object @p obj must be a valid object.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2004-02-16 11:22:48 -08:00
|
|
|
* See also evas_object_clip_set(), evas_object_clip_unset() and
|
2003-10-17 20:34:00 -07:00
|
|
|
* evas_object_clipees_get().
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas_Object *obj;
|
|
|
|
* Evas_Object *clipper;
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* clipper = evas_object_clip_get(obj);
|
|
|
|
* if (clipper) evas_object_show(clipper);
|
|
|
|
* @endcode
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Object *
|
2008-02-08 14:35:19 -08:00
|
|
|
evas_object_clip_get(const Evas_Object *obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return obj->cur.clipper;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2003-10-17 20:34:00 -07:00
|
|
|
* Disable clipping for an object.
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* @param obj The object to cease clipping on
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* This function disables clipping for the object @p obj, if it was already
|
|
|
|
* clipped. If it wasn't, this has no effect. The object @p obj must be a
|
|
|
|
* valid object.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
|
|
|
* See also evas_object_clip_set(), evas_object_clipees_get() and
|
2003-10-17 20:34:00 -07:00
|
|
|
* evas_object_clip_get().
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas_Object *obj;
|
|
|
|
* Evas_Object *clipper;
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* clipper = evas_object_clip_get(obj);
|
|
|
|
* if (clipper)
|
|
|
|
* {
|
|
|
|
* evas_object_clip_unset(obj);
|
|
|
|
* evas_object_hide(obj);
|
|
|
|
* }
|
|
|
|
* @endcode
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_clip_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (!obj->cur.clipper) return;
|
|
|
|
/* unclip */
|
2007-08-22 09:45:37 -07:00
|
|
|
if (evas_object_intercept_call_clip_unset(obj)) return;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (obj->smart.smart)
|
|
|
|
{
|
2003-10-08 20:05:17 -07:00
|
|
|
if (obj->smart.smart->smart_class->clip_unset)
|
|
|
|
obj->smart.smart->smart_class->clip_unset(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2009-09-03 22:13:19 -07:00
|
|
|
if (obj->cur.clipper)
|
2006-09-08 10:59:19 -07:00
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
obj->cur.clipper->clip.clipees = eina_list_remove(obj->cur.clipper->clip.clipees, obj);
|
2009-09-03 22:13:19 -07:00
|
|
|
if (!obj->cur.clipper->clip.clipees)
|
2010-02-01 11:50:01 -08:00
|
|
|
{
|
|
|
|
obj->cur.clipper->cur.have_clipees = 0;
|
|
|
|
if (obj->cur.clipper->cur.visible)
|
|
|
|
evas_damage_rectangle_add(obj->cur.clipper->layer->evas,
|
|
|
|
obj->cur.clipper->cur.geometry.x,
|
|
|
|
obj->cur.clipper->cur.geometry.y,
|
|
|
|
obj->cur.clipper->cur.geometry.w,
|
|
|
|
obj->cur.clipper->cur.geometry.h);
|
|
|
|
}
|
2006-09-08 10:59:19 -07:00
|
|
|
evas_object_change(obj->cur.clipper);
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->cur.clipper = NULL;
|
|
|
|
evas_object_change(obj);
|
2005-04-03 07:22:17 -07:00
|
|
|
evas_object_clip_dirty(obj);
|
2005-07-30 02:52:53 -07:00
|
|
|
evas_object_recalc_clippees(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!obj->smart.smart)
|
|
|
|
{
|
2005-05-21 19:49:50 -07:00
|
|
|
if (evas_object_is_in_output_rect(obj,
|
|
|
|
obj->layer->evas->pointer.x,
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->layer->evas->pointer.y, 1, 1))
|
2005-05-21 19:49:50 -07:00
|
|
|
evas_event_feed_mouse_move(obj->layer->evas,
|
|
|
|
obj->layer->evas->pointer.x,
|
2004-12-13 19:21:32 -08:00
|
|
|
obj->layer->evas->pointer.y,
|
2005-07-25 02:55:47 -07:00
|
|
|
obj->layer->evas->last_timestamp,
|
2004-12-13 19:21:32 -08:00
|
|
|
NULL);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2003-10-17 20:34:00 -07:00
|
|
|
* Return a list of objects currently clipped by a specific object.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* @param obj The object to get a list of clippees from
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* This returns the inernal list handle that contains all objects clipped by
|
|
|
|
* the object @p obj. If none are clipped, it returns NULL. This list is only
|
2004-02-16 11:22:48 -08:00
|
|
|
* valid until the clip list is changed and should be fetched again with another
|
|
|
|
* call to evas_object_clipees_get() if any objects being clipped by this object
|
|
|
|
* are unclipped, clipped by a new object, are deleted or the clipper is
|
|
|
|
* deleted. These operations will invalidate the list returned so it should
|
|
|
|
* not be used anymore after that point. Any use of the list after this may have
|
2003-10-17 20:34:00 -07:00
|
|
|
* undefined results, not limited just to strange behavior but possible
|
2004-02-16 11:22:48 -08:00
|
|
|
* segfaults and other strange memory errors. The object @p obj must be a valid
|
|
|
|
* object.
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2005-05-21 19:49:50 -07:00
|
|
|
* See also evas_object_clip_set(), evas_object_clip_unset() and
|
2003-10-17 20:34:00 -07:00
|
|
|
* evas_object_clip_get().
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas_Object *obj;
|
|
|
|
* Evas_Object *clipper;
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* clipper = evas_object_clip_get(obj);
|
|
|
|
* if (clipper)
|
|
|
|
* {
|
2008-10-21 09:31:05 -07:00
|
|
|
* Eina_List *clippees, *l;
|
|
|
|
* Evas_Object *obj_tmp;
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-10-17 20:34:00 -07:00
|
|
|
* clippees = evas_object_clipees_get(clipper);
|
2008-10-21 09:31:05 -07:00
|
|
|
* printf("Clipper clips %i objects\n", eina_list_count(clippees));
|
|
|
|
* EINA_LIST_FOREACH(clippees, l, obj_tmp)
|
2003-10-17 20:34:00 -07:00
|
|
|
* evas_object_show(obj_tmp);
|
|
|
|
* }
|
|
|
|
* @endcode
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2008-10-21 09:31:05 -07:00
|
|
|
EAPI const Eina_List *
|
2008-02-08 14:35:19 -08:00
|
|
|
evas_object_clipees_get(const Evas_Object *obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return obj->clip.clipees;
|
|
|
|
}
|
2008-11-01 14:50:36 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|