]> git.sesse.net Git - kdenlive/commitdiff
Try to fix keyframe issue:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 23 Nov 2009 22:46:33 +0000 (22:46 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 23 Nov 2009 22:46:33 +0000 (22:46 +0000)
http://kdenlive.org/mantis/view.php?id=1307

svn path=/trunk/kdenlive/; revision=4142

src/effectstackedit.cpp
src/keyframeedit.cpp
src/keyframeedit.h

index c9511d15e819b8ea82dd6ad13d402af6002bcfaf..27fccfa022884801b1cbb2b1e86f7410c42cb837 100644 (file)
@@ -235,7 +235,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
             // keyframe editor widget
             kDebug() << "min: " << m_in << ", MAX: " << m_out;
            if (m_keyframeEditor == NULL) {
-               KeyframeEdit *geo = new KeyframeEdit(pa, m_out - m_in - 1, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode, paramName);
+               KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode, paramName);
                m_vbox->addWidget(geo);
                m_valueItems[paramName+"keyframe"] = geo;
                m_keyframeEditor = geo;
index 5ecc4d2aebdec727851286bb8a2224e3db385847..6f42dd3de9fd0baa9abc979c1b4853df062ae0f3 100644 (file)
@@ -24,8 +24,9 @@
 #include <QHeaderView>
 
 
-KeyframeEdit::KeyframeEdit(QDomElement e, int maxFrame, int minVal, int maxVal, Timecode tc, const QString paramName, QWidget* parent) :
+KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal, int maxVal, Timecode tc, const QString paramName, QWidget* parent) :
         QWidget(parent),
+        m_min(minFrame),
         m_max(maxFrame),
         m_minVal(minVal),
         m_maxVal(maxVal),
@@ -144,31 +145,32 @@ void KeyframeEdit::slotDeleteKeyframe()
 void KeyframeEdit::slotAddKeyframe()
 {
     keyframe_list->blockSignals(true);
-    int pos2;
     QTableWidgetItem *item = keyframe_list->currentItem();
     int row = keyframe_list->currentRow();
     int col = keyframe_list->currentColumn();
     int newrow = row;
     int pos1 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row)->text());
+    int result;
     kDebug()<<"// ADD KF: "<<row<<", MAX: "<<keyframe_list->rowCount()<<", POS: "<<pos1;
     if (row < (keyframe_list->rowCount() - 1)) {
-       pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row + 1)->text());
+       int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row + 1)->text());
+       result = pos1 + (pos2 - pos1) / 2;
        newrow++;
     }
     else if (row == 0) {
-       if (pos1 == 0) {
-           pos2 = m_max * 2;
+       if (pos1 == m_min) {
+           result = m_max - 1;
            newrow++;
        }
         else {
-           pos2 = 0;
-           pos1 = 0;
+           result = m_min;
        }
     }
-    else pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row - 1)->text());
-
-    int result = (pos1 + pos2) / 2;
-    
+    else {
+       int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row - 1)->text());
+       result = pos2 + (pos1 - pos2) / 2;
+    }
+        
     keyframe_list->insertRow(newrow);
     keyframe_list->setVerticalHeaderItem(newrow, new QTableWidgetItem(m_timecode.getTimecodeFromFrames(result)));
     keyframe_list->setItem(newrow, keyframe_list->currentColumn(), new QTableWidgetItem(item->text()));
@@ -187,8 +189,8 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
     if (item == NULL) return;
     QString val = keyframe_list->verticalHeaderItem(row)->text();
     int pos = m_timecode.getFrameCount(val);
-    if (pos <= 0) {
-       pos = 0;
+    if (pos <= m_min) {
+       pos = m_min;
         val = m_timecode.getTimecodeFromFrames(pos);
     }
     if (pos > m_max) {
@@ -220,7 +222,7 @@ void KeyframeEdit::slotAdjustKeyframeInfo()
 {
     QTableWidgetItem *item = keyframe_list->currentItem();
     if (!item) return;
-    int min = 0;
+    int min = m_min;
     int max = m_max;
     QTableWidgetItem *above = keyframe_list->item(item->row() - 1, item->column());
     QTableWidgetItem *below = keyframe_list->item(item->row() + 1, item->column());
index 9e9758208962c957c48e7cfc44ad7c2a66d094ab..1efbfcf20091934810387216ea850ee0be4e7e97 100644 (file)
@@ -75,13 +75,14 @@ class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI
 {
     Q_OBJECT
 public:
-    explicit KeyframeEdit(QDomElement e, int maxFrame, int minVal, int maxVal, Timecode tc, const QString paramName = QString(), QWidget* parent = 0);
+    explicit KeyframeEdit(QDomElement e, int minFrame, int maxFrame, int minVal, int maxVal, Timecode tc, const QString paramName = QString(), QWidget* parent = 0);
     virtual ~KeyframeEdit();
     void setupParam();
     void addParameter(QDomElement e);
 
 private:
     QList <QDomElement> m_params;
+    int m_min;
     int m_max;
     int m_minVal;
     int m_maxVal;