diff --git a/src/plugins/score-plugin-scenario/Scenario/Commands/Scenario/Creations/CreateStateMacro.hpp b/src/plugins/score-plugin-scenario/Scenario/Commands/Scenario/Creations/CreateStateMacro.hpp index f639931ec2..30624ad6d6 100644 --- a/src/plugins/score-plugin-scenario/Scenario/Commands/Scenario/Creations/CreateStateMacro.hpp +++ b/src/plugins/score-plugin-scenario/Scenario/Commands/Scenario/Creations/CreateStateMacro.hpp @@ -19,5 +19,17 @@ class CreateStateMacro final : public score::AggregateCommand SCORE_COMMAND_DECL(CommandFactoryName(), CreateStateMacro, "Drop a state") public: }; + +/** + * @brief The CreateDot class + * + * Used to create a dot by double clicking + * + */ +class CreateDot final : public score::AggregateCommand +{ + SCORE_COMMAND_DECL(CommandFactoryName(), CreateDot, "Create a dot") +public: +}; } } diff --git a/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.cpp b/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.cpp index a2c6e3063f..e69de29bb2 100644 --- a/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.cpp +++ b/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.cpp @@ -1,43 +0,0 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com -#include "SetAutoTrigger.hpp" - -#include - -#include - -namespace Scenario -{ -namespace Command -{ - -SetAutoTrigger::SetAutoTrigger(const TimeSyncModel& tn, bool b) - : m_path{std::move(tn)} - , m_old{tn.autotrigger()} - , m_new{b} -{ -} - -void SetAutoTrigger::undo(const score::DocumentContext& ctx) const -{ - auto& tn = m_path.find(ctx); - tn.setAutotrigger(m_old); -} - -void SetAutoTrigger::redo(const score::DocumentContext& ctx) const -{ - auto& tn = m_path.find(ctx); - tn.setAutotrigger(m_new); -} - -void SetAutoTrigger::serializeImpl(DataStreamInput& s) const -{ - s << m_path << m_old << m_new; -} - -void SetAutoTrigger::deserializeImpl(DataStreamOutput& s) -{ - s >> m_path >> m_old >> m_new; -} -} -} diff --git a/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.hpp b/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.hpp index ec55c9fac0..91d9c1412a 100644 --- a/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.hpp +++ b/src/plugins/score-plugin-scenario/Scenario/Commands/TimeSync/SetAutoTrigger.hpp @@ -8,38 +8,26 @@ #include #include -namespace Scenario +namespace Scenario::Command { -class TimeSyncModel; -namespace Command -{ -using TimeSyncModel = ::Scenario::TimeSyncModel; -class SCORE_PLUGIN_SCENARIO_EXPORT SetAutoTrigger final : public score::Command -{ - SCORE_COMMAND_DECL(CommandFactoryName(), SetAutoTrigger, "Change a trigger") -public: - SetAutoTrigger(const TimeSyncModel& tn, bool t); - - void undo(const score::DocumentContext& ctx) const override; - void redo(const score::DocumentContext& ctx) const override; - -protected: - void serializeImpl(DataStreamInput&) const override; - void deserializeImpl(DataStreamOutput&) override; - -private: - Path m_path; - bool m_old{}, m_new{}; -}; +using TimeSyncModel = Scenario::TimeSyncModel; -} } PROPERTY_COMMAND_T( Scenario::Command, SetTimeSyncMusicalSync, TimeSyncModel::p_musicalSync, "Set sync") SCORE_COMMAND_DECL_T(Scenario::Command::SetTimeSyncMusicalSync) +PROPERTY_COMMAND_T( + Scenario::Command, SetTimeSyncIsActive, TimeSyncModel::p_active, "Set active") +SCORE_COMMAND_DECL_T(Scenario::Command::SetTimeSyncActive) + PROPERTY_COMMAND_T( Scenario::Command, SetTimeSyncIsStartPoint, TimeSyncModel::p_startPoint, "Set start point") SCORE_COMMAND_DECL_T(Scenario::Command::SetTimeSyncIsStartPoint) + +PROPERTY_COMMAND_T( + Scenario::Command, SetTimeSyncIsAutoTrigger, TimeSyncModel::p_autotrigger, + "Set auto-trigger") +SCORE_COMMAND_DECL_T(Scenario::Command::SetTimeSyncIsAutoTrigger) diff --git a/src/plugins/score-plugin-scenario/Scenario/Document/TimeSync/TimeSyncModel.hpp b/src/plugins/score-plugin-scenario/Scenario/Document/TimeSync/TimeSyncModel.hpp index 45b6c0d0a9..0c1fe2df38 100644 --- a/src/plugins/score-plugin-scenario/Scenario/Document/TimeSync/TimeSyncModel.hpp +++ b/src/plugins/score-plugin-scenario/Scenario/Document/TimeSync/TimeSyncModel.hpp @@ -20,7 +20,6 @@ #include -#include #include class DataStream; class JSONObject; @@ -110,8 +109,14 @@ class SCORE_PLUGIN_SCENARIO_EXPORT TimeSyncModel final PROPERTY( ossia::musical_sync, musicalSync READ musicalSync WRITE setMusicalSync NOTIFY musicalSyncChanged) + PROPERTY(bool, active READ active WRITE setActive NOTIFY activeChanged) + PROPERTY( + bool, autotrigger READ autotrigger WRITE setAutotrigger NOTIFY autotriggerChanged) PROPERTY( bool, startPoint READ isStartPoint WRITE setStartPoint NOTIFY startPointChanged) + PROPERTY( + State::Expression, + expression READ expression WRITE setExpression NOTIFY triggerChanged) private: TimeVal m_date{}; diff --git a/src/plugins/score-plugin-scenario/Scenario/Inspector/TimeSync/TimeSyncInspectorWidget.cpp b/src/plugins/score-plugin-scenario/Scenario/Inspector/TimeSync/TimeSyncInspectorWidget.cpp index ca5bb59dd1..97fb3cb64e 100644 --- a/src/plugins/score-plugin-scenario/Scenario/Inspector/TimeSync/TimeSyncInspectorWidget.cpp +++ b/src/plugins/score-plugin-scenario/Scenario/Inspector/TimeSync/TimeSyncInspectorWidget.cpp @@ -70,8 +70,8 @@ to the root of a score.)_")); m_btnLayout.addWidget(m_autotrigger); connect(m_autotrigger, &QAbstractButton::toggled, this, [&](bool t) { if(t != object.autotrigger()) - CommandDispatcher<>{ctx.commandStack}.submit( - object, t); + CommandDispatcher<>{ctx.commandStack} + .submit(object, t); }); connect(&object, &TimeSyncModel::autotriggerChanged, this, [&](bool t) { if(t != m_autotrigger->isDown()) diff --git a/src/plugins/score-plugin-scenario/Scenario/Process/ScenarioPresenter.cpp b/src/plugins/score-plugin-scenario/Scenario/Process/ScenarioPresenter.cpp index 6e148227a1..f0955d48a3 100644 --- a/src/plugins/score-plugin-scenario/Scenario/Process/ScenarioPresenter.cpp +++ b/src/plugins/score-plugin-scenario/Scenario/Process/ScenarioPresenter.cpp @@ -9,11 +9,14 @@ #include #include #include +#include #include #include #include +#include #include #include +#include #include #include #include @@ -757,9 +760,13 @@ void ScenarioPresenter::doubleClick(QPointF pt) auto sp = toScenarioPoint(pt); - // Just create a dot - auto cmd = new Command::CreateTimeSync_Event_State{model(), sp.date, sp.y}; - CommandDispatcher<>{m_context.context.commandStack}.submit(cmd); + Scenario::Command::Macro m{new Scenario::Command::CreateDot, m_context.context}; + auto [ts, ev, s] = m.createDot(model(), sp); + + m.setProperty(ts, true); + m.setProperty(ts, true); + + m.commit(); } void ScenarioPresenter::on_focusChanged()