MoveNewState.hpp
1 #pragma once
2 
3 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
4 
5 #include <score/command/Command.hpp>
6 #include <score/model/Identifier.hpp>
7 #include <score/model/path/Path.hpp>
8 #include <score/tools/std/Optional.hpp>
9 
10 struct DataStreamInput;
11 struct DataStreamOutput;
12 
13 /*
14  * Used on creation mode, when mouse is pressed and is moving.
15  * In this case, only vertical move is allowed (new state on an existing event)
16  */
17 namespace Scenario
18 {
19 class StateModel;
20 class ProcessModel;
21 
22 namespace Command
23 {
24 
25 class SCORE_PLUGIN_SCENARIO_EXPORT MoveNewState final : public score::Command
26 {
27  SCORE_COMMAND_DECL(CommandFactoryName(), MoveNewState, "Move a new state")
28 public:
29  MoveNewState(const Scenario::ProcessModel& scenar, Id<StateModel> stateId, double y);
30 
31  void undo(const score::DocumentContext& ctx) const override;
32  void redo(const score::DocumentContext& ctx) const override;
33 
34  void update(const Path<Scenario::ProcessModel>&, const Id<StateModel>&, double y)
35  {
36  m_y = y;
37  }
38 
39  const Path<Scenario::ProcessModel>& path() const { return m_path; }
40 
41 protected:
42  void serializeImpl(DataStreamInput&) const override;
43  void deserializeImpl(DataStreamOutput&) override;
44 
45 private:
47  Id<StateModel> m_stateId;
48  double m_y{}, m_oldy{};
49 };
50 }
51 }
Definition: MoveNewState.hpp:26
The core hierarchical and temporal process of score.
Definition: ScenarioModel.hpp:37
The id_base_t class.
Definition: Identifier.hpp:57
The Command class.
Definition: Command.hpp:34
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: DocumentContext.hpp:18