Elementary els_scroller: Added mirrored_set and mirroring support.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 8 Feb 2011 12:08:24 +0000 (12:08 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 8 Feb 2011 12:08:24 +0000 (12:08 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@56802 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/els_scroller.c
src/lib/els_scroller.h

index 4d85ff2..bf173c1 100644 (file)
@@ -104,6 +104,7 @@ struct _Smart_Data
    unsigned char bounce_vert : 1;
    unsigned char momentum_animator_disabled :1;
    unsigned char bounce_animator_disabled :1;
+   Eina_Bool is_mirrored : 1;
 };
 
 /* local subsystem functions */
@@ -152,6 +153,36 @@ elm_smart_scroller_add(Evas *evas)
    return evas_object_smart_add(evas, _smart);
 }
 
+static Evas_Coord
+_elm_smart_scroller_x_mirrored_get(Evas_Object *obj, Evas_Coord x)
+{
+   API_ENTRY return x;
+
+   Evas_Coord cw, ch, w;
+   elm_smart_scroller_child_viewport_size_get(obj, &w, NULL);
+   sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch);
+   return (cw - (x + w));
+}
+
+void
+elm_smart_scroller_mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
+{
+   API_ENTRY return;
+   Evas_Coord px, py, wx;
+   if (sd->is_mirrored == mirrored)
+     return;
+
+   sd->is_mirrored = mirrored;
+   edje_object_mirrored_set(sd->edje_obj, mirrored);
+
+   if (sd->is_mirrored)
+     wx = _elm_smart_scroller_x_mirrored_get(sd->smart_obj, sd->wx);
+   else
+     wx = sd->wx;
+
+   elm_smart_scroller_child_pos_set(sd->smart_obj, wx, sd->y);
+}
+
 void
 elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child)
 {
@@ -166,7 +197,9 @@ elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child)
      }
 
    sd->child_obj = child;
-   sd->wx = sd->wy = sd->ww = sd->wh = 0;
+   sd->wx = sd->wy = 0;
+   /* (-1) means want viewports size */
+   sd->ww = sd->wh = -1;
    if (!child) return;
 
    if (!sd->pan_obj)
@@ -1801,6 +1834,10 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
              elm_smart_scroller_child_pos_set(sd->smart_obj, x, y);
              sd->wx = x;
              sd->wy = y;
+
+             if(sd->is_mirrored)
+               sd->wx = _elm_smart_scroller_x_mirrored_get(sd->smart_obj, sd->wx);
+
              elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &sd->ww, &sd->wh);
              if (!_smart_do_page(sd))
                bounce_eval(sd);
@@ -2523,10 +2560,26 @@ static void
 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
 {
    INTERNAL_ENTRY;
+   Evas_Coord ww, wh, wx = sd->wx;
    sd->w = w;
    sd->h = h;
    _smart_reconfigure(sd);
-   elm_smart_scroller_child_region_set(obj, sd->wx, sd->wy, sd->ww, sd->h);
+
+   /* Flip to RTL cords only if init in RTL mode */
+   if(sd->is_mirrored)
+     wx = _elm_smart_scroller_x_mirrored_get(obj, sd->wx);
+
+   if (sd->ww == -1)
+     {
+        elm_smart_scroller_child_viewport_size_get(obj, &ww, &wh);
+     }
+   else
+     {
+        ww = sd->ww;
+        wh = sd->wh;
+     }
+
+   elm_smart_scroller_child_region_set(obj, wx, sd->wy, ww, wh);
 }
 
 static void
index 4fe85fc..1c77179 100644 (file)
@@ -25,6 +25,7 @@ Evas_Object *elm_smart_scroller_edje_object_get (Evas_Object *obj);
 void elm_smart_scroller_single_dir_set          (Evas_Object *obj, Eina_Bool single_dir);
 Eina_Bool elm_smart_scroller_single_dir_get     (Evas_Object *obj);
 void elm_smart_scroller_object_theme_set        (Evas_Object *parent, Evas_Object *obj, const char *clas, const char *group, const char *style);
+void elm_smart_scroller_mirrored_set            (Evas_Object *obj, Eina_Bool mirrored);
 void elm_smart_scroller_hold_set                (Evas_Object *obj, Eina_Bool hold);
 void elm_smart_scroller_freeze_set              (Evas_Object *obj, Eina_Bool freeze);
 void elm_smart_scroller_bounce_allow_set        (Evas_Object *obj, Eina_Bool horiz, Eina_Bool vert);