26 : InspectorWidgetDelegate_T{obj, parent}
27 , m_dispatcher{doc.dispatcher}
29 , m_currentPattern{
this}
34 m_duration.setRange(4, 32);
35 m_rate.setRange(1, 64);
36 m_channel.setRange(1, 16);
37 m_lanes.setRange(1, 127);
39 m_channel.setValue(obj.channel());
41 if(!ossia::valid_index(obj.currentPattern(), obj.patterns()))
43 const Pattern& pat = obj.patterns()[obj.currentPattern()];
44 m_lanes.setValue(pat.lanes.size());
45 m_duration.setValue(pat.length);
46 m_rate.setValue(pat.division);
47 m_currentPattern.setValue(obj.currentPattern());
49 auto lay =
new QFormLayout{
this};
51 con(process(), &ProcessModel::channelChanged,
this, [&](
int c) {
52 if(c != m_channel.value())
53 m_channel.setValue(c);
55 con(process(), &ProcessModel::currentPatternChanged,
this, [&](
int c) {
56 if(c == m_currentPattern.value())
59 m_currentPattern.setValue(c);
61 const Pattern& pat = obj.patterns()[c];
62 m_lanes.blockSignals(
true);
63 m_duration.blockSignals(
true);
64 m_rate.blockSignals(
true);
66 m_lanes.setValue(pat.lanes.size());
67 m_duration.setValue(pat.length);
68 m_rate.setValue(pat.division);
70 m_lanes.blockSignals(
false);
71 m_duration.blockSignals(
false);
72 m_rate.blockSignals(
false);
74 con(process(), &ProcessModel::patternsChanged,
this, [&] {
75 if(!ossia::valid_index(obj.currentPattern(), obj.patterns()))
78 const Pattern& pat = obj.patterns()[obj.currentPattern()];
79 m_lanes.blockSignals(
true);
80 m_duration.blockSignals(
true);
81 m_rate.blockSignals(
true);
83 m_lanes.setValue(pat.lanes.size());
84 m_duration.setValue(pat.length);
85 m_rate.setValue(pat.division);
87 m_lanes.blockSignals(
false);
88 m_duration.blockSignals(
false);
89 m_rate.blockSignals(
false);
92 con(m_channel, qOverload<int>(&QSpinBox::valueChanged),
this, [&](
int v) {
93 if(v != obj.channel())
94 m_dispatcher.
submit<SetPatternChannel>(obj, v);
96 con(m_channel, &QSpinBox::editingFinished,
this, [&] { m_dispatcher.
commit(); });
98 con(m_lanes, qOverload<int>(&QSpinBox::valueChanged),
this, [&](
int nn) {
102 if(!ossia::valid_index(obj.currentPattern(), obj.patterns()))
105 const std::size_t n = nn;
107 auto p = obj.patterns()[obj.currentPattern()];
108 if(n == p.lanes.size())
112 else if(n < p.lanes.size())
118 auto last_lane = p.lanes.back();
119 while(p.lanes.size() < n)
120 p.lanes.push_back(last_lane);
126 con(m_lanes, &QSpinBox::editingFinished,
this, [&]() { m_dispatcher.
commit(); });
128 con(m_currentPattern, qOverload<int>(&QSpinBox::valueChanged),
this, [&](
int v) {
129 if(v != obj.currentPattern())
130 m_dispatcher.
submit<SetCurrentPattern>(obj, v);
132 con(m_currentPattern, &QSpinBox::editingFinished,
this,
133 [&]() { m_dispatcher.
commit(); });
135 con(m_duration, qOverload<int>(&QSpinBox::valueChanged),
this, [&]() {
136 int n = m_duration.value();
140 auto p = obj.patterns()[obj.currentPattern()];
145 if(p.length > int64_t(p.lanes[0].pattern.size()))
147 for(
auto& lane : p.lanes)
149 lane.pattern.resize(n);
155 con(m_duration, &QSpinBox::editingFinished,
this, [&]() { m_dispatcher.
commit(); });
157 con(m_rate, &QDoubleSpinBox::editingFinished,
this, [&] {
158 auto p = obj.patterns()[obj.currentPattern()];
159 if(p.division != m_rate.value())
160 p.division = m_rate.value();
165 lay->addRow(tr(
"Channel"), &m_channel);
166 lay->addRow(tr(
"Current pattern"), &m_currentPattern);
167 lay->addRow(tr(
"Lanes"), &m_lanes);
168 lay->addRow(tr(
"Steps"), &m_duration);
169 lay->addRow(tr(
"Rate"), &m_rate);
176 QSpinBox m_currentPattern;
179 QDoubleSpinBox m_rate;
Definition DocumentContext.hpp:18