]> git.sesse.net Git - kdenlive/commitdiff
New improved widget for position parameter in effects (for example with fade effects)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 21 Jul 2009 12:08:59 +0000 (12:08 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 21 Jul 2009 12:08:59 +0000 (12:08 +0000)
svn path=/trunk/kdenlive/; revision=3752

src/CMakeLists.txt
src/effectstackedit.cpp
src/positionedit.cpp [new file with mode: 0644]
src/positionedit.h [new file with mode: 0644]
src/widgets/positionval_ui.ui

index 38734140481fb9759360b77ad92a0db5832be1c1..ab0e5f0e82d5727d74b6d85ac5686695e83f4076 100644 (file)
@@ -168,6 +168,7 @@ set(kdenlive_SRCS
   documentvalidator.cpp
   cliptranscode.cpp
   keyframeedit.cpp
+  positionedit.cpp
 )
 
 add_definitions( ${KDE4_DEFINITIONS} )
index 4d0877af1c2720480bc85c43222f43ea9a23bdd3..5bb586ad7bda6d338660ae73cf89654d144f9bad 100644 (file)
 #include "ui_listval_ui.h"
 #include "ui_boolval_ui.h"
 #include "ui_colorval_ui.h"
-#include "ui_positionval_ui.h"
 #include "ui_wipeval_ui.h"
 #include "ui_keyframeeditor_ui.h"
 #include "complexparameter.h"
 #include "geometryval.h"
 #include "keyframeedit.h"
+#include "positionedit.h"
 #include "effectslist.h"
 #include "kdenlivesettings.h"
 #include "profilesdialog.h"
@@ -57,10 +57,6 @@ class Listval: public EffectStackEdit::UiItem, public Ui::Listval_UI
 {
 };
 
-class Positionval: public EffectStackEdit::UiItem, public Ui::Positionval_UI
-{
-};
-
 class Wipeval: public EffectStackEdit::UiItem, public Ui::Wipeval_UI
 {
 };
@@ -267,8 +263,6 @@ void EffectStackEdit::transferParamDesc(const QDomElement& d, int in, int out)
             connect(cval->kcolorbutton, SIGNAL(clicked()) , this, SLOT(collectAllParameters()));
             m_uiItems.append(cval);
         } else if (type == "position") {
-            Positionval *pval = new Positionval;
-            pval->setupUi(toFillin);
             int pos = value.toInt();
             if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
                 pos = pos - m_in;
@@ -276,11 +270,11 @@ void EffectStackEdit::transferParamDesc(const QDomElement& d, int in, int out)
                 // fadeout position starts from clip end
                 pos = m_out - (pos - m_in);
             }
-            pval->krestrictedline->setText(m_timecode.getTimecodeFromFrames(pos));
-            pval->label->setText(paramName);
-            m_valueItems[paramName + "position"] = pval;
-            connect(pval->krestrictedline, SIGNAL(editingFinished()), this, SLOT(collectAllParameters()));
-            m_uiItems.append(pval);
+            PositionEdit *posedit = new PositionEdit(paramName, pos, 1, m_out, m_timecode);
+            m_vbox->addWidget(posedit);
+            m_valueItems[paramName+"position"] = posedit;
+            connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
+            m_items.append(posedit);
         } else if (type == "wipe") {
             Wipeval *wpval = new Wipeval;
             wpval->setupUi(toFillin);
@@ -462,24 +456,24 @@ void EffectStackEdit::collectAllParameters()
             Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
             namenode.item(i) = geom->getParamDesc();
         } else if (type == "position") {
-            KRestrictedLine *line = ((Positionval*)m_valueItems.value(paramName))->krestrictedline;
-            int pos = m_timecode.getFrameCount(line->text(), KdenliveSettings::project_fps());
+            PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
+            int pos = pedit->getPosition();
             setValue = QString::number(pos);
             if (m_params.attribute("id") == "fadein" || m_params.attribute("id") == "fade_from_black") {
                 // Make sure duration is not longer than clip
-                if (pos > m_out) {
+                /*if (pos > m_out) {
                     pos = m_out;
-                    line->setText(m_timecode.getTimecodeFromFrames(pos));
-                }
+                    pedit->setPosition(pos);
+                }*/
                 EffectsList::setParameter(m_params, "in", QString::number(m_in));
                 EffectsList::setParameter(m_params, "out", QString::number(m_in + pos));
                 setValue.clear();
             } else if (m_params.attribute("id") == "fadeout" || m_params.attribute("id") == "fade_to_black") {
                 // Make sure duration is not longer than clip
-                if (pos > m_out) {
+                /*if (pos > m_out) {
                     pos = m_out;
-                    line->setText(m_timecode.getTimecodeFromFrames(pos));
-                }
+                    pedit->setPosition(pos);
+                }*/
                 EffectsList::setParameter(m_params, "in", QString::number(m_out + m_in - pos));
                 EffectsList::setParameter(m_params, "out", QString::number(m_out + m_in));
                 setValue.clear();
diff --git a/src/positionedit.cpp b/src/positionedit.cpp
new file mode 100644 (file)
index 0000000..88ccd66
--- /dev/null
@@ -0,0 +1,65 @@
+/***************************************************************************
+                          geomeytrval.cpp  -  description
+                             -------------------
+    begin                : 03 Aug 2008
+    copyright            : (C) 2008 by Marco Gittler
+    email                : g.marco@freenet.de
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "positionedit.h"
+#include "kdenlivesettings.h"
+
+#include <KDebug>
+
+PositionEdit::PositionEdit(const QString name, int pos, int min, int max, const Timecode tc, QWidget* parent) :
+        QWidget(parent),
+        m_tc(tc)
+{
+    m_ui.setupUi(this);
+    m_ui.label->setText(name);
+    m_ui.horizontalSlider->setRange(min, max);
+    connect(m_ui.horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateTimecode()));
+    connect(m_ui.krestrictedline, SIGNAL(editingFinished()), this, SLOT(slotUpdatePosition()));
+    m_ui.horizontalSlider->setValue(pos);
+    m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(pos));
+}
+
+int PositionEdit::getPosition() const
+{
+    return m_ui.horizontalSlider->value();
+}
+
+void PositionEdit::setPosition(int pos)
+{
+    m_ui.horizontalSlider->setValue(pos);
+    m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(pos));
+}
+
+void PositionEdit::slotUpdateTimecode()
+{
+    m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(m_ui.horizontalSlider->value()));
+    emit parameterChanged();
+}
+
+void PositionEdit::slotUpdatePosition()
+{
+    m_ui.horizontalSlider->blockSignals(true);
+    int pos = m_tc.getFrameCount(m_ui.krestrictedline->text(), KdenliveSettings::project_fps());
+    m_ui.horizontalSlider->setValue(pos);
+    if (pos != m_ui.horizontalSlider->value()) {
+        // Value out of range
+        m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(m_ui.horizontalSlider->value()));
+    }
+    m_ui.horizontalSlider->blockSignals(false);
+    emit parameterChanged();
+}
+
diff --git a/src/positionedit.h b/src/positionedit.h
new file mode 100644 (file)
index 0000000..a2916b3
--- /dev/null
@@ -0,0 +1,48 @@
+/***************************************************************************
+                          geomeytrval.h  -  description
+                             -------------------
+    begin                : 03 Aug 2008
+    copyright            : (C) 2008 by Marco Gittler
+    email                : g.marco@freenet.de
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef POSITONEDIT_H
+#define POSITONEDIT_H
+
+
+#include <QWidget>
+
+#include "ui_positionval_ui.h"
+#include "timecode.h"
+
+
+class PositionEdit : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit PositionEdit(const QString name, int pos, int min, int max, const Timecode tc, QWidget* parent = 0);
+    int getPosition() const;
+    void setPosition(int pos);
+
+private:
+    Ui::Positionval_UI m_ui;
+    Timecode m_tc;
+
+private slots:
+    void slotUpdateTimecode();
+    void slotUpdatePosition();
+
+signals:
+    void parameterChanged();
+};
+
+#endif
index 2e3d9dbbc4922ad5d1582a44303d9ea867e80551..a95d31ec72ea6a220d8cc31c5778494b08dd6507 100644 (file)
@@ -1,41 +1,48 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>Positionval_UI</class>
- <widget class="QWidget" name="Positionval_UI" >
-  <property name="geometry" >
+ <widget class="QWidget" name="Positionval_UI">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>135</width>
-    <height>28</height>
+    <width>167</width>
+    <height>54</height>
    </rect>
   </property>
-  <layout class="QGridLayout" name="gridLayout" >
-   <property name="verticalSpacing" >
-    <number>0</number>
-   </property>
-   <property name="margin" >
-    <number>0</number>
-   </property>
-   <item row="0" column="0" >
-    <widget class="QLabel" name="label" >
-     <property name="text" >
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
       <string>Position</string>
      </property>
     </widget>
    </item>
-   <item row="0" column="1" >
-    <widget class="KRestrictedLine" name="krestrictedline" >
-     <property name="inputMask" >
+   <item row="1" column="0">
+    <widget class="KRestrictedLine" name="krestrictedline">
+     <property name="inputMask">
       <string>99:99:99:99; </string>
      </property>
     </widget>
    </item>
+   <item row="1" column="1">
+    <widget class="QSlider" name="horizontalSlider">
+     <property name="pageStep">
+      <number>1</number>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
   </layout>
-  <zorder>checkBox</zorder>
-  <zorder>label</zorder>
-  <zorder>krestrictedline</zorder>
  </widget>
  <customwidgets>
+  <customwidget>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
   <customwidget>
    <class>KRestrictedLine</class>
    <extends>KLineEdit</extends>