2 #include "ValueWidget.hpp"
4 #include <score/widgets/MarginLess.hpp>
5 #include <score/widgets/SpinBoxes.hpp>
6 #include <score/widgets/TextLabel.hpp>
8 #include <ossia/network/domain/domain.hpp>
12 #include <QDialogButtonBox>
13 #include <QGridLayout>
14 #include <QHBoxLayout>
15 #include <QPushButton>
16 #include <QVBoxLayout>
32 lay->addWidget(m_valueSBox);
33 m_valueSBox->setValue(value);
36 ossia::value value()
const override {
return ossia::value{m_valueSBox->value()}; }
46 using set_type = std::vector<T>;
54 auto addbutton =
new QPushButton{tr(
"+"),
this};
55 connect(addbutton, &QPushButton::pressed,
this, [
this] { addRow({}); });
56 lay->addWidget(addbutton);
59 =
new QDialogButtonBox{QDialogButtonBox::Ok | QDialogButtonBox::Cancel};
61 lay->addWidget(buttonBox);
63 connect(buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept);
64 connect(buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
70 for(
auto widg : m_widgs)
72 t.push_back(widg->value().template get<T>());
77 void setValues(
const set_type& t)
80 for(
auto row : m_rows)
94 auto sub_widg =
new QWidget{
this};
97 auto minus_b =
new QPushButton{tr(
"-"),
this};
98 sub_lay->addWidget(minus_b);
100 connect(minus_b, &QPushButton::clicked,
this, [
this, i = m_rows.size()] {
105 sub_lay->addWidget(widg);
107 m_lay->addWidget(sub_widg);
108 m_rows.push_back(sub_widg);
109 m_widgs.push_back(widg);
112 void removeRow(std::size_t i)
114 if(i < m_rows.size())
117 m_rows.erase(m_rows.begin() + i);
118 m_widgs.erase(m_widgs.begin() + i);
122 QVBoxLayout* m_lay{};
123 std::vector<QWidget*> m_rows;
124 std::vector<NumericValueWidget<T>*> m_widgs;
127 template <
typename T>
131 using domain_type = ossia::domain_base<T>;
132 using set_type = std::vector<T>;
138 this->setLayout(lay);
140 m_minCB =
new QCheckBox{tr(
"Min"),
this};
141 m_maxCB =
new QCheckBox{tr(
"Max"),
this};
144 lay->addWidget(m_minCB);
145 lay->addWidget(m_min);
146 lay->addWidget(m_maxCB);
147 lay->addWidget(m_max);
149 m_min->setEnabled(
false);
150 m_max->setEnabled(
false);
152 connect(m_minCB, &QCheckBox::stateChanged,
this, [
this](
int st) {
153 m_min->setEnabled(
bool(st));
155 connect(m_maxCB, &QCheckBox::stateChanged,
this, [
this](
int st) {
156 m_max->setEnabled(
bool(st));
158 auto pb =
new QPushButton{tr(
"Values"),
this};
161 connect(pb, &QPushButton::clicked,
this, [
this] {
163 dial.setValues(m_values);
167 m_values = dial.values();
172 domain_type domain()
const
176 if(m_minCB->checkState())
177 dom.min = m_min->value();
179 dom.min = std::nullopt;
181 if(m_maxCB->checkState())
182 dom.max = m_max->value();
184 dom.max = std::nullopt;
186 dom.values = m_values;
191 void set_domain(ossia::domain dom_base)
194 m_minCB->setCheckState(Qt::Unchecked);
195 m_maxCB->setCheckState(Qt::Unchecked);
197 if(
auto dom_p = dom_base.v.target<domain_type>())
203 m_minCB->setCheckState(Qt::Checked);
204 m_min->setValue(*dom.min);
208 m_maxCB->setCheckState(Qt::Checked);
209 m_max->setValue(*dom.max);
212 m_values = dom.values;
217 QCheckBox* m_minCB{};
218 QCheckBox* m_maxCB{};
Definition: NumericValueWidget.hpp:129
Definition: NumericValueWidget.hpp:44
The SpinBox class.
Definition: SpinBoxes.hpp:68
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
The TemplatedSpinBox class.
Definition: SpinBoxes.hpp:19