2 #include <State/ValueConversion.hpp>
3 #include <State/Widgets/UnitWidget.hpp>
4 #include <State/Widgets/Values/NumericValueWidget.hpp>
5 #include <State/Widgets/Values/VecWidgets.hpp>
7 #include <Device/Address/AddressSettings.hpp>
9 #include <Explorer/Common/AddressSettings/Widgets/AddressSettingsWidget.hpp>
11 #include <ossia/network/dataspace/dataspace_visitors.hpp>
16 template <std::
size_t N>
24 m_domainSelector =
new QComboBox{
this};
25 m_domainSelector->addItems({tr(
"Float"), tr(
"Vec")});
27 m_domainSelector, SignalUtils::QComboBox_currentIndexChanged_int(),
this,
32 m_domainVecEdit->setHidden(
true);
34 m_layout->insertRow(0, makeLabel(tr(
"Value"),
this), m_valueEdit);
35 m_layout->insertRow(1, makeLabel(tr(
"Domain Type"),
this), m_domainSelector);
36 m_layout->insertRow(2, makeLabel(tr(
"Domain"),
this), m_domainFloatEdit);
38 connect(m_unit, &State::UnitWidget::unitChanged,
this, [
this](
const State::Unit& u) {
39 auto dom = ossia::get_unit_default_domain(u.get());
41 if(
auto p = dom.v.target<ossia::vecf_domain<N>>())
43 m_domainVecEdit->set_domain(dom);
44 m_domainSelector->setCurrentIndex(1);
48 m_domainSelector->setCurrentIndex(0);
53 auto settings = getCommonSettings();
54 settings.value = m_valueEdit->value();
55 if(m_domainSelector->currentIndex() == 0)
56 settings.domain = m_domainFloatEdit->domain();
58 settings.domain = m_domainVecEdit->domain();
64 setCommonSettings(settings);
65 m_valueEdit->setValue(State::convert::value<std::array<float, N>>(settings.value));
66 if(settings.domain.get().v.target<ossia::domain_base<float>>())
68 m_domainFloatEdit->set_domain(settings.domain);
69 m_domainSelector->setCurrentIndex(0);
73 m_domainVecEdit->set_domain(settings.domain);
74 m_domainSelector->setCurrentIndex(1);
81 s.value = std::array<float, N>{};
82 s.domain = ossia::make_domain(
float{0},
float{1});
86 void setCanEditProperties(
bool b)
override
88 AddressSettingsWidget::setCanEditProperties(b);
89 m_domainVecEdit->setEnabled(b);
90 m_domainFloatEdit->setEnabled(b);
91 m_domainSelector->setEnabled(b);
94 void on_domainTypeChange(
int id)
100 m_layout->replaceWidget(
101 m_domainVecEdit, m_domainFloatEdit, Qt::FindDirectChildrenOnly);
102 m_domainVecEdit->setHidden(
true);
103 m_domainVecEdit->setDisabled(
true);
104 m_domainFloatEdit->setHidden(
false);
105 m_domainFloatEdit->setDisabled(
false);
110 m_layout->replaceWidget(
111 m_domainFloatEdit, m_domainVecEdit, Qt::FindDirectChildrenOnly);
112 m_domainVecEdit->setHidden(
false);
113 m_domainVecEdit->setDisabled(
false);
114 m_domainFloatEdit->setHidden(
true);
115 m_domainFloatEdit->setDisabled(
true);
122 QComboBox* m_domainSelector{};
Definition: VecWidgets.hpp:81
Definition: AddressSettings.hpp:49