diff options
author | Tim Janik <timj@imendio.com> | 2006-06-16 09:51:39 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2006-06-16 09:51:39 +0000 |
commit | de15bb09c36aade4dafb323b8328e70b8deca767 (patch) | |
tree | 02fa2eebce9ab6b6da926d30ddf99b1e98d0715a | |
parent | 0f0e499c12c77b246de20a649cfe4c30810dc765 (diff) | |
download | gtk+-de15bb09c36aade4dafb323b8328e70b8deca767.tar.gz |
Move activity bar offset and size calculations to separate function.
Fri Jun 16 11:49:53 2006 Tim Janik <timj@imendio.com>
* fixed #337882 by applying patches from Tommi Komulainen:
* gtk/gtkprogressbar.c:
(gtk_progress_bar_paint_activity):
(gtk_progress_bar_get_activity): Move activity bar offset and size
calculations to separate function.
(gtk_progress_bar_paint_text): Allow caller to specify offset for the
prelight part in addition to width.
(gtk_progress_bar_paint): Paint the text also in activity mode, #337882.
* gtk/gtkprogressbar.c: (gtk_progress_bar_paint_text): Paint the
prelighted text on top of the normal rather than side by side, to
simplify painting text in activity mode.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 16 | ||||
-rw-r--r-- | gtk/gtkprogressbar.c | 78 |
3 files changed, 89 insertions, 21 deletions
@@ -1,3 +1,19 @@ +Fri Jun 16 11:49:53 2006 Tim Janik <timj@imendio.com> + + * fixed #337882 by applying patches from Tommi Komulainen: + + * gtk/gtkprogressbar.c: + (gtk_progress_bar_paint_activity): + (gtk_progress_bar_get_activity): Move activity bar offset and size + calculations to separate function. + (gtk_progress_bar_paint_text): Allow caller to specify offset for the + prelight part in addition to width. + (gtk_progress_bar_paint): Paint the text also in activity mode, #337882. + + * gtk/gtkprogressbar.c: (gtk_progress_bar_paint_text): Paint the + prelighted text on top of the normal rather than side by side, to + simplify painting text in activity mode. + 2006-06-16 Matthias Clasen <mclasen@redhat.com> * modules/printbackends/cups/gtkprintbackendcups.c: Include diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 8f0414a4bb..3ec97bd71a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,19 @@ +Fri Jun 16 11:49:53 2006 Tim Janik <timj@imendio.com> + + * fixed #337882 by applying patches from Tommi Komulainen: + + * gtk/gtkprogressbar.c: + (gtk_progress_bar_paint_activity): + (gtk_progress_bar_get_activity): Move activity bar offset and size + calculations to separate function. + (gtk_progress_bar_paint_text): Allow caller to specify offset for the + prelight part in addition to width. + (gtk_progress_bar_paint): Paint the text also in activity mode, #337882. + + * gtk/gtkprogressbar.c: (gtk_progress_bar_paint_text): Paint the + prelighted text on top of the normal rather than side by side, to + simplify painting text in activity mode. + 2006-06-16 Matthias Clasen <mclasen@redhat.com> * modules/printbackends/cups/gtkprintbackendcups.c: Include diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index a37ad3b4d1..b35d82ac91 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -599,6 +599,30 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress) } static void +gtk_progress_bar_get_activity (GtkProgressBar *pbar, + GtkProgressBarOrientation orientation, + gint *offset, + gint *amount) +{ + GtkWidget *widget = GTK_WIDGET (pbar); + + *offset = pbar->activity_pos; + + switch (orientation) + { + case GTK_PROGRESS_LEFT_TO_RIGHT: + case GTK_PROGRESS_RIGHT_TO_LEFT: + *amount = MAX (2, widget->allocation.width / pbar->activity_blocks); + break; + + case GTK_PROGRESS_TOP_TO_BOTTOM: + case GTK_PROGRESS_BOTTOM_TO_TOP: + *amount = MAX (2, widget->allocation.height / pbar->activity_blocks); + break; + } +} + +static void gtk_progress_bar_paint_activity (GtkProgressBar *pbar, GtkProgressBarOrientation orientation) { @@ -610,18 +634,16 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar, { case GTK_PROGRESS_LEFT_TO_RIGHT: case GTK_PROGRESS_RIGHT_TO_LEFT: - area.x = pbar->activity_pos; + gtk_progress_bar_get_activity (pbar, orientation, &area.x, &area.width); area.y = widget->style->ythickness; - area.width = MAX (2, widget->allocation.width / pbar->activity_blocks); area.height = widget->allocation.height - 2 * widget->style->ythickness; break; case GTK_PROGRESS_TOP_TO_BOTTOM: case GTK_PROGRESS_BOTTOM_TO_TOP: + gtk_progress_bar_get_activity (pbar, orientation, &area.y, &area.height); area.x = widget->style->xthickness; - area.y = pbar->activity_pos; area.width = widget->allocation.width - 2 * widget->style->xthickness; - area.height = MAX (2, widget->allocation.height / pbar->activity_blocks); break; default: @@ -738,6 +760,7 @@ gtk_progress_bar_paint_discrete (GtkProgressBar *pbar, static void gtk_progress_bar_paint_text (GtkProgressBar *pbar, + gint offset, gint amount, GtkProgressBarOrientation orientation) { @@ -781,45 +804,49 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, switch (orientation) { case GTK_PROGRESS_LEFT_TO_RIGHT: + if (offset != -1) + prelight_clip.x = offset; 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; + if (offset != -1) + prelight_clip.x = offset; + else + prelight_clip.x = rect.x + rect.width - amount; + prelight_clip.width = amount; break; case GTK_PROGRESS_TOP_TO_BOTTOM: + if (offset != -1) + prelight_clip.y = offset; 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; + if (offset != -1) + prelight_clip.y = offset; + else + prelight_clip.y = rect.y + rect.height - amount; + prelight_clip.height = amount; break; } - + gtk_paint_layout (widget->style, progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, + GTK_STATE_NORMAL, FALSE, - &prelight_clip, + &normal_clip, widget, "progressbar", x, y, layout); - + gtk_paint_layout (widget->style, progress->offscreen_pixmap, - GTK_STATE_NORMAL, + GTK_STATE_PRELIGHT, FALSE, - &normal_clip, + &prelight_clip, widget, "progressbar", x, y, @@ -864,6 +891,15 @@ gtk_progress_bar_paint (GtkProgress *progress) if (progress->activity_mode) { gtk_progress_bar_paint_activity (pbar, orientation); + + if (GTK_PROGRESS (pbar)->show_text) + { + gint offset; + gint amount; + + gtk_progress_bar_get_activity (pbar, orientation, &offset, &amount); + gtk_progress_bar_paint_text (pbar, offset, amount, orientation); + } } else { @@ -884,7 +920,7 @@ gtk_progress_bar_paint (GtkProgress *progress) gtk_progress_bar_paint_continuous (pbar, amount, orientation); if (GTK_PROGRESS (pbar)->show_text) - gtk_progress_bar_paint_text (pbar, amount, orientation); + gtk_progress_bar_paint_text (pbar, -1, amount, orientation); } else gtk_progress_bar_paint_discrete (pbar, orientation); |