m_ui.buttonShowAllHandles->setIcon(KIcon("draw-bezier-curves"));
m_ui.widgetPoint->setEnabled(false);
- m_pX = new DragValue(i18n("In"), 0, 3, -1, QString(), false, this);
- m_pX->setRange(0, 1);
+ m_pX = new DragValue(i18n("In"), 0, 3, 0, 1, -1, QString(), false, this);
m_pX->setStep(0.001);
- m_pY = new DragValue(i18n("Out"), 0, 3, -1, QString(), false, this);
- m_pY->setRange(0, 1);
+ m_pY = new DragValue(i18n("Out"), 0, 3, 0, 1, -1, QString(), false, this);
m_pY->setStep(0.001);
- m_h1X = new DragValue(i18n("X"), 0, 3, -1, QString(), false, this);
- m_h1X->setRange(-2, 2);
+ m_h1X = new DragValue(i18n("X"), 0, 3, -2, 2, -1, QString(), false, this);
m_h1X->setStep(0.001);
- m_h1Y = new DragValue(i18n("Y"), 0, 3, -1, QString(), false, this);
- m_h1Y->setRange(-2, 2);
+ m_h1Y = new DragValue(i18n("Y"), 0, 3, -2, 2, -1, QString(), false, this);
m_h1Y->setStep(0.001);
- m_h2X = new DragValue(i18n("X"), 0, 3, -1, QString(), false, this);
- m_h2X->setRange(-2, 2);
+ m_h2X = new DragValue(i18n("X"), 0, 3, -2, 2, -1, QString(), false, this);
m_h2X->setStep(0.001);
- m_h2Y = new DragValue(i18n("Y"), 0, 3, -1, QString(), false, this);
- m_h2Y->setRange(-2, 2);
+ m_h2Y = new DragValue(i18n("Y"), 0, 3, -2, 2, -1, QString(), false, this);
m_h2Y->setStep(0.001);
m_ui.layoutP->addWidget(m_pX);
if (itemList.at(i)->type() == TRANSITIONWIDGET) {
transitionitem = static_cast <Transition*>(itemList.at(i));
transitionXml = transitionitem->toXML();
+ // luma files in transitions can be in "resource" or "luma" property
QString luma = EffectsList::parameter(transitionXml, "luma");
- if (!luma.isEmpty()) urls << luma;
+ if (luma.isEmpty()) luma = EffectsList::parameter(transitionXml, "resource");
+ if (!luma.isEmpty()) urls << KUrl(luma).path();
}
}
+#if QT_VERSION >= 0x040500
+ urls.removeDuplicates();
+#endif
return urls;
}
#include <QSpinBox>
#include <QToolButton>
+#include <KDebug>
#include <KIcon>
#include <KLocalizedString>
-DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, int id, const QString suffix, QWidget *parent) :
+DoubleParameterWidget::DoubleParameterWidget(const QString &name, double value, double min, double max, double defaultValue, const QString &comment, int id, const QString suffix, int decimals, QWidget *parent) :
QWidget(parent),
m_commentLabel(NULL)
{
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
- m_dragVal = new DragValue(name, defaultValue, 0, id, suffix, this);
- m_dragVal->setRange(min, max);
- m_dragVal->setPrecision(0);
+ m_dragVal = new DragValue(name, defaultValue, decimals, min, max, id, suffix, this);
layout->addWidget(m_dragVal, 0, 1);
if (!comment.isEmpty()) {
* @param comment A comment explaining the parameter. Will be shown for the tooltip.
* @param suffix (optional) Suffix to display in spinbox
* @param parent (optional) Parent Widget */
- DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, int id, const QString suffix = QString(), QWidget* parent = 0);
+ DoubleParameterWidget(const QString &name, double value, double min, double max, double defaultValue, const QString &comment, int id, const QString suffix = QString(), int decimals = 0, QWidget* parent = 0);
/** @brief Gets the parameter's value. */
int getValue();
#include <QPainter>
#include <QStyle>
+#include <KDebug>
#include <KIcon>
#include <KLocalizedString>
#include <KGlobalSettings>
-DragValue::DragValue(const QString &label, double defaultValue, int decimals, int id, const QString suffix, bool showSlider, QWidget* parent) :
+DragValue::DragValue(const QString &label, double defaultValue, int decimals, double min, double max, int id, const QString suffix, bool showSlider, QWidget* parent) :
QWidget(parent),
- m_maximum(100),
- m_minimum(0),
+ m_maximum(max),
+ m_minimum(min),
m_decimals(decimals),
m_default(defaultValue),
m_id(id),
QHBoxLayout *l = new QHBoxLayout;
l->setSpacing(0);
l->setContentsMargins(0, 0, 0, 0);
- m_label = new CustomLabel(label, showSlider, decimals, this);
- m_label->setCursor(Qt::PointingHandCursor);
- m_label->setRange(m_minimum, m_maximum);
+ m_label = new CustomLabel(label, showSlider, this);
l->addWidget(m_label);
if (decimals == 0) {
+ m_label->setStep(m_label->maximum() / (max - min));
m_intEdit = new QSpinBox(this);
m_intEdit->setObjectName("dragBox");
if (!suffix.isEmpty()) m_intEdit->setSuffix(suffix);
m_doubleEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_doubleEdit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
m_doubleEdit->setRange(m_minimum, m_maximum);
+ m_doubleEdit->setSingleStep((m_maximum - m_minimum) / 100.0);
l->addWidget(m_doubleEdit);
connect(m_doubleEdit, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double)));
connect(m_doubleEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
}
- connect(m_label, SIGNAL(valueChanged(double,bool)), this, SLOT(setValue(double,bool)));
+ connect(m_label, SIGNAL(valueChanged(double,bool)), this, SLOT(setValueFromProgress(double,bool)));
connect(m_label, SIGNAL(resetValue()), this, SLOT(slotReset()));
setLayout(l);
if (m_intEdit) m_label->setMaximumHeight(m_intEdit->sizeHint().height());
void DragValue::setMaximum(qreal max)
{
m_maximum = max;
- m_label->setRange(m_minimum, m_maximum);
if (m_intEdit) m_intEdit->setRange(m_minimum, m_maximum);
else m_doubleEdit->setRange(m_minimum, m_maximum);
}
void DragValue::setMinimum(qreal min)
{
m_minimum = min;
- m_label->setRange(m_minimum, m_maximum);
if (m_intEdit) m_intEdit->setRange(m_minimum, m_maximum);
else m_doubleEdit->setRange(m_minimum, m_maximum);
}
{
m_maximum = max;
m_minimum = min;
- m_label->setRange(m_minimum, m_maximum);
if (m_intEdit) m_intEdit->setRange(m_minimum, m_maximum);
else m_doubleEdit->setRange(m_minimum, m_maximum);
}
void DragValue::setStep(qreal step)
{
- m_label->setStep(step);
if (m_intEdit)
m_intEdit->setSingleStep(step);
else
m_doubleEdit->blockSignals(false);
emit valueChanged(m_default, true);
}
- m_label->setProgressValue(m_default);
+ m_label->setProgressValue((m_default - m_minimum) / (m_maximum - m_minimum) * m_label->maximum());
}
void DragValue::slotSetValue(int value)
{
- setValue(value, KdenliveSettings::dragvalue_directupdate());
+ setValue(value, KdenliveSettings::dragvalue_directupdate());
}
void DragValue::slotSetValue(double value)
setValue(value, KdenliveSettings::dragvalue_directupdate());
}
+void DragValue::setValueFromProgress(double value, bool final)
+{
+ value = m_minimum + value * (m_maximum - m_minimum) / m_label->maximum();
+ if (m_decimals == 0) setValue((int) (value + 0.5), final);
+ else setValue(value, final);
+}
+
void DragValue::setValue(double value, bool final)
{
value = qBound(m_minimum, value, m_maximum);
m_doubleEdit->blockSignals(false);
emit valueChanged(value, final);
}
- m_label->setProgressValue(value);
+
+ m_label->setProgressValue((value - m_minimum) / (m_maximum - m_minimum) * m_label->maximum());
}
void DragValue::focusInEvent(QFocusEvent* e)
}
-CustomLabel::CustomLabel(const QString &label, bool showSlider, int precision, QWidget* parent) :
+CustomLabel::CustomLabel(const QString &label, bool showSlider, QWidget* parent) :
QProgressBar(parent),
m_dragMode(false),
- m_step(1.0),
m_showSlider(showSlider),
- m_precision(pow(10, precision)),
- m_value(0)
+ m_step(10.0)
+ //m_precision(pow(10, precision)),
{
setFont(KGlobalSettings::toolBarFont());
setFormat(" " + label);
setFocusPolicy(Qt::ClickFocus);
+ setCursor(Qt::PointingHandCursor);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
+ setRange(0, 1000);
+
if (!showSlider) {
QSize sh;
const QFontMetrics &fm = fontMetrics();
if (KdenliveSettings::dragvalue_mode() == 2)
diff = (diff > 0 ? 1 : -1) * pow(diff, 2);
- double nv = m_value + diff * m_step;
- if (nv != m_value) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+ double nv = value() + diff * m_step;
+ if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
}
else {
double nv = minimum() + ((double) maximum() - minimum()) / width() * e->pos().x();
- if (nv != m_value) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+ if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
}
m_dragLastPosition = e->pos();
e->accept();
return;
}
if (m_dragMode) {
- setNewValue(m_value, true);
+ setNewValue(value(), true);
m_dragLastPosition = m_dragStartPosition;
e->accept();
}
else if (m_showSlider) {
- setNewValue((minimum() + ((double)maximum() - minimum()) / width() * e->pos().x()), true);
+ setNewValue((double) maximum() * e->pos().x() / width(), true);
m_dragLastPosition = m_dragStartPosition;
e->accept();
}
void CustomLabel::wheelEvent(QWheelEvent* e)
{
if (e->delta() > 0) {
- if (e->modifiers() == Qt::ControlModifier) slotValueInc(m_step * 10);
- else if (e->modifiers() == Qt::AltModifier) slotValueInc(m_step / m_precision);
+ if (e->modifiers() == Qt::ControlModifier) slotValueInc(10);
+ else if (e->modifiers() == Qt::AltModifier) slotValueInc(0.1);
else slotValueInc();
}
else {
- if (e->modifiers() == Qt::ControlModifier) slotValueDec(m_step * 10);
- else if (e->modifiers() == Qt::AltModifier) slotValueDec(m_step / m_precision);
+ if (e->modifiers() == Qt::ControlModifier) slotValueDec(10);
+ else if (e->modifiers() == Qt::AltModifier) slotValueDec(0.1);
else slotValueDec();
}
e->accept();
void CustomLabel::slotValueInc(double factor)
{
- setNewValue(m_value + m_step * factor, true);
+ setNewValue(value() + m_step * factor, true);
}
void CustomLabel::slotValueDec(double factor)
{
- setNewValue(m_value - m_step * factor, true);
+ setNewValue(value() - m_step * factor, true);
}
void CustomLabel::setProgressValue(double value)
{
- m_value = value;
- setValue((int) value);
+ setValue((int) (value + 0.5));
}
void CustomLabel::setNewValue(double value, bool update)
{
- m_value = value;
- setValue(value);
- emit valueChanged(value, update);
+ setValue((int) (value + 0.5));
+ emit valueChanged((int) (value + 0.5), update);
}
void CustomLabel::setStep(double step)
{
Q_OBJECT
public:
- CustomLabel(const QString &label, bool showSlider = true, int precision = 0, QWidget *parent = 0);
+ CustomLabel(const QString &label, bool showSlider = true, QWidget *parent = 0);
void setProgressValue(double value);
void setStep(double step);
QPoint m_dragStartPosition;
QPoint m_dragLastPosition;
bool m_dragMode;
- double m_step;
bool m_showSlider;
- double m_precision;
- double m_value;
+ double m_step;
void slotValueInc(double factor = 1);
void slotValueDec(double factor = 1);
void setNewValue(double, bool);
Q_OBJECT
public:
- DragValue(const QString &label, double defaultValue, int decimals, int id, const QString suffix, bool showSlider = true, QWidget* parent = 0);
+ /**
+ * @brief Default constructor.
+ * @param label The label that will be displayed in the progress bar
+ * @param defaultValue The default value
+ * @param decimals The number of decimals for the parameter. 0 means it is an integer
+ * @param min The minimum value
+ * @param max The maximum value
+ * @param id Used to identify this widget. If this parameter is set, "Show in Timeline" will be available in context menu.
+ * @param suffix The suffix that will be displayed in the spinbox (for example '%')
+ * @param showSlider If disabled, user can still drag on the label but no progress bar is shown
+ */
+ DragValue(const QString &label, double defaultValue, int decimals, double min = 0, double max = 100, int id = -1, const QString suffix = QString(), bool showSlider = true, QWidget* parent = 0);
virtual ~DragValue();
/** @brief Returns the precision = number of decimals */
public slots:
/** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
void setValue(double value, bool final = true);
+ void setValueFromProgress(double value, bool final);
/** @brief Resets to default value */
void slotReset();
/** See effects/README for info on the different types */
if (type == "double" || type == "constant") {
- int min;
- int max;
+ double min;
+ double max;
if (pa.attribute("min").startsWith('%'))
- min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
+ min = ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
else
- min = pa.attribute("min").toInt();
+ min = pa.attribute("min").toDouble();
if (pa.attribute("max").startsWith('%'))
- max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
+ max = ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
else
- max = pa.attribute("max").toInt();
+ max = pa.attribute("max").toDouble();
- DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
- pa.attribute("default").toInt(), comment, -1, pa.attribute("suffix"), this);
+ DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
+ pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), this);
m_vbox->addWidget(doubleparam);
m_valueItems[paramName] = doubleparam;
connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
void setFrameSize(QPoint p);
/** @brief Tells the parameters to update their timecode format according to KdenliveSettings. */
void updateTimecodeFormat();
+ /** @brief Returns true if this effect wants to keep track of current position in clip. */
+ bool effectNeedsSyncPosition() const;
private:
/** @brief Deletes all parameter widgets. */
connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
connect(m_ui.buttonSync, SIGNAL(toggled(bool)), this, SLOT(slotSetSynchronize(bool)));
- m_spinX = new DragValue(i18nc("x axis position", "X"), 0, 0, -1, QString(), false, this);
- m_spinX->setRange(-99000, 99000);
+ m_spinX = new DragValue(i18nc("x axis position", "X"), 0, 0, -99000, 99000, -1, QString(), false, this);
m_ui.horizontalLayout->addWidget(m_spinX);
- m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -1, QString(), false, this);
- m_spinY->setRange(-99000, 99000);
+ m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -99000, 99000, -1, QString(), false, this);
m_ui.horizontalLayout->addWidget(m_spinY);
- m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, -1, QString(), false, this);
- m_spinWidth->setRange(1, 99000);
+ m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, 1, 99000, -1, QString(), false, this);
m_ui.horizontalLayout->addWidget(m_spinWidth);
- m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, -1, QString(), false, this);
- m_spinHeight->setRange(1, 99000);
+ m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
m_ui.horizontalLayout->addWidget(m_spinHeight);
QMenu *menu = new QMenu(this);
m_ui.horizontalLayout->addLayout(alignLayout);
m_ui.horizontalLayout->addStretch(10);
- m_spinSize = new DragValue(i18n("Size"), 100, 2, -1, i18n("%"), false, this);
- m_spinSize->setRange(1, 99000);
+ m_spinSize = new DragValue(i18n("Size"), 100, 2, 1, 99000, -1, i18n("%"), false, this);
m_ui.horizontalLayout2->addWidget(m_spinSize);
- m_opacity = new DragValue(i18n("Opacity"), 100, 0, -1, i18n("%"), true, this);
+ m_opacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this);
m_ui.horizontalLayout2->addWidget(m_opacity);
if (showRotation) {
- m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1, QString(), true, this);
- m_rotateX->setRange(-1800, 1800);
+ m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1800, 1800, -1, QString(), true, this);
m_rotateX->setObjectName("rotate_x");
m_ui.horizontalLayout3->addWidget(m_rotateX);
- m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1, QString(), true, this);
- m_rotateY->setRange(-1800, 1800);
+ m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1800, 1800, -1, QString(), true, this);
m_rotateY->setObjectName("rotate_y");
m_ui.horizontalLayout3->addWidget(m_rotateY);
- m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1, QString(), true, this);
- m_rotateZ->setRange(-1800, 1800);
+ m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1800, 1800, -1, QString(), true, this);
m_rotateZ->setObjectName("rotate_z");
m_ui.horizontalLayout3->addWidget(m_rotateZ);
connect(m_rotateX, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
params.setAttribute("type", "constant");
if (QString(paramdesc.get("type")) == "float") {
params.setAttribute("type", "constant");
- params.setAttribute("factor", "1000");
- if (paramdesc.get("maximum")) params.setAttribute("max", QString(paramdesc.get("maximum")).toFloat() * 1000.0);
- if (paramdesc.get("minimum")) params.setAttribute("min", QString(paramdesc.get("minimum")).toFloat() * 1000.0);
+ // param type is float, set default decimals to 3
+ params.setAttribute("decimals", "3");
}
if (QString(paramdesc.get("type")) == "boolean")
params.setAttribute("type", "bool");
keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName));
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0,
- m_params.at(columnId).attribute("min").toInt(), m_params.at(columnId).attribute("max").toInt(),
- m_params.at(columnId).attribute("default").toInt(), comment, columnId, m_params.at(columnId).attribute("suffix"), this);
+ m_params.at(columnId).attribute("min").toDouble(), m_params.at(columnId).attribute("max").toDouble(),
+ m_params.at(columnId).attribute("default").toDouble(), comment, columnId, m_params.at(columnId).attribute("suffix"), m_params.at(columnId).attribute("decimals").toInt(), this);
connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
connect(doubleparam, SIGNAL(setInTimeline(int)), this, SLOT(slotUpdateVisibleParameter(int)));