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 
13 namespace Process
14 {
15 struct Context;
16 }
17 namespace vst
18 {
19 
20 class EffectItem final : public score::EmptyRectItem
21 {
22  QGraphicsItem* rootItem{};
23  std::vector<std::pair<ControlInlet*, score::EmptyRectItem*>> controlItems;
24 
25 public:
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 
30 private:
31  void updateRect();
32 };
33 
34 class 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 
47 private:
48  bool m_grab{};
49  bool m_hasExec{};
50 
51 public:
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(double v);
66  void resetExecution();
67 
68  bool moving = false;
69 
70 public:
71  void valueChanged(double arg_1) W_SIGNAL(valueChanged, arg_1);
72  void sliderMoved() W_SIGNAL(sliderMoved);
73  void sliderReleased() W_SIGNAL(sliderReleased);
74 
75 private:
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 
84 struct VSTFloatSlider : ossia::safe_nodes::control_in
85 {
86  static QWidget* make_widget(
87  AEffect* fx, const ControlInlet& inlet, const score::DocumentContext& ctx,
88  QWidget* parent, QObject* context);
89  static QGraphicsItem* make_item(
90  AEffect* fx, ControlInlet& inlet, const score::DocumentContext& ctx,
91  QGraphicsItem* parent, QObject* context);
92 };
93 
94 }
Definition: RectItem.hpp:64
Definition: Vst/Control.hpp:15
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