2013-06-20 03:53:29 -07:00
|
|
|
#include "evas_common_private.h"
|
2008-10-01 08:42:48 -07:00
|
|
|
#include "evas_private.h"
|
2008-09-06 19:10:17 -07:00
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
#define MY_CLASS EVAS_SMART_CLIPPED_CLASS
|
2012-10-08 18:58:41 -07:00
|
|
|
|
|
|
|
#define CSO_DATA_GET(eo_obj, ptr) \
|
|
|
|
Evas_Object_Smart_Clipped_Data *ptr = (eo_isa(eo_obj, MY_CLASS) ? \
|
2013-05-02 00:47:16 -07:00
|
|
|
eo_data_scope_get(eo_obj, MY_CLASS) : \
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_data_get(eo_obj));
|
|
|
|
|
|
|
|
#define CSO_DATA_GET_OR_RETURN(eo_obj, ptr) \
|
|
|
|
CSO_DATA_GET(eo_obj, ptr) \
|
2008-09-06 19:10:17 -07:00
|
|
|
if (!ptr) return;
|
|
|
|
|
2014-03-11 04:51:35 -07:00
|
|
|
EOLIAN void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_object_smart_smart_move_children_relative(Eo *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED, Evas_Coord dx, Evas_Coord dy)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2010-10-06 20:54:51 -07:00
|
|
|
const Eina_Inlist *lst;
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Object_Protected_Data *child;
|
2008-09-06 19:10:17 -07:00
|
|
|
|
|
|
|
if ((dx == 0) && (dy == 0))
|
|
|
|
return;
|
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
lst = evas_object_smart_members_get_direct(eo_obj);
|
2010-10-06 20:54:51 -07:00
|
|
|
EINA_INLIST_FOREACH(lst, child)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-05-23 23:48:25 -07:00
|
|
|
Evas_Coord orig_x, orig_y;
|
2008-09-06 19:10:17 -07:00
|
|
|
|
2010-09-02 17:06:56 -07:00
|
|
|
if (child->delete_me) continue;
|
|
|
|
if (child->is_static_clip) continue;
|
2013-04-29 08:50:45 -07:00
|
|
|
orig_x = child->cur->geometry.x;
|
|
|
|
orig_y = child->cur->geometry.y;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_move(child->object, orig_x + dx, orig_y + dy);
|
2008-09-06 19:10:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-16 01:45:29 -07:00
|
|
|
static EOLIAN Evas_Object *
|
2016-06-16 01:50:20 -07:00
|
|
|
_evas_smart_clipped_smart_clipped_clipper_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Smart_Clipped_Data *obj)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2016-06-16 01:45:29 -07:00
|
|
|
return obj->clipper;
|
2008-09-06 19:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_clipped_smart_add(Evas_Object *eo_obj)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2008-10-24 19:49:19 -07:00
|
|
|
Evas_Object *clipper;
|
2008-09-06 19:10:17 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
CSO_DATA_GET(eo_obj, cso)
|
2008-09-06 19:10:17 -07:00
|
|
|
if (!cso)
|
2010-11-26 02:01:18 -08:00
|
|
|
cso = calloc(1, sizeof(*cso)); /* users can provide it or realloc() later */
|
2008-09-06 19:10:17 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
cso->evas = evas_object_evas_get(eo_obj);
|
2008-10-24 19:49:19 -07:00
|
|
|
clipper = evas_object_rectangle_add(cso->evas);
|
2010-09-02 17:06:56 -07:00
|
|
|
evas_object_static_clip_set(clipper, 1);
|
2008-10-24 19:49:19 -07:00
|
|
|
cso->clipper = NULL;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_member_add(clipper, eo_obj);
|
2008-10-24 19:49:19 -07:00
|
|
|
cso->clipper = clipper;
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_color_set(cso->clipper, 255, 255, 255, 255);
|
2009-10-09 12:17:55 -07:00
|
|
|
evas_object_move(cso->clipper, -100000, -100000);
|
|
|
|
evas_object_resize(cso->clipper, 200000, 200000);
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_pass_events_set(cso->clipper, 1);
|
|
|
|
evas_object_hide(cso->clipper); /* show when have something clipped to it */
|
2016-04-05 01:19:55 -07:00
|
|
|
evas_obj_no_render_set(cso->clipper, 1);
|
2008-09-06 19:10:17 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_data_set(eo_obj, cso);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_add(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_add(eo_obj);
|
2008-09-06 19:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_clipped_smart_del(Evas_Object *eo_obj)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2009-09-22 15:37:03 -07:00
|
|
|
|
2008-10-24 19:49:19 -07:00
|
|
|
if (cso->clipper)
|
|
|
|
{
|
2012-05-23 23:48:25 -07:00
|
|
|
Evas_Object *clipper = cso->clipper;
|
|
|
|
cso->clipper = NULL;
|
|
|
|
evas_object_del(clipper);
|
2008-10-24 19:49:19 -07:00
|
|
|
}
|
|
|
|
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_object_smart_smart_members_all_del(eo_obj);
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2013-01-05 04:14:41 -08:00
|
|
|
/* If it's a legacy smart object, we should free the cso. */
|
|
|
|
if (!eo_isa(eo_obj, MY_CLASS))
|
|
|
|
free(cso);
|
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_data_set(eo_obj, NULL);
|
|
|
|
}
|
2008-09-06 19:10:17 -07:00
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_del(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_del(eo_obj);
|
2008-09-06 19:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_clipped_smart_move(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
|
|
|
Evas_Coord orig_x, orig_y;
|
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_geometry_get(eo_obj, &orig_x, &orig_y, NULL, NULL);
|
|
|
|
evas_object_smart_move_children_relative(eo_obj, x - orig_x, y - orig_y);
|
2008-09-06 19:10:17 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_move(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED, Evas_Coord x, Evas_Coord y)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_clipped_smart_move(eo_obj, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_show(Evas_Object *eo_obj)
|
|
|
|
{
|
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2013-04-10 21:21:54 -07:00
|
|
|
if (evas_object_clipees_has(cso->clipper))
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_show(cso->clipper); /* just show if clipper being used */
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_show(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_clipped_smart_show(eo_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_hide(Evas_Object *eo_obj)
|
|
|
|
{
|
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_hide(cso->clipper);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_hide(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_hide(eo_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_color_set(Evas_Object *eo_obj, int r, int g, int b, int a)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_color_set(cso->clipper, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_color_set(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED, int r, int g, int b, int a)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_color_set(eo_obj, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_clip_set(Evas_Object *eo_obj, Evas_Object *clip)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_clip_set(cso->clipper, clip);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_clip_set(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED, Evas_Object *clip)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_clip_set(eo_obj, clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_clip_unset(Evas_Object *eo_obj)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_clip_unset(cso->clipper);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_clip_unset(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_clip_unset(eo_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_member_add(Evas_Object *eo_obj, Evas_Object *member)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2012-08-07 03:44:15 -07:00
|
|
|
if (!cso->clipper || member == cso->clipper)
|
2008-10-24 19:49:19 -07:00
|
|
|
return;
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_clip_set(member, cso->clipper);
|
2012-10-08 18:58:41 -07:00
|
|
|
if (evas_object_visible_get(eo_obj))
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_show(cso->clipper);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_member_add(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED, Evas_Object *member)
|
2008-09-06 19:10:17 -07:00
|
|
|
{
|
2016-03-01 10:06:28 -08:00
|
|
|
evas_obj_smart_member_add(eo_super(eo_obj, MY_CLASS), member);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_clipped_smart_member_add(eo_obj, member);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_clipped_smart_member_del(Evas_Object *eo_obj, Evas_Object *member)
|
|
|
|
{
|
|
|
|
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
|
2008-10-24 19:49:19 -07:00
|
|
|
if (!cso->clipper)
|
|
|
|
return;
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_clip_unset(member);
|
2015-10-14 15:54:41 -07:00
|
|
|
if (!evas_object_clipees_has(cso->clipper))
|
2008-09-06 19:10:17 -07:00
|
|
|
evas_object_hide(cso->clipper);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
EOLIAN static void
|
2016-06-16 22:57:31 -07:00
|
|
|
_evas_smart_clipped_evas_object_smart_smart_member_del(Eo *eo_obj, Evas_Object_Smart_Clipped_Data *obj EINA_UNUSED, Evas_Object *member)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_clipped_smart_member_del(eo_obj, member);
|
2016-03-01 10:06:28 -08:00
|
|
|
evas_obj_smart_member_del(eo_super(eo_obj, MY_CLASS), member);
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2008-09-06 19:10:17 -07:00
|
|
|
EAPI void
|
|
|
|
evas_object_smart_clipped_smart_set(Evas_Smart_Class *sc)
|
|
|
|
{
|
|
|
|
if (!sc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sc->add = evas_object_smart_clipped_smart_add;
|
|
|
|
sc->del = evas_object_smart_clipped_smart_del;
|
|
|
|
sc->move = evas_object_smart_clipped_smart_move;
|
|
|
|
sc->show = evas_object_smart_clipped_smart_show;
|
|
|
|
sc->hide = evas_object_smart_clipped_smart_hide;
|
|
|
|
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;
|
2008-10-27 14:21:53 -07:00
|
|
|
sc->calculate = NULL;
|
2008-10-24 19:49:19 -07:00
|
|
|
sc->member_add = evas_object_smart_clipped_smart_member_add;
|
|
|
|
sc->member_del = evas_object_smart_clipped_smart_member_del;
|
2008-09-06 19:10:17 -07:00
|
|
|
}
|
|
|
|
|
2010-03-22 18:22:20 -07:00
|
|
|
EAPI const Evas_Smart_Class *
|
|
|
|
evas_object_smart_clipped_class_get(void)
|
|
|
|
{
|
|
|
|
static Evas_Smart_Class _sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("EvasObjectSmartClipped");
|
|
|
|
static const Evas_Smart_Class *class = NULL;
|
|
|
|
|
|
|
|
if (class)
|
|
|
|
return class;
|
|
|
|
|
|
|
|
evas_object_smart_clipped_smart_set(&_sc);
|
|
|
|
class = &_sc;
|
|
|
|
return class;
|
|
|
|
}
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2015-05-19 03:41:27 -07:00
|
|
|
EOLIAN static Eo *
|
|
|
|
_evas_smart_clipped_eo_base_constructor(Eo *obj, Evas_Object_Smart_Clipped_Data *class_data EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2016-03-01 10:06:28 -08:00
|
|
|
return eo_constructor(eo_super(obj, MY_CLASS));
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:06:46 -07:00
|
|
|
#include "canvas/evas_smart_clipped.eo.c"
|
2014-03-11 04:51:35 -07:00
|
|
|
|