Commit 8b576b43 authored by Nicolas Carion's avatar Nicolas Carion

Effects can now be disabled, at local or timeline level

parent 59cf159e
......@@ -26,6 +26,8 @@
EffectItemModel::EffectItemModel(const QList<QVariant> &data, Mlt::Properties *effect, const QDomElement &xml, const QString &effectId)
: TreeItem(data)
, AssetParameterModel(effect, xml, effectId)
, m_enabled(true)
, m_timelineEffectsEnabled(true)
{
}
......@@ -59,3 +61,25 @@ Mlt::Filter& EffectItemModel::filter() const
{
return *static_cast<Mlt::Filter*>(m_asset.get());
}
void EffectItemModel::setEnabled(bool enabled)
{
m_enabled = enabled;
updateEnable();
}
void EffectItemModel::setTimelineEffectsEnabled(bool enabled)
{
m_timelineEffectsEnabled = enabled;
updateEnable();
}
bool EffectItemModel::isEnabled() const
{
return m_enabled && m_timelineEffectsEnabled;
}
void EffectItemModel::updateEnable()
{
filter().set("disable", isEnabled() ? 0 : 1);
}
......@@ -40,10 +40,27 @@ public:
*/
void plant(std::weak_ptr<Mlt::Service> service);
/* @brief This function change the individual enabled state of the effect */
void setEnabled(bool enabled);
/* @brief This function change the global (timeline-wise) enabled state of the effect */
void setTimelineEffectsEnabled(bool enabled);
/* @brief Returns whether the effect is enabled */
bool isEnabled() const;
Mlt::Filter &filter() const;
protected:
EffectItemModel(const QList<QVariant> &data, Mlt::Properties *effect, const QDomElement &xml, const QString &effectId);
/* @brief Toogles the mlt effect according to the current activation state*/
void updateEnable();
bool m_enabled;
bool m_timelineEffectsEnabled;
};
......
......@@ -25,6 +25,7 @@
EffectStackModel::EffectStackModel(std::weak_ptr<Mlt::Service> service) :
AbstractTreeModel()
, m_service(service)
, m_timelineEffectsEnabled(true)
{
}
......@@ -37,6 +38,18 @@ std::shared_ptr<EffectStackModel> EffectStackModel::construct(std::weak_ptr<Mlt:
void EffectStackModel::appendEffect(const QString& effectId)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
rootItem->appendChild(EffectItemModel::construct(effectId));
auto effect = EffectItemModel::construct(effectId);
effect->setTimelineEffectsEnabled(m_timelineEffectsEnabled);
rootItem->appendChild(effect);
endInsertRows();
}
void EffectStackModel::setTimelineEffectsEnabled(bool enabled)
{
m_timelineEffectsEnabled = enabled;
//Recursively updates children states
for (int i = 0; i < rootItem->childCount(); ++i) {
static_cast<EffectItemModel*>(rootItem->child(i))->setTimelineEffectsEnabled(enabled);
}
}
......@@ -44,10 +44,15 @@ public:
EffectStackModel(std::weak_ptr<Mlt::Service> service);
protected:
/* @brief This function change the global (timeline-wise) enabled state of the effects
*/
void setTimelineEffectsEnabled(bool enabled);
protected:
std::weak_ptr<Mlt::Service> m_service;
bool m_timelineEffectsEnabled;
};
#endif
......@@ -119,3 +119,8 @@ int ClipModel::getPlaytime() const
{
return m_producer->get_playtime();
}
void ClipModel::setTimelineEffectsEnabled(bool enabled)
{
m_effectStack->setTimelineEffectsEnabled(enabled);
}
......@@ -78,6 +78,10 @@ protected:
*/
bool requestResize(int size, bool right, Fun& undo, Fun& redo) override;
/* @brief This function change the global (timeline-wise) enabled state of the effects
*/
void setTimelineEffectsEnabled(bool enabled);
protected:
std::shared_ptr<Mlt::Producer> m_producer;
......
......@@ -54,7 +54,8 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
m_undoStack(undo_stack),
m_profile(profile),
m_blackClip(new Mlt::Producer(*profile,"color:black")),
m_lock(QReadWriteLock::Recursive)
m_lock(QReadWriteLock::Recursive),
m_timelineEffectsEnabled(true)
{
// Create black background track
m_blackClip->set("id", "black_track");
......@@ -851,6 +852,7 @@ void TimelineModel::registerClip(std::shared_ptr<ClipModel> clip)
Q_ASSERT(m_allClips.count(id) == 0);
m_allClips[id] = clip;
m_groups->createGroupItem(id);
clip->setTimelineEffectsEnabled(m_timelineEffectsEnabled);
}
void TimelineModel::registerGroup(int groupId)
......@@ -1373,3 +1375,14 @@ bool TimelineModel::requestItemResizeToPos(int itemId, int position, bool right)
}
return result;
}
void TimelineModel::setTimelineEffectsEnabled(bool enabled)
{
m_timelineEffectsEnabled = enabled;
//propagate info to clips
for (const auto& clip : m_allClips) {
clip.second->setTimelineEffectsEnabled(enabled);
}
//TODO if we support track effects, they should be disabled here too
}
......@@ -360,6 +360,10 @@ public:
/* Same function, but accumulates undo and redo*/
bool requestCompositionInsertion(const QString& transitionId, int trackId, int position, int length, int &id, Fun& undo, Fun& redo);
/* @brief This function change the global (timeline-wise) enabled state of the effects
It disables/enables track and clip effects (recursively)
*/
void setTimelineEffectsEnabled(bool enabled);
protected:
/* @brief Register a new track. This is a call-back meant to be called from TrackModel
......@@ -468,6 +472,8 @@ protected:
std::ofstream m_logFile; //this is a temporary debug member to help reproduce issues
bool m_timelineEffectsEnabled;
//what follows are some virtual function that corresponds to the QML. They are implemented in TimelineItemModel
protected:
virtual void _beginRemoveRows(const QModelIndex&, int , int) = 0;
......
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