Loading...
Searching...
No Matches
Vst/Widgets.hpp
1#pragma once
2#include <Process/Style/ScenarioStyle.hpp>
3
4#include <Vst/EffectModel.hpp>
5
6#include <score/graphics/GraphicWidgets.hpp>
7#include <score/graphics/TextItem.hpp>
8
9#include <ossia/dataflow/safe_nodes/port.hpp>
10
11#include <verdigris>
12
13namespace Process
14{
15struct Context;
16}
17namespace vst
18{
19
20class EffectItem final : public score::EmptyRectItem
21{
22 QGraphicsItem* rootItem{};
23 std::vector<std::pair<ControlInlet*, score::EmptyRectItem*>> controlItems;
24
25public:
26 EffectItem(const Model& effect, const Process::Context& doc, QGraphicsItem* root);
27
28 void setupInlet(const Model& fx, ControlInlet& inlet, const Process::Context& doc);
29
30private:
31 void updateRect();
32};
33
34class GraphicsSlider final
35 : public QObject
36 , public score::QGraphicsSliderBase<GraphicsSlider>
37{
38 W_OBJECT(GraphicsSlider)
39 Q_INTERFACES(QGraphicsItem)
40 friend struct QGraphicsSliderBase<GraphicsSlider>;
41
42 double m_value{};
43 double m_execValue{};
44 AEffect* fx{};
45 int num{};
46
47private:
48 bool m_grab{};
49 bool m_hasExec{};
50
51public:
52 static const constexpr double min = 0.;
53 static const constexpr double max = 1.;
54 static const constexpr double init = 0.5;
55 friend struct score::DefaultControlImpl;
57 GraphicsSlider(AEffect* fx, int num, QGraphicsItem* parent);
58
59 static double from01(double v) { return v; }
60 static double map(double v) { return v; }
61 static double unmap(double v) { return v; }
62
63 void setValue(double v);
64 double value() const;
65 void setExecutionValue(const ossia::value& v);
66 void resetExecution();
67
68 bool moving = false;
69
70public:
71 void valueChanged(double arg_1) W_SIGNAL(valueChanged, arg_1);
72 void sliderMoved() W_SIGNAL(sliderMoved);
73 void sliderReleased() W_SIGNAL(sliderReleased);
74
75private:
76 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
77 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
78 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
79 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
80 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
81 override;
82};
83
85{
86 const std::string_view name;
87
88 explicit constexpr VSTFloatSlider(const char* name)
89 : name{name}
90 {
91 }
92
93 static QWidget* make_widget(
94 AEffect* fx, const ControlInlet& inlet, const score::DocumentContext& ctx,
95 QWidget* parent, QObject* context);
96 static QGraphicsItem* make_item(
97 AEffect* fx, ControlInlet& inlet, const score::DocumentContext& ctx,
98 QGraphicsItem* parent, QObject* context);
99};
100
101}
Definition RectItem.hpp:64
Definition Vst/Control.hpp:19
Definition Vst/Widgets.hpp:21
Definition Vst/Widgets.hpp:37
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Definition ProcessContext.hpp:12
Definition DefaultControlImpl.hpp:10
Definition DefaultGraphicsSliderImpl.hpp:31
Definition DocumentContext.hpp:18
Definition QGraphicsSliderBase.hpp:17
Definition Vst/Widgets.hpp:85