Cosmetics
This commit is contained in:
@@ -38,45 +38,52 @@
|
|||||||
// lcdDrawChar(lcdNextPos, y, ']');
|
// lcdDrawChar(lcdNextPos, y, ']');
|
||||||
//}
|
//}
|
||||||
|
|
||||||
class LogicalSwitchEditWindow: public Page {
|
class LogicalSwitchEditPage: public Page {
|
||||||
public:
|
public:
|
||||||
LogicalSwitchEditWindow(uint8_t ls):
|
explicit LogicalSwitchEditPage(uint8_t index):
|
||||||
Page(ICON_MODEL_LOGICAL_SWITCHES),
|
Page(ICON_MODEL_LOGICAL_SWITCHES),
|
||||||
ls(ls)
|
index(index)
|
||||||
{
|
{
|
||||||
buildBody(&body);
|
|
||||||
buildHeader(&header);
|
buildHeader(&header);
|
||||||
}
|
buildBody(&body);
|
||||||
|
|
||||||
bool isActive() {
|
|
||||||
return getSwitch(SWSRC_FIRST_LOGICAL_SWITCH+ls);
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkEvents() override
|
|
||||||
{
|
|
||||||
if (active != isActive()) {
|
|
||||||
headerSwitchName->setFlags(isActive() ? BOLD|WARNING_COLOR : MENU_TITLE_COLOR);
|
|
||||||
active = !active;
|
|
||||||
}
|
|
||||||
|
|
||||||
Page::checkEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t ls;
|
uint8_t index;
|
||||||
bool active = false;
|
bool active = false;
|
||||||
Window * logicalSwitchOneWindow = nullptr;
|
Window * logicalSwitchOneWindow = nullptr;
|
||||||
StaticText * headerSwitchName = nullptr;
|
StaticText * headerSwitchName = nullptr;
|
||||||
NumberEdit * v2Edit = nullptr;
|
NumberEdit * v2Edit = nullptr;
|
||||||
|
|
||||||
void updateLogicalSwitchOneWindow()
|
bool isActive()
|
||||||
|
{
|
||||||
|
return getSwitch(SWSRC_FIRST_LOGICAL_SWITCH + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkEvents() override
|
||||||
|
{
|
||||||
|
Page::checkEvents();
|
||||||
|
if (active != isActive()) {
|
||||||
|
headerSwitchName->setFlags(isActive() ? BOLD|WARNING_COLOR : MENU_TITLE_COLOR);
|
||||||
|
active = !active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildHeader(Window * window) {
|
||||||
|
new StaticText(window, { PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT }, STR_MENULOGICALSWITCHES, MENU_TITLE_COLOR);
|
||||||
|
headerSwitchName = new StaticText(window, { PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT }, getSwitchPositionName(SWSRC_SW1 + index), MENU_TITLE_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateLogicalSwitchOneWindow(FormField * functionChoice)
|
||||||
{
|
{
|
||||||
FormGridLayout grid;
|
FormGridLayout grid;
|
||||||
logicalSwitchOneWindow->clear();
|
logicalSwitchOneWindow->clear();
|
||||||
|
|
||||||
LogicalSwitchData * cs = lswAddress(ls);
|
LogicalSwitchData * cs = lswAddress(index);
|
||||||
uint8_t cstate = lswFamily(cs->func);
|
uint8_t cstate = lswFamily(cs->func);
|
||||||
|
|
||||||
|
FormField::setCurrentField(functionChoice);
|
||||||
|
|
||||||
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
|
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
|
||||||
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V1);
|
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V1);
|
||||||
auto choice = new SwitchChoice(logicalSwitchOneWindow, grid.getFieldSlot(), SWSRC_FIRST_IN_LOGICAL_SWITCHES, SWSRC_LAST_IN_LOGICAL_SWITCHES, GET_SET_DEFAULT(cs->v1));
|
auto choice = new SwitchChoice(logicalSwitchOneWindow, grid.getFieldSlot(), SWSRC_FIRST_IN_LOGICAL_SWITCHES, SWSRC_LAST_IN_LOGICAL_SWITCHES, GET_SET_DEFAULT(cs->v1));
|
||||||
@@ -104,15 +111,15 @@ class LogicalSwitchEditWindow: public Page {
|
|||||||
edit2->invalidate();
|
edit2->invalidate();
|
||||||
});
|
});
|
||||||
edit1->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
edit1->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||||
dc->drawNumber(2, 2, lswTimerValue(value), flags | PREC1);
|
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, lswTimerValue(value), flags | PREC1);
|
||||||
});
|
});
|
||||||
edit2->setDisplayHandler([=](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
edit2->setDisplayHandler([=](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
dc->drawText(2, 2, "<<", flags);
|
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, "<<", flags);
|
||||||
else if (value == 0)
|
else if (value == 0)
|
||||||
dc->drawText(2, 2, "--", flags);
|
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, "--", flags);
|
||||||
else
|
else
|
||||||
dc->drawNumber(2, 2, lswTimerValue(cs->v2 + value), flags | PREC1);
|
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, lswTimerValue(cs->v2 + value), flags | PREC1);
|
||||||
});
|
});
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
}
|
}
|
||||||
@@ -129,14 +136,14 @@ class LogicalSwitchEditWindow: public Page {
|
|||||||
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V1);
|
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V1);
|
||||||
auto timer = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), -128, 122, GET_SET_DEFAULT(cs->v1));
|
auto timer = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), -128, 122, GET_SET_DEFAULT(cs->v1));
|
||||||
timer->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
timer->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||||
dc->drawNumber(2, 2, lswTimerValue(value), flags | PREC1);
|
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, lswTimerValue(value), flags | PREC1);
|
||||||
});
|
});
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
|
|
||||||
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V2);
|
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V2);
|
||||||
timer = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), -128, 122, GET_SET_DEFAULT(cs->v2));
|
timer = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), -128, 122, GET_SET_DEFAULT(cs->v2));
|
||||||
timer->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
timer->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||||
dc->drawNumber(2, 2, lswTimerValue(value), flags | PREC1);
|
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, lswTimerValue(value), flags | PREC1);
|
||||||
});
|
});
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
}
|
}
|
||||||
@@ -155,7 +162,7 @@ class LogicalSwitchEditWindow: public Page {
|
|||||||
getMixSrcRange(cs->v1, v2_min, v2_max);
|
getMixSrcRange(cs->v1, v2_min, v2_max);
|
||||||
v2Edit = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), 0, MAX_LS_DELAY, GET_SET_DEFAULT(cs->v2));
|
v2Edit = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), 0, MAX_LS_DELAY, GET_SET_DEFAULT(cs->v2));
|
||||||
v2Edit->setDisplayHandler([=](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
v2Edit->setDisplayHandler([=](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||||
drawSourceCustomValue(dc, 2, 2, cs->v1, (cs->v1 <= MIXSRC_LAST_CH ? calc100toRESX(value) : value), flags);
|
drawSourceCustomValue(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, cs->v1, (cs->v1 <= MIXSRC_LAST_CH ? calc100toRESX(value) : value), flags);
|
||||||
});
|
});
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
}
|
}
|
||||||
@@ -182,49 +189,48 @@ class LogicalSwitchEditWindow: public Page {
|
|||||||
edit->setZeroText("---");
|
edit->setZeroText("---");
|
||||||
}
|
}
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
|
|
||||||
|
FormField::link(FormField::getCurrentField(), functionChoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildHeader(Window * window) {
|
void buildBody(FormWindow * window)
|
||||||
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENULOGICALSWITCHES, MENU_TITLE_COLOR);
|
{
|
||||||
headerSwitchName = new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, getSwitchPositionName(SWSRC_SW1+ls), MENU_TITLE_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildBody(Window * window) {
|
|
||||||
LogicalSwitchData * cs = lswAddress(ls);
|
|
||||||
|
|
||||||
FormGridLayout grid;
|
FormGridLayout grid;
|
||||||
grid.spacer(10);
|
grid.spacer(PAGE_PADDING);
|
||||||
|
|
||||||
|
LogicalSwitchData * cs = lswAddress(index);
|
||||||
|
|
||||||
// LS Func
|
// LS Func
|
||||||
new StaticText(window, grid.getLabelSlot(), STR_FUNC);
|
new StaticText(window, grid.getLabelSlot(), STR_FUNC);
|
||||||
Choice * funcChoice = new Choice(window, grid.getFieldSlot(), STR_VCSWFUNC, 0, LS_FUNC_MAX,
|
auto functionChoice = new Choice(window, grid.getFieldSlot(), STR_VCSWFUNC, 0, LS_FUNC_MAX, GET_DEFAULT(cs->func));
|
||||||
GET_DEFAULT(cs->func),
|
functionChoice->setSetValueHandler([=](int32_t newValue) {
|
||||||
[=](int32_t newValue) {
|
cs->func = newValue;
|
||||||
cs->func = newValue;
|
if (lswFamily(cs->func) == LS_FAMILY_TIMER) {
|
||||||
if (lswFamily(cs->func) == LS_FAMILY_TIMER) {
|
cs->v1 = cs->v2 = 0;
|
||||||
cs->v1 = cs->v2 = 0;
|
}
|
||||||
}
|
else if (lswFamily(cs->func) == LS_FAMILY_EDGE) {
|
||||||
else if (lswFamily(cs->func) == LS_FAMILY_EDGE) {
|
cs->v1 = 0;
|
||||||
cs->v1 = 0; cs->v2 = -129; cs->v3 = 0;
|
cs->v2 = -129;
|
||||||
}
|
cs->v3 = 0;
|
||||||
else {
|
}
|
||||||
cs->v1 = cs->v2 = 0;
|
else {
|
||||||
}
|
cs->v1 = cs->v2 = 0;
|
||||||
SET_DIRTY();
|
}
|
||||||
updateLogicalSwitchOneWindow();
|
SET_DIRTY();
|
||||||
});
|
updateLogicalSwitchOneWindow(functionChoice);
|
||||||
funcChoice->setAvailableHandler(isLogicalSwitchFunctionAvailable);
|
});
|
||||||
|
functionChoice->setAvailableHandler(isLogicalSwitchFunctionAvailable);
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
|
|
||||||
logicalSwitchOneWindow = new Window(window, { 0, grid.getWindowHeight(), LCD_W, 0 });
|
logicalSwitchOneWindow = new Window(window, { 0, grid.getWindowHeight(), LCD_W, 0 });
|
||||||
updateLogicalSwitchOneWindow();
|
updateLogicalSwitchOneWindow(functionChoice);
|
||||||
grid.addWindow(logicalSwitchOneWindow);
|
grid.addWindow(logicalSwitchOneWindow);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr coord_t line1 = 2;
|
static constexpr coord_t line1 = FIELD_PADDING_TOP;
|
||||||
static constexpr coord_t line2 = 22;
|
static constexpr coord_t line2 = line1 + PAGE_LINE_HEIGHT;
|
||||||
static constexpr coord_t line3 = 42;
|
static constexpr coord_t line3 = line2 + PAGE_LINE_HEIGHT;
|
||||||
static constexpr coord_t col1 = 20;
|
static constexpr coord_t col1 = 20;
|
||||||
static constexpr coord_t col2 = (LCD_W - 100) / 3 + col1;
|
static constexpr coord_t col2 = (LCD_W - 100) / 3 + col1;
|
||||||
static constexpr coord_t col3 = ((LCD_W - 100) / 3) * 2 + col1;
|
static constexpr coord_t col3 = ((LCD_W - 100) / 3) * 2 + col1;
|
||||||
@@ -258,17 +264,11 @@ class LogicalSwitchButton : public Button {
|
|||||||
Button::checkEvents();
|
Button::checkEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override
|
void paintLogicalSwitchLine(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
LogicalSwitchData * ls = lswAddress(lsIndex);
|
LogicalSwitchData * ls = lswAddress(lsIndex);
|
||||||
uint8_t lsFamily = lswFamily(ls->func);
|
uint8_t lsFamily = lswFamily(ls->func);
|
||||||
|
|
||||||
if (active)
|
|
||||||
dc->drawSolidFilledRect(2, 2, rect.w-4, rect.h-4, WARNING_COLOR);
|
|
||||||
|
|
||||||
// The bounding rect
|
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
|
|
||||||
|
|
||||||
// CSW func
|
// CSW func
|
||||||
dc->drawTextAtIndex(col1, line1, STR_VCSWFUNC, ls->func);
|
dc->drawTextAtIndex(col1, line1, STR_VCSWFUNC, ls->func);
|
||||||
|
|
||||||
@@ -308,6 +308,17 @@ class LogicalSwitchButton : public Button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void paint(BitmapBuffer * dc) override
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
dc->drawSolidFilledRect(2, 2, rect.w-4, rect.h-4, WARNING_COLOR);
|
||||||
|
|
||||||
|
paintLogicalSwitchLine(dc);
|
||||||
|
|
||||||
|
// The bounding rect
|
||||||
|
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t lsIndex;
|
uint8_t lsIndex;
|
||||||
bool active;
|
bool active;
|
||||||
@@ -328,7 +339,7 @@ void ModelLogicalSwitchesPage::rebuild(FormWindow * window, int8_t focusIndex)
|
|||||||
|
|
||||||
void ModelLogicalSwitchesPage::editLogicalSwitch(FormWindow * window, uint8_t lsIndex)
|
void ModelLogicalSwitchesPage::editLogicalSwitch(FormWindow * window, uint8_t lsIndex)
|
||||||
{
|
{
|
||||||
Window * lsWindow = new LogicalSwitchEditWindow(lsIndex);
|
Window * lsWindow = new LogicalSwitchEditPage(lsIndex);
|
||||||
lsWindow->setCloseHandler([=]() {
|
lsWindow->setCloseHandler([=]() {
|
||||||
rebuild(window, lsIndex);
|
rebuild(window, lsIndex);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ class SpecialFunctionEditPage : public Page {
|
|||||||
|
|
||||||
void updateSpecialFunctionOneWindow(FormField * previousField, FormField * nextField)
|
void updateSpecialFunctionOneWindow(FormField * previousField, FormField * nextField)
|
||||||
{
|
{
|
||||||
// SF.one variable part
|
|
||||||
FormGridLayout grid;
|
FormGridLayout grid;
|
||||||
specialFunctionOneWindow->clear();
|
specialFunctionOneWindow->clear();
|
||||||
|
|
||||||
@@ -207,7 +206,7 @@ class SpecialFunctionEditPage : public Page {
|
|||||||
{
|
{
|
||||||
// SF.one
|
// SF.one
|
||||||
FormGridLayout grid;
|
FormGridLayout grid;
|
||||||
grid.spacer(8);
|
grid.spacer(PAGE_PADDING);
|
||||||
|
|
||||||
CustomFunctionData * cfn = &functions[index];
|
CustomFunctionData * cfn = &functions[index];
|
||||||
|
|
||||||
@@ -219,7 +218,7 @@ class SpecialFunctionEditPage : public Page {
|
|||||||
: isSwitchAvailable(value,
|
: isSwitchAvailable(value,
|
||||||
GeneralCustomFunctionsContext));
|
GeneralCustomFunctionsContext));
|
||||||
});
|
});
|
||||||
window->setFirstField(switchChoice);
|
// window->setFirstField(switchChoice);
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
@@ -242,8 +241,8 @@ class SpecialFunctionEditPage : public Page {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr coord_t line1 = 0;
|
static constexpr coord_t line1 = FIELD_PADDING_TOP;
|
||||||
static constexpr coord_t line2 = 20;
|
static constexpr coord_t line2 = line1 + PAGE_LINE_HEIGHT;
|
||||||
static constexpr coord_t col1 = 20;
|
static constexpr coord_t col1 = 20;
|
||||||
static constexpr coord_t col2 = (LCD_W - 100) / 3 + col1;
|
static constexpr coord_t col2 = (LCD_W - 100) / 3 + col1;
|
||||||
static constexpr coord_t col3 = ((LCD_W - 100) / 3) * 2 + col1 + 20;
|
static constexpr coord_t col3 = ((LCD_W - 100) / 3) * 2 + col1 + 20;
|
||||||
@@ -286,7 +285,6 @@ class SpecialFunctionButton : public Button {
|
|||||||
|
|
||||||
void paintSpecialFunctionLine(BitmapBuffer * dc)
|
void paintSpecialFunctionLine(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
// SF.all
|
|
||||||
const CustomFunctionData * cfn = &functions[index];
|
const CustomFunctionData * cfn = &functions[index];
|
||||||
if (functions[index].func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) {
|
if (functions[index].func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) {
|
||||||
functions[index].func = FUNC_OVERRIDE_CHANNEL + 1;
|
functions[index].func = FUNC_OVERRIDE_CHANNEL + 1;
|
||||||
@@ -360,7 +358,7 @@ class SpecialFunctionButton : public Button {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (HAS_ENABLE_PARAM(func)) {
|
if (HAS_ENABLE_PARAM(func)) {
|
||||||
theme->drawCheckBox(dc, col3, line2, CFN_ACTIVE(cfn));
|
theme->drawCheckBox(dc, CFN_ACTIVE(cfn), col3, line2);
|
||||||
}
|
}
|
||||||
else if (HAS_REPEAT_PARAM(func)) {
|
else if (HAS_REPEAT_PARAM(func)) {
|
||||||
if (CFN_PLAY_REPEAT(cfn) == 0) {
|
if (CFN_PLAY_REPEAT(cfn) == 0) {
|
||||||
@@ -379,7 +377,10 @@ class SpecialFunctionButton : public Button {
|
|||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, WARNING_COLOR);
|
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, WARNING_COLOR);
|
||||||
|
|
||||||
paintSpecialFunctionLine(dc);
|
paintSpecialFunctionLine(dc);
|
||||||
|
|
||||||
|
// The bounding rect
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
|
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user