MoveNewEvent.hpp
1 #pragma once
2 
3 #include "MoveEventOnCreationMeta.hpp"
4 
5 #include <Process/ExpandMode.hpp>
6 #include <Process/TimeValue.hpp>
7 
8 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
9 
10 #include <score/command/Command.hpp>
11 #include <score/model/Identifier.hpp>
12 #include <score/model/path/Path.hpp>
13 #include <score/tools/Unused.hpp>
14 #include <score/tools/std/Optional.hpp>
15 
16 #include <score_plugin_scenario_export.h>
17 
18 struct DataStreamInput;
19 struct DataStreamOutput;
20 
21 /*
22  * Used on creation mode, when mouse is pressed and is moving.
23  * In this case, both vertical and horizontal move are allowed
24  */
25 
26 namespace Scenario
27 {
28 class EventModel;
29 class IntervalModel;
30 class ProcessModel;
31 namespace Command
32 {
33 class SCORE_PLUGIN_SCENARIO_EXPORT MoveNewEvent final : public score::Command
34 {
35  SCORE_COMMAND_DECL(CommandFactoryName(), MoveNewEvent, "Move a new event")
36 public:
38  const Scenario::ProcessModel& scenarioPath, Id<IntervalModel> intervalId,
39  Id<EventModel> eventId, TimeVal date, const double y, bool yLocked);
41  const Scenario::ProcessModel& scenarioPath, Id<IntervalModel> intervalId,
42  Id<EventModel> eventId, TimeVal date, const double y, bool yLocked, ExpandMode);
43 
44  void undo(const score::DocumentContext& ctx) const override;
45  void redo(const score::DocumentContext& ctx) const override;
46 
47  void update(
48  Scenario::ProcessModel& s, unused_t, const Id<EventModel>& id, const TimeVal& date,
49  const double y, bool yLocked)
50  {
51  m_cmd.update(s, id, date, y, ExpandMode::Scale, LockMode::Free);
52  m_y = y;
53  m_yLocked = yLocked;
54  }
55 
56  const Path<Scenario::ProcessModel>& path() const { return m_path; }
57 
58 protected:
59  void serializeImpl(DataStreamInput&) const override;
60  void deserializeImpl(DataStreamOutput&) override;
61 
62 private:
64  Id<IntervalModel> m_intervalId{};
65 
67  double m_y{};
68  bool m_yLocked{true}; // default is true and intervals are on the same y.
69 };
70 }
71 }
Definition: MoveEventOnCreationMeta.hpp:27
Definition: MoveNewEvent.hpp:34
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: TimeValue.hpp:21
Definition: DocumentContext.hpp:18
Definition: Unused.hpp:3