Bug 655313 - Use a native rendering for indeterminate vertical progress bar in GTK. r=roc,karlt

This commit is contained in:
Mounir Lamouri 2011-05-16 12:59:10 +02:00
Родитель 5d2f4eb990
Коммит 48b48c1eca
3 изменённых файлов: 28 добавлений и 11 удалений

Просмотреть файл

@ -2248,28 +2248,38 @@ moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
TSOffsetStyleGCs(style, rect->x, rect->y);
if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE) {
if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
/**
* The bar's width and the bar speed are set depending of the progress
* bar size. These could also be constant for all progress bars easily.
* The bar's size and the bar speed are set depending of the progress'
* size. These could also be constant for all progress bars easily.
*/
gboolean vertical = (widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE);
/* The size of the dimension we are going to use for the animation. */
const gint progressSize = vertical ? rect->height : rect->width;
/* The bar is using a fifth of the element size, based on GtkProgressBar
* activity-blocks property. */
const gint barWidth = MAX(1, rect->width / 5);
const gint barSize = MAX(1, progressSize / 5);
/* Represents the travel that has to be done for a complete cycle. */
const gint travel = 2 * (rect->width - barWidth);
const gint travel = 2 * (progressSize - barSize);
/* period equals to travel / pixelsPerMillisecond
* where pixelsPerMillisecond equals rect->width / 1000.0.
* where pixelsPerMillisecond equals progressSize / 1000.0.
* This is equivalent to 1600. */
const guint period = 1600;
static const guint period = 1600;
const gint t = PR_IntervalToMilliseconds(PR_IntervalNow()) % period;
const gint dx = travel * t / period;
rect->x += (dx < travel / 2) ? dx : travel - dx;
rect->width = barWidth;
if (vertical) {
rect->y += (dx < travel / 2) ? dx : travel - dx;
rect->height = barSize;
} else {
rect->x += (dx < travel / 2) ? dx : travel - dx;
rect->width = barSize;
}
}
gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
@ -2986,6 +2996,7 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
case MOZ_GTK_GRIPPER:
case MOZ_GTK_PROGRESS_CHUNK:
case MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE:
case MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE:
case MOZ_GTK_EXPANDER:
case MOZ_GTK_TREEVIEW_EXPANDER:
case MOZ_GTK_TOOLBAR_SEPARATOR:
@ -3333,6 +3344,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
break;
case MOZ_GTK_PROGRESS_CHUNK:
case MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE:
case MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE:
return moz_gtk_progress_chunk_paint(drawable, rect, cliprect,
direction, widget);
break;

Просмотреть файл

@ -180,6 +180,8 @@ typedef enum {
MOZ_GTK_PROGRESS_CHUNK,
/* Paints a progress chunk of an indeterminated GtkProgressBar. */
MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE,
/* Paints a progress chunk of a vertical indeterminated GtkProgressBar. */
MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE,
/* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
MOZ_GTK_TAB,
/* Paints the background and border of a GtkNotebook. */

Просмотреть файл

@ -571,7 +571,9 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
nsEventStates eventStates = GetContentState(stateFrame, aWidgetType);
aGtkWidgetType = IsIndeterminateProgress(stateFrame, eventStates)
? MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE
? (stateFrame->GetStyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL)
? MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE
: MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE
: MOZ_GTK_PROGRESS_CHUNK;
}
break;
@ -881,7 +883,8 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
}
// Indeterminate progress bar are animated.
if (gtkWidgetType == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE) {
if (gtkWidgetType == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
gtkWidgetType == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 30)) {
NS_WARNING("unable to animate widget!");
}