[gtk+/gtk-3-16] GtkRange: Check "inverted" property when drawing



commit 59861241adfe1221f92580fbb9594d72ce9af5a4
Author: Marcus Karlsson <mk acc umu se>
Date:   Tue Mar 24 22:14:27 2015 +0100

    GtkRange: Check "inverted" property when drawing
    
    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 |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index bbbfe22..3f00818 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]