mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +00:00
fix(ui-new): on/off as the words ON / OFF -- the pill switch read as a battery
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -194,26 +194,13 @@ inline int big(DisplayDriver& d, int x, int y, const char* value, const char* un
|
|||||||
}
|
}
|
||||||
inline int bigH(DisplayDriver& d) { return 2 * d.getLineHeight(); }
|
inline int bigH(DisplayDriver& d) { return 2 * d.getLineHeight(); }
|
||||||
|
|
||||||
// An on/off switch, right edge at x_right, centred on a text line at y: a
|
// An on/off state, right edge at x_right on a text line at y: the words ON /
|
||||||
// filled pill with the knob right when on, an outline with the knob left off.
|
// OFF. (A drawn pill switch read as a battery on the small screens.) `inv`
|
||||||
// `inv` draws it in a selected row's colours (dark on the light bar) and
|
// draws it in a selected row's colours (dark on the light bar).
|
||||||
// leaves the ink dark, as the row found it.
|
inline int switchW(DisplayDriver& d) { return d.getTextWidth("OFF"); }
|
||||||
inline int switchW(DisplayDriver& d) { return 13 * miniIconScale(d); }
|
|
||||||
inline void toggle(DisplayDriver& d, int x_right, int y, bool on, bool inv = false) {
|
inline void toggle(DisplayDriver& d, int x_right, int y, bool on, bool inv = false) {
|
||||||
const DisplayDriver::Color ink = inv ? DisplayDriver::DARK : DisplayDriver::LIGHT;
|
d.setColor(inv ? DisplayDriver::DARK : DisplayDriver::LIGHT);
|
||||||
const DisplayDriver::Color paper = inv ? DisplayDriver::LIGHT : DisplayDriver::DARK;
|
d.drawTextRightAlign(x_right, y, on ? "ON" : "OFF");
|
||||||
const int s = miniIconScale(d), w = switchW(d), h = 7 * s;
|
|
||||||
const int x = x_right - w, ty = y + (d.getLineHeight() - h) / 2;
|
|
||||||
d.setColor(ink);
|
|
||||||
if (on) {
|
|
||||||
d.fillSoftRect(x, ty, w, h);
|
|
||||||
d.setColor(paper);
|
|
||||||
d.fillRect(x + w - 5 * s, ty + s, 3 * s, h - 2 * s);
|
|
||||||
} else {
|
|
||||||
d.drawSoftRect(x, ty, w, h);
|
|
||||||
d.fillRect(x + 2 * s, ty + 2 * s, 3 * s, h - 4 * s);
|
|
||||||
}
|
|
||||||
d.setColor(ink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── List rows (call after drawRowSelection(); text is already in the row's ink)
|
// ── List rows (call after drawRowSelection(); text is already in the row's ink)
|
||||||
@@ -233,7 +220,7 @@ inline int valueRow(DisplayDriver& d, int y, const char* label, const char* valu
|
|||||||
return sel && r > 0 ? r : 0;
|
return sel && r > 0 ? r : 0;
|
||||||
}
|
}
|
||||||
// A row from a screen's value formatter: exactly "ON" / "OFF" is a yes/no
|
// A row from a screen's value formatter: exactly "ON" / "OFF" is a yes/no
|
||||||
// setting and gets the switch; anything else (an option that can be "Off"
|
// setting and gets switchRow(); anything else (an option that can be "Off"
|
||||||
// among numbers included) is a value. Returns valueRow()'s marquee delay.
|
// among numbers included) is a value. Returns valueRow()'s marquee delay.
|
||||||
inline void switchRow(DisplayDriver& d, int y, const char* label, bool on, bool sel, int reserve, int x0 = 2);
|
inline void switchRow(DisplayDriver& d, int y, const char* label, bool on, bool sel, int reserve, int x0 = 2);
|
||||||
inline int listRow(DisplayDriver& d, int y, const char* label, const char* value, bool sel,
|
inline int listRow(DisplayDriver& d, int y, const char* label, const char* value, bool sel,
|
||||||
@@ -244,7 +231,7 @@ inline int listRow(DisplayDriver& d, int y, const char* label, const char* value
|
|||||||
}
|
}
|
||||||
return valueRow(d, y, label, value, sel, reserve, x0);
|
return valueRow(d, y, label, value, sel, reserve, x0);
|
||||||
}
|
}
|
||||||
// An on/off row: the label, then a switch at the right edge.
|
// An on/off row: the label, then ON / OFF at the right edge.
|
||||||
inline void switchRow(DisplayDriver& d, int y, const char* label, bool on, bool sel, int reserve, int x0) {
|
inline void switchRow(DisplayDriver& d, int y, const char* label, bool on, bool sel, int reserve, int x0) {
|
||||||
d.setCursor(x0, y);
|
d.setCursor(x0, y);
|
||||||
d.print(label);
|
d.print(label);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ struct PopupMenu {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static int valueWidth(DisplayDriver& d, const char* v) {
|
static int valueWidth(DisplayDriver& d, const char* v) {
|
||||||
return (!strcmp(v, "ON") || !strcmp(v, "OFF")) ? info::switchW(d) : d.getTextWidth(v);
|
return d.getTextWidth(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int render(DisplayDriver& display) {
|
int render(DisplayDriver& display) {
|
||||||
|
|||||||
Reference in New Issue
Block a user