From e82606a5380c62f09ce70daec2946267fa3a8325 Mon Sep 17 00:00:00 2001 From: "g.willems" Date: Wed, 29 May 2024 20:27:24 +0200 Subject: [PATCH] progressbar: fix highlight clipping Clipping using OVERFLOW_HIDDEN relies on widget's padding box. This prevents the highlight to paint itself over the trough's borders. Use the border box instead, with a custom snapshot implementation. Fixes #6332 --- gtk/gtkprogressbar.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 0739715d85..45feb4311b 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -28,12 +28,14 @@ #include "gtkaccessiblerange.h" #include "gtkboxlayout.h" +#include "gtkcssboxesprivate.h" #include "gtkgizmoprivate.h" #include #include "gtklabel.h" #include "gtkorientable.h" #include "gtkprogresstrackerprivate.h" #include "gtkprivate.h" +#include "gtksnapshot.h" #include "gtkwidgetprivate.h" #include @@ -438,7 +440,24 @@ allocate_trough (GtkGizmo *gizmo, } gtk_widget_size_allocate (pbar->progress_widget, &alloc, -1); +} +static void +snapshot_trough (GtkGizmo *gizmo, + GtkSnapshot *snapshot) + +{ + GtkWidget *widget = gtk_widget_get_parent (GTK_WIDGET (gizmo)); + GtkProgressBar *pbar = GTK_PROGRESS_BAR (widget); + + if (pbar->progress_widget) + { + GtkCssBoxes boxes; + gtk_css_boxes_init (&boxes, GTK_WIDGET (gizmo)); + gtk_snapshot_push_rounded_clip (snapshot, gtk_css_boxes_get_border_box (&boxes)); + gtk_widget_snapshot_child (GTK_WIDGET (gizmo), pbar->progress_widget, snapshot); + gtk_snapshot_pop (snapshot); + } } static void @@ -459,10 +478,9 @@ gtk_progress_bar_init (GtkProgressBar *pbar) GTK_ACCESSIBLE_ROLE_NONE, NULL, allocate_trough, - NULL, + snapshot_trough, NULL, NULL, NULL); - gtk_widget_set_overflow (pbar->trough_widget, GTK_OVERFLOW_HIDDEN); gtk_widget_set_parent (pbar->trough_widget, GTK_WIDGET (pbar)); pbar->progress_widget = gtk_gizmo_new_with_role ("progress",