GradientModel.hpp
1 #pragma once
2 #include <State/Address.hpp>
3 #include <State/Unit.hpp>
4 
5 #include <Process/Dataflow/Port.hpp>
6 #include <Process/Process.hpp>
7 
9 
10 #include <ossia/detail/flat_map.hpp>
11 
12 #include <Color/GradientMetadata.hpp>
13 
14 #include <score_plugin_automation_export.h>
15 
16 #include <verdigris>
17 
18 namespace Gradient
19 {
20 class SCORE_PLUGIN_AUTOMATION_EXPORT ProcessModel final : public Process::ProcessModel
21 {
22  SCORE_SERIALIZE_FRIENDS
23  PROCESS_METADATA_IMPL(Gradient::ProcessModel)
24 
25  W_OBJECT(ProcessModel)
26 
27 public:
29  const TimeVal& duration, const Id<Process::ProcessModel>& id, QObject* parent);
30  ~ProcessModel() override;
31 
32  template <typename Impl>
33  ProcessModel(Impl& vis, QObject* parent)
34  : Process::ProcessModel{vis, parent}
35  {
36  vis.writeTo(*this);
37  init();
38  }
39 
40  void init();
41 
42  const State::AddressAccessor& address() const;
43 
44  bool tween() const;
45  void setTween(bool tween);
46 
47  QString prettyName() const noexcept override;
48 
49  using gradient_colors = ossia::flat_map<double, QColor>;
50  const gradient_colors& gradient() const;
51  void setGradient(const gradient_colors& c);
52 
53  std::unique_ptr<Process::Outlet> outlet;
54 
55 public:
56  void tweenChanged(bool tween)
57  E_SIGNAL(SCORE_PLUGIN_AUTOMATION_EXPORT, tweenChanged, tween)
58  void gradientChanged() E_SIGNAL(SCORE_PLUGIN_AUTOMATION_EXPORT, gradientChanged)
59 
60  PROPERTY(bool, tween READ tween WRITE setTween NOTIFY tweenChanged)
61 private:
63  void loadPreset(const Process::Preset& preset) override;
64  Process::Preset savePreset() const noexcept override;
65 
66  std::optional<Process::MagneticInfo>
67  magneticPosition(const QObject* o, const TimeVal t) const noexcept override;
68 
69  void setDurationAndScale(const TimeVal& newDuration) noexcept override;
70  void setDurationAndGrow(const TimeVal& newDuration) noexcept override;
71  void setDurationAndShrink(const TimeVal& newDuration) noexcept override;
72 
73  TimeVal contentDuration() const noexcept override;
74 
75  ossia::flat_map<double, QColor> m_colors;
76 
77  bool m_tween = false;
78 };
79 }
Definition: AutomationModel.hpp:36
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
The id_base_t class.
Definition: Identifier.hpp:57
Definition: Preset.hpp:32
Definition: Address.hpp:108
Definition: TimeValue.hpp:21