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 GraphicsSlider final
21 : public QObject
22 , public score::QGraphicsSliderBase<GraphicsSlider>
23{
24 W_OBJECT(GraphicsSlider)
25 Q_INTERFACES(QGraphicsItem)
26 friend struct QGraphicsSliderBase<GraphicsSlider>;
27
28 double m_value{};
29 double m_execValue{};
30 AEffect* fx{};
31 int num{};
32
33private:
34 bool m_grab{};
35 bool m_hasExec{};
36
37public:
38 static const constexpr double min = 0.;
39 static const constexpr double max = 1.;
40 static const constexpr double init = 0.5;
41 friend struct score::DefaultControlImpl;
43 GraphicsSlider(AEffect* fx, int num, QGraphicsItem* parent);
44
45 static double from01(double v) { return v; }
46 static double map(double v) { return v; }
47 static double unmap(double v) { return v; }
48
49 void setValue(double v);
50 double value() const;
51 void setExecutionValue(const ossia::value& v);
52 void resetExecution();
53
54 bool moving = false;
55
56public:
57 void valueChanged(double arg_1) W_SIGNAL(valueChanged, arg_1);
58 void sliderMoved() W_SIGNAL(sliderMoved);
59 void sliderReleased() W_SIGNAL(sliderReleased);
60
61private:
62 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
63 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
64 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
65 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
66 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
67 override;
68};
69
71{
72 const std::string_view name;
73
74 explicit constexpr VSTFloatSlider(const char* name)
75 : name{name}
76 {
77 }
78
79 static QWidget* make_widget(
80 AEffect* fx, const ControlInlet& inlet, const score::DocumentContext& ctx,
81 QWidget* parent, QObject* context);
82 static QGraphicsItem* make_item(
83 AEffect* fx, ControlInlet& inlet, const score::DocumentContext& ctx,
84 QGraphicsItem* parent, QObject* context);
85};
86
87}
Definition Vst/Control.hpp:19
Definition Vst/Widgets.hpp:23
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Definition DefaultControlImpl.hpp:10
Definition DefaultGraphicsSliderImpl.hpp:31
Definition DocumentContext.hpp:18
Definition QGraphicsSliderBase.hpp:17
Definition Vst/Widgets.hpp:71