summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-16 22:32:00 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-16 22:32:00 (GMT)
commit246e684d6bd956e362a7d98d9f7e61405f6ce7e8 (patch)
tree43d17a9c0e53eb2f12a9138815526b6d4bb3d4ac
parent400590d05b7a532b7290cc2d59e036308bd510dc (diff)
Improve opacity widget and add size control in animated keyframe widget
-rw-r--r--src/effectstack/dragvalue.cpp2
-rw-r--r--src/effectstack/widgets/animationwidget.cpp33
-rw-r--r--src/effectstack/widgets/animationwidget.h4
3 files changed, 33 insertions, 6 deletions
diff --git a/src/effectstack/dragvalue.cpp b/src/effectstack/dragvalue.cpp
index 23a8761..fd79856 100644
--- a/src/effectstack/dragvalue.cpp
+++ b/src/effectstack/dragvalue.cpp
@@ -72,6 +72,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
m_intEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_intEdit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
m_intEdit->setRange((int) m_minimum, (int)m_maximum);
+ m_intEdit->setValue((int) m_default);
l->addWidget(m_intEdit);
connect(m_intEdit, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
connect(m_intEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
@@ -91,6 +92,7 @@ DragValue::DragValue(const QString &label, double defaultValue, int decimals, do
m_label->setStep(1);
m_doubleEdit->setSingleStep((m_maximum - m_minimum) / factor);
l->addWidget(m_doubleEdit);
+ m_doubleEdit->setValue(m_default);
connect(m_doubleEdit, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double)));
connect(m_doubleEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
}
diff --git a/src/effectstack/widgets/animationwidget.cpp b/src/effectstack/widgets/animationwidget.cpp
index 73a68cc..a4c7a6c 100644
--- a/src/effectstack/widgets/animationwidget.cpp
+++ b/src/effectstack/widgets/animationwidget.cpp
@@ -71,6 +71,7 @@ AnimationWidget::AnimationWidget(EffectMetaInfo *info, int clipPos, int min, int
, m_spinY(NULL)
, m_spinWidth(NULL)
, m_spinHeight(NULL)
+ , m_spinSize(NULL)
, m_spinOpacity(NULL)
, m_offset(effectIn - min)
{
@@ -701,14 +702,19 @@ void AnimationWidget::buildRectWidget(const QString &paramTag, const QDomElement
m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
connect(m_spinHeight, SIGNAL(valueChanged(double)), this, SLOT(slotAdjustRectKeyframeValue()));
horLayout->addWidget(m_spinHeight);
+ horLayout->addStretch(10);
+ QHBoxLayout *horLayout2 = new QHBoxLayout;
+ m_spinSize = new DragValue(i18n("Size"), 100, 2, 1, 99000, -1, i18n("%"), false, this);
+ m_spinSize->setStep(10);
+ connect(m_spinSize, &DragValue::valueChanged, this, &AnimationWidget::slotResize);
+ horLayout2->addWidget(m_spinSize);
if (e.attribute(QStringLiteral("opacity")) != QLatin1String("false")) {
- m_spinOpacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, QString(), false, this);
+ m_spinOpacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this);
connect(m_spinOpacity, SIGNAL(valueChanged(double)), this, SLOT(slotAdjustRectKeyframeValue()));
- horLayout->addWidget(m_spinOpacity);
+ horLayout2->addWidget(m_spinOpacity);
}
- horLayout->addStretch(10);
-
+
// Build buttons
QAction *originalSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-original")), i18n("Adjust to original size"), this);
connect(originalSize, SIGNAL(triggered()), this, SLOT(slotAdjustToSource()));
@@ -778,7 +784,7 @@ void AnimationWidget::buildRectWidget(const QString &paramTag, const QDomElement
alignButton->setDefaultAction(fitToWidth);
alignButton->setAutoRaise(true);
alignLayout->addWidget(alignButton);
-
+
alignButton = new QToolButton;
alignButton->setDefaultAction(fitToHeight);
alignButton->setAutoRaise(true);
@@ -787,6 +793,7 @@ void AnimationWidget::buildRectWidget(const QString &paramTag, const QDomElement
static_cast<QVBoxLayout *>(layout())->addLayout(horLayout);
static_cast<QVBoxLayout *>(layout())->addLayout(alignLayout);
+ static_cast<QVBoxLayout *>(layout())->addLayout(horLayout2);
m_animController = m_animProperties.get_animation(paramTag.toUtf8().constData());
}
@@ -838,6 +845,10 @@ void AnimationWidget::slotAdjustRectKeyframeValue()
rect.w = m_spinWidth->value();
rect.h = m_spinHeight->value();
rect.o = m_spinOpacity ? m_spinOpacity->value() / 100.0 : 1;
+ double scale = qMin(m_spinWidth->value() / m_monitor->render->frameRenderWidth(), m_spinHeight->value() / m_monitor->render->renderHeight());
+ m_spinSize->blockSignals(true);
+ m_spinSize->setValue(100.0 * scale);
+ m_spinSize->blockSignals(false);
if (m_animController.is_key(pos)) {
// This is a keyframe
m_animProperties.anim_set(m_rectParameter.toUtf8().constData(), rect, pos, m_outPoint, (mlt_keyframe_type) m_selectType->currentAction()->data().toInt());
@@ -853,6 +864,18 @@ void AnimationWidget::slotAdjustRectKeyframeValue()
}
}
+void AnimationWidget::slotResize(double value)
+{
+ m_spinWidth->blockSignals(true);
+ m_spinHeight->blockSignals(true);
+ m_spinWidth->setValue(m_monitor->render->frameRenderWidth() * value / 100.0);
+ m_spinHeight->setValue(m_monitor->render->renderHeight() * value / 100.0);
+ m_spinWidth->blockSignals(false);
+ m_spinHeight->blockSignals(false);
+ slotAdjustRectKeyframeValue();
+ setupMonitor();
+}
+
bool AnimationWidget::isActive(const QString &name) const
{
return name == m_inTimeline;
diff --git a/src/effectstack/widgets/animationwidget.h b/src/effectstack/widgets/animationwidget.h
index a8fc173..cf12937 100644
--- a/src/effectstack/widgets/animationwidget.h
+++ b/src/effectstack/widgets/animationwidget.h
@@ -95,6 +95,7 @@ private:
DragValue *m_spinY;
DragValue *m_spinWidth;
DragValue *m_spinHeight;
+ DragValue *m_spinSize;
DragValue *m_spinOpacity;
int m_offset;
void parseKeyframes();
@@ -138,7 +139,8 @@ private slots:
void slotAdjustToFrameSize();
void slotFitToWidth();
void slotFitToHeight();
-
+ void slotResize(double value);
+
/** @brief Moves the rect to the left frame border (x position = 0). */
void slotMoveLeft();
/** @brief Centers the rect horizontally. */