#include <KIcon>
#include <KCursor>
#include <KGlobalSettings>
+#include <KColorScheme>
#include <QApplication>
#include <QMouseEvent>
QFontMetricsF fontMetrics(font());
LABEL_SIZE = fontMetrics.ascent() - 2;
m_scale = 3;
- m_zoneColor = QColor(133, 255, 143);
+ m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
littleMarkDistance = FRAME_SIZE;
mediumMarkDistance = FRAME_SIZE * m_timecode.fps();
bigMarkDistance = FRAME_SIZE * m_timecode.fps() * 60;
void CustomRuler::slotGoToGuide(QAction *act)
{
+ m_view->setCursorPos(act->data().toInt(), true);
m_view->initCursorPos(act->data().toInt());
}
void CustomRuler::mouseReleaseEvent(QMouseEvent * /*event*/)
{
+ if (m_moveCursor == RULER_START || m_moveCursor == RULER_END || m_moveCursor == RULER_MIDDLE) {
+ emit zoneMoved(m_zoneStart, m_zoneEnd);
+ m_view->setDocumentModified();
+ }
m_mouseMove = NO_MOVE;
+
}
// virtual
if (qAbs(pos - m_zoneStart * m_factor) < 4) m_moveCursor = RULER_START;
else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * m_factor) < 4) m_moveCursor = RULER_MIDDLE;
else if (qAbs(pos - m_zoneEnd * m_factor) < 4) m_moveCursor = RULER_END;
+ m_view->updateSnapPoints(NULL);
}
if (m_moveCursor == RULER_CURSOR) {
m_view->setCursorPos((int) pos / m_factor);
void CustomRuler::mouseMoveEvent(QMouseEvent * event)
{
if (event->buttons() == Qt::LeftButton) {
- int pos = (int)((event->x() + offset()) / m_factor);
+ int pos;
+ if (m_moveCursor == RULER_START || m_moveCursor == RULER_END) {
+ pos = m_view->getSnapPointForPos((int)((event->x() + offset()) / m_factor));
+ } else pos = (int)((event->x() + offset()) / m_factor);
int zoneStart = m_zoneStart;
int zoneEnd = m_zoneEnd;
if (pos < 0) pos = 0;
m_zoneStart += move;
m_zoneEnd += move;
}
- emit zoneMoved(m_zoneStart, m_zoneEnd);
- m_view->setDocumentModified();
int min = qMin(m_zoneStart, zoneStart);
int max = qMax(m_zoneEnd, zoneEnd);
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;
- p.setPen(palette().dark().color());
+ p.setPen(palette().text().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));
+ 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);
}
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();