cleanup effect activation

parent 94fa15c9
Pipeline #15388 passed with stage
in 19 minutes and 17 seconds
......@@ -171,6 +171,7 @@ void KeyframeView::slotGoToPrev()
void KeyframeView::mousePressEvent(QMouseEvent *event)
{
emit activateEffect();
int offset = pCore->getItemIn(m_model->getOwnerId());
double zoomStart = m_zoomHandle.x() * (width() - 2 * m_offset);
double zoomEnd = m_zoomHandle.y() * (width() - 2 * m_offset);
......
......@@ -97,6 +97,7 @@ signals:
void seekToPos(int pos);
void atKeyframe(bool isKeyframe, bool singleKeyframe);
void modified();
void activateEffect();
};
#endif
......@@ -82,7 +82,6 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
ac->setChecked(true);
}
}
});
emit updatePresets();
connect(m_model.get(), &AssetParameterModel::dataChanged, this, &AssetParameterView::refresh);
......@@ -113,6 +112,7 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
connect(this, &AssetParameterView::initKeyframeView, w, &AbstractParamWidget::slotInitMonitor);
connect(w, &AbstractParamWidget::valueChanged, this, &AssetParameterView::commitChanges);
connect(w, &AbstractParamWidget::seekToPos, this, &AssetParameterView::seekToPos);
connect(w, &AbstractParamWidget::activateEffect, this, &AssetParameterView::activateEffect);
connect(w, &AbstractParamWidget::updateHeight, [&, w]() {
setFixedHeight(contentHeight());
emit updateHeight();
......
......@@ -110,6 +110,7 @@ signals:
/** @brief clear and refill the effect presets */
void updatePresets(const QString &presetName = QString());
void updateHeight();
void activateEffect();
};
#endif
......@@ -63,6 +63,7 @@ signals:
void seekToPos(int);
void updateHeight(int height = -1);
void activateEffect();
public slots:
/** @brief Toggle the comments on or off
......
......@@ -165,6 +165,7 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
connect(m_keyframeview, &KeyframeView::seekToPos, [&](int p) { slotSetPosition(p, true); });
connect(m_keyframeview, &KeyframeView::atKeyframe, this, &KeyframeWidget::slotAtKeyframe);
connect(m_keyframeview, &KeyframeView::modified, this, &KeyframeWidget::slotRefreshParams);
connect(m_keyframeview, &KeyframeView::activateEffect, this, &KeyframeWidget::activateEffect);
connect(m_buttonAddDelete, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotAddRemove);
connect(m_buttonPrevious, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotGoToPrev);
......
......@@ -141,6 +141,12 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
const std::shared_ptr<AssetParameterModel> effectParamModel = std::static_pointer_cast<AssetParameterModel>(effectModel);
m_view->setModel(effectParamModel, frameSize);
connect(m_view, &AssetParameterView::seekToPos, this, &AbstractCollapsibleWidget::seekToPos);
connect(m_view, &AssetParameterView::activateEffect, [this]() {
if (!decoframe->property("active").toBool()) {
// Activate effect if not already active
emit activateEffect(m_model);
}
});
connect(m_view, &AssetParameterView::updateHeight, this, &CollapsibleEffectView::updateHeight);
connect(this, &CollapsibleEffectView::refresh, m_view, &AssetParameterView::slotRefresh);
m_keyframesButton->setVisible(m_view->keyframesAllowed());
......@@ -337,7 +343,7 @@ bool CollapsibleEffectView::isEnabled() const
return m_enabledButton->isActive();
}
void CollapsibleEffectView::slotActivateEffect(QModelIndex ix, bool active)
void CollapsibleEffectView::slotActivateEffect(bool active)
{
// m_colorIcon->setEnabled(active);
// bool active = ix.row() == m_model->row();
......
......@@ -88,7 +88,7 @@ public slots:
void slotDisable(bool disable);
void slotResetEffect();
void importKeyframes(const QString &keyframes);
void slotActivateEffect(QModelIndex ix, bool active);
void slotActivateEffect(bool active);
void updateHeight();
/** @brief Should we block wheel event (if parent is a view with scrollbar) */
void blockWheenEvent(bool block);
......
......@@ -238,7 +238,6 @@ void EffectStackView::loadEffects()
int clipIn = pCore->getItemPosition(m_model->getOwnerId());
emit seekToPos(pos + clipIn);
});
//connect(this, &EffectStackView::doActivateEffect, view, &CollapsibleEffectView::slotActivateEffect);
connect(this, &EffectStackView::switchCollapsedView, view, &CollapsibleEffectView::switchCollapsed);
QModelIndex ix = m_model->getIndexFromItem(effectModel);
m_effectsTree->setIndexWidget(ix, view);
......@@ -247,12 +246,11 @@ void EffectStackView::loadEffects()
view->buttonUp->setEnabled(i > 0);
view->buttonDown->setEnabled(i < max - 1);
if (i == active) {
m_model->setActiveEffect(i);
activeIndex = ix;
}
}
if (activeIndex.isValid()) {
doActivateEffect(activeIndex);
doActivateEffect(active, activeIndex);
}
updateTreeHeight();
qDebug() << "MUTEX UNLOCK!!!!!!!!!!!! loadEffects";
......@@ -281,9 +279,8 @@ void EffectStackView::slotActivateEffect(const std::shared_ptr<EffectItemModel>
{
qDebug() << "MUTEX LOCK!!!!!!!!!!!! slotactivateeffect: " << effectModel->row();
QMutexLocker lock(&m_mutex);
m_model->setActiveEffect(effectModel->row());
QModelIndex activeIx = m_model->getIndexFromItem(effectModel);
doActivateEffect(activeIx);
doActivateEffect(effectModel->row(), activeIx);
qDebug() << "MUTEX UNLOCK!!!!!!!!!!!! slotactivateeffect";
}
......@@ -414,27 +411,25 @@ void EffectStackView::switchCollapsed()
}
}
void EffectStackView::doActivateEffect(QModelIndex activeIx)
void EffectStackView::doActivateEffect(int row, QModelIndex activeIx)
{
int max = m_model->rowCount();
for (int i = 0; i < max; ++i) {
auto item = m_model->getEffectStackRow(i);
if (item->childCount() > 0) {
// TODO: group
continue;
}
std::shared_ptr<EffectItemModel> eff = std::static_pointer_cast<EffectItemModel>(item);
QModelIndex ix = m_model->getIndexFromItem(eff);
if (ix != activeIx) {
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
if (w) {
w->slotActivateEffect(ix, false);
}
int currentActive = m_model->getActiveEffect();
if (row > 0 && row == currentActive) {
// Effect is already active
return;
}
if (row != currentActive) {
auto item = m_model->getEffectStackRow(currentActive);
QModelIndex ix = m_model->getIndexFromItem(item);
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(ix));
if (w) {
w->slotActivateEffect(false);
}
}
m_model->setActiveEffect(row);
CollapsibleEffectView *w = static_cast<CollapsibleEffectView *>(m_effectsTree->indexWidget(activeIx));
if (w) {
w->slotActivateEffect(activeIx, true);
w->slotActivateEffect(true);
}
}
......
......@@ -104,7 +104,7 @@ private slots:
void slotActivateEffect(const std::shared_ptr<EffectItemModel> &effectModel);
void loadEffects();
void updateTreeHeight();
void doActivateEffect(QModelIndex);
void doActivateEffect(int row, QModelIndex ix);
// void switchBuiltStack(bool show);
......
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