Fix fades on clip cuts & resize

parent 30aa6de9
......@@ -149,10 +149,16 @@ bool EffectStackModel::adjustFadeLength(int duration, bool fromStart, bool audio
}
}
QList<QModelIndex> indexes;
auto ptr = m_service.lock();
int in = 0;
if (ptr) {
in = ptr->get_int("in");
}
for (int i = 0; i < rootItem->childCount(); ++i) {
if (fadeIns.contains(std::static_pointer_cast<TreeItem>(rootItem->child(i))->getId())) {
std::shared_ptr<EffectItemModel> effect = std::static_pointer_cast<EffectItemModel>(rootItem->child(i));
effect->filter().set("out", duration);
effect->filter().set("in", in);
effect->filter().set("out", in + duration);
indexes << getIndexFromItem(effect);
}
}
......@@ -169,7 +175,12 @@ bool EffectStackModel::adjustFadeLength(int duration, bool fromStart, bool audio
appendEffect(QStringLiteral("fade_to_black"));
}
}
int out = pCore->getItemDuration(m_ownerId);
int in = 0;
auto ptr = m_service.lock();
if (ptr) {
in = ptr->get_int("in");
}
int out = in + pCore->getItemDuration(m_ownerId);
QList<QModelIndex> indexes;
for (int i = 0; i < rootItem->childCount(); ++i) {
if (fadeOuts.contains(std::static_pointer_cast<TreeItem>(rootItem->child(i))->getId())) {
......
......@@ -98,6 +98,8 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo)
int in = m_producer->get_in();
int out = m_producer->get_out();
int old_in = in, old_out = out;
int fadeInDuration = m_effectStack->getFadePosition(true);
int fadeOutDuration = m_effectStack->getFadePosition(false);
// check if there is enough space on the chosen side
if (!right && in + delta < 0 && !m_endlessResize) {
return false;
......@@ -121,7 +123,7 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo)
Q_ASSERT(false);
}
}
Fun operation = [this, in, out, track_operation]() {
Fun operation = [this, in, out, right, old_in, fadeInDuration, fadeOutDuration, track_operation]() {
if (track_operation()) {
int outPoint = in < 0 ? out - in : out;
if (outPoint >= m_producer->get_length()) {
......@@ -129,6 +131,13 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo)
m_producer->set("length", outPoint + 1);
}
m_producer->set_in_and_out(in < 0 ? 0 : in, outPoint);
if (right) {
if (fadeOutDuration > 0) {
adjustEffectLength(QStringLiteral("fadeout"), fadeOutDuration);
}
} else if (fadeInDuration > 0) {
adjustEffectLength(QStringLiteral("fadein"), fadeInDuration - in);
}
return true;
}
return false;
......@@ -349,7 +358,7 @@ std::shared_ptr<MarkerListModel> ClipModel::getMarkerModel() const
int ClipModel::fadeIn() const
{
return m_effectStack->getFadePosition(true);
return m_effectStack->getFadePosition(true) - getIn();
}
int ClipModel::fadeOut() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment