fix(color): refresh issues on Input edit page (#5447)
This commit is contained in:
@@ -178,15 +178,18 @@ void TextEdit::preview(bool edited, char* text, uint8_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModelTextEdit::ModelTextEdit(Window* parent, const rect_t& rect, char* value,
|
ModelTextEdit::ModelTextEdit(Window* parent, const rect_t& rect, char* value,
|
||||||
uint8_t length) :
|
uint8_t length, std::function<void(void)> updateHandler) :
|
||||||
TextEdit(parent, rect, value, length,
|
TextEdit(parent, rect, value, length,
|
||||||
[]() { storageDirty(EE_MODEL); })
|
[=]() {
|
||||||
|
if (updateHandler) updateHandler();
|
||||||
|
storageDirty(EE_MODEL);
|
||||||
|
})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioTextEdit::RadioTextEdit(Window* parent, const rect_t& rect, char* value,
|
RadioTextEdit::RadioTextEdit(Window* parent, const rect_t& rect, char* value,
|
||||||
uint8_t length) :
|
uint8_t length) :
|
||||||
TextEdit(parent, rect, value, length,
|
TextEdit(parent, rect, value, length,
|
||||||
[]() { storageDirty(EE_GENERAL); })
|
[]() { storageDirty(EE_GENERAL); })
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class TextEdit : public TextButton
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextEdit(Window* parent, const rect_t& rect, char* text, uint8_t length,
|
TextEdit(Window* parent, const rect_t& rect, char* text, uint8_t length,
|
||||||
std::function<void(void)> updateHandler = nullptr);
|
std::function<void(void)> updateHandler = nullptr);
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override { return "TextEdit \"" + text + "\""; }
|
std::string getName() const override { return "TextEdit \"" + text + "\""; }
|
||||||
@@ -51,7 +51,7 @@ class ModelTextEdit : public TextEdit
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModelTextEdit(Window* parent, const rect_t& rect, char* value,
|
ModelTextEdit(Window* parent, const rect_t& rect, char* value,
|
||||||
uint8_t length);
|
uint8_t length, std::function<void(void)> updateHandler = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RadioTextEdit : public TextEdit
|
class RadioTextEdit : public TextEdit
|
||||||
|
|||||||
@@ -36,9 +36,16 @@
|
|||||||
InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
|
InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
|
||||||
Page(ICON_MODEL_INPUTS), input(input), index(index)
|
Page(ICON_MODEL_INPUTS), input(input), index(index)
|
||||||
{
|
{
|
||||||
std::string title2(getSourceString(MIXSRC_FIRST_INPUT + input));
|
|
||||||
header->setTitle(STR_MENUINPUTS);
|
header->setTitle(STR_MENUINPUTS);
|
||||||
header->setTitle2(title2);
|
headerSwitchName = header->setTitle2("");
|
||||||
|
|
||||||
|
etx_txt_color(headerSwitchName->getLvObj(), COLOR_THEME_ACTIVE_INDEX,
|
||||||
|
LV_STATE_USER_1);
|
||||||
|
etx_font(headerSwitchName->getLvObj(), FONT_BOLD_INDEX, LV_STATE_USER_1);
|
||||||
|
|
||||||
|
active = !isActive();
|
||||||
|
|
||||||
|
setTitle();
|
||||||
|
|
||||||
auto body_obj = body->getLvObj();
|
auto body_obj = body->getLvObj();
|
||||||
#if PORTRAIT_LCD // portrait
|
#if PORTRAIT_LCD // portrait
|
||||||
@@ -75,6 +82,17 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
|
|||||||
CurveEdit::SetCurrentSource(expoAddress(index)->srcRaw);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2),
|
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2),
|
||||||
LV_GRID_TEMPLATE_LAST};
|
LV_GRID_TEMPLATE_LAST};
|
||||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||||
@@ -88,9 +106,12 @@ void InputEditWindow::buildBody(Window* form)
|
|||||||
|
|
||||||
// Input Name
|
// Input Name
|
||||||
auto line = form->newLine(grid);
|
auto line = form->newLine(grid);
|
||||||
auto inputName = g_model.inputNames[input->chn];
|
|
||||||
new StaticText(line, rect_t{}, STR_INPUTNAME);
|
new StaticText(line, rect_t{}, STR_INPUTNAME);
|
||||||
new ModelTextEdit(line, rect_t{}, inputName, LEN_INPUT_NAME);
|
new ModelTextEdit(line, rect_t{}, g_model.inputNames[input->chn],
|
||||||
|
LEN_INPUT_NAME,
|
||||||
|
[=]() {
|
||||||
|
setTitle();
|
||||||
|
});
|
||||||
|
|
||||||
// Line Name
|
// Line Name
|
||||||
line = form->newLine(grid);
|
line = form->newLine(grid);
|
||||||
@@ -110,7 +131,7 @@ void InputEditWindow::buildBody(Window* form)
|
|||||||
new SourceNumberEdit(line, -100, 100, GET_DEFAULT(input->weight),
|
new SourceNumberEdit(line, -100, 100, GET_DEFAULT(input->weight),
|
||||||
[=](int32_t newValue) {
|
[=](int32_t newValue) {
|
||||||
input->weight = newValue;
|
input->weight = newValue;
|
||||||
preview->update();
|
updatePreview = true;
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
}, MIXSRC_FIRST);
|
}, MIXSRC_FIRST);
|
||||||
gvar->setSuffix("%");
|
gvar->setSuffix("%");
|
||||||
@@ -121,7 +142,7 @@ void InputEditWindow::buildBody(Window* form)
|
|||||||
gvar = new SourceNumberEdit(line, -100, 100,
|
gvar = new SourceNumberEdit(line, -100, 100,
|
||||||
GET_DEFAULT(input->offset), [=](int32_t newValue) {
|
GET_DEFAULT(input->offset), [=](int32_t newValue) {
|
||||||
input->offset = newValue;
|
input->offset = newValue;
|
||||||
preview->update();
|
updatePreview = true;
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
}, MIXSRC_FIRST);
|
}, MIXSRC_FIRST);
|
||||||
gvar->setSuffix("%");
|
gvar->setSuffix("%");
|
||||||
@@ -130,7 +151,12 @@ void InputEditWindow::buildBody(Window* form)
|
|||||||
line = form->newLine(grid);
|
line = form->newLine(grid);
|
||||||
new StaticText(line, rect_t{}, STR_SWITCH);
|
new StaticText(line, rect_t{}, STR_SWITCH);
|
||||||
new SwitchChoice(line, rect_t{}, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES,
|
new SwitchChoice(line, rect_t{}, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES,
|
||||||
GET_SET_DEFAULT(input->swtch));
|
GET_DEFAULT(input->swtch),
|
||||||
|
[=](int newValue) {
|
||||||
|
input->swtch = newValue;
|
||||||
|
updatePreview = true;
|
||||||
|
SET_DIRTY();
|
||||||
|
});
|
||||||
|
|
||||||
// Curve
|
// Curve
|
||||||
line = form->newLine(grid);
|
line = form->newLine(grid);
|
||||||
@@ -139,13 +165,11 @@ void InputEditWindow::buildBody(Window* form)
|
|||||||
new CurveParam(line, rect_t{}, &input->curve,
|
new CurveParam(line, rect_t{}, &input->curve,
|
||||||
[=](int32_t newValue) {
|
[=](int32_t newValue) {
|
||||||
input->curve.value = newValue;
|
input->curve.value = newValue;
|
||||||
if (preview)
|
updatePreview = true;
|
||||||
preview->update();
|
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
}, MIXSRC_FIRST,
|
}, MIXSRC_FIRST,
|
||||||
[=]() {
|
[=]() {
|
||||||
if (preview)
|
updatePreview = true;
|
||||||
preview->update();
|
|
||||||
});
|
});
|
||||||
lv_obj_set_style_grid_cell_x_align(param->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
lv_obj_set_style_grid_cell_x_align(param->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||||
0);
|
0);
|
||||||
@@ -172,7 +196,6 @@ void InputEditWindow::checkEvents()
|
|||||||
{
|
{
|
||||||
ExpoData* input = expoAddress(index);
|
ExpoData* input = expoAddress(index);
|
||||||
|
|
||||||
bool updatePreview = false;
|
|
||||||
getvalue_t val;
|
getvalue_t val;
|
||||||
SourceNumVal v;
|
SourceNumVal v;
|
||||||
|
|
||||||
@@ -203,8 +226,26 @@ void InputEditWindow::checkEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatePreview)
|
bool sw = getSwitch(input->swtch);
|
||||||
preview->update();
|
if (sw != lastSwitchState) {
|
||||||
|
updatePreview = true;
|
||||||
|
lastSwitchState = sw;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updatePreview) {
|
||||||
|
updatePreview = false;
|
||||||
|
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();
|
Page::checkEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,12 +39,18 @@ class InputEditWindow : public Page
|
|||||||
uint8_t input;
|
uint8_t input;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
Curve* preview = nullptr;
|
Curve* preview = nullptr;
|
||||||
|
bool updatePreview = false;
|
||||||
getvalue_t lastWeightVal = 0;
|
getvalue_t lastWeightVal = 0;
|
||||||
getvalue_t lastOffsetVal = 0;
|
getvalue_t lastOffsetVal = 0;
|
||||||
getvalue_t lastCurveVal = 0;
|
getvalue_t lastCurveVal = 0;
|
||||||
|
bool lastSwitchState = false;
|
||||||
|
bool active = false;
|
||||||
|
StaticText * headerSwitchName = nullptr;
|
||||||
|
|
||||||
|
void setTitle();
|
||||||
void buildBody(Window *window);
|
void buildBody(Window *window);
|
||||||
|
|
||||||
|
bool isActive();
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
void deleteLater(bool detach = true, bool trash = true) override;
|
void deleteLater(bool detach = true, bool trash = true) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,21 +58,6 @@ ModelSetupPage::ModelSetupPage() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ModelNameEdit : public ModelTextEdit {
|
|
||||||
ModelNameEdit(Window *parent, const rect_t &rect) :
|
|
||||||
ModelTextEdit(parent, rect, g_model.header.name,
|
|
||||||
sizeof(g_model.header.name))
|
|
||||||
{
|
|
||||||
setChangeHandler([=]() {
|
|
||||||
auto model = modelslist.getCurrentModel();
|
|
||||||
if (model) {
|
|
||||||
model->setModelName(g_model.header.name);
|
|
||||||
}
|
|
||||||
SET_DIRTY();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void viewOption(Window* parent, coord_t x, coord_t y,
|
static void viewOption(Window* parent, coord_t x, coord_t y,
|
||||||
std::function<uint8_t()> getValue,
|
std::function<uint8_t()> getValue,
|
||||||
std::function<void(uint8_t)> setValue, bool globalState)
|
std::function<void(uint8_t)> setValue, bool globalState)
|
||||||
@@ -297,7 +282,15 @@ static SetupLineDef setupLines[] = {
|
|||||||
// Model name
|
// Model name
|
||||||
STR_MODELNAME,
|
STR_MODELNAME,
|
||||||
[](Window* parent, coord_t x, coord_t y) {
|
[](Window* parent, coord_t x, coord_t y) {
|
||||||
new ModelNameEdit(parent, {x, y, ModelSetupPage::NAM_W, 0});
|
new ModelTextEdit(parent, {x, y, ModelSetupPage::NAM_W, 0},
|
||||||
|
g_model.header.name, sizeof(g_model.header.name),
|
||||||
|
[=]() {
|
||||||
|
auto model = modelslist.getCurrentModel();
|
||||||
|
if (model) {
|
||||||
|
model->setModelName(g_model.header.name);
|
||||||
|
}
|
||||||
|
SET_DIRTY();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user