score-plugin-spline/Spline/Model.hpp
1 #pragma once
2 #include <State/Address.hpp>
3 #include <State/Unit.hpp>
4 
5 #include <Process/Process.hpp>
6 
8 
9 #include <ossia/dataflow/nodes/spline/spline2d.hpp>
10 
11 #include <Spline/Metadata.hpp>
12 
13 #include <verdigris>
14 
15 namespace Spline
16 {
17 
18 class ProcessModel final : public Process::ProcessModel
19 {
20  SCORE_SERIALIZE_FRIENDS
21  PROCESS_METADATA_IMPL(Spline::ProcessModel)
22 
23  W_OBJECT(ProcessModel)
24 
25 public:
27  const TimeVal& duration, const Id<Process::ProcessModel>& id, QObject* parent);
28  ~ProcessModel() override;
29 
30  template <typename Impl>
31  ProcessModel(Impl& vis, QObject* parent)
32  : Process::ProcessModel{vis, parent}
33  {
34  vis.writeTo(*this);
35  init();
36  }
37 
38  void init();
39  State::AddressAccessor address() const;
40  void setAddress(const State::AddressAccessor& arg);
41  State::Unit unit() const;
42  void setUnit(const State::Unit&);
43 
44  bool tween() const { return m_tween; }
45  void setTween(bool tween)
46  {
47  if(m_tween == tween)
48  return;
49 
50  m_tween = tween;
51  tweenChanged(tween);
52  }
53 
54  QString prettyName() const noexcept override;
55 
56  const ossia::spline_data& spline() const noexcept { return m_spline; }
57  void setSpline(const ossia::spline_data& c)
58  {
59  if(m_spline != c)
60  {
61  m_spline = c;
62  splineChanged();
63  }
64  }
65 
66  std::unique_ptr<Process::Outlet> outlet;
67 
68  void addressChanged(const ::State::AddressAccessor& arg_1)
69  W_SIGNAL(addressChanged, arg_1);
70  void tweenChanged(bool tween) W_SIGNAL(tweenChanged, tween);
71  void unitChanged(const State::Unit& arg_1) W_SIGNAL(unitChanged, arg_1);
72  void splineChanged() W_SIGNAL(splineChanged);
73 
74 private:
76  void loadPreset(const Process::Preset& preset) override;
77  Process::Preset savePreset() const noexcept override;
78 
79  void setDurationAndScale(const TimeVal& newDuration) noexcept override;
80  void setDurationAndGrow(const TimeVal& newDuration) noexcept override;
81  void setDurationAndShrink(const TimeVal& newDuration) noexcept override;
82 
83  TimeVal contentDuration() const noexcept override;
84 
85  ossia::spline_data m_spline;
86 
87  bool m_tween = false;
88 
89  W_PROPERTY(State::Unit, unit READ unit WRITE setUnit NOTIFY unitChanged)
90 
91  W_PROPERTY(bool, tween READ tween WRITE setTween NOTIFY tweenChanged)
92 
93  W_PROPERTY(
95  address READ address WRITE setAddress NOTIFY addressChanged)
96 };
97 }
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Definition: score-plugin-spline/Spline/Model.hpp:19
The id_base_t class.
Definition: Identifier.hpp:57
Definition: Preset.hpp:32
Definition: Address.hpp:108
Definition: Unit.hpp:18
Definition: TimeValue.hpp:21