From 91f9d7dac2de431e077c6c82aef9e8042554ee76 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 11 Dec 2006 15:35:25 +0000 Subject: [PATCH] Be more careful when overdrawing antialiased text. (#352435, Alex Jones, 2006-12-11 Matthias Clasen * gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): Be more careful when overdrawing antialiased text. (#352435, Alex Jones, patch by Benjamin Otte) --- ChangeLog | 6 ++++- gtk/gtkprogressbar.c | 60 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b9b9eb59f..77857f444c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2006-12-11 Matthias Clasen - * gtksettings.c: Change the way in which color scheme information + * gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): Be more + careful when overdrawing antialiased text. (#352435, Alex Jones, + patch by Benjamin Otte) + + * gtk/gtksettings.c: Change the way in which color scheme information is merged to correctly handle vanishing colors. (#374420, Benjamin Berg, patch by Callum McKenzie) Also allow to separate entries in color schemes by ';' diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 295f4143a1..53b746bd64 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -76,6 +76,8 @@ static gboolean gtk_progress_bar_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_progress_bar_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void gtk_progress_bar_style_set (GtkWidget *widget, + GtkStyle *previous); static void gtk_progress_bar_real_update (GtkProgress *progress); static void gtk_progress_bar_paint (GtkProgress *progress); static void gtk_progress_bar_act_mode_enter (GtkProgress *progress); @@ -108,6 +110,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class) widget_class->expose_event = gtk_progress_bar_expose; widget_class->size_request = gtk_progress_bar_size_request; + widget_class->style_set = gtk_progress_bar_style_set; progress_class->paint = gtk_progress_bar_paint; progress_class->update = gtk_progress_bar_real_update; @@ -551,6 +554,17 @@ gtk_progress_bar_size_request (GtkWidget *widget, } } +static void +gtk_progress_bar_style_set (GtkWidget *widget, + GtkStyle *previous) +{ + GtkProgressBar *pbar = GTK_PROGRESS_BAR (widget); + + pbar->dirty = TRUE; + + GTK_WIDGET_CLASS (gtk_progress_bar_parent_class)->style_set (widget, previous); +} + static void gtk_progress_bar_act_mode_enter (GtkProgress *progress) { @@ -779,7 +793,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, GdkRectangle rect; PangoLayout *layout; PangoRectangle logical_rect; - GdkRectangle prelight_clip, normal_clip; + GdkRectangle prelight_clip, start_clip, end_clip; gfloat text_xalign = progress->x_align; gfloat text_yalign = progress->y_align; @@ -808,7 +822,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, rect.width = widget->allocation.width - 2 * widget->style->xthickness; rect.height = widget->allocation.height - 2 * widget->style->ythickness; - prelight_clip = normal_clip = rect; + prelight_clip = start_clip = end_clip = rect; switch (orientation) { @@ -816,6 +830,9 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, if (offset != -1) prelight_clip.x = offset; prelight_clip.width = amount; + start_clip.width = prelight_clip.x - start_clip.x; + end_clip.x = start_clip.x + start_clip.width + prelight_clip.width; + end_clip.width -= prelight_clip.width + start_clip.width; break; case GTK_PROGRESS_RIGHT_TO_LEFT: @@ -824,12 +841,18 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, else prelight_clip.x = rect.x + rect.width - amount; prelight_clip.width = amount; + start_clip.width = prelight_clip.x - start_clip.x; + end_clip.x = start_clip.x + start_clip.width + prelight_clip.width; + end_clip.width -= prelight_clip.width + start_clip.width; break; case GTK_PROGRESS_TOP_TO_BOTTOM: if (offset != -1) prelight_clip.y = offset; prelight_clip.height = amount; + start_clip.height = prelight_clip.y - start_clip.y; + end_clip.y = start_clip.y + start_clip.height + prelight_clip.height; + end_clip.height -= prelight_clip.height + start_clip.height; break; case GTK_PROGRESS_BOTTOM_TO_TOP: @@ -838,18 +861,33 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, else prelight_clip.y = rect.y + rect.height - amount; prelight_clip.height = amount; + start_clip.height = prelight_clip.y - start_clip.y; + end_clip.y = start_clip.y + start_clip.height + prelight_clip.height; + end_clip.height -= prelight_clip.height + start_clip.height; break; } - gtk_paint_layout (widget->style, - progress->offscreen_pixmap, - GTK_STATE_NORMAL, - FALSE, - &normal_clip, - widget, - "progressbar", - x, y, - layout); + if (start_clip.width > 0 && start_clip.height > 0) + gtk_paint_layout (widget->style, + progress->offscreen_pixmap, + GTK_STATE_NORMAL, + FALSE, + &start_clip, + widget, + "progressbar", + x, y, + layout); + + if (end_clip.width > 0 && end_clip.height > 0) + gtk_paint_layout (widget->style, + progress->offscreen_pixmap, + GTK_STATE_NORMAL, + FALSE, + &end_clip, + widget, + "progressbar", + x, y, + layout); gtk_paint_layout (widget->style, progress->offscreen_pixmap,