2#include <Process/Dataflow/ControlWidgets.hpp>
4#include <Crousti/Executor.hpp>
5#include <Crousti/Layer.hpp>
6#include <Crousti/ProcessModel.hpp>
7#include <Crousti/ScoreLayer.hpp>
8#include <Dataflow/WidgetInletFactory.hpp>
10#include <score/graphics/DefaultGraphicsKnobImpl.hpp>
11#include <score/graphics/DefaultGraphicsSliderImpl.hpp>
12#include <score/graphics/GraphicsSliderBaseImpl.hpp>
13#include <score/graphics/widgets/QGraphicsRangeSlider.hpp>
14#include <score/graphics/widgets/QGraphicsSlider.hpp>
16#include <ossia/detail/for_each.hpp>
20template <
typename Node>
26template <
typename Node>
35using reflect_mapped_controls =
36 typename avnd::mapped_control_input_introspection<N>::field_reflections_type;
38template <
typename Field>
41 static inline constexpr auto mapper = avnd::get_mapper<Field>();
42 static float map(
float val)
noexcept {
return mapper.map(val); }
43 static float unmap(
float val)
noexcept {
return mapper.unmap(val); }
46 static float to01(
const T& slider,
float val)
noexcept
48 const auto min = slider.getMin();
49 const auto max = slider.getMax();
52 const auto in_01 = (val - min) / (max - min);
59 static float from01(
const T& slider,
float in_01)
noexcept
61 const auto min = slider.getMin();
62 const auto max = slider.getMax();
65 const auto unmapped = unmap(in_01);
68 return min + unmapped * (max - min);
72template <
typename Field>
76 using score::QGraphicsSlider::QGraphicsSlider;
78 double getMin()
const noexcept {
return this->min; }
79 double getMax()
const noexcept {
return this->max; }
80 double unmap(
double v)
const noexcept
84 double map(
double v)
const noexcept
90 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
93 score::DefaultGraphicsSliderImpl::paint(
94 *
this, score::Skin::instance(), QString::number(map(m_value),
'f', 3), painter,
98 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
100 score::DefaultGraphicsSliderImpl::mousePressEvent(*
this, event);
103 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
override
105 score::DefaultGraphicsSliderImpl::mouseMoveEvent(*
this, event);
108 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override
110 score::DefaultGraphicsSliderImpl::mouseReleaseEvent(*
this, event);
113 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
override
119template <
typename Field>
123 using score::QGraphicsKnob::QGraphicsKnob;
125 double getMin()
const noexcept {
return this->min; }
126 double getMax()
const noexcept {
return this->max; }
127 double unmap(
double v)
const noexcept
131 double map(
double v)
const noexcept
137 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
140 const double val = map(m_value);
141 const double abs = std::abs(val);
142 int pres = abs < 10. ? 3 : abs < 100. ? 2 : abs < 1000. ? 1 : 0;
143 score::DefaultGraphicsKnobImpl::paint(
144 *
this, score::Skin::instance(), QString::number(val,
'f', pres), painter,
148 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
150 score::DefaultGraphicsKnobImpl::mousePressEvent(*
this, event);
153 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
override
155 score::DefaultGraphicsKnobImpl::mouseMoveEvent(*
this, event);
158 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override
160 score::DefaultGraphicsKnobImpl::mouseReleaseEvent(*
this, event);
163 void contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
override
169template <
typename Field>
174template <
typename Field>
184template <
typename Node,
typename Refl>
186template <
typename Node, std::
size_t N,
typename Field>
189 oscr::CustomFloatControl<Node, avnd::field_index<N>>,
190 WidgetFactory::FloatControl<
191 typename MatchingWidget<Field>::type, NormalizerFromMapper<Field>, true>>
195template <
typename... Nodes>
196static void instantiate_fx(
197 std::vector<score::InterfaceBase*>& v,
200 if(key == Execution::ProcessComponentFactory::static_interfaceKey())
207 else if(key == Process::ProcessModelFactory::static_interfaceKey())
213 else if(key == Process::LayerFactory::static_interfaceKey())
215 auto fun = [&]<
typename type>() {
216 if constexpr(avnd::has_ui<type>)
227 (fun.template operator()<Nodes>(), ...);
229 else if(key == Process::PortFactory::static_interfaceKey())
233 using namespace boost::mp11;
235 auto fun = [&]<
typename N,
typename... Fields>(avnd::typelist<Fields...>) {
240 (fun.template operator()<Nodes>(reflect_mapped_controls<Nodes>{}), ...);
245void custom_factories(
246 std::vector<score::InterfaceBase*>& fx,
Definition Process/Execution/ProcessComponent.hpp:119
Definition Process/Execution/ProcessComponent.hpp:102
Definition score-lib-process/Process/ProcessFactory.hpp:59
Definition PortFactory.hpp:30
Definition GenericProcessFactory.hpp:15
The ProcessFactory class.
Definition score-lib-process/Process/ProcessFactory.hpp:35
Definition UuidKey.hpp:343
Definition Factories.hpp:121
Definition Factories.hpp:74
Definition score-plugin-avnd/Crousti/Executor.hpp:107
Definition score-plugin-avnd/Crousti/Layer.hpp:396
Definition score-plugin-avnd/Crousti/ProcessModel.hpp:77
Definition ScoreLayer.hpp:13
Definition QGraphicsKnob.hpp:16
Definition QGraphicsSlider.hpp:17
Definition ScoreLayer.hpp:9
Definition Factories.hpp:19
Definition Factories.hpp:185
Definition Factories.hpp:29
Definition Factories.hpp:40
Definition Factories.hpp:22
Used to access all the application-wide state and structures.
Definition ApplicationContext.hpp:24