- p.setClipRect(e->rect());
-
- //p.fillRect(e->rect(), QBrush(QColor(200, 200, 200)));
- //kDebug()<<"RULER ZONE: "<<m_zoneStart<<", OFF: "<<offset()<<", END: "<<m_zoneEnd<<", FACTOR: "<<pixelPerMark() * FRAME_SIZE;
- int projectEnd = (int)(m_duration * pixelPerMark() * FRAME_SIZE);
- p.fillRect(QRect(- offset(), e->rect().y(), projectEnd, e->rect().height()), QBrush(QColor(245, 245, 245)));
-
-
- int zoneStart = (int)(m_zoneStart * pixelPerMark() * FRAME_SIZE);
- int zoneEnd = (int)(m_zoneEnd * pixelPerMark() * FRAME_SIZE);
-
- p.fillRect(QRect(zoneStart - offset(), e->rect().y() + e->rect().height() / 2, zoneEnd - zoneStart, e->rect().height() / 2), QBrush(QColor(133, 255, 143)));
-
- int value = m_view->cursorPos() - offset();
- int minval = minimum();
- int maxval = maximum() + offset() - endOffset();
-
- //ioffsetval = value-offset;
- // pixelpm = (int)ppm;
- // left = clip.left(),
- // right = clip.right();
- double f, fend,
- offsetmin = (double)(minval - offset()),
- offsetmax = (double)(maxval - offset()),
- fontOffset = (((double)minval) > offsetmin) ? (double)minval : offsetmin;
- QRect bg = QRect((int)offsetmin, 0, (int)offsetmax, height());
-
- QPalette palette;
- //p.fillRect(bg, palette.light());
- // draw labels
- p.setPen(palette.dark().color());
- // draw littlemarklabel
-
- // draw mediummarklabel
-
- // draw bigmarklabel
-
- // draw endlabel
- /*if (d->showEndL) {
- if (d->dir == Qt::Horizontal) {
- p.translate( fontOffset, 0 );
- p.drawText( END_LABEL_X, END_LABEL_Y, d->endlabel );
- }*/
-
- // draw the tiny marks
- //if (showTinyMarks())
- /*{
- fend = pixelPerMark()*tinyMarkDistance();
- if (fend > 5) for ( f=offsetmin; f<offsetmax; f+=fend ) {
- p.drawLine((int)f, BASE_MARK_X1, (int)f, BASE_MARK_X2);
- }
- }*/
-
- for (f = offsetmin; f < offsetmax; f += m_textSpacing) {
- QString lab = m_timecode.getTimecodeFromFrames((int)((f - offsetmin) / pixelPerMark() / FRAME_SIZE + 0.5));
- p.drawText((int)f + 2, LABEL_SIZE, lab);
- }
-
- if (showLittleMarks()) {
- // draw the little marks
- fend = pixelPerMark() * littleMarkDistance();
- if (fend > 5) for (f = offsetmin; f < offsetmax; f += fend)
- p.drawLine((int)f, LITTLE_MARK_X1, (int)f, LITTLE_MARK_X2);
+ const QRect &paintRect = e->rect();
+ p.setClipRect(paintRect);
+
+ // Draw zone background
+ const int zoneStart = (int)(m_zoneStart * m_factor);
+ const int zoneEnd = (int)(m_zoneEnd * m_factor);
+ p.fillRect(zoneStart - m_offset, LABEL_SIZE + 2, zoneEnd - zoneStart, MAX_HEIGHT - LABEL_SIZE - 2, m_zoneColor);
+
+ int minval = (paintRect.left() + m_offset) / FRAME_SIZE - 1;
+ const int maxval = (paintRect.right() + m_offset) / FRAME_SIZE + 1;
+ if (minval < 0)
+ minval = 0;
+
+ double f, fend;
+ const int offsetmax = maxval * FRAME_SIZE;
+ int offsetmin;
+
+ p.setPen(palette().text().color());
+
+ // draw time labels
+ if (paintRect.y() < LABEL_SIZE) {
+ offsetmin = (paintRect.left() + m_offset) / m_textSpacing;
+ offsetmin = offsetmin * m_textSpacing;
+ for (f = offsetmin; f < offsetmax; f += m_textSpacing) {
+ QString lab;
+ if (KdenliveSettings::frametimecode())
+ lab = QString::number((int)(f / m_factor + 0.5));
+ else
+ lab = m_timecode.getTimecodeFromFrames((int)(f / m_factor + 0.5));
+ p.drawText(f - m_offset + 2, LABEL_SIZE, lab);
+ }