fix(color): input curve preview not updating when 'Side' value changed (#6675)

This commit is contained in:
philmoz
2025-10-17 14:36:36 +10:00
committed by GitHub
parent 9fa93c2062
commit e70826928e
5 changed files with 73 additions and 115 deletions
-1
View File
@@ -57,7 +57,6 @@ set(GUI_SRC
startup_shutdown.cpp
model/curveedit.cpp
model/input_edit_adv.cpp
model/input_edit.cpp
model/mixer_edit_adv.cpp
model/mixer_edit.cpp
+68 -2
View File
@@ -25,11 +25,11 @@
#include "curveedit.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "input_edit_adv.h"
#include "input_source.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#include "switchchoice.h"
#include "fm_matrix.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -171,12 +171,68 @@ void InputEditWindow::buildBody(Window* form)
line->padAll(PAD_LARGE);
auto btn =
new TextButton(line, rect_t{}, LV_SYMBOL_SETTINGS, [=]() -> uint8_t {
new InputEditAdvanced(this->input, index);
showAdvanced();
return 0;
});
lv_obj_set_width(btn->getLvObj(), lv_pct(100));
}
void InputEditWindow::showAdvanced()
{
if (!advWindow) {
advWindow = new Window(this,
{0, EdgeTxStyles::MENU_HEADER_HEIGHT, LCD_W, LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT});
advWindow->setWindowFlag(NO_FOCUS);
advWindow->padAll(PAD_SMALL);
etx_solid_bg(advWindow->getLvObj());
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
advWindow->setFlexLayout();
advWindow->setHeight(LCD_H - EdgeTxStyles::MENU_HEADER_HEIGHT);
ExpoData* input = expoAddress(index);
// Side
auto line = advWindow->newLine(grid);
new StaticText(line, rect_t{}, STR_SIDE);
new Choice(
line, rect_t{}, STR_VCURVEFUNC, 1, 3,
[=]() -> int16_t { return 4 - input->mode; },
[=](int16_t newValue) {
input->mode = 4 - newValue;
updatePreview = true;
SET_DIRTY();
});
// Trim
line = advWindow->newLine(grid);
new StaticText(line, rect_t{}, STR_TRIM);
const auto trimLast = TRIM_OFF + keysGetMaxTrims() - 1;
auto c = new Choice(line, rect_t{}, -TRIM_OFF, trimLast,
GET_VALUE(-input->trimSource),
SET_VALUE(input->trimSource, -newValue));
uint16_t srcRaw = input->srcRaw;
c->setAvailableHandler([=](int value) {
return value != TRIM_ON || srcRaw <= MIXSRC_LAST_STICK;
});
c->setTextHandler([=](int value) -> std::string {
return getTrimSourceLabel(srcRaw, -value);
});
// Flight modes
if (modelFMEnabled()) {
line = advWindow->newLine(grid);
new StaticText(line, rect_t{}, STR_FLMODE);
new FMMatrix<ExpoData>(line, rect_t{}, input);
}
}
advWindow->show();
advEdit = true;
}
void InputEditWindow::checkEvents()
{
ExpoData* input = expoAddress(index);
@@ -239,3 +295,13 @@ void InputEditWindow::checkEvents()
Page::checkEvents();
}
void InputEditWindow::onCancel()
{
if (advEdit) {
advEdit = false;
advWindow->hide();
} else {
Page::onCancel();
}
}
@@ -45,9 +45,14 @@ class InputEditWindow : public Page
getvalue_t lastCurveVal = 0;
uint8_t lastActiveIndex = 255;
StaticText * headerSwitchName = nullptr;
Window* advWindow = nullptr;
bool advEdit = false;
void setTitle();
void buildBody(Window *window);
void showAdvanced();
void onCancel() override;
void checkEvents() override;
};
@@ -1,79 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "input_edit_adv.h"
#include "fm_matrix.h"
#include "edgetx.h"
#include "etx_lv_theme.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2),
LV_GRID_TEMPLATE_LAST};
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
InputEditAdvanced::InputEditAdvanced(uint8_t input_n, uint8_t index) :
Page(ICON_MODEL_INPUTS)
{
std::string title2(getSourceString(MIXSRC_FIRST_INPUT + input_n));
header->setTitle(STR_MENUINPUTS);
header->setTitle2(title2);
FlexGridLayout grid(col_dsc, row_dsc, PAD_TINY);
body->setFlexLayout();
ExpoData* input = expoAddress(index);
// Side
auto line = body->newLine(grid);
new StaticText(line, rect_t{}, STR_SIDE);
new Choice(
line, rect_t{}, STR_VCURVEFUNC, 1, 3,
[=]() -> int16_t { return 4 - input->mode; },
[=](int16_t newValue) {
input->mode = 4 - newValue;
SET_DIRTY();
});
// Trim
line = body->newLine(grid);
new StaticText(line, rect_t{}, STR_TRIM);
const auto trimLast = TRIM_OFF + keysGetMaxTrims() - 1;
auto c = new Choice(line, rect_t{}, -TRIM_OFF, trimLast,
GET_VALUE(-input->trimSource),
SET_VALUE(input->trimSource, -newValue));
uint16_t srcRaw = input->srcRaw;
c->setAvailableHandler([=](int value) {
return value != TRIM_ON || srcRaw <= MIXSRC_LAST_STICK;
});
c->setTextHandler([=](int value) -> std::string {
return getTrimSourceLabel(srcRaw, -value);
});
// Flight modes
if (modelFMEnabled()) {
line = body->newLine(grid);
new StaticText(line, rect_t{}, STR_FLMODE);
new FMMatrix<ExpoData>(line, rect_t{}, input);
}
}
@@ -1,33 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "page.h"
#include "button_matrix.h"
struct ExpoData;
class InputEditAdvanced : public Page
{
public:
InputEditAdvanced(uint8_t input_n, uint8_t index);
};