/Vst3/Widgets.hpp
1 #pragma once
2 #include <Process/Style/ScenarioStyle.hpp>
3 
4 #include <Vst3/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 <QDialog>
12 
13 #include <verdigris>
14 
15 namespace vst3
16 {
17 class VSTEffectItem final : public score::EmptyRectItem
18 {
19  QGraphicsItem* rootItem{};
20  std::vector<std::pair<ControlInlet*, score::EmptyRectItem*>> controlItems;
21 
22 public:
23  VSTEffectItem(const Model& effect, const Process::Context& doc, QGraphicsItem* root);
24 
25  void setupInlet(const Model& fx, ControlInlet& inlet, const Process::Context& doc);
26 
27 private:
28  void updateRect();
29 };
30 
31 class VSTGraphicsSlider final
32  : public QObject
33  , public score::QGraphicsSliderBase<VSTGraphicsSlider>
34 {
35  W_OBJECT(VSTGraphicsSlider)
36  Q_INTERFACES(QGraphicsItem)
37  friend struct QGraphicsSliderBase<VSTGraphicsSlider>;
38 
39  double m_value{};
40  double m_execValue{};
41  Steinberg::Vst::IEditController* fx{};
42  Steinberg::Vst::ParamID num{};
43 
44 private:
45  bool m_grab{};
46  bool m_hasExec{};
47 
48 public:
49  static const constexpr double min = 0.;
50  static const constexpr double max = 1.;
51  static const constexpr double init = 0.5;
52  friend struct score::DefaultControlImpl;
55  Steinberg::Vst::IEditController* fx, Steinberg::Vst::ParamID num,
56  QGraphicsItem* parent);
57 
58  static double from01(double v) { return v; }
59  static double map(double v) { return v; }
60  static double unmap(double v) { return v; }
61 
62  void setValue(double v);
63  double value() const;
64  void setExecutionValue(double v);
65  void resetExecution();
66 
67  bool moving = false;
68 
69 public:
70  void valueChanged(double arg_1) W_SIGNAL(valueChanged, arg_1);
71  void sliderMoved() W_SIGNAL(sliderMoved);
72  void sliderReleased() W_SIGNAL(sliderReleased);
73 
74 private:
75  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
76  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
77  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
78  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
79  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
80  override;
81 };
82 
83 struct VSTFloatSlider : ossia::safe_nodes::control_in
84 {
85  static QWidget* make_widget(
86  Steinberg::Vst::IEditController* fx, const ControlInlet& inlet,
87  const score::DocumentContext& ctx, QWidget* parent, QObject* context);
88  static QGraphicsItem* make_item(
89  Steinberg::Vst::IEditController* fx, ControlInlet& inlet,
90  const score::DocumentContext& ctx, QGraphicsItem* parent, QObject* context);
91 };
92 
93 }
Definition: RectItem.hpp:64
Definition: /Vst3/Control.hpp:15
Definition: score-plugin-vst3/Vst3/EffectModel.hpp:41
Definition: /Vst3/Widgets.hpp:18
Definition: /Vst3/Widgets.hpp:34
Definition: ProcessContext.hpp:12
Definition: DefaultControlImpl.hpp:10
Definition: DefaultGraphicsSliderImpl.hpp:31
Definition: DocumentContext.hpp:18
Definition: QGraphicsSliderBase.hpp:17
Definition: /Vst3/Widgets.hpp:84