+ event->accept();
+}
+
+
+// virtual
+void SmallRuler::leaveEvent(QEvent * event)
+{
+ QWidget::leaveEvent(event);
+ if (m_cursorColor == palette().highlight()) {
+ m_cursorColor = palette().text();
+ update();
+ }
+}
+
+// virtual
+void SmallRuler::mouseMoveEvent(QMouseEvent * event)
+{
+ const int pos = event->x() / m_scale;
+ if (event->buttons() & Qt::LeftButton) {
+ if (pos != m_lastSeekPosition && pos != m_cursorFramePosition) {
+ m_render->seekToFrame(pos);
+ m_lastSeekPosition = pos;
+ update();
+ }
+ }
+ else {
+ if (m_cursorColor == palette().text() && qAbs(pos - m_cursorFramePosition) * m_scale < 7) {
+ // Mouse is over cursor
+ m_cursorColor = palette().highlight();
+ update();
+ }
+ else if (m_cursorColor == palette().highlight() && qAbs(pos - m_cursorFramePosition) * m_scale >= 7) {
+ m_cursorColor = palette().text();
+ update();
+ }
+ if (qAbs((pos - m_zoneStart) * m_scale) < 4) {
+ setToolTip(i18n("Zone start: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneStart)));
+ } else if (qAbs((pos - m_zoneEnd) * m_scale) < 4) {
+ setToolTip(i18n("Zone end: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneEnd)));
+ } else if (pos > m_zoneStart && pos < m_zoneEnd) {
+ setToolTip(i18n("Zone duration: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneEnd - m_zoneStart)));
+ } else setToolTip(i18n("Position: %1", m_manager->timecode().getTimecodeFromFrames(pos)));
+ }
+ event->accept();
+}
+
+void SmallRuler::refreshRuler()
+{
+ m_lastSeekPosition = SEEK_INACTIVE;
+ update();
+}
+
+bool SmallRuler::slotNewValue(int value)
+{
+ if (value == m_cursorFramePosition) return false;
+ if (value == m_lastSeekPosition) m_lastSeekPosition = SEEK_INACTIVE;
+ m_cursorFramePosition = value;
+ /*int oldPos = m_cursorPosition;
+ m_cursorPosition = value * m_scale;
+ const int offset = 6;
+ const int x = qMin(oldPos, m_cursorPosition);
+ const int w = qAbs(oldPos - m_cursorPosition);
+ update(x - offset, 0, w + 2 * offset, height());*/
+ update();
+ return true;
+}
+
+
+//virtual
+void SmallRuler::resizeEvent(QResizeEvent *)
+{
+ adjustScale(m_maxval);
+}
+
+void SmallRuler::updatePixmap()
+{
+ m_pixmap = QPixmap(width(), height());
+ m_pixmap.fill(palette().window().color());
+ m_lastSeekPosition = SEEK_INACTIVE;
+ QPainter p(&m_pixmap);
+ double f, fend;
+
+ const int zoneStart = (int)(m_zoneStart * m_scale);
+ const int zoneEnd = (int)(m_zoneEnd * m_scale);
+ p.setPen(Qt::NoPen);
+ p.setBrush(m_zoneBrush.brush(this));
+ p.drawRect(zoneStart, height() / 2 - 1, zoneEnd - zoneStart, height() / 2);
+
+ // draw ruler
+ p.setPen(palette().text().color());
+ // draw the little marks
+ fend = m_scale * m_small;
+ if (fend > 2) for (f = 0; f < width(); f += fend) {
+ p.drawLine((int)f, 0, (int)f, 3);
+ }
+
+ // draw medium marks
+ fend = m_scale * m_medium;
+ if (fend > 2) for (f = 0; f < width(); f += fend) {
+ p.drawLine((int)f, 0, (int)f, 6);
+ }
+ // draw markers
+ if (!m_markers.isEmpty()) {
+ for (int i = 0; i < m_markers.count(); i++) {
+ int pos = m_markers.at(i).time().frames(m_manager->timecode().fps()) * m_scale;
+ p.setPen(CommentedTime::markerColor(m_markers.at(i).markerType()));
+ p.drawLine(pos, 0, pos, 9);
+ }
+ }
+ p.end();
+ update();