[gtk+/gtk-3-14] GtkRange: Fix drawing of fill-level
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] GtkRange: Fix drawing of fill-level
- Date: Sun, 29 Mar 2015 23:14:11 +0000 (UTC)
commit 5a61fcd1b31605a222711f6916c10eb1357fd624
Author: Marcus Karlsson <mk acc umu se>
Date: Tue Mar 24 22:31:52 2015 +0100
GtkRange: Fix drawing of fill-level
Compute the proportion of the range that should be filled to match the
fill level, and use it to compute the starting point and length of the
area between the slider and the fill level.
https://bugzilla.gnome.org/show_bug.cgi?id=734741
gtk/gtkrange.c | 56 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 30 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 036802e..51726c8 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2130,11 +2130,12 @@ gtk_range_draw (GtkWidget *widget,
gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) -
gtk_adjustment_get_lower (priv->adjustment) != 0)
{
- gdouble fill_level = priv->fill_level;
- gint fill_x = x;
- gint fill_y = y;
- gint fill_width = width;
- gint fill_height = height;
+ gdouble fill_level = priv->fill_level;
+ gint fill_x = x;
+ gint fill_y = y;
+ gint fill_width = width;
+ gint fill_height = height;
+ gdouble fill_proportion = 0.0;
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
@@ -2143,33 +2144,36 @@ gtk_range_draw (GtkWidget *widget,
gtk_adjustment_get_upper (priv->adjustment) -
gtk_adjustment_get_page_size (priv->adjustment));
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- fill_x = priv->trough.x;
- fill_width = (priv->slider.width +
- (fill_level - gtk_adjustment_get_lower (priv->adjustment)) /
+ fill_proportion = (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)) *
- (priv->trough.width -
- priv->slider.width));
+ gtk_adjustment_get_page_size (priv->adjustment));
- if (should_invert (range))
- fill_x += priv->trough.width - fill_width;
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (!should_invert (range))
+ {
+ fill_x = priv->slider.x + (priv->slider.width / 2);
+ fill_width = (width * fill_proportion) - fill_x + x;
+ }
+ else
+ {
+ fill_x = x + width * (1.0 - fill_proportion);
+ fill_width = priv->slider.x + (priv->slider.width / 2) - fill_x;
+ }
}
else
{
- fill_y = priv->trough.y;
- fill_height = (priv->slider.height +
- (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)) *
- (priv->trough.height -
- priv->slider.height));
-
- if (should_invert (range))
- fill_y += priv->trough.height - fill_height;
+ if (!should_invert (range))
+ {
+ fill_y = priv->slider.y + (priv->slider.height / 2);
+ fill_height = (height * fill_proportion) - fill_y + y;
+ }
+ else
+ {
+ fill_y = y + height * (1.0 - fill_proportion);
+ fill_height = priv->slider.y + (priv->slider.height / 2) - fill_y;
+ }
}
gtk_render_background (context, cr, fill_x, fill_y, fill_width, fill_height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]