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
|
|
|
|
2011-03-21 08:18:26 -07:00
|
|
|
if (obj->cur.cache.clip.dirty) return ;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-08-31 15:16:08 -07:00
|
|
|
/* aaaaargh (pirate voice) ... notes!
|
|
|
|
*
|
|
|
|
* we have a big problem until now that's gone undetected... until yesterday.
|
|
|
|
* that problem involves clips and maps and smart objects. hooray! 3 of the
|
|
|
|
* more complex bits of evas - and maps and smart objects being one of the
|
|
|
|
* nastiest ones.
|
|
|
|
*
|
|
|
|
* what is the problem? when a clip crosses a map boundary. that is to say
|
|
|
|
* that when the clipper and clippee are not within the child tree of the
|
|
|
|
* mapped object. in this case "bad stuff" happens. basically as clips are
|
|
|
|
* then used to render objects, but they no longer apply as you'd expect as
|
|
|
|
* the map transfomr the objects to-be-clipped separately from the objects
|
|
|
|
* that clip them and this whole relationship is broken by maps. it somehow
|
|
|
|
* managed to not break with the advent of smart objects. lucky me... but
|
|
|
|
* maps killed it. now... what do we do? that is a good question. detect
|
|
|
|
* such a broken link and "turn off clipping" in that event - sure. but this
|
|
|
|
* isn't going to be cheap as ANY addition or deletion of a map to an object
|
|
|
|
* or any change in clipper of an object or any change in smart object
|
|
|
|
* membership needs to walk the obj tree both up and down from the changed
|
|
|
|
* object and probably walk entire object trees to find these and mark them.
|
|
|
|
* thats silly-expensive and i was about to fix it that way but it has since
|
|
|
|
* dawned on me that that is just going to kill performance in some critical
|
|
|
|
* areas like during object setup and manipulation, as well as teardown.
|
|
|
|
*
|
|
|
|
* aaaaagh! best for now is to document this as a "don't do it damnit!" thing
|
|
|
|
* and have the apps avoid it. but even then - how to do this? this is not
|
|
|
|
* easy. everywhere i turn so far i come up to either expensive operations,
|
|
|
|
* breaks in logic, or nasty re-work of apps or4 the whole concept of clipping,
|
|
|
|
* smart objects and maps... and that will have to wait for evas 2.0
|
|
|
|
*
|
2010-09-01 14:38:34 -07:00
|
|
|
* the below does clip fixups etc. in the even a clip spans a map boundary.
|
|
|
|
* not pretty, but necessary.
|
2010-08-31 15:16:08 -07:00
|
|
|
*/
|
|
|
|
|
2010-09-01 14:37:10 -07:00
|
|
|
#define MAP_ACROSS 1
|
2010-08-31 15:16:08 -07:00
|
|
|
static void
|
2010-09-01 14:37:10 -07:00
|
|
|
evas_object_child_map_across_mark(Evas_Object *obj, Evas_Object *map_obj, Eina_Bool force)
|
2010-08-31 15:16:08 -07:00
|
|
|
{
|
2010-09-01 14:37:10 -07:00
|
|
|
#ifdef MAP_ACROSS
|
|
|
|
if ((obj->cur.map_parent != map_obj) || force)
|
2010-08-31 15:16:08 -07:00
|
|
|
{
|
2010-09-01 14:37:10 -07:00
|
|
|
obj->cur.map_parent = map_obj;
|
|
|
|
obj->cur.cache.clip.dirty = 1;
|
|
|
|
evas_object_clip_recalc(obj);
|
|
|
|
if (obj->smart.smart)
|
|
|
|
{
|
|
|
|
Evas_Object *obj2;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
|
|
|
|
{
|
|
|
|
// if obj has its own map - skip it. already done
|
|
|
|
if ((obj2->cur.map) && (obj2->cur.usemap)) continue;
|
|
|
|
evas_object_child_map_across_mark(obj2, map_obj, force);
|
|
|
|
}
|
|
|
|
}
|
2010-09-02 02:40:23 -07:00
|
|
|
else if (obj->clip.clipees)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *obj2;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(obj->clip.clipees, l, obj2)
|
|
|
|
evas_object_child_map_across_mark(obj2, map_obj, force);
|
|
|
|
}
|
2010-08-31 15:16:08 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-09-02 02:40:23 -07:00
|
|
|
void
|
2010-09-01 14:37:10 -07:00
|
|
|
evas_object_clip_across_check(Evas_Object *obj)
|
|
|
|
{
|
2010-09-02 02:40:23 -07:00
|
|
|
#ifdef MAP_ACROSS
|
2010-09-01 14:37:10 -07:00
|
|
|
if (!obj->cur.clipper) return;
|
|
|
|
if (obj->cur.clipper->cur.map_parent != obj->cur.map_parent)
|
|
|
|
evas_object_child_map_across_mark(obj, obj->cur.map_parent, 1);
|
2010-09-02 02:40:23 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_clip_across_clippees_check(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
#ifdef MAP_ACROSS
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *obj2;
|
|
|
|
|
|
|
|
if (!obj->clip.clipees) return;
|
2010-09-03 01:23:38 -07:00
|
|
|
// schloooooooooooow:
|
|
|
|
// evas_object_child_map_across_mark(obj, obj->cur.map_parent, 1);
|
|
|
|
// buggy:
|
|
|
|
evas_object_child_map_across_mark(obj, obj->cur.map_parent, 0);
|
2010-09-02 02:40:23 -07:00
|
|
|
if (obj->cur.cache.clip.dirty)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(obj->clip.clipees, l, obj2)
|
|
|
|
evas_object_clip_across_clippees_check(obj2);
|
|
|
|
}
|
|
|
|
#endif
|
2010-09-01 14:37:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function is called on an object when map is enabled or disabled on it
|
|
|
|
// thus creating a "map boundary" at that point.
|
2010-09-01 15:51:00 -07:00
|
|
|
//
|
|
|
|
// FIXME: flip2 test broken in elm - might be show/hide of clips
|
2010-08-31 15:16:08 -07:00
|
|
|
void
|
|
|
|
evas_object_mapped_clip_across_mark(Evas_Object *obj)
|
|
|
|
{
|
2010-09-01 14:37:10 -07:00
|
|
|
#ifdef MAP_ACROSS
|
2010-09-01 15:45:30 -07:00
|
|
|
if ((obj->cur.map) && (obj->cur.usemap))
|
|
|
|
evas_object_child_map_across_mark(obj, obj, 0);
|
2010-08-31 15:16:08 -07:00
|
|
|
else
|
2010-09-01 14:37:10 -07:00
|
|
|
{
|
|
|
|
if (obj->smart.parent)
|
|
|
|
evas_object_child_map_across_mark
|
|
|
|
(obj, obj->smart.parent->cur.map_parent, 0);
|
|
|
|
else
|
|
|
|
evas_object_child_map_across_mark(obj, NULL, 0);
|
|
|
|
}
|
2010-08-31 15:16:08 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* public functions */
|
|
|
|
|
2008-11-01 14:50:36 -07: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;
|
2011-04-05 22:38:38 -07:00
|
|
|
|
|
|
|
/* If it's NOT a rectangle set the mask bits too */
|
|
|
|
/* FIXME: Optmz ths chck */
|
|
|
|
if (strcmp(evas_object_type_get(clip),"rectangle") == 0)
|
|
|
|
obj->cur.mask = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
void *engdata;
|
|
|
|
obj->cur.mask = clip;
|
|
|
|
engdata = clip->func->engine_data_get(clip);
|
|
|
|
/* FIXME: Images only */
|
|
|
|
clip->layer->evas->engine.func->image_mask_create(
|
|
|
|
clip->layer->evas->engine.data.output,
|
|
|
|
engdata);
|
|
|
|
}
|
2005-11-01 20:03:55 -08:00
|
|
|
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);
|
2010-09-01 15:45:30 -07:00
|
|
|
if ((!obj->smart.smart) &&
|
|
|
|
(!((obj->cur.map) && (obj->cur.usemap))))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
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
|
|
|
}
|
2010-09-01 14:37:10 -07:00
|
|
|
evas_object_clip_across_check(obj);
|
2002-11-08 00:02:15 -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;
|
|
|
|
}
|
|
|
|
|
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);
|
2010-09-01 15:45:30 -07:00
|
|
|
if ((!obj->smart.smart) &&
|
|
|
|
(!((obj->cur.map) && (obj->cur.usemap))))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
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
|
|
|
}
|
2010-09-01 14:37:10 -07:00
|
|
|
evas_object_clip_across_check(obj);
|
2002-11-08 00:02:15 -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;
|
|
|
|
}
|