ui: support selected button enabled for ButtonParamControlSP (#937)

ui: support specific button enabled selections for `ButtonParamControlSP`

Replaced setDisabledSelectedButton with setEnableSelectedButtons for improved flexibility. The new implementation allows enabling multiple buttons based on a given list and maintains clarity in handling button states. This enhances functionality and aligns with better code practices.
This commit is contained in:
Jason Wen
2025-05-19 11:49:44 -04:00
committed by GitHub
parent ebe56410d3
commit c4d202c6bb
@@ -324,10 +324,11 @@ public:
}
}
void setDisabledSelectedButton(std::string val) {
int value = atoi(val.c_str());
void setEnableSelectedButtons(bool enable, const std::vector<int>& enabled_btns = {}) const {
for (int i = 0; i < button_group->buttons().size(); i++) {
button_group->buttons()[i]->setEnabled(i != value);
// Enable the button if its index is in the enabled list
bool should_enable = std::find(enabled_btns.begin(), enabled_btns.end(), i) != enabled_btns.end();
button_group->buttons()[i]->setEnabled(enable && should_enable);
}
}