From: PRINCE KUMAR DUBEY <prince.dubey@samsung.com>
authorPRINCE KUMAR DUBEY <prince.dubey@samsung.com>
Thu, 13 Sep 2012 11:55:24 +0000 (11:55 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Thu, 13 Sep 2012 11:55:24 +0000 (11:55 +0000)
Subject: [E-devel] [Patch] [Elementary] Support for circular effect in
elm_diskselector, in case scroller's bounce effect is disabled.

Can someone please review the attached patch created by Sumanth.

[Issue Details] :
elm_diskselector_round_enable_set() API is not working, if
elm_scroller's bounce effect is disabled.

[Root cause] :
For diskselector circular effect, the boundary checking is done based
on scroller's geometry.
If bouncing effect is disabled in elm_scroller, its geometry can lie
between 0 on left and CHILD_SIZE on right but it can never go beyond
that point.
Unless the scroller's geometry goes beyond its child (here, elm_box)
size, diskselector cann't trigger the circular effect.

[Change Description] :
For diskselector items circular effect, the boundary checking is
performed at the left/right edges of its child, elm_box.
Once the scroller reaches to the left/right edge of box or goes beyond
that point, circular effect will be triggered.

SVN revision: 76606

ChangeLog
NEWS
src/lib/elm_diskselector.c
src/lib/elm_widget_diskselector.h

index 28fccf8..28359e0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-09-12  Davide Andreoli (davemds)
 
        * Add external property "play length" to Video widget, read-only.
+
+2012-09-13  Prince Kumar Dubey
+
+       * Fix diskselector when bounce off and round enabled.
diff --git a/NEWS b/NEWS
index b663cfe..c1fe0b0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,7 +23,8 @@ Fixes:
    * Now elm_datetime_field_limit_set() can set year limits wihtout problems.
    * Fix re-order animation when it doesn't end correctly.
    * Fix popup to apply the same style to the notify sub-widget.
-   * Fix Ctxpopup direction if -1 priority used
+   * Fix Ctxpopup direction if unknown priority used.
+   * Fix diskselector when bounce off and round enabled.
    
 Removals:
 
index 532038d..39c6664 100644 (file)
@@ -848,7 +848,9 @@ static void
 _scroll_cb(Evas_Object *obj,
            void *data __UNUSED__)
 {
-   Evas_Coord x, y, w, h, bw;
+   Evas_Coord x, y, w, h, bw, x_boundary;
+   unsigned int adjust_pixels;
+   Eina_Bool h_bounce;
 
    ELM_DISKSELECTOR_DATA_GET(obj, sd);
 
@@ -858,15 +860,41 @@ _scroll_cb(Evas_Object *obj,
    if (sd->round)
      {
         evas_object_geometry_get(sd->main_box, NULL, NULL, &bw, NULL);
-        if (x > ((w / sd->display_item_num) * (sd->item_count
-                                               + (sd->display_item_num % 2))))
-          sd->s_iface->content_region_show
-            (obj, x - ((w / sd->display_item_num) * sd->item_count),
-            y, w, h);
-        else if (x < 0)
-          sd->s_iface->content_region_show
-            (obj, x + ((w / sd->display_item_num) * sd->item_count),
-            y, w, h);
+        x_boundary = bw - w;
+
+        if (x >= x_boundary)
+          {
+              if (sd->left_boundary_reached) return;
+
+              sd->right_boundary_reached = EINA_TRUE;
+              sd->s_iface->bounce_allow_get(obj, &h_bounce, NULL);
+              /* If scroller's bounce effect is disabled, add 1 pixel
+               *  to provide circular effect */
+              adjust_pixels = (_elm_config->thumbscroll_bounce_enable
+                               && h_bounce) ? 0 : 1;
+              sd->s_iface->content_region_show
+                 (obj, x - x_boundary + adjust_pixels, y, w, h);
+              sd->left_boundary_reached = EINA_FALSE;
+          }
+        else if (x <= 0)
+          {
+              if (sd->right_boundary_reached) return;
+
+              sd->left_boundary_reached = EINA_TRUE;
+              sd->s_iface->bounce_allow_get(obj, &h_bounce, NULL);
+              /* If scroller's bounce effect is disabled, subtract 1 pixel
+               *  to provide circular effect */
+              adjust_pixels = (_elm_config->thumbscroll_bounce_enable
+                               && h_bounce) ? 0 : 1;
+              sd->s_iface->content_region_show
+                 (obj, x + x_boundary - adjust_pixels, y, w, h);
+              sd->right_boundary_reached = EINA_FALSE;
+          }
+        else
+          {
+              sd->left_boundary_reached = EINA_FALSE;
+              sd->right_boundary_reached = EINA_FALSE;
+          }
      }
 }
 
index 30d92c4..6a21cd4 100644 (file)
@@ -151,6 +151,8 @@ struct _Elm_Diskselector_Smart_Data
    Eina_Bool                             init : 1;
    Eina_Bool                             round : 1;
    Eina_Bool                             display_item_num_by_api : 1;
+   Eina_Bool                             left_boundary_reached:1;
+   Eina_Bool                             right_boundary_reached:1;
 };
 
 struct _Elm_Diskselector_Item