GradientPresenter.hpp
1 #pragma once
2 #include <Device/Address/AddressSettings.hpp>
3 
4 #include <Process/LayerPresenter.hpp>
5 
6 #include <Automation/Commands/AutomationCommandFactory.hpp>
7 
8 #include <score/model/path/PathSerialization.hpp>
9 #include <score/serialization/MapSerialization.hpp>
10 
11 #include <Color/GradientModel.hpp>
12 
13 namespace Gradient
14 {
15 
16 class ChangeGradient final : public score::Command
17 {
18  SCORE_COMMAND_DECL(Automation::CommandFactoryName(), ChangeGradient, "ChangeGradient")
19 public:
20  ChangeGradient(const ProcessModel& autom, const ProcessModel::gradient_colors& newval)
21  : m_path{autom}
22  , m_old{autom.gradient()}
23  , m_new{newval}
24  {
25  }
26 
27 public:
28  void undo(const score::DocumentContext& ctx) const override
29  {
30  m_path.find(ctx).setGradient(m_old);
31  }
32  void redo(const score::DocumentContext& ctx) const override
33  {
34  m_path.find(ctx).setGradient(m_new);
35  }
36 
37 protected:
38  void serializeImpl(DataStreamInput& s) const override
39  {
40  s << m_path << m_old << m_new;
41  }
42  void deserializeImpl(DataStreamOutput& s) override { s >> m_path >> m_old >> m_new; }
43 
44 private:
45  Path<ProcessModel> m_path;
46  ProcessModel::gradient_colors m_old, m_new;
47 };
48 
49 class View;
50 class Presenter final : public Process::LayerPresenter
51 {
52 public:
53  explicit Presenter(
54  const Gradient::ProcessModel& model, Gradient::View* view,
55  const Process::Context& ctx, QObject* parent);
56 
57  void setWidth(qreal width, qreal defaultWidth) override;
58  void setHeight(qreal height) override;
59 
60  void putToFront() override;
61  void putBehind() override;
62 
63  void on_zoomRatioChanged(ZoomRatio) override;
64 
65  void parentGeometryChanged() override;
66 
67 private:
68  View* m_view{};
69  ZoomRatio m_zoomRatio{};
70 };
71 }
Definition: AutomationModel.hpp:36
Definition: GradientPresenter.hpp:17
Definition: GradientPresenter.hpp:51
Definition: GradientView.hpp:10
Definition: LayerPresenter.hpp:34
The Command class.
Definition: Command.hpp:34
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: ProcessContext.hpp:12
Definition: DocumentContext.hpp:18