raster pushed a commit to branch master.

commit 7b62f6a6e1454f89a9518c0373a267efa74bbf36
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Tue Apr 9 21:01:42 2013 +0900

    add elm_mapbuf_auto_set/get()
---
 ChangeLog                   |  5 +++
 NEWS                        |  1 +
 src/lib/elm_mapbuf.c        | 86 +++++++++++++++++++++++++++++++++++++++++++++
 src/lib/elm_mapbuf.h        | 60 +++++++++++++++++++++++++++++++
 src/lib/elm_widget_mapbuf.h |  2 +-
 5 files changed, 153 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 8684204..5359943 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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()
+
diff --git a/NEWS b/NEWS
index 49b677f..927165e 100644
--- a/NEWS
+++ b/NEWS
@@ -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:
 
diff --git a/src/lib/elm_mapbuf.c b/src/lib/elm_mapbuf.c
index 3a6157d..a4ad557 100644
--- a/src/lib/elm_mapbuf.c
+++ b/src/lib/elm_mapbuf.c
@@ -135,12 +135,29 @@ _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)
 {
    Evas_Coord x = va_arg(*list, Evas_Coord);
    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 = {
diff --git a/src/lib/elm_mapbuf.h b/src/lib/elm_mapbuf.h
index 7eb63a9..6975831 100644
--- a/src/lib/elm_mapbuf.h
+++ b/src/lib/elm_mapbuf.h
@@ -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
  * @{
@@ -241,5 +267,39 @@ 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);
+
+/**
  * @}
  */
diff --git a/src/lib/elm_widget_mapbuf.h b/src/lib/elm_widget_mapbuf.h
index fdc7ae8..49b0301 100644
--- a/src/lib/elm_widget_mapbuf.h
+++ b/src/lib/elm_widget_mapbuf.h
@@ -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;
 };
 
 /**

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to