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
This commit is contained in:
Owen W. Taylor 2010-03-10 13:57:05 -05:00
parent f6cbb14393
commit c83883f1f7
3 changed files with 16 additions and 8 deletions

View File

@ -770,10 +770,10 @@ st_box_layout_allocate (ClutterActor *actor,
g_object_set (G_OBJECT (priv->vadjustment), g_object_set (G_OBJECT (priv->vadjustment),
"lower", 0.0, "lower", 0.0,
"upper", min_height, "upper", MAX (min_height, avail_height),
"page-size", avail_height, "page-size", avail_height,
"step-increment", avail_height / 6, "step-increment", avail_height / 6,
"page-increment", avail_height, "page-increment", avail_height - avail_height / 6,
NULL); NULL);
prev_value = st_adjustment_get_value (priv->vadjustment); 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), g_object_set (G_OBJECT (priv->hadjustment),
"lower", 0.0, "lower", 0.0,
"upper", min_width, "upper", MAX (min_width, avail_width),
"page-size", avail_width, "page-size", avail_width,
"step-increment", avail_width / 6, "step-increment", avail_width / 6,
"page-increment", avail_width, "page-increment", avail_width - avail_width / 6,
NULL); NULL);
prev_value = st_adjustment_get_value (priv->hadjustment); prev_value = st_adjustment_get_value (priv->hadjustment);

View File

@ -171,8 +171,8 @@ update_shadow_visibility (StScrollView *scroll)
st_adjustment_get_values (priv->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size); st_adjustment_get_values (priv->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size);
priv->top_shadow_visible = fabs (value - lower) > 0.1; priv->top_shadow_visible = value > lower + 0.1;
priv->bottom_shadow_visible = fabs (upper - value - page_size) > 0.1; priv->bottom_shadow_visible = value < upper - page_size - 0.1;
} }
else else
{ {

View File

@ -66,8 +66,16 @@
* resize the scroll view small enough so that the scrolled area * resize the scroll view small enough so that the scrolled area
* vanishes. * vanishes.
* *
* width-for-height size negotation is similar, with the roles of width * In response to allocate, in addition to normal handling, the
* and height reversed. * 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 static void
st_scrollable_base_init (gpointer g_iface) st_scrollable_base_init (gpointer g_iface)