#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;
connect(m_deleteGuide , SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
QAction *delAllGuides = m_contextMenu->addAction(KIcon("edit-delete"), i18n("Delete All Guides"));
connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides()));
+ m_goMenu = m_contextMenu->addMenu(i18n("Go To"));
+ connect(m_goMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToGuide(QAction *)));
setMouseTracking(true);
setMinimumHeight(20);
}
m_view->slotDeleteGuide(m_clickedGuide);
}
+void CustomRuler::slotGoToGuide(QAction *act)
+{
+ m_view->setCursorPos(act->data().toInt(), true);
+ m_view->initCursorPos(act->data().toInt());
+}
+
void CustomRuler::setZone(QPoint p)
{
m_zoneStart = p.x();
m_clickedGuide = m_view->hasGuide((int)(pos / m_factor), (int)(5 / m_factor + 1));
m_editGuide->setEnabled(m_clickedGuide > 0);
m_deleteGuide->setEnabled(m_clickedGuide > 0);
+ m_view->buildGuidesMenu(m_goMenu);
m_contextMenu->exec(event->globalPos());
return;
}
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;
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();