[gtk+] range: Use the correct size for scaling



commit 6ecc1089f2bd299f6a88507da183a80ea41abd5d
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 28 23:02:01 2012 -0500

    range: Use the correct size for scaling
    
    When scaling the scroll delta, always use the 'large' dimension
    of a range widget. When dx was 0, the code code accidentally
    use the small dimension.

 gtk/gtkrange.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index b38fa89..a81b260 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2803,6 +2803,7 @@ _gtk_range_get_wheel_delta (GtkRange       *range,
   gdouble dx, dy;
   gdouble delta;
   gdouble page_size;
+  gdouble size;
 
   page_size = gtk_adjustment_get_page_size (adjustment);
 
@@ -2812,22 +2813,27 @@ _gtk_range_get_wheel_delta (GtkRange       *range,
 
       gtk_widget_get_allocation (GTK_WIDGET (range), &allocation);
 
+      if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
+        size = allocation.width;
+      else
+        size = allocation.height;
+
       if (dx != 0 &&
           gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
         {
           if (GTK_IS_SCROLLBAR (range) && page_size > 0)
-            delta = dx * page_size / allocation.width;
+            delta = dx * page_size / size;
           else
             delta = dx * (gtk_adjustment_get_upper (adjustment) -
-                          gtk_adjustment_get_lower (adjustment)) / allocation.width;
+                          gtk_adjustment_get_lower (adjustment)) / size;
         }
       else
         {
           if (GTK_IS_SCROLLBAR (range) && page_size > 0)
-            delta = dy * page_size / allocation.height;
+            delta = dy * page_size / size;
           else
             delta = dy * (gtk_adjustment_get_upper (adjustment) -
-                          gtk_adjustment_get_lower (adjustment)) / allocation.height;
+                          gtk_adjustment_get_lower (adjustment)) / size;
         }
     }
   else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]