fix(color): model setup and logical switch monitor may not display correctly (#7431)

This commit is contained in:
philmoz
2026-06-16 09:31:20 +10:00
committed by GitHub
parent 15921e18ae
commit a1021a7a1b
7 changed files with 18 additions and 14 deletions
+6
View File
@@ -102,6 +102,12 @@ void ButtonBase::checkEvents()
if (checkHandler) checkHandler(); if (checkHandler) checkHandler();
} }
void ButtonBase::setCheckHandler(std::function<void(void)> handler)
{
checkHandler = std::move(handler);
if (checkHandler) checkHandler();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
TextButton::TextButton(Window* parent, const rect_t& rect, std::string text, TextButton::TextButton(Window* parent, const rect_t& rect, std::string text,
+1 -4
View File
@@ -54,10 +54,7 @@ class ButtonBase : public FormField
longPressHandler = std::move(handler); longPressHandler = std::move(handler);
} }
void setCheckHandler(std::function<void(void)> handler) void setCheckHandler(std::function<void(void)> handler);
{
checkHandler = std::move(handler);
}
protected: protected:
std::function<uint8_t(void)> pressHandler; std::function<uint8_t(void)> pressHandler;
+3 -2
View File
@@ -98,8 +98,7 @@ FileChoice::FileChoice(Window *parent, const rect_t &rect, const std::string fol
std::function<std::string()> getValue, std::function<std::string()> getValue,
std::function<void(std::string)> setValue, std::function<void(std::string)> setValue,
bool stripExtension, const char *title) : bool stripExtension, const char *title) :
Choice( Choice(parent, rect, 0, 0, nullptr,
parent, rect, 0, 0, [=]() { return selectedIdx; },
[=](int val) { setValue(getString(val)); selectedIdx = val; }, title, CHOICE_TYPE_FOLDER), [=](int val) { setValue(getString(val)); selectedIdx = val; }, title, CHOICE_TYPE_FOLDER),
folder(std::move(folder)), folder(std::move(folder)),
extension(std::move(extension)), extension(std::move(extension)),
@@ -107,6 +106,8 @@ FileChoice::FileChoice(Window *parent, const rect_t &rect, const std::string fol
getValue(std::move(getValue)), getValue(std::move(getValue)),
stripExtension(stripExtension) stripExtension(stripExtension)
{ {
// getValue function set here to ensure selectedIdx is set before use
setGetValueHandler([=]() { return selectedIdx; });
update(); update();
} }
@@ -487,7 +487,7 @@ void ModelFlightModesPage::build(Window* form)
btn->setPressHandler([=]() { btn->setPressHandler([=]() {
(new FlightModeEdit(i))->setCloseHandler([=]() { btn->refresh(); }); (new FlightModeEdit(i))->setCloseHandler([=]() { btn->refresh(); });
return 0; return btn->isActive();
}); });
} }
@@ -182,10 +182,10 @@ class InputLineButton : public InputMixButtonBase
} }
} }
bool isActive() const override { return isExpoActive(index); }
protected: protected:
Messaging refreshMsg; Messaging refreshMsg;
bool isActive() const override { return isExpoActive(index); }
}; };
class InputGroup : public InputMixGroupBase class InputGroup : public InputMixGroupBase
@@ -277,7 +277,7 @@ InputMixButtonBase* ModelInputsPage::createLineButton(InputMixGroupBase* group,
uint8_t idx = button->getIndex(); uint8_t idx = button->getIndex();
deleteInput(idx); deleteInput(idx);
}); });
return 0; return button->isActive();
}); });
return button; return button;
@@ -620,7 +620,7 @@ void ModelLogicalSwitchesPage::build(Window* window)
storageDirty(EE_MODEL); storageDirty(EE_MODEL);
rebuild(window); rebuild(window);
}); });
return 0; return button->isActive();
}); });
if (focusIndex == i) { if (focusIndex == i) {
+3 -3
View File
@@ -164,12 +164,12 @@ class MixLineButton : public InputMixButtonBase
} }
} }
bool isActive() const override { return isMixActive(index); }
static LAYOUT_VAL_SCALED(MPLEX_XO, 28) static LAYOUT_VAL_SCALED(MPLEX_XO, 28)
protected: protected:
MPlexIcon* mplex = nullptr; MPlexIcon* mplex = nullptr;
bool isActive() const override { return isMixActive(index); }
}; };
class MixGroup : public InputMixGroupBase class MixGroup : public InputMixGroupBase
@@ -301,7 +301,7 @@ InputMixButtonBase* ModelMixesPage::createLineButton(InputMixGroupBase *group, u
uint8_t idx = button->getIndex(); uint8_t idx = button->getIndex();
deleteMix(idx); deleteMix(idx);
}); });
return 0; return button->isActive();
}); });
return button; return button;