GtkRange: Check "inverted" property when drawing
authorMarcus Karlsson <mk@acc.umu.se>
Tue, 24 Mar 2015 21:14:27 +0000 (22:14 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 25 Mar 2015 03:19:50 +0000 (23:19 -0400)
The direction in which the slider moves can be inverted by setting the
inverted property. But the draw method does not check this, instead it
checks if the direction of the widget is set to be right to left.

Call the should_invert function in order to determine if the direction
of the range should be inverted. It too checks the widget's direction,
but also checks the "inverted" property, and allows the range to be
drawn inverted even if it is vertically oriented.

https://bugzilla.gnome.org/show_bug.cgi?id=746712

gtk/gtkrange.c

index bbbfe220be0f8d293f70d5dd9fa74869197471b5..3f0081896cd5cf7aba9334c4073388f209b805b3 100644 (file)
@@ -2037,8 +2037,6 @@ gtk_range_draw (GtkWidget *widget,
             }
           else
             {
-              gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
-
               gint trough_change_pos_x = width;
               gint trough_change_pos_y = height;
 
@@ -2053,15 +2051,13 @@ gtk_range_draw (GtkWidget *widget,
 
               gtk_style_context_save (context);
               if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-                {
-                  gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
-
-                  if (!is_rtl)
-                    gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
-                }
+                gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
               else
                 gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
 
+              if (!should_invert (range))
+                gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
+
               gtk_render_background (context, cr, x, y,
                                      trough_change_pos_x,
                                      trough_change_pos_y);
@@ -2079,17 +2075,12 @@ gtk_range_draw (GtkWidget *widget,
 
               gtk_style_context_save (context);
               if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-                {
-                  gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
-
-                  if (is_rtl)
-                    gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
-                }
+                gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
               else
-                {
-                  gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
-                  gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
-                }
+                gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+
+              if (should_invert (range))
+                gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
 
               gtk_render_background (context, cr,
                                      x + trough_change_pos_x, y + trough_change_pos_y,