Commit 3c6d6c58 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Cleanup mini timeline and keyframes in rotoscoping widget

parent f71d36d6
......@@ -33,7 +33,6 @@ SimpleTimelineWidget::SimpleTimelineWidget(QWidget* parent) :
m_currentKeyframe(-1),
m_currentKeyframeOriginal(-1),
m_hoverKeyframe(-1),
m_lineHeight(10),
m_scale(1)
{
setMouseTracking(true);
......@@ -44,6 +43,10 @@ SimpleTimelineWidget::SimpleTimelineWidget(QWidget* parent) :
KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
m_colSelected = palette().highlight().color();
m_colKeyframe = scheme.foreground(KColorScheme::NormalText).color();
m_size = QFontInfo(font()).pixelSize() * 1.8;
m_lineHeight = m_size / 2;
setMinimumHeight(m_size);
setMaximumHeight(m_size);
}
void SimpleTimelineWidget::setKeyframes(const QList<int> &keyframes)
......@@ -266,23 +269,21 @@ void SimpleTimelineWidget::paintEvent(QPaintEvent* event)
QStylePainter p(this);
m_scale = width() / (double)(m_duration);
p.translate(0, m_lineHeight);
//p.translate(0, m_lineHeight);
int headOffset = m_lineHeight / 1.5;
/*
* keyframes
*/
QPolygonF keyframe = QPolygonF() << QPointF(0, -10) << QPointF(-4, -6) << QPointF(0, -2) << QPointF(4, -6);
QPolygonF tmp;
foreach (const int &pos, m_keyframes) {
tmp = keyframe;
tmp.translate(pos * m_scale, 0);
if (pos == m_currentKeyframe || pos == m_hoverKeyframe) {
p.setBrush(m_colSelected);
} else {
p.setBrush(m_colKeyframe);
}
p.drawConvexPolygon(tmp);
p.drawLine(QLineF(0, -1, 0, 5).translated(pos * m_scale, 0));
} else {
p.setBrush(m_colKeyframe);
}
int scaledPos = pos * m_scale;
p.drawLine(scaledPos, headOffset, scaledPos, m_lineHeight + (headOffset / 2));
p.drawEllipse(scaledPos - headOffset / 2, 0, headOffset, headOffset);
}
p.setPen(palette().dark().color());
......@@ -291,15 +292,17 @@ void SimpleTimelineWidget::paintEvent(QPaintEvent* event)
* Time-"line"
*/
p.setPen(m_colKeyframe);
p.drawLine(0, 0, width(), 0);
p.drawLine(0, m_lineHeight + (headOffset / 2), width(), m_lineHeight + (headOffset / 2));
/*
* current position
*/
QPolygonF position = QPolygonF() << QPointF(0, 1) << QPointF(5, 6) << QPointF(-5, 6);
QPolygon pa(3);
int cursorwidth = (m_size - (m_lineHeight + headOffset / 2)) / 2 + 1;
QPolygonF position = QPolygonF() << QPointF(-cursorwidth, m_size) << QPointF(cursorwidth, m_size) << QPointF(0, m_lineHeight + (headOffset / 2) + 1);
position.translate(m_position * m_scale, 0);
p.setBrush(m_colKeyframe);
p.drawConvexPolygon(position);
p.drawPolygon(position);
}
......@@ -55,6 +55,7 @@ private:
QList <int> m_keyframes;
int m_lineHeight;
double m_scale;
int m_size;
QColor m_colSelected;
QColor m_colKeyframe;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment