fix: EM trigger / input focux loss in when editing outputs (#1657)
* handle events on the outputs screen (#1652) * change background color instead of font color * Auto formatting only (except for include order) Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
@@ -20,236 +20,238 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "model_outputs.h"
|
#include "model_outputs.h"
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "libopenui.h"
|
#include "libopenui.h"
|
||||||
|
|
||||||
#include "gvar_numberedit.h"
|
#include "gvar_numberedit.h"
|
||||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
|
||||||
|
|
||||||
class OutputEditWindow : public Page {
|
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||||
public:
|
|
||||||
explicit OutputEditWindow(uint8_t channel) :
|
|
||||||
Page(ICON_MODEL_OUTPUTS),
|
|
||||||
channel(channel)
|
|
||||||
{
|
|
||||||
chanZero = calcRESXto100(channelOutputs[channel]);
|
|
||||||
buildBody(&body);
|
|
||||||
buildHeader(&header);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
class OutputEditWindow : public Page
|
||||||
uint8_t channel;
|
{
|
||||||
int value = 0;
|
public:
|
||||||
int chanZero = 0;
|
explicit OutputEditWindow(uint8_t channel) :
|
||||||
|
Page(ICON_MODEL_OUTPUTS), channel(channel)
|
||||||
|
{
|
||||||
|
chanZero = calcRESXto100(channelOutputs[channel]);
|
||||||
|
buildBody(&body);
|
||||||
|
buildHeader(&header);
|
||||||
|
}
|
||||||
|
|
||||||
void checkEvents() override
|
protected:
|
||||||
{
|
uint8_t channel;
|
||||||
Window::checkEvents();
|
int value = 0;
|
||||||
int newValue = channelOutputs[channel];
|
int chanZero = 0;
|
||||||
if (value != newValue) {
|
StaticText *minText;
|
||||||
value = newValue;
|
StaticText *maxText;
|
||||||
body.clear();
|
|
||||||
buildBody(&body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildHeader(Window * window)
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
new StaticText(window,
|
int newValue = channelOutputs[channel];
|
||||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP,
|
if (value != newValue) {
|
||||||
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
|
value = newValue;
|
||||||
STR_MENULIMITS, 0, COLOR_THEME_PRIMARY2);
|
|
||||||
new StaticText(window,
|
|
||||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
|
|
||||||
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
|
|
||||||
getSourceString(MIXSRC_CH1 + channel), 0,
|
|
||||||
COLOR_THEME_PRIMARY2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildBody(FormWindow * window)
|
|
||||||
{
|
|
||||||
FormGridLayout grid;
|
|
||||||
grid.spacer(8);
|
|
||||||
|
|
||||||
int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX);
|
|
||||||
|
|
||||||
LimitData *output = limitAddress(channel);
|
|
||||||
int chanVal = calcRESXto100(channelOutputs[channel]);
|
|
||||||
|
|
||||||
// Name
|
|
||||||
new StaticText(window, grid.getLabelSlot(), STR_NAME, 0,
|
|
||||||
COLOR_THEME_PRIMARY1);
|
|
||||||
new ModelTextEdit(window, grid.getFieldSlot(), output->name,
|
|
||||||
sizeof(output->name));
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Offset
|
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIM,
|
|
||||||
0, COLOR_THEME_PRIMARY1);
|
|
||||||
new GVarNumberEdit(window, grid.getFieldSlot(), -LIMIT_STD_MAX,
|
|
||||||
+LIMIT_STD_MAX, GET_SET_DEFAULT(output->offset), 0,
|
|
||||||
PREC1);
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
//TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
|
|
||||||
|
|
||||||
// Min
|
|
||||||
new StaticText(
|
|
||||||
window, grid.getLabelSlot(), TR_MIN, 0,
|
|
||||||
chanVal < chanZero - 1 ? COLOR_THEME_ACTIVE : COLOR_THEME_PRIMARY1);
|
|
||||||
new GVarNumberEdit(window, grid.getFieldSlot(), -limit, 0,
|
|
||||||
GET_SET_DEFAULT(output->min), 0, PREC1,
|
|
||||||
-LIMIT_STD_MAX);
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Max
|
|
||||||
new StaticText(
|
|
||||||
window, grid.getLabelSlot(), TR_MAX, 0,
|
|
||||||
chanVal > chanZero + 1 ? COLOR_THEME_ACTIVE : COLOR_THEME_PRIMARY1);
|
|
||||||
new GVarNumberEdit(window, grid.getFieldSlot(), 0, +limit,
|
|
||||||
GET_SET_DEFAULT(output->max), 0, PREC1,
|
|
||||||
+LIMIT_STD_MAX);
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Direction
|
|
||||||
new StaticText(window, grid.getLabelSlot(), STR_INVERTED, 0,
|
|
||||||
COLOR_THEME_PRIMARY1);
|
|
||||||
new CheckBox(window, grid.getFieldSlot(),
|
|
||||||
GET_DEFAULT(output->revert),
|
|
||||||
[output, this] (uint8_t newValue) {
|
|
||||||
if (newValue != output->revert) chanZero = -chanZero;
|
|
||||||
output->revert = newValue;
|
|
||||||
SET_DIRTY();
|
|
||||||
});
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Curve
|
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_CURVE, 0,
|
|
||||||
COLOR_THEME_PRIMARY1);
|
|
||||||
auto edit = new NumberEdit(window, grid.getFieldSlot(), -MAX_CURVES,
|
|
||||||
+MAX_CURVES, GET_SET_DEFAULT(output->curve));
|
|
||||||
edit->setDisplayHandler(
|
|
||||||
[](BitmapBuffer *dc, LcdFlags flags, int32_t value) {
|
|
||||||
dc->drawText(2, 2, getCurveString(value));
|
|
||||||
});
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// PPM center
|
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_PPMCENTER,
|
|
||||||
0, COLOR_THEME_PRIMARY1);
|
|
||||||
new NumberEdit(window, grid.getFieldSlot(), PPM_CENTER - PPM_CENTER_MAX,
|
|
||||||
PPM_CENTER + PPM_CENTER_MAX,
|
|
||||||
GET_VALUE(output->ppmCenter + PPM_CENTER),
|
|
||||||
SET_VALUE(output->ppmCenter, newValue - PPM_CENTER));
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Subtrims mode
|
|
||||||
new StaticText(window, grid.getLabelSlot(),
|
|
||||||
TR_LIMITS_HEADERS_SUBTRIMMODE, 0, COLOR_THEME_PRIMARY1);
|
|
||||||
new Choice(window, grid.getFieldSlot(), STR_SUBTRIMMODES, 0, 1,
|
|
||||||
GET_SET_DEFAULT(output->symetrical));
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
window->setInnerHeight(grid.getWindowHeight());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OutputLineButton : public Button {
|
|
||||||
public:
|
|
||||||
OutputLineButton(FormGroup * parent, const rect_t &rect, LimitData * output, int ch) :
|
|
||||||
Button(parent, rect),
|
|
||||||
output(output),
|
|
||||||
channel(ch)
|
|
||||||
{
|
|
||||||
if (output->revert || output->curve || output->name[0]) {
|
|
||||||
setHeight(height() + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP);
|
|
||||||
}
|
|
||||||
chanZero = calcRESXto100(channelOutputs[channel]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override
|
|
||||||
{
|
|
||||||
LcdFlags textColor = COLOR_THEME_SECONDARY1;
|
|
||||||
LcdFlags bgColor = COLOR_THEME_PRIMARY2;
|
|
||||||
LcdFlags textColorActive = COLOR_THEME_ACTIVE;
|
|
||||||
LcdFlags textFlag;
|
|
||||||
int chanVal = calcRESXto100(channelOutputs[channel]);
|
int chanVal = calcRESXto100(channelOutputs[channel]);
|
||||||
|
minText->setBackgroundColor(chanVal < chanZero - 1 ? COLOR_THEME_ACTIVE
|
||||||
|
: 0U);
|
||||||
|
minText->invalidate();
|
||||||
|
maxText->setBackgroundColor(chanVal > chanZero + 1 ? COLOR_THEME_ACTIVE
|
||||||
|
: 0U);
|
||||||
|
maxText->invalidate();
|
||||||
|
}
|
||||||
|
Window::checkEvents();
|
||||||
|
}
|
||||||
|
|
||||||
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
|
void buildHeader(Window *window)
|
||||||
|
{
|
||||||
|
new StaticText(window,
|
||||||
|
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
|
||||||
|
PAGE_LINE_HEIGHT},
|
||||||
|
STR_MENULIMITS, 0, COLOR_THEME_PRIMARY2);
|
||||||
|
new StaticText(window,
|
||||||
|
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
|
||||||
|
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
|
||||||
|
getSourceString(MIXSRC_CH1 + channel), 0,
|
||||||
|
COLOR_THEME_PRIMARY2);
|
||||||
|
}
|
||||||
|
|
||||||
//TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
|
void buildBody(FormWindow *window)
|
||||||
// first line
|
{
|
||||||
|
FormGridLayout grid;
|
||||||
|
grid.spacer(8);
|
||||||
|
|
||||||
// Min
|
int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX);
|
||||||
textFlag = (chanVal < chanZero - 1) ? textColorActive : textColor;
|
|
||||||
drawValueOrGVar(
|
|
||||||
dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min,
|
|
||||||
-GV_RANGELARGE, 0, PREC1 | textFlag, nullptr,
|
|
||||||
-LIMITS_MIN_MAX_OFFSET);
|
|
||||||
|
|
||||||
// Max
|
LimitData *output = limitAddress(channel);
|
||||||
textFlag = (chanVal > chanZero + 1) ? textColorActive : textColor;
|
|
||||||
drawValueOrGVar(dc, 68, FIELD_PADDING_TOP,
|
|
||||||
output->max, 0,
|
|
||||||
GV_RANGELARGE, PREC1 | textFlag, nullptr,
|
|
||||||
+LIMITS_MIN_MAX_OFFSET);
|
|
||||||
|
|
||||||
// Offset
|
// Name
|
||||||
drawValueOrGVar(dc, 132, FIELD_PADDING_TOP, output->offset, -LIMIT_STD_MAX,
|
new StaticText(window, grid.getLabelSlot(), STR_NAME, 0,
|
||||||
+LIMIT_STD_MAX, PREC1 | textColor, nullptr);
|
COLOR_THEME_PRIMARY1);
|
||||||
|
new ModelTextEdit(window, grid.getFieldSlot(), output->name,
|
||||||
|
sizeof(output->name));
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
// PPM center
|
// Offset
|
||||||
dc->drawNumber(226, FIELD_PADDING_TOP, PPM_CENTER + output->ppmCenter,
|
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIM, 0,
|
||||||
RIGHT | textColor);
|
COLOR_THEME_PRIMARY1);
|
||||||
dc->drawText(228, FIELD_PADDING_TOP, output->symetrical ? "=" : "\210",
|
new GVarNumberEdit(window, grid.getFieldSlot(), -LIMIT_STD_MAX,
|
||||||
textColor);
|
+LIMIT_STD_MAX, GET_SET_DEFAULT(output->offset), 0,
|
||||||
|
PREC1);
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
// second line
|
// TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
|
||||||
if (output->revert) {
|
|
||||||
dc->drawTextAtIndex(4, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, STR_MMMINV,
|
|
||||||
output->revert, textColor);
|
|
||||||
}
|
|
||||||
if (output->curve) {
|
|
||||||
dc->drawMask(68, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
|
||||||
mixerSetupCurveIcon, textColor);
|
|
||||||
dc->drawText(88, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
|
||||||
getCurveString(output->curve), textColor);
|
|
||||||
}
|
|
||||||
if (output->name[0]) {
|
|
||||||
dc->drawMask(146, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
|
||||||
mixerSetupLabelIcon, textColor);
|
|
||||||
dc->drawSizedText(166, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
|
||||||
output->name, sizeof(output->name), textColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bounding rect
|
// Min
|
||||||
if (hasFocus())
|
minText = new StaticText(window, grid.getLabelSlot(), TR_MIN, 0,
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, COLOR_THEME_FOCUS);
|
COLOR_THEME_PRIMARY1);
|
||||||
else
|
new GVarNumberEdit(window, grid.getFieldSlot(), -limit, 0,
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, COLOR_THEME_SECONDARY2);
|
GET_SET_DEFAULT(output->min), 0, PREC1, -LIMIT_STD_MAX);
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
// Max
|
||||||
|
maxText = new StaticText(window, grid.getLabelSlot(), TR_MAX, 0,
|
||||||
|
COLOR_THEME_PRIMARY1);
|
||||||
|
new GVarNumberEdit(window, grid.getFieldSlot(), 0, +limit,
|
||||||
|
GET_SET_DEFAULT(output->max), 0, PREC1, +LIMIT_STD_MAX);
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
// Direction
|
||||||
|
new StaticText(window, grid.getLabelSlot(), STR_INVERTED, 0,
|
||||||
|
COLOR_THEME_PRIMARY1);
|
||||||
|
new CheckBox(window, grid.getFieldSlot(), GET_DEFAULT(output->revert),
|
||||||
|
[output, this](uint8_t newValue) {
|
||||||
|
if (newValue != output->revert) chanZero = -chanZero;
|
||||||
|
output->revert = newValue;
|
||||||
|
SET_DIRTY();
|
||||||
|
});
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
// Curve
|
||||||
|
new StaticText(window, grid.getLabelSlot(), TR_CURVE, 0,
|
||||||
|
COLOR_THEME_PRIMARY1);
|
||||||
|
auto edit = new NumberEdit(window, grid.getFieldSlot(), -MAX_CURVES,
|
||||||
|
+MAX_CURVES, GET_SET_DEFAULT(output->curve));
|
||||||
|
edit->setDisplayHandler(
|
||||||
|
[](BitmapBuffer *dc, LcdFlags flags, int32_t value) {
|
||||||
|
dc->drawText(2, 2, getCurveString(value));
|
||||||
|
});
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
// PPM center
|
||||||
|
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_PPMCENTER, 0,
|
||||||
|
COLOR_THEME_PRIMARY1);
|
||||||
|
new NumberEdit(window, grid.getFieldSlot(), PPM_CENTER - PPM_CENTER_MAX,
|
||||||
|
PPM_CENTER + PPM_CENTER_MAX,
|
||||||
|
GET_VALUE(output->ppmCenter + PPM_CENTER),
|
||||||
|
SET_VALUE(output->ppmCenter, newValue - PPM_CENTER));
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
// Subtrims mode
|
||||||
|
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIMMODE,
|
||||||
|
0, COLOR_THEME_PRIMARY1);
|
||||||
|
new Choice(window, grid.getFieldSlot(), STR_SUBTRIMMODES, 0, 1,
|
||||||
|
GET_SET_DEFAULT(output->symetrical));
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
window->setInnerHeight(grid.getWindowHeight());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class OutputLineButton : public Button
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OutputLineButton(FormGroup *parent, const rect_t &rect, LimitData *output,
|
||||||
|
int ch) :
|
||||||
|
Button(parent, rect), output(output), channel(ch)
|
||||||
|
{
|
||||||
|
if (output->revert || output->curve || output->name[0]) {
|
||||||
|
setHeight(height() + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP);
|
||||||
|
}
|
||||||
|
chanZero = calcRESXto100(channelOutputs[channel]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void paint(BitmapBuffer *dc) override
|
||||||
|
{
|
||||||
|
LcdFlags textColor = COLOR_THEME_SECONDARY1;
|
||||||
|
LcdFlags bgColor = COLOR_THEME_PRIMARY2;
|
||||||
|
LcdFlags textColorActive = COLOR_THEME_ACTIVE;
|
||||||
|
LcdFlags textFlag;
|
||||||
|
int chanVal = calcRESXto100(channelOutputs[channel]);
|
||||||
|
|
||||||
|
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
|
||||||
|
|
||||||
|
// TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
|
||||||
|
// first line
|
||||||
|
|
||||||
|
// Min
|
||||||
|
textFlag = (chanVal < chanZero - 1) ? textColorActive : textColor;
|
||||||
|
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min,
|
||||||
|
-GV_RANGELARGE, 0, PREC1 | textFlag, nullptr,
|
||||||
|
-LIMITS_MIN_MAX_OFFSET);
|
||||||
|
|
||||||
|
// Max
|
||||||
|
textFlag = (chanVal > chanZero + 1) ? textColorActive : textColor;
|
||||||
|
drawValueOrGVar(dc, 68, FIELD_PADDING_TOP, output->max, 0, GV_RANGELARGE,
|
||||||
|
PREC1 | textFlag, nullptr, +LIMITS_MIN_MAX_OFFSET);
|
||||||
|
|
||||||
|
// Offset
|
||||||
|
drawValueOrGVar(dc, 132, FIELD_PADDING_TOP, output->offset, -LIMIT_STD_MAX,
|
||||||
|
+LIMIT_STD_MAX, PREC1 | textColor, nullptr);
|
||||||
|
|
||||||
|
// PPM center
|
||||||
|
dc->drawNumber(226, FIELD_PADDING_TOP, PPM_CENTER + output->ppmCenter,
|
||||||
|
RIGHT | textColor);
|
||||||
|
dc->drawText(228, FIELD_PADDING_TOP, output->symetrical ? "=" : "\210",
|
||||||
|
textColor);
|
||||||
|
|
||||||
|
// second line
|
||||||
|
if (output->revert) {
|
||||||
|
dc->drawTextAtIndex(4, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, STR_MMMINV,
|
||||||
|
output->revert, textColor);
|
||||||
|
}
|
||||||
|
if (output->curve) {
|
||||||
|
dc->drawMask(68, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
||||||
|
mixerSetupCurveIcon, textColor);
|
||||||
|
dc->drawText(88, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
||||||
|
getCurveString(output->curve), textColor);
|
||||||
|
}
|
||||||
|
if (output->name[0]) {
|
||||||
|
dc->drawMask(146, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
|
||||||
|
mixerSetupLabelIcon, textColor);
|
||||||
|
dc->drawSizedText(166, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, output->name,
|
||||||
|
sizeof(output->name), textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
// bounding rect
|
||||||
void checkEvents() override
|
if (hasFocus())
|
||||||
{
|
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, COLOR_THEME_FOCUS);
|
||||||
Window::checkEvents();
|
else
|
||||||
int newValue = channelOutputs[channel];
|
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, COLOR_THEME_SECONDARY2);
|
||||||
if (value != newValue) {
|
}
|
||||||
value = newValue;
|
|
||||||
invalidate();
|
protected:
|
||||||
}
|
void checkEvents() override
|
||||||
|
{
|
||||||
|
Window::checkEvents();
|
||||||
|
int newValue = channelOutputs[channel];
|
||||||
|
if (value != newValue) {
|
||||||
|
value = newValue;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
LimitData *output;
|
}
|
||||||
int channel;
|
LimitData *output;
|
||||||
int chanZero;
|
int channel;
|
||||||
int value = 0;
|
int chanZero;
|
||||||
};
|
int value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
ModelOutputsPage::ModelOutputsPage() :
|
ModelOutputsPage::ModelOutputsPage() :
|
||||||
PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS)
|
PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOutputsPage::rebuild(FormWindow * window, int8_t focusChannel)
|
void ModelOutputsPage::rebuild(FormWindow *window, int8_t focusChannel)
|
||||||
{
|
{
|
||||||
coord_t scrollPosition = window->getScrollPositionY();
|
coord_t scrollPosition = window->getScrollPositionY();
|
||||||
window->clear();
|
window->clear();
|
||||||
@@ -257,35 +259,37 @@ void ModelOutputsPage::rebuild(FormWindow * window, int8_t focusChannel)
|
|||||||
window->setScrollPositionY(scrollPosition);
|
window->setScrollPositionY(scrollPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
|
void ModelOutputsPage::build(FormWindow *window, int8_t focusChannel)
|
||||||
{
|
{
|
||||||
FormGridLayout grid;
|
FormGridLayout grid;
|
||||||
grid.spacer(PAGE_PADDING);
|
grid.spacer(PAGE_PADDING);
|
||||||
grid.setLabelWidth(66);
|
grid.setLabelWidth(66);
|
||||||
|
|
||||||
new TextButton(window, grid.getLineSlot(), STR_ADD_ALL_TRIMS_TO_SUBTRIMS,
|
new TextButton(
|
||||||
[=] () {
|
window, grid.getLineSlot(), STR_ADD_ALL_TRIMS_TO_SUBTRIMS,
|
||||||
moveTrimsToOffsets(); // if highlighted and menu pressed - move trims to offsets
|
[=]() {
|
||||||
rebuild(window, 0);
|
moveTrimsToOffsets(); // if highlighted and menu pressed - move trims
|
||||||
return 0;
|
// to offsets
|
||||||
}, 0, COLOR_THEME_PRIMARY1);
|
rebuild(window, 0);
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
0, COLOR_THEME_PRIMARY1);
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
|
|
||||||
for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
|
for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
|
||||||
LimitData * output = limitAddress(ch);
|
LimitData *output = limitAddress(ch);
|
||||||
|
|
||||||
// Channel label
|
// Channel label
|
||||||
auto txt = new StaticText(window, grid.getLabelSlot(),
|
auto txt = new StaticText(
|
||||||
getSourceString(MIXSRC_CH1 + ch),
|
window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch),
|
||||||
BUTTON_BACKGROUND, CENTERED | COLOR_THEME_PRIMARY1);
|
BUTTON_BACKGROUND, CENTERED | COLOR_THEME_PRIMARY1);
|
||||||
|
|
||||||
// Channel settings
|
// Channel settings
|
||||||
Button * button = new OutputLineButton(window, grid.getFieldSlot(), output, ch);
|
Button *button =
|
||||||
|
new OutputLineButton(window, grid.getFieldSlot(), output, ch);
|
||||||
button->setPressHandler([=]() -> uint8_t {
|
button->setPressHandler([=]() -> uint8_t {
|
||||||
Menu * menu = new Menu(window);
|
Menu *menu = new Menu(window);
|
||||||
menu->addLine(STR_EDIT, [=]() {
|
menu->addLine(STR_EDIT, [=]() { editOutput(window, ch); });
|
||||||
editOutput(window, ch);
|
|
||||||
});
|
|
||||||
menu->addLine(STR_RESET, [=]() {
|
menu->addLine(STR_RESET, [=]() {
|
||||||
output->min = 0;
|
output->min = 0;
|
||||||
output->max = 0;
|
output->max = 0;
|
||||||
@@ -336,11 +340,9 @@ void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
|
|||||||
window->setInnerHeight(grid.getWindowHeight());
|
window->setInnerHeight(grid.getWindowHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOutputsPage::editOutput(FormWindow * window, uint8_t channel)
|
void ModelOutputsPage::editOutput(FormWindow *window, uint8_t channel)
|
||||||
{
|
{
|
||||||
Window::clearFocus();
|
Window::clearFocus();
|
||||||
Window * editWindow = new OutputEditWindow(channel);
|
Window *editWindow = new OutputEditWindow(channel);
|
||||||
editWindow->setCloseHandler([=]() {
|
editWindow->setCloseHandler([=]() { rebuild(window, channel); });
|
||||||
rebuild(window, channel);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user