add elm_mapbuf_auto_set/get()

This commit is contained in:
Carsten Haitzler 2013-04-09 21:01:42 +09:00
parent f1da69d77a
commit 06756cd71d
5 changed files with 153 additions and 1 deletions

View File

@ -1225,3 +1225,8 @@
2013-04-09 Daniel Juyung Seo (SeoZ)
* Fix elc_player crash issue.
2013-04-09 Carsten Haitzler (The Rasterman)
* Add elm_mapbuf_auto_set()/elm_mapbuf_auto_get()

View File

@ -58,6 +58,7 @@ Additions:
* Add the repeat_events_set/get for blocking the events of content objects.
* Add convenient macros - elm_object_translatable_part_text_set(), elm_object_item_translatable_part_text_set().
* Add the API elm_scroller_page_scroll_limit_set/get.
* Add elm_mapbuf_auto_set/get.
Improvements:

View File

@ -134,6 +134,22 @@ _configure(Evas_Object *obj, Eina_Bool update_force)
}
}
static void
_mapbuf_auto_eval(Evas_Object *obj)
{
Eina_Bool vis;
Evas_Coord x, y, w, h;
Evas_Coord vx, vy, vw, vh;
Eina_Bool on = EINA_FALSE;
vis = evas_object_visible_get(obj);
evas_object_geometry_get(obj, &x, &y, &w, &h);
evas_output_viewport_get(obj, &vx, &vy, &vw, &vh);
if ((vis) && (ELM_RECTS_INTERSECT(x, y, w, h, vx, vy, vw, vh)))
on = EINA_TRUE;
elm_mapbuf_enabled_set(obj, on);
}
static void
_elm_mapbuf_smart_move(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
@ -141,6 +157,7 @@ _elm_mapbuf_smart_move(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
Evas_Coord y = va_arg(*list, Evas_Coord);
eo_do_super(obj, MY_CLASS, evas_obj_smart_move(x, y));
_mapbuf_auto_eval(obj);
_configure(obj, EINA_FALSE);
}
@ -151,6 +168,25 @@ _elm_mapbuf_smart_resize(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
Evas_Coord h = va_arg(*list, Evas_Coord);
eo_do_super(obj, MY_CLASS, evas_obj_smart_resize(w, h));
_mapbuf_auto_eval(obj);
_configure(obj, EINA_FALSE);
}
static void
_elm_mapbuf_smart_show(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_do_super(obj, MY_CLASS, evas_obj_smart_show());
_mapbuf_auto_eval(obj);
_configure(obj, EINA_FALSE);
}
static void
_elm_mapbuf_smart_hide(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
{
eo_do_super(obj, MY_CLASS, evas_obj_smart_hide());
_mapbuf_auto_eval(obj);
_configure(obj, EINA_FALSE);
}
@ -379,6 +415,50 @@ _alpha_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
*ret = sd->alpha;
}
EAPI void
elm_mapbuf_auto_set(Evas_Object *obj,
Eina_Bool on)
{
ELM_MAPBUF_CHECK(obj);
eo_do(obj, elm_obj_mapbuf_auto_set(on));
}
static void
_auto_set(Eo *obj, void *_pd, va_list *list)
{
Eina_Bool on = va_arg(*list, int);
Elm_Mapbuf_Smart_Data *sd = _pd;
if (sd->automode == on) return;
sd->automode = on;
if (on)
{
_mapbuf_auto_eval(obj);
}
else
{
_enabled_set(obj, _pd, EINA_FALSE);
}
_configure(obj, EINA_TRUE);
}
EAPI Eina_Bool
elm_mapbuf_auto_get(const Evas_Object *obj)
{
ELM_MAPBUF_CHECK(obj) EINA_FALSE;
Eina_Bool ret = EINA_FALSE;
eo_do((Eo *) obj, elm_obj_mapbuf_auto_get(&ret));
return ret;
}
static void
_auto_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Elm_Mapbuf_Smart_Data *sd = _pd;
*ret = sd->automode;
}
static void
_class_constructor(Eo_Class *klass)
{
@ -388,6 +468,8 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_mapbuf_smart_add),
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_RESIZE), _elm_mapbuf_smart_resize),
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_MOVE), _elm_mapbuf_smart_move),
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_mapbuf_smart_show),
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_HIDE), _elm_mapbuf_smart_hide),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_mapbuf_smart_theme),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_SUB_OBJECT_DEL), _elm_mapbuf_smart_sub_object_del),
@ -402,6 +484,8 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_SMOOTH_GET), _smooth_get),
EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_SET), _alpha_set),
EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET), _alpha_get),
EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET), _auto_set),
EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET), _auto_get),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
@ -415,6 +499,8 @@ static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_SMOOTH_GET, "Get a value whether smooth map rendering is enabled or not."),
EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_SET, "Set or unset alpha flag for map rendering."),
EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET, "Get a value whether alpha blending is enabled or not."),
EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET, "Turn map on or off automatically based on object visibility."),
EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET, "Get automatic mode state."),
EO_OP_DESCRIPTION_SENTINEL
};
static const Eo_Class_Description class_desc = {

View File

@ -45,6 +45,8 @@ enum
ELM_OBJ_MAPBUF_SUB_ID_SMOOTH_GET,
ELM_OBJ_MAPBUF_SUB_ID_ALPHA_SET,
ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET,
ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET,
ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET,
ELM_OBJ_MAPBUF_SUB_ID_LAST
};
@ -122,6 +124,30 @@ enum
* @see elm_mapbuf_alpha_get
*/
#define elm_obj_mapbuf_alpha_get(ret) ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET), EO_TYPECHECK(Eina_Bool *, ret)
/**
* @def elm_obj_mapbuf_auto_set
* @since 1.8
*
* Set or unset automatic flag for map rendering.
*
* @param[in] on
*
* @see elm_mapbuf_auto_set
*/
#define elm_obj_mapbuf_auto_set(on) ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET), EO_TYPECHECK(Eina_Bool, on)
/**
* @def elm_obj_mapbuf_auto_get
* @since 1.8
*
* Get a value automatic map mode is enabled ore not.
*
* @param[out] ret
*
* @see elm_mapbuf_auto_get
*/
#define elm_obj_mapbuf_auto_get(ret) ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET), EO_TYPECHECK(Eina_Bool *, ret)
/**
* @addtogroup Mapbuf
* @{
@ -240,6 +266,40 @@ EAPI void elm_mapbuf_alpha_set(Evas_Object *obj, Eina_Bo
*/
EAPI Eina_Bool elm_mapbuf_alpha_get(const Evas_Object *obj);
/**
* Set or unset auto flag for map rendering.
*
* @param obj The mapbuf object.
* @param on @c EINA_TRUE to enable auto mode or @c EINA_FALSE
* to disable it.
*
* When a ampbuf object has "auto mode" enabled, then it will enable and
* disable map mode based on current visibility. Mapbuf will track if you show
* or hide it AND if the object is inside the canvas viewport or not when it
* is moved or resized. Note that if you turn automode off, then map mode
* will be in a disabled state at this point. When you turn it on for the
* first time, the current state will be evaluated base on current properties
* of the mapbuf object.
*
* Auto mode is disabled by default.
*
* @ingroup Mapbuf
*/
EAPI void elm_mapbuf_auto_set(Evas_Object *obj, Eina_Bool on);
/**
* Get a value whether auto mode is enabled or not.
*
* @param obj The mapbuf object.
* @return @c EINA_TRUE means autso mode is enabled. @c EINA_FALSE
* indicates it's disabled. If @p obj is @c NULL, @c EINA_FALSE is returned.
*
* @see elm_mapbuf_auto_set() for details.
*
* @ingroup Mapbuf
*/
EAPI Eina_Bool elm_mapbuf_auto_get(const Evas_Object *obj);
/**
* @}
*/

View File

@ -25,7 +25,7 @@ struct _Elm_Mapbuf_Smart_Data
Eina_Bool enabled : 1;
Eina_Bool smooth : 1;
Eina_Bool alpha : 1;
Eina_Bool outside : 1;
Eina_Bool automode : 1;
};
/**