-// virtual
-void CustomRuler::paintEvent(QPaintEvent * /*e*/)
- {
- // debug ("KRuler::drawContents, %s",(horizontal==dir)?"horizontal":"vertical");
-
- QStylePainter p(this);
-
-
- int value = this->value(),
- minval = minimum(),
- maxval;
- 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(offsetmin, 0, offsetmax, height());
-
- QPalette palette;
- //p.fillRect(bg, palette.light());
- // draw labels
- QFont font = p.font();
- font.setPointSize(LABEL_SIZE);
- p.setFont( font );
- 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);
- }
- }*/
- 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);
- if (fend > 60) {
- QString lab = m_timecode.getTimecodeFromFrames((int) ((f - offsetmin) / pixelPerMark() / FRAME_SIZE + 0.5));
- p.drawText( (int)f + 2, LABEL_SIZE, lab );
- }
- }
- }
- if (showMediumMarks()) {
- // draw medium marks
- fend = pixelPerMark()*mediumMarkDistance();
- if (fend > 5) for ( f=offsetmin; f<offsetmax; f+=fend ) {
- p.drawLine((int)f, MIDDLE_MARK_X1, (int)f, MIDDLE_MARK_X2);
- if (fend > 60) {
- QString lab = m_timecode.getTimecodeFromFrames((int) ((f - offsetmin) / pixelPerMark() / FRAME_SIZE + 0.5) );
- p.drawText( (int)f + 2, LABEL_SIZE, lab );
- }
- }
- }
- if (showBigMarks()) {
- // draw big marks
- fend = pixelPerMark()*bigMarkDistance();
- if (fend > 5) for ( f=offsetmin; f<offsetmax; f+=fend ) {
- p.drawLine((int)f, BIG_MARK_X1, (int)f, BIG_MARK_X2);
- if (fend > 60) {
- QString lab = m_timecode.getTimecodeFromFrames((int) ((f - offsetmin) / pixelPerMark() / FRAME_SIZE + 0.5) );
- p.drawText( (int)f + 2, LABEL_SIZE, lab );
- }
- else if (((int) (f - offsetmin)) % ((int)(fend * 5)) == 0) {
- QString lab = m_timecode.getTimecodeFromFrames((int) ((f - offsetmin) / pixelPerMark() / FRAME_SIZE + 0.5) );
- p.drawText( (int)f + 2, LABEL_SIZE, lab );
- }
- }
- }
-/* if (d->showem) {
- // draw end marks
- if (d->dir == Qt::Horizontal) {
- p.drawLine(minval-d->offset, END_MARK_X1, minval-d->offset, END_MARK_X2);
- p.drawLine(maxval-d->offset, END_MARK_X1, maxval-d->offset, END_MARK_X2);
- }
- else {
- p.drawLine(END_MARK_X1, minval-d->offset, END_MARK_X2, minval-d->offset);
- p.drawLine(END_MARK_X1, maxval-d->offset, END_MARK_X2, maxval-d->offset);
- }
- }*/
-
- // draw pointer
- if (showPointer()) {
- QPolygon pa(4);
- pa.setPoints(3, value-6, 9, value+6, 9, value/*+0*/, 16);
- p.setBrush( QBrush(Qt::yellow) );
- p.drawPolygon( pa );
- }
-
- }
+// virtual
+void CustomRuler::paintEvent(QPaintEvent *e)
+{
+ QStylePainter p(this);
+ p.setClipRect(e->rect());
+ const int projectEnd = (int)(m_duration * m_factor);
+ p.fillRect(0, 0, projectEnd - m_offset, height(), palette().alternateBase().color());
+
+ const int zoneStart = (int)(m_zoneStart * m_factor);
+ const int zoneEnd = (int)(m_zoneEnd * m_factor);
+ const QRect zoneRect();
+
+ p.fillRect(zoneStart - m_offset, height() / 2, zoneEnd - zoneStart, height() / 2, m_zoneColor);
+
+ const int value = m_view->cursorPos() * m_factor - m_offset;
+ int minval = (e->rect().left() + m_offset) / FRAME_SIZE - 1;
+ const int maxval = (e->rect().right() + m_offset) / FRAME_SIZE + 1;
+ if (minval < 0) minval = 0;
+
+ double f, fend;
+ const int offsetmax = maxval * FRAME_SIZE;
+
+ p.setPen(palette().dark().color());
+
+ // draw time labels
+ int offsetmin = (e->rect().left() + m_offset) / m_textSpacing;
+ offsetmin = offsetmin * m_textSpacing;
+ for (f = offsetmin; f < offsetmax; f += m_textSpacing) {
+ QString lab = m_timecode.getTimecodeFromFrames((int)(f / m_factor + 0.5));
+
+ p.drawText(f - m_offset + 2, LABEL_SIZE, lab);
+ }
+
+ offsetmin = (e->rect().left() + m_offset) / littleMarkDistance;
+ offsetmin = offsetmin * littleMarkDistance;
+ // draw the little marks
+ fend = m_scale * littleMarkDistance;
+ if (fend > 5) for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
+ p.drawLine((int)f, LITTLE_MARK_X1, (int)f, LITTLE_MARK_X2);
+
+ offsetmin = (e->rect().left() + m_offset) / mediumMarkDistance;
+ offsetmin = offsetmin * mediumMarkDistance;
+ // draw medium marks
+ fend = m_scale * mediumMarkDistance;
+ if (fend > 5) for (f = offsetmin - m_offset - fend; f < offsetmax - m_offset + fend; f += fend)
+ p.drawLine((int)f, MIDDLE_MARK_X1, (int)f, MIDDLE_MARK_X2);
+
+ offsetmin = (e->rect().left() + m_offset) / bigMarkDistance;
+ offsetmin = offsetmin * bigMarkDistance;
+ // draw big marks
+ fend = m_scale * bigMarkDistance;
+ if (fend > 5) for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
+ p.drawLine((int)f, BIG_MARK_X1, (int)f, BIG_MARK_X2);
+
+ // draw zone cursors
+ int off = offset();
+ if (zoneStart > 0) {
+ QPolygon pa(4);
+ pa.setPoints(4, zoneStart - off + 3, 9, zoneStart - off, 9, zoneStart - off, 18, zoneStart - off + 3, 18);
+ p.drawPolyline(pa);
+ }
+
+ if (zoneEnd > 0) {
+ QRect rec(zoneStart - off + (zoneEnd - zoneStart) / 2 - 4, 9, 8, 9);
+ p.fillRect(rec, QColor(255, 255, 255, 150));
+ p.drawRect(rec);
+
+ QPolygon pa(4);
+ pa.setPoints(4, zoneEnd - off - 3, 9, zoneEnd - off, 9, zoneEnd - off, 18, zoneEnd - off - 3, 18);
+ p.drawPolyline(pa);
+ }
+
+ // draw pointer
+ QPolygon pa(3);
+ pa.setPoints(3, value - 6, 8, value + 6, 8, value, 16);
+ p.setBrush(palette().highlight());
+ p.drawPolygon(pa);
+}