void TaskbarThumbnailEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) { effects->paintWindow(w, mask, region, data); // paint window first if (thumbnails.contains(w)) { // paint thumbnails on it int mask = PAINT_WINDOW_TRANSFORMED; if (data.opacity() == 1.0) mask |= PAINT_WINDOW_OPAQUE; else mask |= PAINT_WINDOW_TRANSLUCENT; mask |= PAINT_WINDOW_LANCZOS; foreach (const Data & thumb, thumbnails.values(w)) { EffectWindow* thumbw = effects->findWindow(thumb.window); if (thumbw == NULL) continue; WindowPaintData thumbData(thumbw); thumbData.multiplyOpacity(data.opacity()); QRect r, thumbRect(thumb.rect); thumbRect.translate(w->pos() + QPoint(data.xTranslation(), data.yTranslation())); thumbRect.setSize(QSize(thumbRect.width() * data.xScale(), thumbRect.height() * data.yScale())); // QSize has no vector multiplicator... :-( if (effects->isOpenGLCompositing()) { if (data.shader) { thumbData.shader = data.shader; } } // if ( effects->compositingType() == KWin::OpenGLCompositing ) setPositionTransformations(thumbData, r, thumbw, thumbRect, Qt::KeepAspectRatio); effects->drawWindow(thumbw, mask, r, thumbData); } }
bool RenderThemeGtk::paintSliderThumb(RenderObject* object, const PaintInfo& info, const IntRect& rect) { if (info.context->paintingDisabled()) return false; ControlPart part = object->style()->appearance(); ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart); GtkWidget* widget = 0; const char* detail = 0; GtkOrientation orientation; if (part == SliderThumbVerticalPart) { widget = gtkVScale(); detail = "vscale"; orientation = GTK_ORIENTATION_VERTICAL; } else { widget = gtkHScale(); detail = "hscale"; orientation = GTK_ORIENTATION_HORIZONTAL; } gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction())); // Only some themes have slider thumbs respond to clicks and some don't. This information is // gathered via the 'activate-slider' property, but it's deprecated in GTK+ 2.22 and removed in // GTK+ 3.x. The drawback of not honoring it is that slider thumbs change color when you click // on them. IntRect thumbRect(IntPoint(), rect.size()); WidgetRenderingContext widgetContext(info.context, rect); widgetContext.gtkPaintSlider(thumbRect, widget, getGtkStateType(object), GTK_SHADOW_OUT, detail, orientation); return false; }
Rect CPetSlider::getThumbRect() const { Rect thumbRect(0, 0, _thumbWidth, _thumbHeight); Point centroid = getThumbCentroidPos(); thumbRect.moveTo(centroid.x - _thumbWidth / 2, centroid.y - _thumbHeight / 2); return thumbRect; }
void RenderSlider::layout() { ASSERT(needsLayout()); SliderThumbElement* thumbElement = shadowSliderThumb(); RenderBox* thumb = thumbElement ? toRenderBox(thumbElement->renderer()) : 0; IntSize baseSize(borderAndPaddingWidth(), borderAndPaddingHeight()); if (thumb) { // Allow the theme to set the size of the thumb. if (thumb->style()->hasAppearance()) { // FIXME: This should pass the style, not the renderer, to the theme. theme()->adjustSliderThumbSize(thumb); } baseSize.expand(thumb->style()->width().calcMinValue(0), thumb->style()->height().calcMinValue(0)); } LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); IntSize oldSize = size(); setSize(baseSize); computeLogicalWidth(); computeLogicalHeight(); updateLayerTransform(); if (thumb) { if (oldSize != size()) thumb->setChildNeedsLayout(true, false); LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), style()->isFlippedBlocksWritingMode()); IntRect oldThumbRect = thumb->frameRect(); thumb->layoutIfNeeded(); IntRect rect = thumbRect(); thumb->setFrameRect(rect); if (thumb->checkForRepaintDuringLayout()) thumb->repaintDuringLayoutIfMoved(oldThumbRect); statePusher.pop(); addOverflowFromChild(thumb); } repainter.repaintAfterLayout(); setNeedsLayout(false); }
void ImageListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { if(option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); QSharedPointer<Aqsis::CqImage> img = index.data().value<QSharedPointer<Aqsis::CqImage> >(); // Draw thumbnail int thumbW = std::min(option.rect.height(), option.rect.width()); QRect thumbRect(option.rect.left()+1, option.rect.top()+1, thumbW-2, thumbW-2); const QImage& qimg = img->displayBuffer(); if(!qimg.isNull()) painter->drawImage(thumbRect, qimg, QRect(0,0, qimg.width(), qimg.height())); // Draw filename QRect textRect(option.rect.left() + thumbW + 1, option.rect.top(), option.rect.width(), option.rect.height()); painter->drawText(textRect, 0, QString::fromStdString(img->name())); }
NS_IMETHODIMP nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { // if we are too small to have a thumb don't paint it. nsIBox* thumb = GetChildBox(); if (thumb) { nsRect thumbRect(thumb->GetRect()); nsMargin m; thumb->GetMargin(m); thumbRect.Inflate(m); nsRect crect; GetClientRect(crect); if (crect.width < thumbRect.width || crect.height < thumbRect.height) return NS_OK; } return nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists); }
void EventKnownItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->setRenderHint(QPainter::Antialiasing); QRectF rect = boundingRect(); QColor eventColor = QColor(mData[STATE_COLOR_RED].toInt(), mData[STATE_COLOR_GREEN].toInt(), mData[STATE_COLOR_BLUE].toInt()); painter->setPen(Qt::NoPen); painter->setBrush(eventColor); painter->drawEllipse(rect); if(isSelected()) { painter->setPen(QPen(Painting::mainColorDark, 3.f)); painter->setBrush(Qt::NoBrush); painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); } double side = 40.f; double top = 25.f; QRectF nameRect(rect.x() + side, rect.y() + top, rect.width() - 2*side, mTitleHeight); QRectF thumbRect(rect.x() + side, rect.y() + top + mEltsMargin + mTitleHeight, rect.width() - 2*side, mThumbH); QRectF phasesRect(rect.x() + side, rect.y() + top + 2*mEltsMargin + mTitleHeight + mThumbH, rect.width() - 2*side, mPhasesHeight); phasesRect.adjust(1, 1, -1, -1); // Name QFont font = qApp->font(); painter->setFont(font); QFontMetrics metrics(font); QString name = mData[STATE_NAME].toString(); name = metrics.elidedText(name, Qt::ElideRight, nameRect.width()); QColor frontColor = getContrastedColor(eventColor); painter->setPen(frontColor); painter->drawText(nameRect, Qt::AlignCenter, name); // Thumb painter->drawPixmap(thumbRect, mThumb, mThumb.rect()); // Phases QJsonArray phases = getPhases(); int numPhases = (int)phases.size(); double w = phasesRect.width()/numPhases; for(int i=0; i<numPhases; ++i) { QJsonObject phase = phases[i].toObject(); QColor c(phase[STATE_COLOR_RED].toInt(), phase[STATE_COLOR_GREEN].toInt(), phase[STATE_COLOR_BLUE].toInt()); painter->setPen(c); painter->setBrush(c); painter->drawRect(phasesRect.x() + i*w, phasesRect.y(), w, phasesRect.height()); } if(numPhases == 0) { QFont font = qApp->font(); font.setPointSizeF(pointSize(11)); painter->setFont(font); painter->fillRect(phasesRect, QColor(0, 0, 0, 180)); painter->setPen(QColor(200, 200, 200)); painter->drawText(phasesRect, Qt::AlignCenter, tr("No Phase")); } painter->setPen(QColor(0, 0, 0)); painter->setBrush(Qt::NoBrush); painter->drawRect(phasesRect); /*if(mGreyedOut) { painter->setPen(Painting::greyedOut); painter->setBrush(Painting::greyedOut); painter->drawEllipse(boundingRect()); }*/ // Border painter->setBrush(Qt::NoBrush); if(mMergeable) { painter->setPen(QPen(Qt::white, 5.f)); painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); painter->setPen(QPen(Painting::mainColorLight, 3.f, Qt::DashLine)); painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); } else if(isSelected()) { painter->setPen(QPen(Qt::white, 5.f)); painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); painter->setPen(QPen(Qt::red, 3.f)); painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); } }
bool ScrollbarThemeGtk::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect) { if (graphicsContext->paintingDisabled()) return false; // Create the ScrollbarControlPartMask based on the damageRect ScrollbarControlPartMask scrollMask = NoPart; IntRect backButtonStartPaintRect; IntRect backButtonEndPaintRect; IntRect forwardButtonStartPaintRect; IntRect forwardButtonEndPaintRect; if (hasButtons(scrollbar)) { backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart, true); if (damageRect.intersects(backButtonStartPaintRect)) scrollMask |= BackButtonStartPart; backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, true); if (damageRect.intersects(backButtonEndPaintRect)) scrollMask |= BackButtonEndPart; forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButtonStartPart, true); if (damageRect.intersects(forwardButtonStartPaintRect)) scrollMask |= ForwardButtonStartPart; forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEndPart, true); if (damageRect.intersects(forwardButtonEndPaintRect)) scrollMask |= ForwardButtonEndPart; } IntRect trackPaintRect = trackRect(scrollbar, true); if (damageRect.intersects(trackPaintRect)) scrollMask |= TrackBGPart; if (m_troughUnderSteppers && (scrollMask & BackButtonStartPart || scrollMask & BackButtonEndPart || scrollMask & ForwardButtonStartPart || scrollMask & ForwardButtonEndPart)) scrollMask |= TrackBGPart; bool thumbPresent = hasThumb(scrollbar); IntRect currentThumbRect; if (thumbPresent) { IntRect track = trackRect(scrollbar, false); currentThumbRect = thumbRect(scrollbar, track); if (damageRect.intersects(currentThumbRect)) scrollMask |= ThumbPart; } ScrollbarControlPartMask allButtons = BackButtonStartPart | BackButtonEndPart | ForwardButtonStartPart | ForwardButtonEndPart; if (scrollMask & TrackBGPart || scrollMask & ThumbPart || scrollMask & allButtons) paintScrollbarBackground(graphicsContext, scrollbar); paintTrackBackground(graphicsContext, scrollbar, trackPaintRect); // Paint the back and forward buttons. if (scrollMask & BackButtonStartPart) paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackButtonStartPart); if (scrollMask & BackButtonEndPart) paintButton(graphicsContext, scrollbar, backButtonEndPaintRect, BackButtonEndPart); if (scrollMask & ForwardButtonStartPart) paintButton(graphicsContext, scrollbar, forwardButtonStartPaintRect, ForwardButtonStartPart); if (scrollMask & ForwardButtonEndPart) paintButton(graphicsContext, scrollbar, forwardButtonEndPaintRect, ForwardButtonEndPart); // Paint the thumb. if (scrollMask & ThumbPart) paintThumb(graphicsContext, scrollbar, currentThumbRect); return true; }
void tcOptionsView::Draw() { static unsigned int drawCount = 0; std::string activeTab = GetTab(); StartDraw(); wxASSERT(mpOptions); UpdateButtonInfo(); std::vector<tcOptions::OptionInfo>& optionList = mpOptions->maOptionInfo; for(size_t k=0; k<buttonInfo.size(); k++) { if (!buttonInfo[k].isSlider) { int optionIdx = buttonInfo[k].optionIdx; int valueIdx = buttonInfo[k].valueIdx; tcString sText = optionList[optionIdx].mzCaption[valueIdx]; float x = (float)buttonInfo[k].textX; float y = (float)buttonInfo[k].textY; DrawText(sText.c_str(), x, y, defaultFont.get(), Vec4(0.86f, 0.86f, 1.0f, 1.0f), fontSize, LEFT_CENTER); if (optionList[optionIdx].mnValue == valueIdx) { DrawButton(buttonInfo[k].buttonX, buttonInfo[k].buttonY, 1); } else { DrawButton(buttonInfo[k].buttonX, buttonInfo[k].buttonY, 0); } } else { int optionIdx = buttonInfo[k].optionIdx; tcString sText = optionList[optionIdx].mzCaption[0]; bool thisSliderActive = sliderDragActive && (sliderIdx == k); float sliderVal = thisSliderActive ? sliderDragValue : optionList[optionIdx].floatVal; float sliderMin = optionList[optionIdx].floatMin; float sliderMax = optionList[optionIdx].floatMax; float sliderFraction = (sliderVal - sliderMin) / (sliderMax - sliderMin); float xText = (float)buttonInfo[k].textX; float yText = (float)buttonInfo[k].textY; float xBar = (float)buttonInfo[k].buttonX; float yBar = (float)buttonInfo[k].buttonY; DrawText(sText.c_str(), xText, yText, defaultFont.get(), Vec4(0.86f, 0.86f, 1.0f, 1.0f), fontSize, LEFT_CENTER); float xThumb = xBar + sliderFraction*sliderBarWidth; tcRect thumbRect(xThumb-2.0f, xThumb+2.0f, yBar-8.0f, yBar+8.0f); buttonInfo[k].thumbRect = thumbRect; // draw slider here DrawSlider(xBar, yBar, thumbRect, sliderVal, thisSliderActive); } } FinishDraw(); }
NS_IMETHODIMP nsSliderFrame::DoLayout(nsBoxLayoutState& aState) { // get the thumb should be our only child nsIBox* thumbBox = GetChildBox(); if (!thumbBox) { SyncLayout(aState); return NS_OK; } EnsureOrient(); #ifdef DEBUG_LAYOUT if (mState & NS_STATE_DEBUG_WAS_SET) { if (mState & NS_STATE_SET_TO_DEBUG) SetDebug(aState, PR_TRUE); else SetDebug(aState, PR_FALSE); } #endif // get the content area inside our borders nsRect clientRect; GetClientRect(clientRect); // get the scrollbar nsIBox* scrollbarBox = GetScrollbar(); nsCOMPtr<nsIContent> scrollbar; scrollbar = GetContentOfBox(scrollbarBox); // get the thumb's pref size nsSize thumbSize = thumbBox->GetPrefSize(aState); if (IsHorizontal()) thumbSize.height = clientRect.height; else thumbSize.width = clientRect.width; PRInt32 curPos = GetCurrentPosition(scrollbar); PRInt32 minPos = GetMinPosition(scrollbar); PRInt32 maxPos = GetMaxPosition(scrollbar); PRInt32 pageIncrement = GetPageIncrement(scrollbar); maxPos = NS_MAX(minPos, maxPos); curPos = NS_MAX(minPos, NS_MIN(curPos, maxPos)); nscoord& availableLength = IsHorizontal() ? clientRect.width : clientRect.height; nscoord& thumbLength = IsHorizontal() ? thumbSize.width : thumbSize.height; if ((pageIncrement + maxPos - minPos) > 0 && thumbBox->GetFlex(aState) > 0) { float ratio = float(pageIncrement) / float(maxPos - minPos + pageIncrement); thumbLength = NS_MAX(thumbLength, NSToCoordRound(availableLength * ratio)); } // Round the thumb's length to device pixels. nsPresContext* presContext = PresContext(); thumbLength = presContext->DevPixelsToAppUnits( presContext->AppUnitsToDevPixels(thumbLength)); // mRatio translates the thumb position in app units to the value. mRatio = (minPos != maxPos) ? float(availableLength - thumbLength) / float(maxPos - minPos) : 1; // in reverse mode, curpos is reversed such that lower values are to the // right or bottom and increase leftwards or upwards. In this case, use the // offset from the end instead of the beginning. PRBool reverse = mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir, nsGkAtoms::reverse, eCaseMatters); nscoord pos = reverse ? (maxPos - curPos) : (curPos - minPos); // set the thumb's coord to be the current pos * the ratio. nsRect thumbRect(clientRect.x, clientRect.y, thumbSize.width, thumbSize.height); PRInt32& thumbPos = (IsHorizontal() ? thumbRect.x : thumbRect.y); thumbPos += NSToCoordRound(pos * mRatio); nsRect oldThumbRect(thumbBox->GetRect()); LayoutChildAt(aState, thumbBox, thumbRect); SyncLayout(aState); // Redraw only if thumb changed size. if (oldThumbRect != thumbRect) Redraw(aState); return NS_OK; }