From: Jean-Baptiste Mardelle Date: Mon, 23 Nov 2009 22:46:33 +0000 (+0000) Subject: Try to fix keyframe issue: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=adf2cb55879c1c14632b2dd907dc4ba74d90b073;p=kdenlive Try to fix keyframe issue: http://kdenlive.org/mantis/view.php?id=1307 svn path=/trunk/kdenlive/; revision=4142 --- diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index c9511d15..27fccfa0 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -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; diff --git a/src/keyframeedit.cpp b/src/keyframeedit.cpp index 5ecc4d2a..6f42dd3d 100644 --- a/src/keyframeedit.cpp +++ b/src/keyframeedit.cpp @@ -24,8 +24,9 @@ #include -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: "<rowCount()<<", POS: "<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()); diff --git a/src/keyframeedit.h b/src/keyframeedit.h index 9e975820..1efbfcf2 100644 --- a/src/keyframeedit.h +++ b/src/keyframeedit.h @@ -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 m_params; + int m_min; int m_max; int m_minVal; int m_maxVal;