InterpolationPresenter.hpp
1 #pragma once
2 #include <State/UpdateAddress.hpp>
3 
4 #include <Device/Node/NodeListMimeSerialization.hpp>
5 
6 #include <Curve/CurveStyle.hpp>
7 #include <Curve/Process/CurveProcessPresenter.hpp>
8 
9 #include <Interpolation/Commands/ChangeAddress.hpp>
10 #include <Interpolation/InterpolationProcess.hpp>
11 #include <Interpolation/InterpolationView.hpp>
12 
13 #include <verdigris>
14 
15 namespace Interpolation
16 {
17 class Presenter final : public Curve::CurveProcessPresenter<ProcessModel, View>
18 {
19  W_OBJECT(Presenter)
20 public:
21  Presenter(
22  const Curve::Style& style, const ProcessModel& layer, View* view,
23  const Process::Context& context, QObject* parent)
24  : CurveProcessPresenter{style, layer, view, context, parent}
25  {
26  con(layer, &ProcessModel::tweenChanged, this, &Presenter::on_tweenChanges);
27  connect(m_view, &View::dropReceived, this, &Presenter::on_dropReceived);
28 
29  on_tweenChanges(layer.tween());
30  con(layer.curve(), &Curve::Model::curveReset, this,
31  [&] { on_tweenChanges(layer.tween()); });
32  }
33 
34 private:
35  void setFullView() override { m_curve.setBoundedMove(false); }
36 
37  void on_tweenChanges(bool b)
38  {
39  for(Curve::SegmentView& seg : m_curve.segments())
40  {
41  if(seg.model().start().x() != 0.)
42  {
43  seg.setTween(false);
44  }
45  else
46  {
47  seg.setTween(b);
48  }
49  }
50  }
51 
52  void on_dropReceived(const QPointF&, const QMimeData& mime)
53  {
54  if(auto newAddr = State::onUpdatableAddress(model().address(), mime))
55  {
56  CommandDispatcher<> disp{context().context.commandStack};
57  ChangeInterpolationAddress(model(), std::move(*newAddr), disp);
58  }
59  }
60 };
61 }
The CommandDispatcher class.
Definition: CommandDispatcher.hpp:13
Definition: CurveProcessPresenter.hpp:28
Definition: CurveSegmentView.hpp:26
Definition: InterpolationPresenter.hpp:18
Definition: InterpolationView.hpp:11
Definition: CurveStyle.hpp:13
Definition: ProcessContext.hpp:12