Пример #1
0
void TrackView::paintTracks(QStylePainter &painter, const QRegion &region)
{
	const QRect &rect = region.boundingRect();
	int startTrack = qBound(0, getTrackFromPhysicalX(qMax(rect.left(), leftMarginWidth)), getTrackCount());
	int endTrack = qBound(0, getTrackFromPhysicalX(rect.right()) + 1, getTrackCount());

	painter.setClipRect(QRectF(QPointF(leftMarginWidth - 0.5f, topMarginHeight - 0.5f),
	                           QPointF(rect.right() + 1.0f, rect.bottom() + 1.0f)));
	painter.fillRect(rect, palette().dark());

	for (int track = startTrack; track < endTrack; ++track)
		paintTrack(painter, region, track);
}
Пример #2
0
void TrackView::paintTopMargin(QStylePainter &painter, const QRegion &region)
{
	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));
}
Пример #3
0
void TrackView::paintLeftMargin(QStylePainter &painter, const QRegion &region)
{
	const QRect &rect = region.boundingRect();
	const SyncDocument *doc = getDocument();

	int firstRow = qBound(0, getRowFromPhysicalY(qMax(rect.top(), topMarginHeight)), getRows() - 1);
	int lastRow = qBound(0, getRowFromPhysicalY(qMax(rect.bottom(), topMarginHeight)), getRows() - 1);

	painter.setClipRect(QRectF(QPointF(0.0f, topMarginHeight - 0.5f),
	                           QPointF(leftMarginWidth - 0.5f, rect.bottom() + 1.0f)));

	QRectF padding(QPointF(rect.left(), topMarginHeight - 0.5f),
	               QPointF(leftMarginWidth - 0.5f, rect.bottom() + 1.0f));
	painter.fillRect(padding, palette().dark());

	for (int row = firstRow; row <= lastRow; ++row) {
		QRect leftMargin(0, getPhysicalY(row), leftMarginWidth, rowHeight);
		if (!region.intersects(leftMargin))
			continue;

		QBrush fillBrush;
		if (row == editRow)
			fillBrush = editBrush;
		else if (doc->isRowBookmark(row))
			fillBrush = bookmarkBrush;
		else
			fillBrush = palette().button();

		painter.fillRect(leftMargin.adjusted(1, 1, -1, -1), fillBrush);
		qDrawWinButton(&painter, leftMargin, QPalette(fillBrush.color()));

		if ((row % 8) == 0)      painter.setPen(QColor(0, 0, 0));
		else if ((row % 4) == 0) painter.setPen(QColor(64, 64, 64));
		else                     painter.setPen(QColor(128, 128, 128));

		painter.drawText(leftMargin, QString("%1").arg(row, 5, 16, QChar('0')).toUpper() + "h");
	}
}