bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) { if (!renderObject->isProgress()) return true; GtkWidget* progressBarWidget = moz_gtk_get_progress_widget(); if (!progressBarWidget) return true; if (paintRenderObject(MOZ_GTK_PROGRESSBAR, renderObject, paintInfo.context, rect)) return true; IntRect chunkRect(rect); RenderProgress* renderProgress = toRenderProgress(renderObject); GtkStyle* style = gtk_widget_get_style(progressBarWidget); chunkRect.setHeight(chunkRect.height() - (2 * style->ythickness)); chunkRect.setY(chunkRect.y() + style->ythickness); chunkRect.setWidth((chunkRect.width() - (2 * style->xthickness)) * renderProgress->position()); if (renderObject->style()->direction() == RTL) chunkRect.setX(rect.x() + rect.width() - chunkRect.width() - style->xthickness); else chunkRect.setX(chunkRect.x() + style->xthickness); return paintRenderObject(MOZ_GTK_PROGRESS_CHUNK, renderObject, paintInfo.context, chunkRect); }
IntRect RenderThemeGtk::calculateProgressRect(RenderObject* renderObject, const IntRect& fullBarRect) { IntRect progressRect(fullBarRect); RenderProgress* renderProgress = toRenderProgress(renderObject); if (renderProgress->isDeterminate()) { int progressWidth = progressRect.width() * renderProgress->position(); if (renderObject->style()->direction() == RTL) progressRect.setX(progressRect.x() + progressRect.width() - progressWidth); progressRect.setWidth(progressWidth); return progressRect; } double animationProgress = renderProgress->animationProgress(); // Never let the progress rect shrink smaller than 2 pixels. int newWidth = max(2, progressRect.width() / progressActivityBlocks); int movableWidth = progressRect.width() - newWidth; progressRect.setWidth(newWidth); // We want the first 0.5 units of the animation progress to represent the // forward motion and the second 0.5 units to represent the backward motion, // thus we multiply by two here to get the full sweep of the progress bar with // each direction. if (animationProgress < 0.5) progressRect.setX(progressRect.x() + (animationProgress * 2 * movableWidth)); else progressRect.setX(progressRect.x() + ((1.0 - animationProgress) * 2 * movableWidth)); return progressRect; }
bool RenderThemeNix::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { RenderProgress* renderProgress = toRenderProgress(o); WebKit::WebThemeEngine::ProgressBarExtraParams extraParams; extraParams.isDeterminate = renderProgress->isDeterminate(); extraParams.position = renderProgress->position(); extraParams.animationProgress = renderProgress->animationProgress(); extraParams.animationStartTime = renderProgress->animationStartTime(); themeEngine()->paintProgressBar(webCanvas(i), getWebThemeState(this, o), WebKit::WebRect(rect), extraParams); return false; }
bool RenderThemeQStyle::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r) { if (!o->isProgress()) return true; StylePainterQStyle p(this, pi, o); if (!p.isValid()) return true; p.styleOption.rect = r; RenderProgress* renderProgress = toRenderProgress(o); p.paintProgressBar(renderProgress->position(), renderProgress->animationProgress()); return false; }
bool RenderThemeQtMobile::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r) { if (!o->isProgress()) return true; StylePainterMobile p(this, pi); if (!p.isValid()) return true; RenderProgress* renderProgress = toRenderProgress(o); const bool isRTL = (renderProgress->style()->direction() == RTL); if (renderProgress->isDeterminate()) p.drawProgress(r, renderProgress->position(), !isRTL); else p.drawProgress(r, renderProgress->animationProgress(), !isRTL, true); return false; }
bool RenderThemeQStyle::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r) { if (!o->isProgress()) return true; StylePainterQStyle p(this, pi); if (!p.isValid()) return true; QStyleOptionProgressBarV2 option; initStyleOption(p.widget, option); initializeCommonQStyleOptions(option, o); RenderProgress* renderProgress = toRenderProgress(o); option.rect = r; option.maximum = std::numeric_limits<int>::max(); option.minimum = 0; option.progress = (renderProgress->position() * std::numeric_limits<int>::max()); const QPoint topLeft = r.location(); p.painter->translate(topLeft); option.rect.moveTo(QPoint(0, 0)); option.rect.setSize(r.size()); if (option.progress < 0) { // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, // we simulate one square animating across the progress bar. p.drawControl(QStyle::CE_ProgressBarGroove, option); int chunkWidth = qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option); QColor color = (option.palette.highlight() == option.palette.background()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight); if (renderProgress->style()->direction() == RTL) p.painter->fillRect(option.rect.right() - chunkWidth - renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); else p.painter->fillRect(renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); } else p.drawControl(QStyle::CE_ProgressBar, option); p.painter->translate(-topLeft); return false; }