38 const ToolPalette_T& stateMachine,
const Scenario_T& scenarioPath,
44 this->setObjectName(
"MoveIntervalBraceState");
45 using namespace Scenario::Command;
46 auto finalState =
new QFinalState{
this};
48 auto mainState =
new QState{
this};
50 auto pressed =
new QState{mainState};
51 auto released =
new QState{mainState};
52 auto moving =
new QState{mainState};
54 mainState->setInitialState(pressed);
55 released->addTransition(finalState);
57 score::make_transition<MoveOnAnything_Transition<Scenario_T>>(
58 pressed, moving, *
this);
59 score::make_transition<ReleaseOnAnything_Transition>(pressed, finalState);
61 score::make_transition<MoveOnAnything_Transition<Scenario_T>>(
62 moving, moving, *
this);
63 score::make_transition<ReleaseOnAnything_Transition>(moving, released);
65 QObject::connect(pressed, &QState::entered, [&]() {
66 this->m_initialDate = this->currentPoint.date;
67 if(this->clickedInterval)
69 auto& scenar = stateMachine.model();
70 auto& cstr = scenar.interval(*this->clickedInterval);
71 this->m_initialDuration
73 .*MoveBraceCommand_T::corresponding_member)();
80 QObject::connect(moving, &QState::entered, [&]() {
81 if(this->clickedInterval)
83 auto& scenar = stateMachine.model();
84 auto& cstr = scenar.interval(*this->clickedInterval);
85 auto date = this->currentPoint.date - *m_initialDate + *m_initialDuration;
87 date = stateMachine.magnetic().getPosition(&stateMachine.model(), date);
89 this->m_dispatcher.submit(cstr, date,
false);
94 released, &QState::entered, [&]() { this->m_dispatcher.commit(); });
97 auto rollbackState =
new QState{
this};
98 score::make_transition<score::Cancel_Transition>(mainState, rollbackState);
99 rollbackState->addTransition(finalState);
101 rollbackState, &QState::entered, [&]() { m_dispatcher.rollback(); });
103 this->setInitialState(mainState);
108 std::optional<TimeVal> m_initialDate;
109 std::optional<TimeVal> m_initialDuration;
119 const ToolPalette_T& stateMachine,
const Scenario_T& scenarioPath,
123 , m_dispatcher{stack}
125 this->setObjectName(
"MoveTimeSyncState");
126 using namespace Scenario::Command;
127 auto finalState =
new QFinalState{
this};
129 auto mainState =
new QState{
this};
131 auto pressed =
new QState{mainState};
132 auto released =
new QState{mainState};
133 auto moving =
new QState{mainState};
136 mainState->setInitialState(pressed);
137 released->addTransition(finalState);
139 score::make_transition<MoveOnAnything_Transition<Scenario_T>>(
140 pressed, moving, *
this);
141 score::make_transition<ReleaseOnAnything_Transition>(pressed, finalState);
142 score::make_transition<MoveOnAnything_Transition<Scenario_T>>(
143 moving, moving, *
this);
144 score::make_transition<ReleaseOnAnything_Transition>(moving, released);
147 QObject::connect(pressed, &QState::entered, [&]() {
148 if(!this->clickedTimeSync)
151 auto& scenar = stateMachine.model();
154 = previousNonGraphIntervals(scenar.timeSync(*this->clickedTimeSync), scenar);
155 if(!prev_csts.empty())
159 for(
const auto& cst_id : prev_csts)
161 const auto& other_date = scenar.interval(cst_id).date();
165 this->m_pressedPrevious = t;
169 this->m_pressedPrevious = std::nullopt;
173 QObject::connect(moving, &QState::entered, [&]() {
174 if(!this->clickedTimeSync)
178 auto& scenar = stateMachine.model();
179 auto& tn = scenar.timeSync(*this->clickedTimeSync);
180 SCORE_ASSERT(!tn.events().empty());
181 const auto& ev_id = tn.events().front();
182 auto date = this->currentPoint.date;
184 date = stateMachine.magnetic().getPosition(&stateMachine.model(), date);
186 if(this->m_pressedPrevious)
188 date = max(date, *this->m_pressedPrevious);
192 this->m_scenario, ev_id, date, this->currentPoint.y,
193 stateMachine.editionSettings().expandMode(),
194 stateMachine.editionSettings().lockMode());
197 QObject::connect(released, &QState::entered, [&]() {
198 m_dispatcher.commit();
199 m_pressedPrevious = {};
203 auto rollbackState =
new QState{
this};
204 score::make_transition<score::Cancel_Transition>(mainState, rollbackState);
205 rollbackState->addTransition(finalState);
207 rollbackState, &QState::entered, [&]() { m_dispatcher.rollback(); });
209 this->setInitialState(mainState);
213 std::optional<TimeVal> m_pressedPrevious;