Change the parameter of the elm_toolbar_item_show/bring_in. Add the scroll type.
authorJaehwan Kim <jae.hwan.kim.neo@gmail.com>
Thu, 15 Nov 2012 10:27:46 +0000 (10:27 +0000)
committerJaehwan Kim <jae.hwan.kim.neo@gmail.com>
Thu, 15 Nov 2012 10:27:46 +0000 (10:27 +0000)
SVN revision: 79333

src/lib/elm_toolbar.c
src/lib/elm_toolbar.h

index 3864ca5..0fd97dc 100644 (file)
@@ -267,6 +267,59 @@ _items_size_fit(Evas_Object *obj, Evas_Coord *bl, Evas_Coord view)
    if (sumf != 0) *bl = (Evas_Coord)(((sumf + sumb) * view) / sumf);
 }
 
+static Eina_Bool
+_elm_toolbar_item_coordinates_calc(Elm_Object_Item *item,
+                                   Elm_Toolbar_Item_Scrollto_Type type,
+                                   Evas_Coord *x,
+                                   Evas_Coord *y,
+                                   Evas_Coord *w,
+                                   Evas_Coord *h)
+{
+   Evas_Coord ix, iy, iw, ih, bx, by, vw, vh;
+
+   ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
+
+   sd->s_iface->content_viewport_size_get(WIDGET(item), &vw, &vh);
+   evas_object_geometry_get(sd->bx, &bx, &by, NULL, NULL);
+   evas_object_geometry_get(VIEW(item), &ix, &iy, &iw, &ih);
+
+   switch (type)
+     {
+      case ELM_TOOLBAR_ITEM_SCROLLTO_IN:
+         *x = ix - bx;
+         *y = iy - by;
+         *w = iw;
+         *h = ih;
+         break;
+
+      case ELM_TOOLBAR_ITEM_SCROLLTO_FIRST:
+         *x = ix - bx;
+         *y = iy - by;
+         *w = vw;
+         *h = vh;
+         break;
+
+      case ELM_TOOLBAR_ITEM_SCROLLTO_MIDDLE:
+         *x = ix - bx + (iw / 2) - (vw / 2);
+         *y = iy - by + (ih / 2) - (vh / 2);
+         *w = vw;
+         *h = vh;
+         break;
+
+      case ELM_TOOLBAR_ITEM_SCROLLTO_LAST:
+         *x = ix - bx + iw - vw;
+         *y = iy - by + ih - vh;
+         *w = vw;
+         *h = vh;
+         break;
+
+      default:
+         return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
+
 static void
 _resize_job(void *data)
 {
@@ -3290,33 +3343,27 @@ elm_toolbar_reorder_mode_get(const Evas_Object *obj)
 }
 
 EAPI void
-elm_toolbar_item_show(Elm_Object_Item *it)
+elm_toolbar_item_show(Elm_Object_Item *it, Elm_Toolbar_Item_Scrollto_Type type)
 {
-   Evas_Coord x, y, w, h, bx, by;
+   Evas_Coord x, y, w, h;
    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
 
    ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
    ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
 
-   evas_object_geometry_get(sd->bx, &bx, &by, NULL, NULL);
-   evas_object_geometry_get(VIEW(item), &x, &y, &w, &h);
-   x = x - bx;
-   y = y - by;
-   sd->s_iface->content_region_show(WIDGET(item), x, y, w, h);
+   if (_elm_toolbar_item_coordinates_calc(it, type, &x, &y, &w, &h))
+     sd->s_iface->content_region_show(WIDGET(item), x, y, w, h);
 }
 
 EAPI void
-elm_toolbar_item_bring_in(Elm_Object_Item *it)
+elm_toolbar_item_bring_in(Elm_Object_Item *it, Elm_Toolbar_Item_Scrollto_Type type)
 {
-   Evas_Coord x, y, w, h, bx, by;
+   Evas_Coord x, y, w, h;
    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
 
    ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
    ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
 
-   evas_object_geometry_get(sd->bx, &bx, &by, NULL, NULL);
-   evas_object_geometry_get(VIEW(item), &x, &y, &w, &h);
-   x = x - bx;
-   y = y - by;
-   sd->s_iface->region_bring_in(WIDGET(item), x, y, w, h);
+   if (_elm_toolbar_item_coordinates_calc(it, type, &x, &y, &w, &h))
+     sd->s_iface->region_bring_in(WIDGET(item), x, y, w, h);
 }
index 040ba70..b0a855e 100644 (file)
@@ -81,6 +81,20 @@ typedef enum
    ELM_TOOLBAR_SHRINK_LAST /**< Indicates error if returned by elm_toolbar_shrink_mode_get() */
 } Elm_Toolbar_Shrink_Mode;
 
+/**
+ * Defines where to position the item in the toolbar.
+ *
+ * @ingroup Toolbar
+ */
+typedef enum
+{
+   ELM_TOOLBAR_ITEM_SCROLLTO_NONE = 0,   /**< no scrollto */
+   ELM_TOOLBAR_ITEM_SCROLLTO_IN = (1 << 0),   /**< to the nearest viewport */
+   ELM_TOOLBAR_ITEM_SCROLLTO_FIRST = (1 << 1),   /**< to the first of viewport */
+   ELM_TOOLBAR_ITEM_SCROLLTO_MIDDLE = (1 << 2),   /**< to the middle of viewport */
+   ELM_TOOLBAR_ITEM_SCROLLTO_LAST = (1 << 3)   /**< to the last of viewport */
+} Elm_Toolbar_Item_Scrollto_Type;
+
 typedef struct _Elm_Toolbar_Item_State Elm_Toolbar_Item_State;    /**< State of a Elm_Toolbar_Item. Can be created with elm_toolbar_item_state_add() and removed with elm_toolbar_item_state_del(). */
 
 /**
@@ -1007,7 +1021,7 @@ EAPI Eina_Bool                     elm_toolbar_reorder_mode_get(const Evas_Objec
  * @since 1.8
  * @ingroup Toolbar
  */
-EAPI void                          elm_toolbar_item_show(Elm_Object_Item *it);
+EAPI void                          elm_toolbar_item_show(Elm_Object_Item *it, Elm_Toolbar_Item_Scrollto_Type type);
 
 /**
  * Show a specific item with scroll animation, when the toolbar can be scrolled.
@@ -1019,7 +1033,7 @@ EAPI void                          elm_toolbar_item_show(Elm_Object_Item *it);
  * @since 1.8
  * @ingroup Toolbar
  */
-EAPI void                          elm_toolbar_item_bring_in(Elm_Object_Item *it);
+EAPI void                          elm_toolbar_item_bring_in(Elm_Object_Item *it, Elm_Toolbar_Item_Scrollto_Type type);
 
 /**
  * @}