/*! * \brief Returns the resize handle corresponding to a given point. * * \param point The point to be tested for collision with handles. * \param handles The mask indicating the handle areas to be tested. * \param rect The rectangle around which resize handles are to be tested. */ Caneda::ResizeHandle Painting::handleHitTest(const QPointF& point, Caneda::ResizeHandles handles, const QRectF& rect) { if(handles == Caneda::NoHandle) { return Caneda::NoHandle; } if(handles.testFlag(Caneda::TopLeftHandle)) { if(handleRect().translated(rect.topLeft()).contains(point)) { return Caneda::TopLeftHandle; } } if(handles.testFlag(Caneda::TopRightHandle)) { if(handleRect().translated(rect.topRight()).contains(point)) { return Caneda::TopRightHandle; } } if(handles.testFlag(Caneda::BottomLeftHandle)){ if(handleRect().translated(rect.bottomLeft()).contains(point)) { return Caneda::BottomLeftHandle; } } if(handles.testFlag(Caneda::BottomRightHandle)){ if(handleRect().translated(rect.bottomRight()).contains(point)) { return Caneda::BottomRightHandle; } } return Caneda::NoHandle; }
bool UnicornVolumeSlider::sliderEventFilter( QSlider* slider, QEvent* e ) const { switch( e->type()) { case QEvent::Paint: { QPaintEvent* event = static_cast< QPaintEvent*>(e); QPainter p( slider ); p.setClipRect( event->rect()); int midX = qRound( slider->rect().width() / 2.0f ); QPixmap pm( ":/RadioControls/volume/handle.png" ); p.setPen( QPen( QColor( 0x10, 0x10, 0x10 ), 2, Qt::SolidLine, Qt::RoundCap ) ); p.drawLine( midX, slider->rect().top() + (pm.height() / 2), midX, slider->rect().bottom() - (pm.height() / 2) ); int handleY = slider->height() - pm.height() - ((slider->height() - pm.height()) * ( slider->value() / qreal(slider->maximum()))); QRect handleRect( midX - (qreal(pm.width()) / 2.0f), handleY, pm.width(), pm.height()); p.drawPixmap( handleRect, pm ); return true; } default: return false; } }
void RazorPanelPluginPrivate::setMovable(bool movable) { if (mMovable == movable) return; Q_Q(RazorPanelPlugin); mMovable = movable; QMargins m = q->contentsMargins(); if (movable) m.setLeft(m.left() + handleRect().width()); else m.setLeft(m.left() - handleRect().width()); q->setContentsMargins(m); updateStyleSheet(); }
//! Adjust geometry of item to accommodate resize handles. void Painting::adjustGeometry() { // First obtain the shape of the painting item QRectF boundRect = m_paintingRect; QPainterPath _shape = shapeForRect(m_paintingRect); // Now determine how to adjust the bounding rect based on the resize // handles being used. if(m_resizeHandles.testFlag(Caneda::TopLeftHandle)) { QRectF rect = handleRect().translated(m_paintingRect.topLeft()); boundRect |= rect; _shape.addRect(rect); } if(m_resizeHandles.testFlag(Caneda::TopRightHandle)) { QRectF rect = handleRect().translated(m_paintingRect.topRight()); boundRect |= rect; _shape.addRect(rect); } if(m_resizeHandles.testFlag(Caneda::BottomLeftHandle)) { QRectF rect = handleRect().translated(m_paintingRect.bottomLeft()); boundRect |= rect; _shape.addRect(rect); } if(m_resizeHandles.testFlag(Caneda::BottomRightHandle)) { QRectF rect = handleRect().translated(m_paintingRect.bottomRight()); boundRect |= rect; _shape.addRect(rect); } // Extend the shape to allow for a thick selection band. This is // specially usefull when trying to select diagonal lines or arrows. QPainterPathStroker stroker; stroker.setWidth(10); _shape = stroker.createStroke(_shape); setShapeAndBoundRect(_shape, boundRect, m_pen.widthF()); update(); }
void QvisKeyframeDrawer::drawPlotRange(QPainter *p, const QRect &r, int start, int end, bool highlight, int activePoint) { // Draw the background. drawBackground(p, r); // draw the big bar int x0 = getX(start); int xn = getX(end); int y=rect.y() + rect.height()/2; p->fillRect(x0, y-6, xn-x0, 13, highlight ? kfPlotRangeH : kfPlotRange); QRect r2(rect.x(), y-6, rect.width(), 13); if(start != end) drawVerticalLines(p, r2, start, end, kfPlotRangeLines); // Draw the end points. p->fillRect(handleRect(start), (activePoint==0) ? kfHandleH : kfHandle); p->fillRect(handleRect(end), (activePoint==1) ? kfHandleH : kfHandle); }
void ControlSlider::mousePressEvent(QMouseEvent *event) { setSliderDown(true); if(handleRect().contains(event->pos())) { handlePressed = true; setSliderDown(true); int sliderValue = style()->sliderValueFromPosition(minimum(),maximum(),event->pos().x()-6,width()-12); setValue(sliderValue); } }
/*! Mouse press event handler \param event Mouse event */ void QwtSlider::mousePressEvent( QMouseEvent *event ) { if ( isReadOnly() ) { event->ignore(); return; } const QPoint pos = event->pos(); if ( isValid() && d_data->sliderRect.contains( pos ) ) { if ( !handleRect().contains( pos ) ) { const int markerPos = transform( value() ); d_data->stepsIncrement = pageSteps(); if ( d_data->orientation == Qt::Horizontal ) { if ( pos.x() < markerPos ) d_data->stepsIncrement = -d_data->stepsIncrement; } else { if ( pos.y() < markerPos ) d_data->stepsIncrement = -d_data->stepsIncrement; } if ( isInverted() ) d_data->stepsIncrement = -d_data->stepsIncrement; const double v = value(); incrementValue( d_data->stepsIncrement ); if ( v != value() ) { if ( isTracking() ) Q_EMIT valueChanged( value() ); else d_data->pendingValueChange = true; Q_EMIT sliderMoved( value() ); } d_data->timerTick = false; d_data->repeatTimerId = startTimer( qMax( 250, 2 * updateInterval() ) ); return; } } QwtAbstractSlider::mousePressEvent( event ); }
/*! Draw the thumb at a position \param painter Painter \param sliderRect Bounding rectangle of the slider \param pos Position of the slider thumb */ void QwtSlider::drawHandle( QPainter *painter, const QRect &sliderRect, int pos ) const { const int bw = d_data->borderWidth; pos++; // shade line points one pixel below if ( orientation() == Qt::Horizontal ) { QRect handleRect( pos - d_data->handleSize.width() / 2, sliderRect.y(), d_data->handleSize.width(), sliderRect.height() ); qDrawShadePanel( painter, handleRect, palette(), false, bw, &palette().brush( QPalette::Button ) ); qDrawShadeLine( painter, pos, sliderRect.top() + bw, pos, sliderRect.bottom() - bw, palette(), true, 1 ); } else // Vertical { QRect handleRect( sliderRect.left(), pos - d_data->handleSize.height() / 2, sliderRect.width(), d_data->handleSize.height() ); qDrawShadePanel( painter, handleRect, palette(), false, bw, &palette().brush( QPalette::Button ) ); qDrawShadeLine( painter, sliderRect.left() + bw, pos, sliderRect.right() - bw, pos, palette(), true, 1 ); } }
/*! \brief Determine what to do when the user presses a mouse button. \param pos Mouse position \retval True, when handleRect() contains pos \sa scrolledTo() */ bool QwtSlider::isScrollPosition( const QPoint &pos ) const { if ( handleRect().contains( pos ) ) { const double v = ( orientation() == Qt::Horizontal ) ? pos.x() : pos.y(); d_data->mouseOffset = v - transform( value() ); return true; } return false; }
CropHandle RegionFrameItem::Private::handleAt(const QPointF& pos) const { if (flags & ShowResizeHandles) { foreach(const CropHandle& handle, cropHandleList) { QRectF rect = handleRect(handle); if (rect.contains(pos)) { return handle; } }
void KoParameterShape::paintHandle(QPainter & painter, const KoViewConverter & converter, int handleId, int handleRadius) { applyConversion(painter, converter); QMatrix worldMatrix = painter.worldMatrix(); painter.setMatrix(QMatrix()); QMatrix matrix; matrix.rotate(45.0); QPolygonF poly(handleRect(QPointF(0, 0), handleRadius)); poly = matrix.map(poly); poly.translate(worldMatrix.map(m_handles[handleId])); painter.drawPolygon(poly); }
/*! Draw the slider into the specified rectangle. \param painter Painter \param sliderRect Bounding rectangle of the slider */ void QwtSlider::drawSlider( QPainter *painter, const QRect &sliderRect ) const { QRect innerRect( sliderRect ); if ( d_data->hasTrough ) { const int bw = d_data->borderWidth; innerRect = sliderRect.adjusted( bw, bw, -bw, -bw ); painter->fillRect( innerRect, palette().brush( QPalette::Mid ) ); qDrawShadePanel( painter, sliderRect, palette(), true, bw, NULL ); } const QSize handleSize = qwtHandleSize( d_data->handleSize, d_data->orientation, d_data->hasTrough ); if ( d_data->hasGroove ) { const int slotExtent = 4; const int slotMargin = 4; QRect slotRect; if ( orientation() == Qt::Horizontal ) { int slotOffset = qMax( 1, handleSize.width() / 2 - slotMargin ); int slotHeight = slotExtent + ( innerRect.height() % 2 ); slotRect.setWidth( innerRect.width() - 2 * slotOffset ); slotRect.setHeight( slotHeight ); } else { int slotOffset = qMax( 1, handleSize.height() / 2 - slotMargin ); int slotWidth = slotExtent + ( innerRect.width() % 2 ); slotRect.setWidth( slotWidth ); slotRect.setHeight( innerRect.height() - 2 * slotOffset ); } slotRect.moveCenter( innerRect.center() ); QBrush brush = palette().brush( QPalette::Dark ); qDrawShadePanel( painter, slotRect, palette(), true, 1 , &brush ); } if ( isValid() ) drawHandle( painter, handleRect(), transform( value() ) ); }
QRectF KisTransformUtils::handleRect(qreal radius, const QTransform &t, const QRectF &limitingRect, qreal *dOut) { qreal handlesExtraScale = scaleFromPerspectiveMatrix(t, limitingRect.center()); const qreal maxD = 0.2 * effectiveSize(limitingRect); const qreal d = qMin(maxD, radius / handlesExtraScale); QRectF handleRect(-0.5 * d, -0.5 * d, d, d); if (dOut) { *dOut = d; } return handleRect; }
/*! * \brief Draw resize handle for painting items. * * \param centrePos The center point of the handle. * \param painter The painter used to draw the handle. */ void Painting::drawResizeHandle(const QPointF ¢rePos, QPainter *painter) { QPen savedPen = painter->pen(); QBrush savedBrush = painter->brush(); Settings *settings = Settings::instance(); painter->setPen(QPen(settings->currentValue("gui/selectionColor").value<QColor>())); painter->setBrush(Qt::NoBrush); // handleRect is defined as QRectF(-w/2, -h/2, w, h) painter->drawRect(handleRect().translated(centrePos)); painter->setPen(savedPen); painter->setBrush(savedBrush); }
//-------------------------------------------------------------------------- void GuiRectHandles::onRender(Point2I offset, const RectI &updateRect) { Parent::onRender( offset, updateRect ); ColorI handleColor = mProfile->mBorderColor; if(mUseCustomColor) handleColor = mHandleColor; // The handles range from 0-1, so scale to fit within the // control's bounds. const Point2I& extent = getExtent(); Point2I pos(extent.x*mHandleRect.point.x, extent.y*mHandleRect.point.y); Point2I size(extent.x*mHandleRect.extent.x, extent.y*mHandleRect.extent.y); RectI box(offset+pos, size); // Draw border GFX->getDrawUtil()->drawRect(box, handleColor); // Draw each handle Point2I handleSize(mHandleSize, mHandleSize); RectI handleRect(box.point, handleSize); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Upper left handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Upper right handleRect.point = Point2I(box.point.x, box.point.y+size.y-handleSize.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Lower left handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y+size.y-handleSize.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Lower right Point2I halfSize = size / 2; Point2I halfHandleSize = handleSize / 2; handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Upper middle handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y+size.y-handleSize.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Lower middle handleRect.point = Point2I(box.point.x, box.point.y+halfSize.y-halfHandleSize.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Left middle handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y+halfSize.y-halfHandleSize.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Right middle handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y+halfSize.y-halfHandleSize.y); GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Middle renderChildControls(offset, updateRect); }
void KoParameterShape::paintHandles(QPainter & painter, const KoViewConverter & converter, int handleRadius) { applyConversion(painter, converter); QMatrix worldMatrix = painter.worldMatrix(); painter.setMatrix(QMatrix()); QMatrix matrix; matrix.rotate(45.0); QPolygonF poly(handleRect(QPointF(0, 0), handleRadius)); poly = matrix.map(poly); QList<QPointF>::const_iterator it(m_handles.constBegin()); for (; it != m_handles.constEnd(); ++it) { QPointF moveVector = worldMatrix.map(*it); poly.translate(moveVector.x(), moveVector.y()); painter.drawPolygon(poly); poly.translate(-moveVector.x(), -moveVector.y()); } }
QPainterPath ControlSlider::handlePath() { QPainterPath path; path.addEllipse(handleRect()); return path; }
void RowArea::drawOnionSkinSelection(QPainter &p) { TApp *app = TApp::instance(); OnionSkinMask osMask = app->getCurrentOnionSkin()->getOnionSkinMask(); TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); assert(xsh); int currentRow = m_viewer->getCurrentRow(); // get onion colors TPixel frontPixel, backPixel; bool inksOnly; Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly); QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128); QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128); int onionDotDiam = 8; int onionHandleDiam = RowHeight - 1; int onionDotYPos = (RowHeight - onionDotDiam) / 2; // If the onion skin is disabled, draw dash line instead. if (osMask.isEnabled()) p.setPen(Qt::red); else { QPen currentPen = p.pen(); currentPen.setStyle(Qt::DashLine); currentPen.setColor(QColor(128, 128, 128, 255)); p.setPen(currentPen); } // Draw onion skin extender handles. QRectF handleRect(3, m_viewer->rowToY(currentRow) + 1, onionHandleDiam, onionHandleDiam); int angle180 = 16 * 180; p.setBrush(QBrush(backColor)); p.drawChord(handleRect, 0, angle180); p.setBrush(QBrush(frontColor)); p.drawChord(handleRect, angle180, angle180); //-- draw movable onions // draw line between onion skin range int minMos = 0; int maxMos = 0; int mosCount = osMask.getMosCount(); for (int i = 0; i < mosCount; i++) { int mos = osMask.getMos(i); if (minMos > mos) minMos = mos; if (maxMos < mos) maxMos = mos; } p.setBrush(Qt::NoBrush); if (minMos < 0) // previous frames { int y0 = m_viewer->rowToY(currentRow + minMos) + onionDotYPos + onionDotDiam; int y1 = m_viewer->rowToY(currentRow); p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1); } if (maxMos > 0) // foward frames { int y0 = m_viewer->rowToY(currentRow + 1); int y1 = m_viewer->rowToY(currentRow + maxMos) + onionDotYPos; p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1); } // draw onion skin dots p.setPen(Qt::red); for (int i = 0; i < mosCount; i++) { // mos : frame offset from the current frame int mos = osMask.getMos(i); // skip drawing if the frame is under the mouse cursor if (m_showOnionToSet == Mos && currentRow + mos == m_row) continue; int y = m_viewer->rowToY(currentRow + mos) + onionDotYPos; if (osMask.isEnabled()) p.setBrush(mos < 0 ? backColor : frontColor); else p.setBrush(Qt::NoBrush); p.drawEllipse(onionDotDiam, y, onionDotDiam, onionDotDiam); } //-- draw fixed onions for (int i = 0; i < osMask.getFosCount(); i++) { int fos = osMask.getFos(i); if (fos == currentRow) continue; // skip drawing if the frame is under the mouse cursor if (m_showOnionToSet == Fos && fos == m_row) continue; int y = m_viewer->rowToY(fos) + onionDotYPos; if (osMask.isEnabled()) p.setBrush(QBrush(QColor(0, 255, 255, 128))); else p.setBrush(Qt::NoBrush); p.drawEllipse(0, y, onionDotDiam, onionDotDiam); } //-- draw highlighted onion if (m_showOnionToSet != None) { int y = m_viewer->rowToY(m_row) + onionDotYPos; int xPos = (m_showOnionToSet == Fos) ? 0 : onionDotDiam; p.setPen(QColor(255, 128, 0)); p.setBrush(QBrush(QColor(255, 255, 0, 200))); p.drawEllipse(xPos, y, onionDotDiam, onionDotDiam); } }
void FilmstripFrameHeadGadget::drawOnionSkinSelection(QPainter &p, const QColor &lightColor, const QColor &darkColor) { int currentRow = getCurrentFrame(); TPixel frontPixel, backPixel; bool inksOnly; Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly); QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128); QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128); OnionSkinMask osMask = TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask(); int mosCount = osMask.getMosCount(); int i; //OnionSkinの円の左上座標のy値 int onionDotYPos = m_dy / 2 - 5; p.setPen(Qt::red); //--- OnionSkinが有効なら実線、無効なら点線 if (!osMask.isEnabled()) { QPen currentPen = p.pen(); currentPen.setStyle(Qt::DashLine); currentPen.setColor(QColor(128, 128, 128, 255)); p.setPen(currentPen); } //カレントフレームにOnionSkinを伸ばすハンドルを描画 { int angle180 = 16 * 180; QRectF handleRect(0, 0, 30, 30); //上向きのハンドル:1フレーム目のときは描画しない if (currentRow > 0) { int y0 = index2y(currentRow) - 15; p.setBrush(QBrush(backColor)); p.drawChord(handleRect.translated(0, y0), 0, angle180); } //下向きのハンドル:最終フレームの時は描画しない std::vector<TFrameId> fids; m_filmstrip->getLevel()->getFids(fids); int frameCount = (int)fids.size(); if (currentRow < frameCount - 1) { int y1 = index2y(currentRow + 1) - 15; p.setBrush(QBrush(frontColor)); p.drawChord(handleRect.translated(0, y1), angle180, angle180); } //--- 動く Onion Skinの描画 その1 //先に線を描く //まず OnionSkinの最大/最小値を取得 int minMos = 0; int maxMos = 0; for (i = 0; i < mosCount; i++) { int mos = osMask.getMos(i); if (minMos > mos) minMos = mos; if (maxMos < mos) maxMos = mos; } p.setBrush(Qt::NoBrush); //min/maxが更新されていたら、線を描く if (minMos < 0) //上方向に伸ばす線 { int y0 = index2y(currentRow + minMos) + onionDotYPos + 10; //10は●の直径 int y1 = index2y(currentRow) - 15; p.drawLine(15, y0, 15, y1); } if (maxMos > 0) //下方向に伸ばす線 { int y0 = index2y(currentRow + 1) + 15; int y1 = index2y(currentRow + maxMos) + onionDotYPos; p.drawLine(15, y0, 15, y1); } } //--- Fix Onion Skinの描画 for (i = 0; i < osMask.getFosCount(); i++) { int fos = osMask.getFos(i); //if(fos == currentRow) continue; int y = index2y(fos) + onionDotYPos; p.setPen(Qt::red); //OnionSkinがDisableなら中空にする p.setBrush(osMask.isEnabled() ? QBrush(QColor(0, 255, 255, 128)) : Qt::NoBrush); p.drawEllipse(0, y, 10, 10); } //--- //--- 動く Onion Skinの描画 その2 //続いて、各OnionSkinの●を描く p.setPen(Qt::red); for (i = 0; i < mosCount; i++) { //mosはOnionSkinの描かれるフレームのオフセット値 int mos = osMask.getMos(i); //100312 iwasawa ハイライトする場合は後で描くのでスキップする if (currentRow + mos == m_highlightedMosFrame) continue; int y = index2y(currentRow + mos) + onionDotYPos; p.setBrush(mos < 0 ? backColor : frontColor); p.drawEllipse(10, y, 10, 10); } //Fix Onion Skin ハイライトの描画 FixOnionSkinがマウスが乗ってハイライトされていて、 //かつ 現在のフレームでないときに描画 if (m_highlightedFosFrame >= 0 && m_highlightedFosFrame != currentRow) { p.setPen(QColor(255, 128, 0)); p.setBrush(QBrush(QColor(255, 255, 0, 200))); p.drawEllipse(0, index2y(m_highlightedFosFrame) + onionDotYPos, 10, 10); } //通常のOnion Skin ハイライトの描画 if (m_highlightedMosFrame >= 0 && m_highlightedMosFrame != currentRow) { p.setPen(QColor(255, 128, 0)); p.setBrush(QBrush(QColor(255, 255, 0, 200))); p.drawEllipse(10, index2y(m_highlightedMosFrame) + onionDotYPos, 10, 10); } }
void HighlightScrollBarOverlay::paintEvent(QPaintEvent *paintEvent) { QWidget::paintEvent(paintEvent); updateCache(); if (m_highlightCache.isEmpty()) return; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, false); const QRect &gRect = overlayRect(); const QRect &hRect = handleRect(); const int marginX = 3; const int marginH = -2 * marginX + 1; const QRect aboveHandleRect = QRect(gRect.x() + marginX, gRect.y(), gRect.width() + marginH, hRect.y() - gRect.y()); const QRect handleRect = QRect(gRect.x() + marginX, hRect.y(), gRect.width() + marginH, hRect.height()); const QRect belowHandleRect = QRect(gRect.x() + marginX, hRect.y() + hRect.height(), gRect.width() + marginH, gRect.height() - hRect.height() + gRect.y() - hRect.y()); const int aboveValue = m_scrollBar->value(); const int belowValue = m_scrollBar->maximum() - m_scrollBar->value(); const int sizeDocAbove = aboveValue * int(m_highlightController->lineHeight()); const int sizeDocBelow = belowValue * int(m_highlightController->lineHeight()); const int sizeDocVisible = int(m_highlightController->visibleRange()); const int scrollBarBackgroundHeight = aboveHandleRect.height() + belowHandleRect.height(); const int sizeDocInvisible = sizeDocAbove + sizeDocBelow; const double backgroundRatio = sizeDocInvisible ? ((double)scrollBarBackgroundHeight / sizeDocInvisible) : 0; if (aboveValue) { drawHighlights(&painter, 0, sizeDocAbove, backgroundRatio, 0, aboveHandleRect); } if (belowValue) { // This is the hypothetical handle height if the handle would // be stretched using the background ratio. const double handleVirtualHeight = sizeDocVisible * backgroundRatio; // Skip the doc above and visible part. const int offset = qRound(aboveHandleRect.height() + handleVirtualHeight); drawHighlights(&painter, sizeDocAbove + sizeDocVisible, sizeDocBelow, backgroundRatio, offset, belowHandleRect); } const double handleRatio = sizeDocVisible ? ((double)handleRect.height() / sizeDocVisible) : 0; // This is the hypothetical handle position if the background would // be stretched using the handle ratio. const double aboveVirtualHeight = sizeDocAbove * handleRatio; // This is the accurate handle position (double) const double accurateHandlePos = sizeDocAbove * backgroundRatio; // The correction between handle position (int) and accurate position (double) const double correction = aboveHandleRect.height() - accurateHandlePos; // Skip the doc above and apply correction const int offset = qRound(aboveVirtualHeight + correction); drawHighlights(&painter, sizeDocAbove, sizeDocVisible, handleRatio, offset, handleRect); }