47 using set_type = std::vector<T>;
55 auto addbutton =
new QPushButton{tr(
"+"),
this};
56 connect(addbutton, &QPushButton::pressed,
this, [
this] { addRow({}); });
57 lay->addWidget(addbutton);
60 =
new QDialogButtonBox{QDialogButtonBox::Ok | QDialogButtonBox::Cancel};
62 lay->addWidget(buttonBox);
64 connect(buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept);
65 connect(buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
71 for(
auto widg : m_widgs)
73 t.push_back(widg->value().template get<T>());
78 void setValues(
const set_type& t)
81 for(
auto row : m_rows)
95 auto sub_widg =
new QWidget{
this};
98 auto minus_b =
new QPushButton{tr(
"-"),
this};
99 sub_lay->addWidget(minus_b);
101 connect(minus_b, &QPushButton::clicked,
this, [
this, i = m_rows.size()] {
106 sub_lay->addWidget(widg);
108 m_lay->addWidget(sub_widg);
109 m_rows.push_back(sub_widg);
110 m_widgs.push_back(widg);
113 void removeRow(std::size_t i)
115 if(i < m_rows.size())
118 m_rows.erase(m_rows.begin() + i);
119 m_widgs.erase(m_widgs.begin() + i);
123 QVBoxLayout* m_lay{};
124 std::vector<QWidget*> m_rows;
125 std::vector<NumericValueWidget<T>*> m_widgs;
132 using domain_type = ossia::domain_base<T>;
133 using set_type = std::vector<T>;
139 this->setLayout(lay);
141 m_minCB =
new QCheckBox{tr(
"Min"),
this};
142 m_maxCB =
new QCheckBox{tr(
"Max"),
this};
145 lay->addWidget(m_minCB);
146 lay->addWidget(m_min);
147 lay->addWidget(m_maxCB);
148 lay->addWidget(m_max);
150 m_min->setEnabled(
false);
151 m_max->setEnabled(
false);
153 connect(m_minCB, SignalUtils::QCheckBox_checkStateChanged(),
this, [
this](
int st) {
154 m_min->setEnabled(
bool(st));
156 connect(m_maxCB, SignalUtils::QCheckBox_checkStateChanged(),
this, [
this](
int st) {
157 m_max->setEnabled(
bool(st));
159 auto pb =
new QPushButton{tr(
"Values"),
this};
162 connect(pb, &QPushButton::clicked,
this, [
this] {
164 dial.setValues(m_values);
168 m_values = dial.values();
173 domain_type domain()
const
177 if(m_minCB->checkState())
178 dom.min = m_min->value();
180 dom.min = std::nullopt;
182 if(m_maxCB->checkState())
183 dom.max = m_max->value();
185 dom.max = std::nullopt;
187 dom.values = m_values;
192 void set_domain(ossia::domain dom_base)
195 m_minCB->setCheckState(Qt::Unchecked);
196 m_maxCB->setCheckState(Qt::Unchecked);
198 if(
auto dom_p = dom_base.v.target<domain_type>())
204 m_minCB->setCheckState(Qt::Checked);
205 m_min->setValue(*dom.min);
209 m_maxCB->setCheckState(Qt::Checked);
210 m_max->setValue(*dom.max);
213 m_values = dom.values;
218 QCheckBox* m_minCB{};
219 QCheckBox* m_maxCB{};