fix(color): input edit preview refresh, missing switch display (#5449)

This commit is contained in:
philmoz
2024-08-17 21:20:52 +10:00
committed by GitHub
parent f865578b42
commit f40ff60b55
3 changed files with 20 additions and 25 deletions
+18 -21
View File
@@ -43,8 +43,6 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
LV_STATE_USER_1);
etx_font(headerSwitchName->getLvObj(), FONT_BOLD_INDEX, LV_STATE_USER_1);
active = !isActive();
setTitle();
auto body_obj = body->getLvObj();
@@ -82,12 +80,6 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
CurveEdit::SetCurrentSource(expoAddress(index)->srcRaw);
}
bool InputEditWindow::isActive()
{
ExpoData* input = expoAddress(index);
return getSwitch(input->swtch);
}
void InputEditWindow::setTitle()
{
headerSwitchName->setText(getSourceString(MIXSRC_FIRST_INPUT + input));
@@ -226,10 +218,25 @@ void InputEditWindow::checkEvents()
}
}
bool sw = getSwitch(input->swtch);
if (sw != lastSwitchState) {
uint8_t activeIdx = 255;
for (int i = 0; i < MAX_EXPOS; i += 1) {
auto inp = expoAddress(i);
if (inp->chn == input->chn) {
if (getSwitch(inp->swtch)) {
activeIdx = i;
break;
}
}
}
if (activeIdx != lastActiveIndex) {
updatePreview = true;
lastSwitchState = sw;
lastActiveIndex = activeIdx;
}
if (lastActiveIndex == index) {
lv_obj_add_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
} else {
lv_obj_clear_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
}
if (updatePreview) {
@@ -237,15 +244,5 @@ void InputEditWindow::checkEvents()
if (preview) preview->update();
}
bool act = isActive();
if (active != act) {
active = act;
if (active) {
lv_obj_add_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
} else {
lv_obj_clear_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
}
}
Page::checkEvents();
}
+1 -3
View File
@@ -43,14 +43,12 @@ class InputEditWindow : public Page
getvalue_t lastWeightVal = 0;
getvalue_t lastOffsetVal = 0;
getvalue_t lastCurveVal = 0;
bool lastSwitchState = false;
bool active = false;
uint8_t lastActiveIndex = 255;
StaticText * headerSwitchName = nullptr;
void setTitle();
void buildBody(Window *window);
bool isActive();
void checkEvents() override;
void deleteLater(bool detach = true, bool trash = true) override;
};
@@ -151,7 +151,7 @@ class InputLineButton : public InputMixButtonBase
}
}
setOpts(s);
setOpts(tmp_str);
setFlightModes(line.flightModes);
}