25 const ToolPalette_T& stateMachine,
const Scenario_T& scenarioPath,
28 stateMachine, stack, std::move(scenarioPath), parent}
30 using namespace Scenario::Command;
31 auto finalState =
new QFinalState{
this};
32 QObject::connect(finalState, &QState::entered, [&]() { this->clearCreatedIds(); });
34 auto mainState =
new QState{
this};
36 auto pressed =
new QState{mainState};
37 auto released =
new QState{mainState};
44 mainState->setInitialState(pressed);
45 released->addTransition(finalState);
48 score::make_transition<ReleaseOnAnything_Transition>(mainState, released);
51 auto t_pressed_moving_nothing
52 = score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
53 pressed, move_nothing, *
this);
55 QObject::connect(t_pressed_moving_nothing, &QAbstractTransition::triggered, [&]() {
62 score::make_transition<MoveOnNothing_Transition<Scenario_T>>(
63 move_nothing, move_nothing, *
this);
66 this->add_transition(move_nothing, move_state, [&]() {
72 this->add_transition(move_nothing, move_event, [&]() {
73 if(this->hoveredEvent && this->createdEvents.contains(*this->hoveredEvent))
83 this->add_transition(move_nothing, move_timesync, [&]() {
84 if(this->hoveredTimeSync
85 && this->createdTimeSyncs.contains(*this->hoveredTimeSync))
95 this->add_transition(move_state, move_nothing, [&]() {
104 this->add_transition(move_state, move_event, [&]() {
110 this->add_transition(move_state, move_timesync, [&]() {
117 this->add_transition(move_event, move_nothing, [&]() {
123 this->add_transition(move_event, move_state, [&]() {
129 score::make_transition<MoveOnEvent_Transition<Scenario_T>>(
130 move_event, move_event, *
this);
133 this->add_transition(move_event, move_timesync, [&]() {
134 if(this->hoveredTimeSync
135 && this->createdTimeSyncs.contains(*this->hoveredTimeSync))
145 this->add_transition(move_timesync, move_nothing, [&]() {
151 this->add_transition(move_timesync, move_state, [&]() {
157 this->add_transition(move_timesync, move_event, [&]() {
158 if(this->hoveredEvent && this->createdEvents.contains(*this->hoveredEvent))
168 score::make_transition<MoveOnTimeSync_Transition<Scenario_T>>(
169 move_timesync, move_timesync, *
this);
172 QObject::connect(pressed, &QState::entered, [&]() {
173 this->m_clickedPoint = this->currentPoint;
174 createInitialEventAndState();
177 QObject::connect(move_nothing, &QState::entered, [&]() {
178 if(this->createdEvents.empty() || this->createdIntervals.empty())
184 this->currentPoint.date = stateMachine.magnetic().getPosition(
185 &stateMachine.model(), this->currentPoint.date);
187 if(this->currentPoint.date <= this->m_clickedPoint.date)
189 this->currentPoint.date = this->m_clickedPoint.date + TimeVal::fromMsecs(10);
194 this->m_dispatcher.template submit<MoveNewEvent>(
195 this->m_scenario, this->createdIntervals.last(), this->createdEvents.last(),
196 this->currentPoint.date, this->currentPoint.y,
197 stateMachine.editionSettings().tool() == Tool::CreateSequence);
200 QObject::connect(move_timesync, &QState::entered, [&]() {
201 if(this->createdEvents.empty())
207 if(this->currentPoint.date <= this->m_clickedPoint.date)
212 this->m_dispatcher.template submit<MoveEventMeta>(
213 this->m_scenario, this->createdEvents.last(), TimeVal::zero(), 0.,
214 stateMachine.editionSettings().expandMode(), LockMode::Free);
217 QObject::connect(released, &QState::entered,
this, &Creation_FromTimeSync::commit);
220 auto rollbackState =
new QState{
this};
221 score::make_transition<score::Cancel_Transition>(mainState, rollbackState);
222 rollbackState->addTransition(finalState);
224 rollbackState, &QState::entered,
this, &Creation_FromTimeSync::rollback);
226 this->setInitialState(mainState);