m_geom(NULL),
m_position(0),
m_scale(0),
- m_movingKeyframe(false)
+ m_movingKeyframe(false),
+ m_lineHeight(9)
{
setFont(KGlobalSettings::toolBarFont());
}
// virtual
void KeyframeHelper::mousePressEvent(QMouseEvent * event)
{
- if (m_geom != NULL && (event->y() < height() / 2) && event->button() == Qt::LeftButton) {
+ if (m_geom != NULL && (event->y() < m_lineHeight) && event->button() == Qt::LeftButton) {
// check if we want to move a keyframe
- int mousePos = qMax((int)(event->x() / m_scale - 5), 0);
+ int mousePos = qMax((int)(event->x() / m_scale), 0);
Mlt::GeometryItem item;
if (m_geom->next_key(&item, mousePos) == 0) {
- if (item.frame() - mousePos < 10) {
+ if (qAbs(item.frame() * m_scale - (int)(event->x())) < 3) {
m_movingItem.x(item.x());
m_movingItem.y(item.y());
m_movingItem.w(item.w());
m_geom->remove(m_movingItem.frame());
}
int pos = qMax(0, (int)(event->x() / m_scale));
- pos = qMin(m_length, pos);
+ pos = qMin(frameLength, pos);
m_movingItem.frame(pos);
update();
return;
}
m_position = event->x() / m_scale;
m_position = qMax(0, m_position);
- m_position = qMin(m_length, m_position);
+ m_position = qMin(frameLength, m_position);
emit positionChanged(m_position);
update();
}
// virtual
void KeyframeHelper::wheelEvent(QWheelEvent * e)
{
- if (e->delta() < 0) m_position = m_position - 1;
- else m_position = m_position + 1;
+ if (e->delta() < 0)
+ --m_position;
+ else
+ ++m_position;
m_position = qMax(0, m_position);
- m_position = qMin(m_length, m_position);
+ m_position = qMin(frameLength, m_position);
emit positionChanged(m_position);
update();
/* int delta = 1;
QStylePainter p(this);
const QRectF clipRect = e->rect();
p.setClipRect(clipRect);
- m_scale = (double) width() / m_length;
+ m_scale = (double) width() / frameLength;
if (m_geom != NULL) {
int pos = 0;
p.setPen(QColor(255, 20, 20));
pos = item.frame();
int scaledPos = pos * m_scale;
// draw keyframes
- p.drawLine(scaledPos, 6, scaledPos, 10);
+ p.drawLine(scaledPos, 10, scaledPos, 14);
// draw pointer
- QPolygon pa(3);
- pa.setPoints(3, scaledPos - 4, 0, scaledPos + 4, 0, scaledPos, 4);
+ QPolygon pa(4);
+ pa.setPoints(4,
+ scaledPos, 0,
+ scaledPos - 4, 4,
+ scaledPos, 8,
+ scaledPos + 4, 4);
p.drawPolygon(pa);
//p.fillRect(QRect(scaledPos - 1, 0, 2, 15), QBrush(QColor(255, 20, 20)));
pos++;
if (m_movingKeyframe) {
int scaledPos = (int)(m_movingItem.frame() * m_scale);
// draw keyframes
- p.drawLine(scaledPos, 6, scaledPos, 10);
+ p.drawLine(scaledPos, 10, scaledPos, 14);
// draw pointer
- QPolygon pa(3);
- pa.setPoints(3, scaledPos - 4, 0, scaledPos + 4, 0, scaledPos, 4);
+ QPolygon pa(5);
+ pa.setPoints(4,
+ scaledPos, 0,
+ scaledPos - 4, 4,
+ scaledPos, 8,
+ scaledPos + 4, 4);
p.drawPolygon(pa);
}
}
p.setPen(palette().dark().color());
- p.drawLine(clipRect.x(), 5, clipRect.right(), 5);
+ p.drawLine(clipRect.x(), m_lineHeight, clipRect.right(), m_lineHeight);
// draw pointer
QPolygon pa(3);
const int cursor = m_position * m_scale;
- pa.setPoints(3, cursor - 5, 11, cursor + 5, 11, cursor, 6);
+ pa.setPoints(3, cursor - 5, 15, cursor + 5, 15, cursor, 10);
p.setBrush(palette().dark().color());
p.drawPolygon(pa);
void KeyframeHelper::setKeyGeometry(Mlt::Geometry *geom, const int length)
{
m_geom = geom;
- m_length = length;
+ frameLength = length;
update();
}