2 #include <Process/Dataflow/ControlWidgets.hpp>
4 #include <Crousti/Executor.hpp>
5 #include <Crousti/Layer.hpp>
6 #include <Crousti/ProcessModel.hpp>
7 #include <Dataflow/WidgetInletFactory.hpp>
9 #include <score/graphics/DefaultGraphicsKnobImpl.hpp>
10 #include <score/graphics/DefaultGraphicsSliderImpl.hpp>
11 #include <score/graphics/GraphicsSliderBaseImpl.hpp>
12 #include <score/graphics/widgets/QGraphicsRangeSlider.hpp>
13 #include <score/graphics/widgets/QGraphicsSlider.hpp>
15 #include <ossia/detail/for_each.hpp>
19 template <
typename Node>
25 template <
typename Node>
34 using reflect_mapped_controls =
35 typename avnd::mapped_control_input_introspection<N>::field_reflections_type;
37 template <
typename Field>
40 static inline constexpr
auto mapper = avnd::get_mapper<Field>();
41 static float map(
float val) noexcept {
return mapper.map(val); }
42 static float unmap(
float val) noexcept {
return mapper.unmap(val); }
45 static float to01(
const T& slider,
float val) noexcept
47 const auto min = slider.getMin();
48 const auto max = slider.getMax();
51 const auto in_01 = (val - min) / (max - min);
58 static float from01(
const T& slider,
float in_01) noexcept
60 const auto min = slider.getMin();
61 const auto max = slider.getMax();
64 const auto unmapped = unmap(in_01);
67 return min + unmapped * (max - min);
71 template <
typename Field>
75 using score::QGraphicsSlider::QGraphicsSlider;
77 double getMin()
const noexcept {
return this->min; }
78 double getMax()
const noexcept {
return this->max; }
79 double unmap(
double v)
const noexcept
83 double map(
double v)
const noexcept
89 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
92 score::DefaultGraphicsSliderImpl::paint(
93 *
this, score::Skin::instance(), QString::number(map(m_value),
'f', 3), painter,
97 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
99 score::DefaultGraphicsSliderImpl::mousePressEvent(*
this, event);
102 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
override
104 score::DefaultGraphicsSliderImpl::mouseMoveEvent(*
this, event);
107 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override
109 score::DefaultGraphicsSliderImpl::mouseReleaseEvent(*
this, event);
112 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
override
118 template <
typename Field>
122 using score::QGraphicsKnob::QGraphicsKnob;
124 double getMin()
const noexcept {
return this->min; }
125 double getMax()
const noexcept {
return this->max; }
126 double unmap(
double v)
const noexcept
130 double map(
double v)
const noexcept
136 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
139 const double val = map(m_value);
140 const double abs = std::abs(val);
141 int pres = abs < 10. ? 3 : abs < 100. ? 2 : abs < 1000. ? 1 : 0;
142 score::DefaultGraphicsKnobImpl::paint(
143 *
this, score::Skin::instance(), QString::number(val,
'f', pres), painter,
147 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
149 score::DefaultGraphicsKnobImpl::mousePressEvent(*
this, event);
152 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
override
154 score::DefaultGraphicsKnobImpl::mouseMoveEvent(*
this, event);
157 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override
159 score::DefaultGraphicsKnobImpl::mouseReleaseEvent(*
this, event);
162 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
override
168 template <
typename Field>
173 template <
typename Field>
183 template <
typename Node,
typename Refl>
185 template <
typename Node, std::
size_t N,
typename Field>
188 oscr::CustomFloatControl<Node, avnd::field_index<N>>,
189 WidgetFactory::FloatControl<
190 typename MatchingWidget<Field>::type, NormalizerFromMapper<Field>, true>>
194 template <
typename... Nodes>
195 static void instantiate_fx(
196 std::vector<score::InterfaceBase*>& v,
199 if(key == Execution::ProcessComponentFactory::static_interfaceKey())
206 else if(key == Process::ProcessModelFactory::static_interfaceKey())
212 else if(key == Process::LayerFactory::static_interfaceKey())
214 auto fun = [&]<
typename type>() {
215 if constexpr(avnd::has_ui<type>)
221 (fun.template operator()<Nodes>(), ...);
223 else if(key == Process::PortFactory::static_interfaceKey())
227 using namespace boost::mp11;
229 auto fun = [&]<
typename N,
typename... Fields>(avnd::typelist<Fields...>) {
234 (fun.template operator()<Nodes>(reflect_mapped_controls<Nodes>{}), ...);
238 template <
typename T>
239 void custom_factories(
240 std::vector<score::InterfaceBase*>& fx,
245 namespace Avnd = oscr;
Definition: Process/Execution/ProcessComponent.hpp:119
Definition: Process/Execution/ProcessComponent.hpp:102
Definition: score-lib-process/Process/ProcessFactory.hpp:58
Definition: PortFactory.hpp:21
Definition: GenericProcessFactory.hpp:15
The ProcessFactory class.
Definition: score-lib-process/Process/ProcessFactory.hpp:35
Definition: UuidKey.hpp:343
Definition: Factories.hpp:120
Definition: Factories.hpp:73
Definition: score-plugin-avnd/Crousti/Executor.hpp:546
Definition: score-plugin-avnd/Crousti/Layer.hpp:283
Definition: QGraphicsKnob.hpp:16
Definition: QGraphicsSlider.hpp:17
Definition: Factories.hpp:184
Definition: Factories.hpp:28
Definition: Factories.hpp:39
Definition: Factories.hpp:21
Used to access all the application-wide state and structures.
Definition: ApplicationContext.hpp:24