mirror of https://github.com/AxioDL/amuse.git
Merge pull request #43 from lioncash/array2
AudioGroupPool: Use std::array where applicable
This commit is contained in:
commit
757defee7a
|
@ -239,14 +239,15 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amus
|
|||
break;
|
||||
}
|
||||
case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: {
|
||||
FieldComboBox* cb = new FieldComboBox(this);
|
||||
auto* const cb = new FieldComboBox(this);
|
||||
cb->setFixedHeight(30);
|
||||
cb->setProperty("fieldIndex", f);
|
||||
cb->setProperty("fieldName", fieldName);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
if (field.m_choices[j].empty())
|
||||
for (const auto choice : field.m_choices) {
|
||||
if (choice.empty()) {
|
||||
break;
|
||||
cb->addItem(tr(field.m_choices[j].data()));
|
||||
}
|
||||
cb->addItem(tr(choice.data()));
|
||||
}
|
||||
cb->setCurrentIndex(int(amuse::AccessField<int8_t>(m_cmd, field)));
|
||||
connect(cb, qOverload<int>(&FieldComboBox::currentIndexChanged), this, &CommandWidget::numChanged);
|
||||
|
|
|
@ -150,12 +150,12 @@ struct SoundMacro {
|
|||
size_t m_offset;
|
||||
std::string_view m_name;
|
||||
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;
|
||||
std::string_view m_name;
|
||||
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 */
|
||||
|
|
|
@ -37,9 +37,11 @@ struct MakeDefaultCmdOp {
|
|||
static std::unique_ptr<SoundMacro::ICmd> Do(R& r) {
|
||||
std::unique_ptr<SoundMacro::ICmd> ret = std::make_unique<Tp>();
|
||||
if (const SoundMacro::CmdIntrospection* introspection = SoundMacro::GetCmdIntrospection(r)) {
|
||||
for (int f = 0; f < 7; ++f) {
|
||||
const amuse::SoundMacro::CmdIntrospection::Field& field = introspection->m_fields[f];
|
||||
if (!field.m_name.empty()) {
|
||||
for (const auto& field : introspection->m_fields) {
|
||||
if (field.m_name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (field.m_tp) {
|
||||
case amuse::SoundMacro::CmdIntrospection::Field::Type::Bool:
|
||||
AccessField<bool>(ret.get(), field) = bool(field.m_default);
|
||||
|
@ -74,7 +76,6 @@ struct MakeDefaultCmdOp {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue