Use autoswitch in SourceChoice as well

This commit is contained in:
Raphael Coeffic
2021-06-07 11:08:36 +02:00
committed by Raphael Coeffic
parent 589398a65c
commit 92e8baf916
4 changed files with 24 additions and 15 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

+12 -3
View File
@@ -79,7 +79,6 @@ void SourceChoice::fillMenu(Menu * menu, const std::function<bool(int16_t)> & fi
int current = 0;
menu->removeLines();
for (int i = vmin; i <= vmax; ++i) {
if (filter && !filter(i)) continue;
if (isValueAvailable && !isValueAvailable(i)) continue;
@@ -96,7 +95,7 @@ void SourceChoice::fillMenu(Menu * menu, const std::function<bool(int16_t)> & fi
#if defined(AUTOSOURCE)
menu->setWaitHandler([=]() {
int8_t val = getMovedSource(0);
int16_t val = getMovedSource(0);
if (val) {
if (filter && filter(val)) {
return;
@@ -105,7 +104,17 @@ void SourceChoice::fillMenu(Menu * menu, const std::function<bool(int16_t)> & fi
setValue(val);
}
this->fillMenu(menu);
menu->setFocusBody();
}
else {
swsrc_t swtch = getMovedSwitch();
if (swtch) {
div_t info = switchInfo(swtch);
val = info.quot + MIXSRC_FIRST_SWITCH;
if (val && (!filter || !filter(val))) {
if (setValue) setValue(val);
this->fillMenu(menu);
}
}
}
});
#endif
+12 -12
View File
@@ -77,18 +77,6 @@ void SwitchChoice::fillMenu(Menu * menu, std::function<bool(int16_t)> filter)
if (current >= 0) {
menu->select(current);
}
}
void SwitchChoice::openMenu()
{
auto menu = new Menu(this);
fillMenu(menu);
menu->setToolbar(new SwitchChoiceMenuToolbar(this, menu));
menu->setCloseHandler([=]() {
editMode = false;
setFocus(SET_FOCUS_DEFAULT);
});
#if defined(AUTOSWITCH)
menu->setWaitHandler([=]() {
@@ -112,6 +100,18 @@ void SwitchChoice::openMenu()
#endif
}
void SwitchChoice::openMenu()
{
auto menu = new Menu(this);
fillMenu(menu);
menu->setToolbar(new SwitchChoiceMenuToolbar(this, menu));
menu->setCloseHandler([=]() {
editMode = false;
setFocus(SET_FOCUS_DEFAULT);
});
}
#if defined(HARDWARE_KEYS)
void SwitchChoice::onEvent(event_t event)
{