From: Till Theato Date: Sat, 22 May 2010 22:08:56 +0000 (+0000) Subject: Make timeline's ruler time labels obey to frame <-> timecode setting X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=cf96b357df6458f9c800270879517dee2755097d;p=kdenlive Make timeline's ruler time labels obey to frame <-> timecode setting svn path=/trunk/kdenlive/; revision=4474 --- diff --git a/src/customruler.cpp b/src/customruler.cpp index 6606b770..8a952693 100644 --- a/src/customruler.cpp +++ b/src/customruler.cpp @@ -335,7 +335,8 @@ void CustomRuler::paintEvent(QPaintEvent *e) 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; + if (minval < 0) + minval = 0; double f, fend; const int offsetmax = maxval * FRAME_SIZE; @@ -346,7 +347,11 @@ void CustomRuler::paintEvent(QPaintEvent *e) 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)); + 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); } @@ -354,22 +359,28 @@ void CustomRuler::paintEvent(QPaintEvent *e) 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) + 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) + 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) + 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(); diff --git a/src/customruler.h b/src/customruler.h index eb6ec3f4..3ebcd107 100644 --- a/src/customruler.h +++ b/src/customruler.h @@ -17,6 +17,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ +/** + * @class CustomRuler + * @author Jean-Baptiste Mardelle + * @brief Manages the timeline ruler. + */ + #ifndef CUSTOMRULER_H #define CUSTOMRULER_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e9a89676..ce4d1d2c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3315,6 +3315,7 @@ void MainWindow::slotUpdateTimecodeFormat(int ix) m_clipMonitor->updateTimecodeFormat(); m_projectMonitor->updateTimecodeFormat(); m_activeTimeline->projectView()->clearSelection(); + m_activeTimeline->updateRuler(); } void MainWindow::slotRemoveFocus() diff --git a/src/mainwindow.h b/src/mainwindow.h index 136de76b..2fea45c0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -388,6 +388,8 @@ private slots: void slotTranscodeClip(); void slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file); void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile); + /** @brief Switches between displaying frames or timecode. + * @param ix 0 = display timecode, 1 = display frames. */ void slotUpdateTimecodeFormat(int ix); /** @brief Removes the focus of anything. */ void slotRemoveFocus(); diff --git a/src/trackview.cpp b/src/trackview.cpp index 969d5aec..db91031c 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -951,4 +951,9 @@ void TrackView::slotUpdateVerticalScroll(int /*min*/, int max) headers_container->layout()->setContentsMargins(0, m_trackview->frameWidth(), 0, height); } +void TrackView::updateRuler() +{ + m_ruler->update(); +} + #include "trackview.moc" diff --git a/src/trackview.h b/src/trackview.h index ea4cf277..efa5a230 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -63,6 +63,10 @@ public: int outPoint() const; int inPoint() const; int fitZoom() const; + /** @brief Updates (redraws) the ruler. + * + * Used to change from displaying frames to timecode or vice versa. */ + void updateRuler(); protected: virtual void keyPressEvent(QKeyEvent * event);