diff options
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r-- | gtk/gtkrange.c | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index e5bbaa994a..3981dcff74 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1858,7 +1858,6 @@ draw_stepper (GtkRange *range, GtkStateFlags state = 0; GtkStyleContext *context; GtkWidget *widget = GTK_WIDGET (range); - GdkWindow *window; gfloat arrow_scaling; GdkRectangle *rect; gint arrow_x; @@ -1910,7 +1909,6 @@ draw_stepper (GtkRange *range, state |= GTK_STATE_FLAG_PRELIGHT; } - window = gtk_widget_get_window (widget); context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); @@ -1937,8 +1935,8 @@ draw_stepper (GtkRange *range, gtk_range_get_props (GTK_RANGE (widget), NULL, NULL, NULL, NULL, NULL, NULL, - &arrow_displacement_x, &arrow_displacement_y); - + &arrow_displacement_x, &arrow_displacement_y); + arrow_x += arrow_displacement_x; arrow_y += arrow_displacement_y; } @@ -1969,14 +1967,13 @@ draw_stepper (GtkRange *range, } static gboolean -gtk_range_draw (GtkWidget *widget, - cairo_t *cr) +gtk_range_draw (GtkWidget *widget, + cairo_t *cr) { GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = range->priv; gboolean sensitive; GtkStateFlags state = 0; - GdkWindow *window; gint focus_line_width = 0; gint focus_padding = 0; gboolean touchscreen; @@ -1998,8 +1995,6 @@ gtk_range_draw (GtkWidget *widget, "focus-padding", &focus_padding, NULL); - window = gtk_widget_get_window (widget); - /* we're now exposing, so there's no need to force early repaints */ if (priv->repaint_id) g_source_remove (priv->repaint_id); @@ -2085,22 +2080,22 @@ gtk_range_draw (GtkWidget *widget, y += offset; height -= shorter; } - } + } gtk_style_context_save (context); gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH); if (draw_trough) { - gint trough_change_pos_x = width; - gint trough_change_pos_y = height; + gint trough_change_pos_x = width; + gint trough_change_pos_y = height; - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - trough_change_pos_x = (priv->slider.x + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + trough_change_pos_x = (priv->slider.x + priv->slider.width / 2 - x); - else - trough_change_pos_y = (priv->slider.y + + else + trough_change_pos_y = (priv->slider.y + priv->slider.height / 2 - y); @@ -2111,10 +2106,10 @@ gtk_range_draw (GtkWidget *widget, trough_change_pos_x, trough_change_pos_y); - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - trough_change_pos_y = 0; - else - trough_change_pos_x = 0; + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + trough_change_pos_y = 0; + else + trough_change_pos_x = 0; gtk_render_background (context, cr, x + trough_change_pos_x, y + trough_change_pos_y, @@ -2137,13 +2132,12 @@ gtk_range_draw (GtkWidget *widget, 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) - { + { gdouble fill_level = priv->fill_level; - gint fill_x = x; - gint fill_y = y; - gint fill_width = width; - gint fill_height = height; - gchar *fill_detail; + gint fill_x = x; + gint fill_y = y; + gint fill_width = width; + gint fill_height = height; gtk_style_context_save (context); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); @@ -2152,10 +2146,10 @@ 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 + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + fill_x = priv->trough.x; + fill_width = (priv->slider.width + (fill_level - gtk_adjustment_get_lower (priv->adjustment)) / (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) - @@ -2165,11 +2159,11 @@ gtk_range_draw (GtkWidget *widget, if (should_invert (range)) fill_x += priv->trough.width - fill_width; - } - else - { - fill_y = priv->trough.y; - fill_height = (priv->slider.height + + } + 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) - @@ -2179,19 +2173,21 @@ gtk_range_draw (GtkWidget *widget, if (should_invert (range)) fill_y += priv->trough.height - fill_height; - } + } - if (fill_level < gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)) - fill_detail = "trough-fill-level-full"; - else - fill_detail = "trough-fill-level"; +#if 0 + if (fill_level < gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)) + fill_detail = "trough-fill-level-full"; + else + fill_detail = "trough-fill-level"; +#endif gtk_render_activity (context, cr, fill_x, fill_y, fill_width, fill_height); gtk_style_context_restore (context); - } + } gtk_style_context_restore (context); @@ -2266,7 +2262,7 @@ gtk_range_draw (GtkWidget *widget, priv->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, priv->grab_location == MOUSE_STEPPER_D, !touchscreen && priv->mouse_location == MOUSE_STEPPER_D); - + return FALSE; } |