]> git.sesse.net Git - kdenlive/commitdiff
Keyframe widget: Make it possible to change the position of a keyframe with more...
authorTill Theato <root@ttill.de>
Sat, 8 Jan 2011 19:00:23 +0000 (19:00 +0000)
committerTill Theato <root@ttill.de>
Sat, 8 Jan 2011 19:00:23 +0000 (19:00 +0000)
svn path=/trunk/kdenlive/; revision=5303

src/keyframeedit.cpp
src/keyframeedit.h
src/positionedit.cpp
src/positionedit.h
src/widgets/keyframeeditor_ui.ui

index 2ff857ad7e6505820e3ac73726eaf89ca6f28f4d..ffe754963ffbad8c696e37e5176f2196a4ab12c1 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "keyframeedit.h"
 #include "doubleparameterwidget.h"
+#include "positionedit.h"
 #include "kdenlivesettings.h"
 
 #include <KDebug>
@@ -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 <DoubleParameterWidget*>(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()
index 54f4e99587d8eb16ef4e390d989154f4b8db9e01..8dc1d5dea7cd9242c109e1e03fc92c505d1dff2e 100644 (file)
@@ -26,6 +26,7 @@
 #include <QSpinBox>
 
 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.
index 31b3ddc71b0143b086077c8a1e7e339a1a65646b..51ac2dfb98c011628fc565f7573ede9627c625e7 100644 (file)
@@ -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"
index ba3163630450a60f1c8c7a2232dc40c8f1ed015b..2a2639781645a32613fd67245bdbc773de66a92d 100644 (file)
@@ -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
index b101e6c60fa07e0558a082895eeeaab1dc570da5..109d3dce1bad3bfd0ddc224134f74abcca0008cb 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>346</width>
-    <height>196</height>
+    <width>343</width>
+    <height>178</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout">
@@ -40,7 +40,7 @@
       <property name="margin">
        <number>0</number>
       </property>
-      <item row="3" column="0" colspan="5">
+      <item row="0" column="0" colspan="5">
        <widget class="QTableWidget" name="keyframe_list">
         <property name="alternatingRowColors">
          <bool>true</bool>
@@ -62,7 +62,7 @@
         </attribute>
        </widget>
       </item>
-      <item row="4" column="0">
+      <item row="1" column="0">
        <widget class="QToolButton" name="button_add">
         <property name="text">
          <string>A</string>
         </property>
        </widget>
       </item>
-      <item row="5" column="0" colspan="2">
-       <widget class="QLabel" name="label">
-        <property name="text">
-         <string>Position</string>
-        </property>
-       </widget>
-      </item>
-      <item row="5" column="2" colspan="3">
-       <widget class="QSlider" name="keyframe_pos">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-       </widget>
-      </item>
-      <item row="4" column="1">
+      <item row="1" column="1">
        <widget class="QToolButton" name="button_delete">
         <property name="text">
          <string>D</string>
@@ -96,7 +82,7 @@
         </property>
        </widget>
       </item>
-      <item row="4" column="2">
+      <item row="1" column="2">
        <widget class="QToolButton" name="buttonResetKeyframe">
         <property name="toolTip">
          <string>Reset the parameters to their default values</string>
         </property>
        </widget>
       </item>
-      <item row="4" column="3">
+      <item row="1" column="3">
        <widget class="QToolButton" name="buttonSeek">
         <property name="toolTip">
          <string>Seek to active keyframe</string>