From: Jean-Baptiste Mardelle Date: Tue, 21 Jul 2009 12:08:59 +0000 (+0000) Subject: New improved widget for position parameter in effects (for example with fade effects) X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a6b4582eafd6284710aa77dd76dfe4d595e28ce6;p=kdenlive New improved widget for position parameter in effects (for example with fade effects) svn path=/trunk/kdenlive/; revision=3752 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 38734140..ab0e5f0e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,6 +168,7 @@ set(kdenlive_SRCS documentvalidator.cpp cliptranscode.cpp keyframeedit.cpp + positionedit.cpp ) add_definitions( ${KDE4_DEFINITIONS} ) diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 4d0877af..5bb586ad 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -20,12 +20,12 @@ #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 index 00000000..88ccd662 --- /dev/null +++ b/src/positionedit.cpp @@ -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 + +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 index 00000000..a2916b33 --- /dev/null +++ b/src/positionedit.h @@ -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 + +#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 diff --git a/src/widgets/positionval_ui.ui b/src/widgets/positionval_ui.ui index 2e3d9dbb..a95d31ec 100644 --- a/src/widgets/positionval_ui.ui +++ b/src/widgets/positionval_ui.ui @@ -1,41 +1,48 @@ - + + Positionval_UI - - + + 0 0 - 135 - 28 + 167 + 54 - - - 0 - - - 0 - - - - + + + + Position - - - + + + 99:99:99:99; + + + + 1 + + + Qt::Horizontal + + + - checkBox - label - krestrictedline + + KLineEdit + QLineEdit +
klineedit.h
+
KRestrictedLine KLineEdit