[gtk/wip/baedert/for-master] range: Avoid rounding errors when allocating highlight



commit c718eb4c88edc1dc0ec760ae0f053d236d371b8a
Author: Timm Bäder <mail baedert org>
Date:   Sat Feb 15 10:14:13 2020 +0100

    range: Avoid rounding errors when allocating highlight
    
    Fixes #2438

 gtk/gtkrange.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 9feab541fc..9f54696a28 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1451,26 +1451,24 @@ gtk_range_allocate_trough (GtkGizmo *gizmo,
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
           highlight_alloc.y = 0;
+          highlight_alloc.width = MAX (min, value * width);
           highlight_alloc.height = height;
 
           if (!should_invert (range))
             highlight_alloc.x = 0;
           else
-            highlight_alloc.x = (width * (1 - value));
-
-          highlight_alloc.width = MAX (min, width * value);
+            highlight_alloc.x = width - highlight_alloc.width;
         }
       else
         {
           highlight_alloc.x = 0;
           highlight_alloc.width = width;
+          highlight_alloc.height = MAX (min, height * value);
 
           if (!should_invert (range))
             highlight_alloc.y = 0;
           else
-            highlight_alloc.y = (height * (1 - value));
-
-          highlight_alloc.height = MAX (min, height * value);
+            highlight_alloc.y = height - highlight_alloc.height;
         }
 
       gtk_widget_size_allocate (priv->highlight_widget, &highlight_alloc, -1);


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