const int CustomRuler::comboScale[] = { 1, 2, 5, 10, 25, 50, 125, 250, 500, 750, 1500, 3000, 6000, 12000};
-CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
+CustomRuler::CustomRuler(const Timecode &tc, CustomTrackView *parent) :
QWidget(parent),
m_timecode(tc),
m_view(parent),
updateFrameSize();
m_scale = 3;
m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
+ m_zoneColor.setAlpha(180);
m_zoneStart = 0;
m_zoneEnd = 100;
m_contextMenu = new QMenu(this);
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 *)));
+ connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*)));
setMouseTracking(true);
}
void CustomRuler::updatePalette()
{
m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
+ m_zoneColor.setAlpha(180);
}
-void CustomRuler::updateProjectFps(Timecode t)
+void CustomRuler::updateProjectFps(const Timecode &t)
{
m_timecode = t;
mediumMarkDistance = FRAME_SIZE * m_timecode.fps();
m_view->initCursorPos(act->data().toInt());
}
-void CustomRuler::setZone(QPoint p)
+void CustomRuler::setZone(const QPoint &p)
{
m_zoneStart = p.x();
m_zoneEnd = p.y();
// virtual
void CustomRuler::mouseMoveEvent(QMouseEvent * event)
{
+ int mappedXPos = (int)((event->x() + offset()) / m_factor);
+ emit mousePosition(mappedXPos);
if (event->buttons() == Qt::LeftButton) {
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);
+ pos = m_view->getSnapPointForPos(mappedXPos);
+ } else pos = mappedXPos;
int zoneStart = m_zoneStart;
int zoneEnd = m_zoneEnd;
if (pos < 0) pos = 0;
int pos = (int)((event->x() + m_offset));
if (m_cursorColor == palette().text() && qAbs(pos - m_view->cursorPos() * m_factor) < 7) {
// Mouse is over cursor
- m_cursorColor = palette().highlight();
+ m_cursorColor = palette().link();
update(m_view->cursorPos() * m_factor - m_offset - 10, LABEL_SIZE + 2, 20, MAX_HEIGHT - LABEL_SIZE - 2);
}
- else if (m_cursorColor == palette().highlight() && qAbs(pos - m_view->cursorPos() * m_factor) >= 7) {
+ else if (m_cursorColor == palette().link() && qAbs(pos - m_view->cursorPos() * m_factor) >= 7) {
m_cursorColor = palette().text();
update(m_view->cursorPos() * m_factor - m_offset - 10, LABEL_SIZE + 2, 20, MAX_HEIGHT - LABEL_SIZE - 2);
}
void CustomRuler::leaveEvent(QEvent * event)
{
QWidget::leaveEvent(event);
- if (m_cursorColor == palette().highlight()) {
- m_cursorColor = palette().text();
- update();
+ if (m_cursorColor == palette().link()) {
+ m_cursorColor = palette().text();
+ update();
}
}
void CustomRuler::wheelEvent(QWheelEvent * e)
{
int delta = 1;
+ m_view->activateMonitor();
if (e->modifiers() == Qt::ControlModifier) delta = m_timecode.fps();
if (e->delta() < 0) delta = 0 - delta;
m_view->moveCursorPos(delta);
void CustomRuler::slotMoveRuler(int newPos)
{
- m_offset = newPos;
- update();
+ if (m_offset != newPos) {
+ m_offset = newPos;
+ update();
+ }
}
int CustomRuler::offset() const
p.drawPolygon(pa);
if (m_lastSeekPosition != SEEK_INACTIVE && m_lastSeekPosition != m_view->cursorPos()) {
- p.fillRect(m_lastSeekPosition * m_factor - m_offset - 1, BIG_MARK_X + 1, 3, MAX_HEIGHT - BIG_MARK_X - 1, palette().highlight());
+ p.fillRect(m_lastSeekPosition * m_factor - m_offset - 1, BIG_MARK_X + 1, 3, MAX_HEIGHT - BIG_MARK_X - 1, palette().linkVisited());
}
}