void TrackView::paintTopMargin(QStylePainter &painter, const QRegion ®ion) { const QRect &rect = region.boundingRect(); painter.setClipRect(QRectF(QPointF(0.0f, 0.0f), QPointF(rect.right() + 1.0f, topMarginHeight - 0.5f))); QRect topMargin(QPoint(-2, 0), QPoint(rect.right() + 3, topMarginHeight - 1)); painter.fillRect(topMargin.adjusted(1, 1, -1, -1), palette().button()); qDrawWinButton(&painter, topMargin, palette()); int startTrack = qBound(0, getTrackFromPhysicalX(qMax(rect.left(), leftMarginWidth)), getTrackCount()); int endTrack = qBound(0, getTrackFromPhysicalX(rect.right()) + 1, getTrackCount()); for (int track = startTrack; track < endTrack; ++track) { const SyncTrack *t = getTrack(track); QRect topMargin(getPhysicalX(track), 0, trackWidth, topMarginHeight); if (!region.intersects(topMargin)) continue; QRect fillRect = topMargin; QBrush bgBrush = palette().button(); if (track == editTrack) bgBrush = editBrush; painter.fillRect(fillRect.adjusted(1, 1, -1, -1), bgBrush); qDrawWinButton(&painter, fillRect, bgBrush.color()); if (!t->isActive()) painter.setPen(QColor(128, 128, 128)); else painter.setPen(QColor(0, 0, 0)); painter.drawText(fillRect, t->getDisplayName()); } // make sure that the top margin isn't overdrawn by the track-data painter.setClipRegion(QRect(0, topMarginHeight, rect.right() + 1, rect.bottom() + 1)); }