Loading...
Searching...
No Matches
AutomationPresenter.hpp
1#pragma once
2#include <State/UpdateAddress.hpp>
3
4#include <Device/Node/NodeListMimeSerialization.hpp>
5
6#include <Process/ProcessContext.hpp>
7#include <Process/ProcessMimeSerialization.hpp>
8
9#include <Curve/Process/CurveProcessPresenter.hpp>
10
11#include <Automation/AutomationModel.hpp>
12#include <Automation/AutomationView.hpp>
13#include <Automation/Commands/ChangeAddress.hpp>
14
15#include <verdigris>
16
17namespace Automation
18{
19class LayerPresenter final : public Curve::CurveProcessPresenter<ProcessModel, LayerView>
20{
21 W_OBJECT(LayerPresenter)
22public:
24 const Curve::Style& style, const Automation::ProcessModel& layer, LayerView* view,
25 const Process::Context& context, QObject* parent)
26 : CurveProcessPresenter{style, layer, view, context, parent}
27 {
28 // TODO instead have a prettyNameChanged signal.
29 con(layer, &ProcessModel::tweenChanged, this, &LayerPresenter::on_tweenChanges);
30
31 connect(m_view, &LayerView::dropReceived, this, &LayerPresenter::on_dropReceived);
32
33 on_tweenChanges(layer.tween());
34 con(layer.curve(), &Curve::Model::curveReset, this,
35 [&] { on_tweenChanges(layer.tween()); });
36 }
37
38private:
39 void setFullView() override { m_curve.setBoundedMove(false); }
40
41 void on_tweenChanges(bool b)
42 {
43 for(Curve::SegmentView& seg : m_curve.segments())
44 {
45 if(seg.model().start().x() != 0.)
46 {
47 seg.setTween(false);
48 }
49 else
50 {
51 seg.setTween(b);
52 }
53 }
54 }
55
56 void on_dropReceived(const QPointF& pos, const QMimeData& mime)
57 {
58 if(auto addr = State::onUpdatableAddress(model().address(), mime))
59 {
60 CommandDispatcher<>{context().context.commandStack}.submit(
61 new ChangeAddress{model(), *addr});
62 }
63 else if(mime.formats().contains(score::mime::processpreset()))
64 {
65 handlePresetDrop(pos, mime);
66 }
67 }
68};
69}
Definition score-plugin-automation/Automation/Commands/ChangeAddress.hpp:22
Definition AutomationPresenter.hpp:20
Definition AutomationView.hpp:16
Definition AutomationModel.hpp:36
The CommandDispatcher class.
Definition CommandDispatcher.hpp:13
Definition CurveProcessPresenter.hpp:28
Definition CurveSegmentView.hpp:26
Namespace related to the Automation process.
Definition AutomationColors.cpp:8
Definition CurveStyle.hpp:13
Definition ProcessContext.hpp:12