2 #include <State/Value.hpp>
4 #include <score/widgets/MarginLess.hpp>
5 #include <score/widgets/SignalUtils.hpp>
6 #include <score/widgets/TextLabel.hpp>
8 #include <ossia/network/domain/domain.hpp>
10 #include <QDoubleSpinBox>
11 #include <QFormLayout>
12 #include <QHBoxLayout>
23 using QWidget::QWidget;
26 void changed() E_SIGNAL(SCORE_LIB_STATE_EXPORT, changed)
29 template <std::
size_t N>
36 auto lay =
new QHBoxLayout;
39 for(std::size_t i = 0; i < N; i++)
41 auto box =
new QDoubleSpinBox{
this};
42 box->setMinimum(-9999);
43 box->setMaximum(9999);
46 connect(box, &QDoubleSpinBox::editingFinished,
this, [
this] { changed(); });
53 void setValue(std::array<float, N> v)
55 for(std::size_t i = 0; i < N; i++)
57 m_boxes[i]->setValue(v[i]);
61 std::array<float, N> value()
const
63 std::array<float, N> v;
64 for(std::size_t i = 0; i < N; i++)
66 v[i] = m_boxes[i]->value();
72 std::array<QDoubleSpinBox*, N> m_boxes;
79 template <std::
size_t N>
83 using domain_type = ossia::vecf_domain<N>;
84 using set_type = ossia::flat_set<float>;
92 auto min_l =
new TextLabel{tr(
"Min"),
this};
93 min_l->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
95 auto max_l =
new TextLabel{tr(
"Max"),
this};
96 max_l->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
98 lay->addWidget(min_l);
99 lay->addWidget(m_min);
100 lay->addWidget(max_l);
101 lay->addWidget(m_max);
104 static std::array<std::optional<float>, N> toOptional(
const std::array<float, N>& f)
106 std::array<std::optional<float>, N> res;
107 for(std::size_t i = 0; i < N; i++)
114 static std::array<float, N> fromOptional(
const std::array<std::optional<float>, N>& f)
116 std::array<float, N> res;
117 for(std::size_t i = 0; i < N; i++)
119 res[i] = f[i] ? *f[i] : 0;
124 domain_type domain()
const
128 dom.min = toOptional(m_min->value());
129 dom.max = toOptional(m_max->value());
134 void set_domain(ossia::domain dom_base)
136 m_min->setValue(ossia::fill_vec<N>(0));
137 m_max->setValue(ossia::fill_vec<N>(1));
139 if(
auto dom_p = dom_base.v.target<domain_type>())
143 m_min->setValue(fromOptional(dom.min));
144 m_max->setValue(fromOptional(dom.max));
Definition: VecWidgets.hpp:81
Definition: TextLabel.hpp:6
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
Definition: VecWidgets.hpp:20