mirror of https://github.com/AxioDL/amuse.git
AudioGroupPool: Use std::array where applicable
Makes the array types strongly-typed and also allows for size querying.
This commit is contained in:
parent
6c07ec907a
commit
321a229dfd
|
@ -239,14 +239,15 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amus
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: {
|
case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: {
|
||||||
FieldComboBox* cb = new FieldComboBox(this);
|
auto* const cb = new FieldComboBox(this);
|
||||||
cb->setFixedHeight(30);
|
cb->setFixedHeight(30);
|
||||||
cb->setProperty("fieldIndex", f);
|
cb->setProperty("fieldIndex", f);
|
||||||
cb->setProperty("fieldName", fieldName);
|
cb->setProperty("fieldName", fieldName);
|
||||||
for (int j = 0; j < 4; ++j) {
|
for (const auto choice : field.m_choices) {
|
||||||
if (field.m_choices[j].empty())
|
if (choice.empty()) {
|
||||||
break;
|
break;
|
||||||
cb->addItem(tr(field.m_choices[j].data()));
|
}
|
||||||
|
cb->addItem(tr(choice.data()));
|
||||||
}
|
}
|
||||||
cb->setCurrentIndex(int(amuse::AccessField<int8_t>(m_cmd, field)));
|
cb->setCurrentIndex(int(amuse::AccessField<int8_t>(m_cmd, field)));
|
||||||
connect(cb, qOverload<int>(&FieldComboBox::currentIndexChanged), this, &CommandWidget::numChanged);
|
connect(cb, qOverload<int>(&FieldComboBox::currentIndexChanged), this, &CommandWidget::numChanged);
|
||||||
|
|
|
@ -150,12 +150,12 @@ struct SoundMacro {
|
||||||
size_t m_offset;
|
size_t m_offset;
|
||||||
std::string_view m_name;
|
std::string_view m_name;
|
||||||
int64_t m_min, m_max, m_default;
|
int64_t m_min, m_max, m_default;
|
||||||
std::string_view m_choices[4];
|
std::array<std::string_view, 4> m_choices;
|
||||||
};
|
};
|
||||||
CmdType m_tp;
|
CmdType m_tp;
|
||||||
std::string_view m_name;
|
std::string_view m_name;
|
||||||
std::string_view m_description;
|
std::string_view m_description;
|
||||||
Field m_fields[7];
|
std::array<Field, 7> m_fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Base command interface. All versions of MusyX encode little-endian parameters */
|
/** Base command interface. All versions of MusyX encode little-endian parameters */
|
||||||
|
|
|
@ -37,9 +37,11 @@ struct MakeDefaultCmdOp {
|
||||||
static std::unique_ptr<SoundMacro::ICmd> Do(R& r) {
|
static std::unique_ptr<SoundMacro::ICmd> Do(R& r) {
|
||||||
std::unique_ptr<SoundMacro::ICmd> ret = std::make_unique<Tp>();
|
std::unique_ptr<SoundMacro::ICmd> ret = std::make_unique<Tp>();
|
||||||
if (const SoundMacro::CmdIntrospection* introspection = SoundMacro::GetCmdIntrospection(r)) {
|
if (const SoundMacro::CmdIntrospection* introspection = SoundMacro::GetCmdIntrospection(r)) {
|
||||||
for (int f = 0; f < 7; ++f) {
|
for (const auto& field : introspection->m_fields) {
|
||||||
const amuse::SoundMacro::CmdIntrospection::Field& field = introspection->m_fields[f];
|
if (field.m_name.empty()) {
|
||||||
if (!field.m_name.empty()) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (field.m_tp) {
|
switch (field.m_tp) {
|
||||||
case amuse::SoundMacro::CmdIntrospection::Field::Type::Bool:
|
case amuse::SoundMacro::CmdIntrospection::Field::Type::Bool:
|
||||||
AccessField<bool>(ret.get(), field) = bool(field.m_default);
|
AccessField<bool>(ret.get(), field) = bool(field.m_default);
|
||||||
|
@ -74,7 +76,6 @@ struct MakeDefaultCmdOp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue