}
}
+void KeyframeHelper::leaveEvent( QEvent * event )
+{
+ Q_UNUSED(event);
+ if (m_hoverKeyframe != -1) {
+ m_hoverKeyframe = -1;
+ update();
+ }
+}
+
// virtual
void KeyframeHelper::mouseMoveEvent(QMouseEvent * event)
{
int xPos = event->x() - margin;
if (!m_drag) {
int mousePos = qMax((int)(xPos / m_scale), 0);
- if (qAbs(m_position * m_scale - xPos) < cursorWidth && event->y() >= m_lineHeight && event->y() < 17) {
+ if (qAbs(m_position * m_scale - xPos) < cursorWidth && event->y() >= m_lineHeight) {
// Mouse over time cursor
- m_hoverKeyframe = -2;
- update();
+ if (m_hoverKeyframe != -2) {
+ m_hoverKeyframe = -2;
+ update();
+ }
event->accept();
return;
}
const int cursor = margin + m_position * m_scale;
pa.setPoints(3, cursor - cursorWidth, 16, cursor + cursorWidth, 16, cursor, 10);
if (m_hoverKeyframe == -2)
- p.setBrush(m_selected);
+ p.setBrush(palette().highlight());
else
p.setBrush(palette().dark().color());
p.drawPolygon(pa);
,m_scale(1)
,m_maxval(25)
,m_manager(manager)
+ ,m_overCursor(false)
{
m_zoneStart = 10;
m_zoneEnd = 60;
- m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
+ KSharedConfigPtr config = KSharedConfig::openConfig(KdenliveSettings::colortheme());
+ m_zoneBrush = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, config);
+
setMouseTracking(true);
setMinimumHeight(10);
}
} else emit seekRenderer((int) pos);
}
+void SmallRuler::leaveEvent( QEvent * event )
+{
+ Q_UNUSED(event);
+ if (m_overCursor) {
+ m_overCursor = false;
+ update();
+ }
+}
+
// virtual
void SmallRuler::mouseMoveEvent(QMouseEvent * event)
{
const int pos = event->x() / m_scale;
- if (event->buttons() & Qt::LeftButton) emit seekRenderer((int) pos);
+ if (event->button() == Qt::NoButton) {
+ if (qAbs(pos * m_scale - m_cursorPosition) < 6) {
+ if (!m_overCursor) {
+ m_overCursor = true;
+ update();
+ }
+ }
+ else if (m_overCursor) {
+ m_overCursor = false;
+ update();
+ }
+ }
+ if (event->buttons() & Qt::LeftButton) {
+ m_overCursor = true;
+ emit seekRenderer((int) pos);
+ }
else {
if (qAbs((pos - m_zoneStart) * m_scale) < 4) {
setToolTip(i18n("Zone start: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneStart)));
const int zoneStart = (int)(m_zoneStart * m_scale);
const int zoneEnd = (int)(m_zoneEnd * m_scale);
- p.fillRect(zoneStart, height() / 2 - 1, zoneEnd - zoneStart, height() / 2, m_zoneColor);
+ 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 pointer
QPolygon pa(3);
- pa.setPoints(3, m_cursorPosition - 5, 10, m_cursorPosition + 5, 10, m_cursorPosition/*+0*/, 5);
- p.setBrush(palette().text().color());
+ pa.setPoints(3, m_cursorPosition - 6, 10, m_cursorPosition + 6, 10, m_cursorPosition/*+0*/, 4);
+ if (m_overCursor) p.setBrush(palette().highlight());
+ else p.setBrush(palette().text().color());
p.setPen(Qt::NoPen);
p.drawPolygon(pa);
}
#ifndef SMALLRULER_H
#define SMALLRULER_H
+#include <KColorScheme>
#include <QWidget>
#include "monitormanager.h"
+
class SmallRuler : public QWidget
{
Q_OBJECT
SmallRuler(MonitorManager *manager, QWidget *parent = 0);
virtual void mousePressEvent(QMouseEvent * event);
virtual void mouseMoveEvent(QMouseEvent * event);
+ virtual void leaveEvent( QEvent * event );
void adjustScale(int maximum);
void setZone(int start, int end);
QPoint zone();
int m_maxval;
int m_zoneStart;
int m_zoneEnd;
- QColor m_zoneColor;
+ KStatefulBrush m_zoneBrush;
QList <int> m_markers;
QPixmap m_pixmap;
MonitorManager *m_manager;
+ /** @brief True is mouse is over the ruler cursor. */
+ bool m_overCursor;
void updatePixmap();
public slots: