[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive] src/timeline: anim keyframes: fix default value line and hover detection
From:       Jean-Baptiste Mardelle <jb () kdenlive ! org>
Date:       2016-02-01 2:20:46
Message-ID: E1aQ46g-0000Al-Tl () scm ! kde ! org
[Download RAW message or body]

Git commit faa4f5e0409f3988c75ffc521c85c91866bfd47c by Jean-Baptiste Mardelle.
Committed on 01/02/2016 at 02:20.
Pushed by mardelle into branch 'master'.

anim keyframes: fix default value line and hover detection

M  +18   -3    src/timeline/abstractclipitem.cpp
M  +1    -0    src/timeline/abstractclipitem.h

http://commits.kde.org/kdenlive/faa4f5e0409f3988c75ffc521c85c91866bfd47c

diff --git a/src/timeline/abstractclipitem.cpp b/src/timeline/abstractclipitem.cpp
index d02e4d6..8d2c1da 100644
--- a/src/timeline/abstractclipitem.cpp
+++ b/src/timeline/abstractclipitem.cpp
@@ -233,6 +233,11 @@ double AbstractClipItem::keyframeUnmap(double y) {
     return ((br.bottom() - y) / br.height() * (m_keyframeMax - m_keyframeMin) + \
m_keyframeMin) / m_keyframeFactor;  }
 
+double AbstractClipItem::keyframeMap(double value) {
+    QRectF br = rect();
+    return br.bottom() - br.height() * (value * m_keyframeFactor - m_keyframeMin) / \
(m_keyframeMax - m_keyframeMin); +}
+
 QPointF AbstractClipItem::keyframeMap(int frame, double value) {
     QRectF br = rect();
     return QPointF(br.x() + br.width() * (frame - cropStart().frames(m_fps)) / \
cropDuration().frames(m_fps), @@ -249,6 +254,7 @@ void \
AbstractClipItem::drawKeyFrames(QPainter *painter, const QTransform &transf  if \
(m_keyAnim.key_count() < 1)  return;
     bool antialiasing = painter->renderHints() & QPainter::Antialiasing;
+    painter->save();
     bool active = isSelected() || (parentItem() && parentItem()->isSelected());
     QRectF br = rect();
 
@@ -274,7 +280,10 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, const \
QTransform &transf  
     // draw line showing default value
     if (active) {
-        double y = keyframeUnmap(m_keyframeDefault);
+        QColor col(Qt::black);
+        col.setAlpha(140);
+        painter->fillRect(QRectF(transformation.map(br.topLeft()), \
transformation.map(br.bottomRight())), col); +        double y = \
                keyframeMap(m_keyframeDefault);
         QLineF line = transformation.map(QLineF(br.x(), y, br.right(), y));
         painter->setPen(QColor(168, 168, 168, 180));
         painter->drawLine(line);
@@ -286,7 +295,8 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, const \
QTransform &transf  
     QPointF start = keyframePoint(0);
     QPainterPath path;
-    path.moveTo(br.x(), start.y());
+    path.moveTo(br.x(), br.bottom());
+    path.lineTo(br.x(), start.y());
     path.lineTo(start);
     for(int i = 0; i < m_keyAnim.key_count(); ++i) {
         if (active)
@@ -318,15 +328,20 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, const \
QTransform &transf  path.lineTo(br.right(), start.y());
         }
     }
+    path.lineTo(br.right(), br.bottom());
+    QColor col(Qt::white);//QApplication::palette().highlight().color());
+    col.setAlpha(active ? 120 : 80);
+    painter->setBrush(col);
     painter->drawPath(transformation.map(path));
     painter->setRenderHint(QPainter::Antialiasing, antialiasing);
+    painter->restore();
 }
 
 int AbstractClipItem::mouseOverKeyFrames(QPointF pos, double maxOffset)
 {
     for(int i = 0; i < m_keyAnim.key_count(); ++i) {
         int key = m_keyAnim.key_get_frame(i);
-        int value = m_keyProperties.anim_get_double("keyframes", key);
+        double value = m_keyProperties.anim_get_double("keyframes", key);
         QPointF p = keyframeMap(key, value);
         if (m_keyframeType == GeometryKeyframe)
             p.setY(rect().bottom() - rect().height() / 2);
diff --git a/src/timeline/abstractclipitem.h b/src/timeline/abstractclipitem.h
index 76a9d04..878d615 100644
--- a/src/timeline/abstractclipitem.h
+++ b/src/timeline/abstractclipitem.h
@@ -129,6 +129,7 @@ protected:
       * @param painter The painter device for the clip
       */
     double keyframeUnmap(double y);
+    double keyframeMap(double value);
     QPointF keyframeMap(int frame, double value);
     QPointF keyframePoint(int index);
     void drawKeyFrames(QPainter *painter, const QTransform &transformation);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic