diff options
author | Timm Bäder <mail@baedert.org> | 2018-02-22 18:24:06 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2018-02-23 10:47:05 +0100 |
commit | af4474f7520aca1c1b8e3bd91a33f57c97e5a6ec (patch) | |
tree | 72f4ce54cf6dd8efcc3d3aecfb42412b0c68c28e /gtk/gtkrange.c | |
parent | 1fea98093098965fe6ce9e4ea84fd2c58f21c00c (diff) | |
download | gtk+-af4474f7520aca1c1b8e3bd91a33f57c97e5a6ec.tar.gz |
range: Simplify allocate_trough
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r-- | gtk/gtkrange.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 71554ebf26..5eff55328d 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1371,6 +1371,9 @@ gtk_range_allocate_trough (GtkGizmo *gizmo, GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = gtk_range_get_instance_private (range); GtkAllocation slider_alloc; + const double lower = gtk_adjustment_get_lower (priv->adjustment); + const double upper = gtk_adjustment_get_upper (priv->adjustment); + const double page_size = gtk_adjustment_get_page_size (priv->adjustment); double value; /* Slider */ @@ -1382,30 +1385,22 @@ gtk_range_allocate_trough (GtkGizmo *gizmo, gtk_widget_size_allocate (priv->slider_widget, &slider_alloc, -1, out_clip); - if (gtk_adjustment_get_lower (priv->adjustment) == gtk_adjustment_get_upper (priv->adjustment)) + if (lower == upper) value = 0; else - value = (gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)) / - (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)); + value = (gtk_adjustment_get_value (priv->adjustment) - lower) / (upper - lower); if (priv->show_fill_level && - gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) - - gtk_adjustment_get_lower (priv->adjustment) != 0) + upper - page_size - lower != 0) { - gdouble level, fill; + double level, fill; GtkAllocation fill_alloc, fill_clip; fill_alloc = *allocation; - level = CLAMP (priv->fill_level, - gtk_adjustment_get_lower (priv->adjustment), - gtk_adjustment_get_upper (priv->adjustment) - - gtk_adjustment_get_page_size (priv->adjustment)); + level = CLAMP (priv->fill_level, lower, upper - page_size); - fill = (level - gtk_adjustment_get_lower (priv->adjustment)) / - (gtk_adjustment_get_upper (priv->adjustment) - - gtk_adjustment_get_lower (priv->adjustment) - - gtk_adjustment_get_page_size (priv->adjustment)); + fill = (level - lower) / (lower - upper - page_size); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { |