[gnome-shell] Fixes for setting up scrolling adjustments



commit c83883f1f747195effababbbbd31bc4b4ea4a5d4
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Mar 10 13:57:05 2010 -0500

    Fixes for setting up scrolling adjustments
    
    StScrollable: Document how to set adjustments
    StBoxLayout: Make sure that we always have upper >= lower + page_size,
      so that clamping works properly. Set the page_increment to be slightly
      less than the page_size so there is some overlap, as is customary.
    StScrollView: Remove unnecessary fabs() calls, rewrite expressions
      for additional clarity.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=611740

 src/st/st-box-layout.c  |    8 ++++----
 src/st/st-scroll-view.c |    4 ++--
 src/st/st-scrollable.c  |   12 ++++++++++--
 3 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c
index 17690f5..96013e3 100644
--- a/src/st/st-box-layout.c
+++ b/src/st/st-box-layout.c
@@ -770,10 +770,10 @@ st_box_layout_allocate (ClutterActor          *actor,
 
       g_object_set (G_OBJECT (priv->vadjustment),
                     "lower", 0.0,
-                    "upper", min_height,
+                    "upper", MAX (min_height, avail_height),
                     "page-size", avail_height,
                     "step-increment", avail_height / 6,
-                    "page-increment", avail_height,
+                    "page-increment", avail_height - avail_height / 6,
                     NULL);
 
       prev_value = st_adjustment_get_value (priv->vadjustment);
@@ -786,10 +786,10 @@ st_box_layout_allocate (ClutterActor          *actor,
 
       g_object_set (G_OBJECT (priv->hadjustment),
                     "lower", 0.0,
-                    "upper", min_width,
+                    "upper", MAX (min_width, avail_width),
                     "page-size", avail_width,
                     "step-increment", avail_width / 6,
-                    "page-increment", avail_width,
+                    "page-increment", avail_width - avail_width / 6,
                     NULL);
 
       prev_value = st_adjustment_get_value (priv->hadjustment);
diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c
index 4c3a8a2..f3e244b 100644
--- a/src/st/st-scroll-view.c
+++ b/src/st/st-scroll-view.c
@@ -171,8 +171,8 @@ update_shadow_visibility (StScrollView *scroll)
 
       st_adjustment_get_values (priv->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size);
 
-      priv->top_shadow_visible = fabs (value - lower) > 0.1;
-      priv->bottom_shadow_visible = fabs (upper - value - page_size) > 0.1;
+      priv->top_shadow_visible = value > lower + 0.1;
+      priv->bottom_shadow_visible = value < upper - page_size - 0.1;
     }
   else
     {
diff --git a/src/st/st-scrollable.c b/src/st/st-scrollable.c
index 38a25b1..d9fa3e8 100644
--- a/src/st/st-scrollable.c
+++ b/src/st/st-scrollable.c
@@ -66,8 +66,16 @@
  * resize the scroll view small enough so that the scrolled area
  * vanishes.
  *
- * width-for-height size negotation is similar, with the roles of width
- * and height reversed.
+ * In response to allocate, in addition to normal handling, the
+ * scrollable should also set the limits of the the horizontal and
+ * vertical adjustments that were set on it earlier. The standard
+ * settings are:
+ *
+ *  lower: 0
+ *  page_size: allocated size (width or height)
+ *  upper: MAX (total size of the scrolled area,allocated_size)
+ *  step_increment: natural row/column height or a fixed fraction of the page size
+ *  page_increment: page_size - step_increment
  */
 static void
 st_scrollable_base_init (gpointer g_iface)



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