From: Till Theato Date: Sat, 8 Jan 2011 19:00:23 +0000 (+0000) Subject: Keyframe widget: Make it possible to change the position of a keyframe with more... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b7a99cc6862e5dd90bff9dc7206bbbb033ab55dc;p=kdenlive Keyframe widget: Make it possible to change the position of a keyframe with more precision by using the position edit widget svn path=/trunk/kdenlive/; revision=5303 --- diff --git a/src/keyframeedit.cpp b/src/keyframeedit.cpp index 2ff857ad..ffe75496 100644 --- a/src/keyframeedit.cpp +++ b/src/keyframeedit.cpp @@ -17,6 +17,7 @@ #include "keyframeedit.h" #include "doubleparameterwidget.h" +#include "positionedit.h" #include "kdenlivesettings.h" #include @@ -51,6 +52,9 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode t connect(keyframe_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotAdjustKeyframeInfo())); connect(keyframe_list, SIGNAL(cellChanged(int, int)), this, SLOT(slotGenerateParams(int, int))); + m_position = new PositionEdit(i18n("Position"), 0, 0, 1, tc, widgetTable); + ((QGridLayout*)widgetTable->layout())->addWidget(m_position, 2, 0, 1, -1); + m_showButtons = new QButtonGroup(this); m_slidersLayout = new QGridLayout(param_sliders); keyframe_list->setSelectionBehavior(QAbstractItemView::SelectRows); @@ -63,12 +67,11 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode t connect(button_add, SIGNAL(clicked()), this, SLOT(slotAddKeyframe())); connect(buttonKeyframes, SIGNAL(clicked()), this, SLOT(slotKeyframeMode())); connect(buttonResetKeyframe, SIGNAL(clicked()), this, SLOT(slotResetKeyframe())); - connect(keyframe_pos, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframePos(int))); + connect(m_position, SIGNAL(parameterChanged(int)), this, SLOT(slotAdjustKeyframePos(int))); connect(m_showButtons, SIGNAL(buttonClicked(int)), this, SLOT(slotUpdateVisibleParameter(int))); //connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int))); - keyframe_pos->setPageStep(1); if (!keyframe_list->currentItem()) { keyframe_list->setCurrentCell(0, 0); keyframe_list->selectRow(0); @@ -329,10 +332,11 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek) if (below) max = getPos(below->row()) - 1; - keyframe_pos->blockSignals(true); - keyframe_pos->setRange(min, max); - keyframe_pos->setValue(getPos(item->row())); - keyframe_pos->blockSignals(false); + m_position->blockSignals(true); + m_position->setRange(min, max); + m_position->setPosition(getPos(item->row())); + m_position->blockSignals(false); + for (int col = 0; col < keyframe_list->columnCount(); col++) { DoubleParameterWidget *doubleparam = static_cast (m_slidersLayout->itemAtPosition(col, 0)->widget()); if (!doubleparam) @@ -346,7 +350,7 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek) doubleparam->blockSignals(false); } if (KdenliveSettings::keyframeseek() && seek) - emit seekToPos(keyframe_pos->value() - m_min); + emit seekToPos(m_position->getPosition() - m_min); } void KeyframeEdit::slotAdjustKeyframePos(int value) @@ -406,6 +410,8 @@ void KeyframeEdit::updateTimecodeFormat() else keyframe_list->verticalHeaderItem(row)->setText(m_timecode.getTimecodeFromFrames(pos.toInt())); } + + m_position->updateTimecodeFormat(); } void KeyframeEdit::slotKeyframeMode() diff --git a/src/keyframeedit.h b/src/keyframeedit.h index 54f4e995..8dc1d5de 100644 --- a/src/keyframeedit.h +++ b/src/keyframeedit.h @@ -26,6 +26,7 @@ #include class QButtonGroup; +class PositionEdit; #include "ui_keyframeeditor_ui.h" #include "definitions.h" @@ -100,6 +101,7 @@ private: Timecode m_timecode; QGridLayout *m_slidersLayout; QButtonGroup *m_showButtons; + PositionEdit *m_position; void generateAllParams(); /** @brief Gets the position of a keyframe from the table. diff --git a/src/positionedit.cpp b/src/positionedit.cpp index 31b3ddc7..51ac2dfb 100644 --- a/src/positionedit.cpp +++ b/src/positionedit.cpp @@ -44,7 +44,7 @@ PositionEdit::PositionEdit(const QString name, int pos, int min, int max, const layout->addWidget(m_display); connect(m_slider, SIGNAL(valueChanged(int)), m_display, SLOT(setValue(int))); - connect(m_slider, SIGNAL(valueChanged(int)), this, SIGNAL(parameterChanged())); + connect(m_slider, SIGNAL(valueChanged(int)), this, SIGNAL(parameterChanged(int))); connect(m_display, SIGNAL(editingFinished()), this, SLOT(slotUpdatePosition())); m_slider->setValue(pos); } @@ -77,7 +77,13 @@ void PositionEdit::slotUpdatePosition() m_slider->blockSignals(true); m_slider->setValue(m_display->getValue()); m_slider->blockSignals(false); - emit parameterChanged(); + emit parameterChanged(m_display->getValue()); +} + +void PositionEdit::setRange(int min, int max) +{ + m_slider->setRange(min, max); + m_display->setRange(min, max); } #include "positionedit.moc" diff --git a/src/positionedit.h b/src/positionedit.h index ba316363..2a263978 100644 --- a/src/positionedit.h +++ b/src/positionedit.h @@ -35,6 +35,7 @@ public: int getPosition() const; void setPosition(int pos); void updateTimecodeFormat(); + void setRange(int min, int max); private: TimecodeDisplay *m_display; @@ -44,7 +45,7 @@ private slots: void slotUpdatePosition(); signals: - void parameterChanged(); + void parameterChanged(int pos); }; #endif diff --git a/src/widgets/keyframeeditor_ui.ui b/src/widgets/keyframeeditor_ui.ui index b101e6c6..109d3dce 100644 --- a/src/widgets/keyframeeditor_ui.ui +++ b/src/widgets/keyframeeditor_ui.ui @@ -6,8 +6,8 @@ 0 0 - 346 - 196 + 343 + 178 @@ -40,7 +40,7 @@ 0 - + true @@ -62,7 +62,7 @@ - + A @@ -72,21 +72,7 @@ - - - - Position - - - - - - - Qt::Horizontal - - - - + D @@ -96,7 +82,7 @@ - + Reset the parameters to their default values @@ -106,7 +92,7 @@ - + Seek to active keyframe