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