Commit e6107bc2 authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen
Browse files

draw text twice, once with the prelight state and clipped to the progress

Tue Nov 26 00:40:53 2002  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
	twice, once with the prelight state and clipped to the progress
	bar, and once with the normal state and clipped to the visible
	part of the trough. Also fix a spelling error pointed out by
	Matthias Clasen.
parent a1f5e821
Tue Nov 26 00:40:53 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
twice, once with the prelight state and clipped to the progress
bar, and once with the normal state and clipped to the visible
part of the trough. Also fix a spelling error pointed out by
Matthias Clasen.
Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com> Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com>
Fixes from #98358, Havoc Pennington. Fixes from #98358, Havoc Pennington.
......
Tue Nov 26 00:40:53 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
twice, once with the prelight state and clipped to the progress
bar, and once with the normal state and clipped to the visible
part of the trough. Also fix a spelling error pointed out by
Matthias Clasen.
Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com> Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com>
Fixes from #98358, Havoc Pennington. Fixes from #98358, Havoc Pennington.
......
Tue Nov 26 00:40:53 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
twice, once with the prelight state and clipped to the progress
bar, and once with the normal state and clipped to the visible
part of the trough. Also fix a spelling error pointed out by
Matthias Clasen.
Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com> Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com>
Fixes from #98358, Havoc Pennington. Fixes from #98358, Havoc Pennington.
......
Tue Nov 26 00:40:53 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
twice, once with the prelight state and clipped to the progress
bar, and once with the normal state and clipped to the visible
part of the trough. Also fix a spelling error pointed out by
Matthias Clasen.
Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com> Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com>
Fixes from #98358, Havoc Pennington. Fixes from #98358, Havoc Pennington.
......
Tue Nov 26 00:40:53 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
twice, once with the prelight state and clipped to the progress
bar, and once with the normal state and clipped to the visible
part of the trough. Also fix a spelling error pointed out by
Matthias Clasen.
Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com> Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com>
Fixes from #98358, Havoc Pennington. Fixes from #98358, Havoc Pennington.
......
Tue Nov 26 00:40:53 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkprogressbar.c (gtk_progress_bar_paint_text): draw text
twice, once with the prelight state and clipped to the progress
bar, and once with the normal state and clipped to the visible
part of the trough. Also fix a spelling error pointed out by
Matthias Clasen.
Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com> Mon Nov 25 17:44:09 2002 Owen Taylor <otaylor@redhat.com>
Fixes from #98358, Havoc Pennington. Fixes from #98358, Havoc Pennington.
......
...@@ -619,25 +619,16 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar, ...@@ -619,25 +619,16 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar,
} }
static void static void
gtk_progress_bar_paint_continous (GtkProgressBar *pbar, gtk_progress_bar_paint_continuous (GtkProgressBar *pbar,
GtkProgressBarOrientation orientation) gint amount,
GtkProgressBarOrientation orientation)
{ {
GtkWidget *widget = GTK_WIDGET (pbar); GtkWidget *widget = GTK_WIDGET (pbar);
gint space;
gint amount;
gint x, y, w, h; gint x, y, w, h;
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
space = widget->allocation.width - 2 * widget->style->xthickness;
else
space = widget->allocation.height - 2 * widget->style->ythickness;
amount = space * gtk_progress_get_current_percentage (GTK_PROGRESS (pbar));
if (amount <= 0) if (amount <= 0)
return; return;
switch (orientation) switch (orientation)
{ {
case GTK_PROGRESS_LEFT_TO_RIGHT: case GTK_PROGRESS_LEFT_TO_RIGHT:
...@@ -727,7 +718,9 @@ gtk_progress_bar_paint_discrete (GtkProgressBar *pbar, ...@@ -727,7 +718,9 @@ gtk_progress_bar_paint_discrete (GtkProgressBar *pbar,
} }
static void static void
gtk_progress_bar_paint_text (GtkProgressBar *pbar) gtk_progress_bar_paint_text (GtkProgressBar *pbar,
gint amount,
GtkProgressBarOrientation orientation)
{ {
GtkProgress *progress = GTK_PROGRESS (pbar); GtkProgress *progress = GTK_PROGRESS (pbar);
GtkWidget *widget = GTK_WIDGET (pbar); GtkWidget *widget = GTK_WIDGET (pbar);
...@@ -738,6 +731,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar) ...@@ -738,6 +731,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;
buf = gtk_progress_get_current_text (progress); buf = gtk_progress_get_current_text (progress);
...@@ -748,29 +742,66 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar) ...@@ -748,29 +742,66 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar)
(widget->allocation.width - 2 * widget->style->xthickness - (widget->allocation.width - 2 * widget->style->xthickness -
3 - logical_rect.width) 3 - logical_rect.width)
* progress->x_align; * progress->x_align;
y = widget->style->ythickness + 1 + y = widget->style->ythickness + 1 +
(widget->allocation.height - 2 * widget->style->ythickness - (widget->allocation.height - 2 * widget->style->ythickness -
3 - logical_rect.height) 3 - logical_rect.height)
* progress->y_align; * progress->y_align;
rect.x = widget->style->xthickness + 1; rect.x = widget->style->xthickness;
rect.y = widget->style->ythickness + 1; rect.y = widget->style->ythickness;
rect.width = widget->allocation.width - rect.width = widget->allocation.width - 2 * widget->style->xthickness;
2 * widget->style->xthickness - 3; rect.height = widget->allocation.height - 2 * widget->style->ythickness;
rect.height = widget->allocation.height -
2 * widget->style->ythickness - 3; prelight_clip = normal_clip = rect;
switch (orientation)
{
case GTK_PROGRESS_LEFT_TO_RIGHT:
prelight_clip.width = amount;
normal_clip.x += amount;
normal_clip.width -= amount;
break;
case GTK_PROGRESS_RIGHT_TO_LEFT:
normal_clip.width -= amount;
prelight_clip.x += normal_clip.width;
prelight_clip.width -= normal_clip.width;
break;
case GTK_PROGRESS_TOP_TO_BOTTOM:
prelight_clip.height = amount;
normal_clip.y += amount;
normal_clip.height -= amount;
break;
case GTK_PROGRESS_BOTTOM_TO_TOP:
normal_clip.height -= amount;
prelight_clip.y += normal_clip.height;
prelight_clip.height -= normal_clip.height;
break;
}
gtk_paint_layout (widget->style, gtk_paint_layout (widget->style,
progress->offscreen_pixmap, progress->offscreen_pixmap,
GTK_WIDGET_STATE (widget), GTK_STATE_PRELIGHT,
FALSE, FALSE,
&rect, &prelight_clip,
widget, widget,
"progressbar", "progressbar",
x, y, x, y,
layout); layout);
gtk_paint_layout (widget->style,
progress->offscreen_pixmap,
GTK_STATE_NORMAL,
FALSE,
&normal_clip,
widget,
"progressbar",
x, y,
layout);
g_object_unref (layout); g_object_unref (layout);
g_free (buf); g_free (buf);
} }
...@@ -813,13 +844,27 @@ gtk_progress_bar_paint (GtkProgress *progress) ...@@ -813,13 +844,27 @@ gtk_progress_bar_paint (GtkProgress *progress)
} }
else else
{ {
gint amount;
gint space;
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
space = widget->allocation.width - 2 * widget->style->xthickness;
else
space = widget->allocation.height - 2 * widget->style->ythickness;
amount = space *
gtk_progress_get_current_percentage (GTK_PROGRESS (pbar));
if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS)
gtk_progress_bar_paint_continous (pbar, orientation); {
gtk_progress_bar_paint_continuous (pbar, amount, orientation);
if (GTK_PROGRESS (pbar)->show_text)
gtk_progress_bar_paint_text (pbar, amount, orientation);
}
else else
gtk_progress_bar_paint_discrete (pbar, orientation); gtk_progress_bar_paint_discrete (pbar, orientation);
if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
gtk_progress_bar_paint_text (pbar);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment