Be more careful when overdrawing antialiased text. (#352435, Alex Jones,

2006-12-11  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): Be more
        careful when overdrawing antialiased text.  (#352435, Alex Jones,
        patch by Benjamin Otte)
This commit is contained in:
Matthias Clasen
2006-12-11 15:35:25 +00:00
committed by Matthias Clasen
parent 57b078de1e
commit 91f9d7dac2
2 changed files with 54 additions and 12 deletions

View File

@ -1,6 +1,10 @@
2006-12-11 Matthias Clasen <mclasen@redhat.com> 2006-12-11 Matthias Clasen <mclasen@redhat.com>
* 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, is merged to correctly handle vanishing colors. (#374420,
Benjamin Berg, patch by Callum McKenzie) Benjamin Berg, patch by Callum McKenzie)
Also allow to separate entries in color schemes by ';' Also allow to separate entries in color schemes by ';'

View File

@ -76,6 +76,8 @@ static gboolean gtk_progress_bar_expose (GtkWidget *widget,
GdkEventExpose *event); GdkEventExpose *event);
static void gtk_progress_bar_size_request (GtkWidget *widget, static void gtk_progress_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition); 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_real_update (GtkProgress *progress);
static void gtk_progress_bar_paint (GtkProgress *progress); static void gtk_progress_bar_paint (GtkProgress *progress);
static void gtk_progress_bar_act_mode_enter (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->expose_event = gtk_progress_bar_expose;
widget_class->size_request = gtk_progress_bar_size_request; 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->paint = gtk_progress_bar_paint;
progress_class->update = gtk_progress_bar_real_update; 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 static void
gtk_progress_bar_act_mode_enter (GtkProgress *progress) gtk_progress_bar_act_mode_enter (GtkProgress *progress)
{ {
@ -779,7 +793,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
GdkRectangle rect; GdkRectangle rect;
PangoLayout *layout; PangoLayout *layout;
PangoRectangle logical_rect; PangoRectangle logical_rect;
GdkRectangle prelight_clip, normal_clip; GdkRectangle prelight_clip, start_clip, end_clip;
gfloat text_xalign = progress->x_align; gfloat text_xalign = progress->x_align;
gfloat text_yalign = progress->y_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.width = widget->allocation.width - 2 * widget->style->xthickness;
rect.height = widget->allocation.height - 2 * widget->style->ythickness; rect.height = widget->allocation.height - 2 * widget->style->ythickness;
prelight_clip = normal_clip = rect; prelight_clip = start_clip = end_clip = rect;
switch (orientation) switch (orientation)
{ {
@ -816,6 +830,9 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
if (offset != -1) if (offset != -1)
prelight_clip.x = offset; prelight_clip.x = offset;
prelight_clip.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; break;
case GTK_PROGRESS_RIGHT_TO_LEFT: case GTK_PROGRESS_RIGHT_TO_LEFT:
@ -824,12 +841,18 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
else else
prelight_clip.x = rect.x + rect.width - amount; prelight_clip.x = rect.x + rect.width - amount;
prelight_clip.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; break;
case GTK_PROGRESS_TOP_TO_BOTTOM: case GTK_PROGRESS_TOP_TO_BOTTOM:
if (offset != -1) if (offset != -1)
prelight_clip.y = offset; prelight_clip.y = offset;
prelight_clip.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; break;
case GTK_PROGRESS_BOTTOM_TO_TOP: case GTK_PROGRESS_BOTTOM_TO_TOP:
@ -838,14 +861,29 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
else else
prelight_clip.y = rect.y + rect.height - amount; prelight_clip.y = rect.y + rect.height - amount;
prelight_clip.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; break;
} }
if (start_clip.width > 0 && start_clip.height > 0)
gtk_paint_layout (widget->style, gtk_paint_layout (widget->style,
progress->offscreen_pixmap, progress->offscreen_pixmap,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
FALSE, FALSE,
&normal_clip, &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, widget,
"progressbar", "progressbar",
x, y, x, y,