fix(ui): revert corner-anchored context menus, centre unread badge, add room logout

- Context menus (PopupMenu, Nearby/QuickMsg call sites) go back to centring on
  screen; the header's discoverable-menu glyph stays, but dropping the popup
  out of its corner looked bad on some screens.
- Unread pill badge digit wasn't centred: Adafruit_GFX's classic built-in font
  (SH1106/SSD1306) always pads a measured string by one trailing advance
  column regardless of the glyph drawn, so centring on the raw width left 1px
  more slack on the right than the left. New DisplayDriver::
  textWidthTrailingGap() (0 by default) corrects for it on those two backends.
- On-device room Logout: mirrors the app's CMD_LOGOUT (drops keep-alive
  tracking, forgets the saved password) so a room can be deliberately signed
  out of from the Room options menu, not just re-logged-in.

Not build-verified — no PlatformIO toolchain available this session.
This commit is contained in:
Jakub
2026-07-10 16:01:14 +02:00
parent a1ee67ae94
commit cf3c2c0353
7 changed files with 90 additions and 31 deletions
+3 -14
View File
@@ -17,16 +17,14 @@ struct PopupMenu {
int _cap; // actual visible cap, updated each render()
bool active;
const char* _title;
bool anchor_tr = false; // opt-in: drop from the top-right ≡ hint instead of centring
enum Result { NONE, SELECTED, CANCELLED };
PopupMenu() : _count(0), _sel(0), _scroll(0), _visible(3), _cap(3), active(false), _title(nullptr) {}
void begin(const char* title, int visible = 3, bool anchor_top_right = false) {
void begin(const char* title, int visible = 3) {
_count = 0; _sel = 0; _scroll = 0;
_visible = visible; _cap = visible; active = true; _title = title;
anchor_tr = anchor_top_right;
}
void addItem(const char* item) {
@@ -88,17 +86,8 @@ struct PopupMenu {
int bh = title_h + vis * item_h + 1; // +1 keeps the last row off the bottom border
// Centre on screen (clamped to the margins on small displays).
int bx, by;
if (anchor_tr) {
// Drop out of the top-right ≡ hint: right-aligned under the header, so the
// menu reads as emerging from the glyph that spawned it.
bx = display.width() - bw - margin;
by = display.headerH();
if (by + bh > display.height() - margin) by = display.height() - margin - bh;
} else {
bx = (display.width() - bw) / 2;
by = (display.height() - bh) / 2;
}
int bx = (display.width() - bw) / 2;
int by = (display.height() - bh) / 2;
if (bx < margin) bx = margin;
if (by < margin) by = margin;