UI refinement pass

Remove gesture-help bottom-bars from many places in the UI, adjust
layouts to be able to handle larger fonts, and other small UI fixes.
This commit is contained in:
James Babcock committed 2026-08-22 18:48:20 -07:00
1 parent dc18737dfc
commit 35e6977c6c
17 files changed
+394 -321

No files matched your search

+2 -2
View File
@@ -738,10 +738,10 @@ export function textSettingMenuItem<TId extends string = string>(
void ctx.actions.startTextSettingEdit(setting);
ctx.stack.push(new EditTextSettingLayer(setting));
},
render: ({ image, x, y }) => {
render: ({ image, x, y, width }) => {
// displayValue honors the setting's formatValue, so secrets (API keys,
// tokens) can mask themselves instead of rendering in the clear.
image.drawText(getDefaultSmallFont(), x, y + LIST_ROW_TEXT_INSET, `${setting.label}: ${truncateSetting(setting.displayValue())}`, 200);
drawRightValueMenuItem(image, getDefaultSmallFont(), x, y, width, setting.label, truncateSetting(setting.displayValue()));
}
};
}
+71 -27
View File
@@ -1,9 +1,8 @@
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { GrayImage } from "../../graphics/image";
import { GrayImage, type UiFont } from "../../graphics/image";
import { wrapText } from "../../graphics/textwrap";
import { clamp } from "../../util/numeric-util";
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL } from "../gestures";
import { DashboardInputEvent, Layer, LayerContext } from "../layers";
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "../layers";
import { drawSelectionHighlight, isMenuItemDisabled, MenuItem, MenuLayer, openModalMenu } from "../menu";
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "../metrics";
import { shell } from "../shell/shell";
@@ -76,8 +75,7 @@ export class SettingsPanelLayer implements Layer {
const rowH = listRowHeight(font);
const top = PAD;
const hintY = height - font.lineHeight + 2;
const listBottom = hintY - 8; // leave a band for the gesture hint
const listBottom = height - PAD;
// Left column: section labels.
const leftRows = Math.max(1, ((listBottom - top) / rowH) | 0);
@@ -104,17 +102,16 @@ export class SettingsPanelLayer implements Layer {
rightTop = typeof used === "number" ? Math.min(top + used, listBottom) : listBottom;
}
if (rightItems.length && rightTop < listBottom) {
// Once focus is in the right column, the bottom of the pane shows the
// selected item's extended description (when it has one), with the row
// list shrunk to make room.
const selectedItem = this.focus === "right" ? rightItems[this.rightIndex] : undefined;
const descriptionLines = selectedItem?.description
? wrapText(font, selectedItem.description, rightW - 4).slice(0, MAX_DESCRIPTION_LINES)
: [];
const descriptionH = descriptionLines.length ? descriptionLines.length * lineStep(font) + 10 : 0;
const rightListBottom = listBottom - descriptionH;
const rightRows = Math.max(1, ((rightListBottom - rightTop) / rowH) | 0);
this.rightScroll = clampScroll(this.rightIndex, this.rightScroll, rightRows, rightItems.length);
// Once focus is in the right column, the selected item's extended
// description (when it has one) is drawn over the bottom of the pane by
// the companion SettingsDescriptionOverlayLayer. The row list keeps the
// full column height — rows the description band covers are drawn and
// partially occluded by the overlay's plane — but the scroll clamp uses
// the shrunk height so the selected row always stays clear of it.
const descriptionH = this.descriptionHeight(font, rightW);
const clampRows = Math.max(1, ((listBottom - descriptionH - rightTop) / rowH) | 0);
const rightRows = Math.max(1, ((listBottom - rightTop) / rowH) | 0);
this.rightScroll = clampScroll(this.rightIndex, this.rightScroll, clampRows, rightItems.length);
for (let i = this.rightScroll; i < Math.min(rightItems.length, this.rightScroll + rightRows); i++) {
const item = rightItems[i]!;
const rowY = rightTop + (i - this.rightScroll) * rowH;
@@ -141,22 +138,49 @@ export class SettingsPanelLayer implements Layer {
image.drawText(font, rightX + 8, rowY + LIST_ROW_TEXT_INSET, item.label, disabled ? 70 : selected ? 255 : 200);
}
}
if (descriptionLines.length) {
image.drawLine(rightX, rightListBottom, rightX + rightW, rightListBottom, 40);
for (let i = 0; i < descriptionLines.length; i++) {
image.drawText(font, rightX + 4, rightListBottom + 6 + i * lineStep(font), descriptionLines[i]!, 150);
}
}
}
const hint =
this.focus === "left"
? `${GESTURE_SCROLL} section ${GESTURE_CLICK} open ${GESTURE_DOUBLE_CLICK} exit`
: `${GESTURE_SCROLL} item ${GESTURE_CLICK} select ${GESTURE_DOUBLE_CLICK} back`;
image.drawText(font, PAD, hintY, hint, 110);
return image;
}
/** The selected item's wrapped help text, or [] when none applies. */
private descriptionLines(font: UiFont, rightW: number): string[] {
if (this.focus !== "right") return [];
const items = this.section().items;
const item = items[clamp(this.rightIndex, 0, Math.max(0, items.length - 1))];
if (!item?.description) return [];
return wrapText(font, item.description, rightW - 4).slice(0, MAX_DESCRIPTION_LINES);
}
private descriptionHeight(font: UiFont, rightW: number): number {
const lines = this.descriptionLines(font, rightW);
return lines.length ? lines.length * lineStep(font) + 10 : 0;
}
/**
* Draw the selected item's help text band (separator + text on an opaque
* background) at the bottom of the right column. Called by the companion
* overlay layer with the overlay's own canvas: as a separate plane its
* raster covers the row list's glyphs, so it can partially occlude a row —
* which raster drawn into the panel's own image cannot do.
*/
paintDescriptionOverlay(image: GrayImage, ctx: LayerContext): void {
const font = getDefaultSmallFont();
const { width, height } = ctx.stack.getBaseSize();
const listBottom = height - PAD;
const rightX = PAD + LEFT_W + 6 + 14;
const rightW = width - rightX - PAD;
const lines = this.descriptionLines(font, rightW);
if (!lines.length) return;
const top = listBottom - (lines.length * lineStep(font) + 10);
// 1 is opaque black in the plane model (0 is transparent).
image.fillRect(rightX - 2, top, rightW + 4, listBottom - top, 1);
image.drawLine(rightX, top, rightX + rightW, top, 40);
for (let i = 0; i < lines.length; i++) {
image.drawText(font, rightX + 4, top + 6 + i * lineStep(font), lines[i]!, 150);
}
}
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
if (this.focus === "left") {
switch (event.type) {
@@ -211,6 +235,26 @@ export class SettingsPanelLayer implements Layer {
}
}
/**
* Companion layer for SettingsPanelLayer, sitting permanently above it in the
* settings app's stack: paints the selected item's help text as its own plane
* (see paintDescriptionOverlay) and forwards all input to the panel. Pushed
* layers (modal menus, the text editor) stack above it as before.
*/
export class SettingsDescriptionOverlayLayer implements Layer {
constructor(private readonly panel: SettingsPanelLayer) {}
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
const image = paintBelow();
this.panel.paintDescriptionOverlay(image, ctx);
return image;
}
handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
return this.panel.handleInput(event, ctx);
}
}
/**
* Open a third-level menu as a centered, bordered modal over the panel. Reuses
* MenuLayer (which draws the border and self-closes on double-click).
+17 -2
View File
@@ -19,9 +19,14 @@ export function listRowHeight(font: UiFont): number {
/** Vertical inset of a listRowHeight row's text within the row. */
export const LIST_ROW_TEXT_INSET = 4;
/** Height of one row in dense lists (file browser, track lists). */
/**
* Height of one row in dense lists (file browser, track lists). Grows at
* half the lineHeight's rate above the 12px anchor: TTF line heights carry
* internal leading that already reads as row spacing, so full-rate growth
* made large-font rows feel too tall.
*/
export function tightRowHeight(font: UiFont): number {
return font.lineHeight + 4;
return font.lineHeight + 4 - Math.floor(Math.max(0, font.lineHeight - 12) / 2);
}
/** Step between consecutive lines of body/paragraph text. */
@@ -33,3 +38,13 @@ export function lineStep(font: UiFont): number {
export function menuTitleHeight(font: UiFont): number {
return font.lineHeight + 4;
}
/**
* Minimum height of an icon-grid cell (icon, label line, breathing room).
* Grid views divide their available height into as many rows of at least
* this height as fit, so cells grow with the font instead of the label
* overflowing a fixed-height row.
*/
export function iconGridMinRowHeight(font: UiFont, iconSize: number, labelGap: number): number {
return iconSize + labelGap + font.lineHeight + 8;
}
+11 -5
View File
@@ -5,7 +5,6 @@ import { truncateText } from "../graphics/textwrap";
import { GrayImage, type UiFont } from "../graphics/image";
import { wrapText } from "../graphics/textwrap";
import { lineStep, listRowHeight } from "./metrics";
import { GESTURE_DOUBLE_CLICK } from "./gestures";
import {
dismissNotification,
invokeNotificationAction,
@@ -20,6 +19,9 @@ import { type DashboardInputEvent, type Layer, type LayerContext, type PaintBelo
const PAGE_X = 12;
const PAGE_Y = 12;
// Title position, shared with the other list apps (terminal, calendar).
const TITLE_X = 18;
const TITLE_Y = 10;
const LIST_TOP = 38;
const CARD_X = 20;
const ICON_SIZE = 24;
@@ -79,10 +81,8 @@ export class NotificationsListLayer implements Layer {
buildNotificationCardLayout(font, notification, index === selectedIndex, cardTextWidth),
);
image.drawText(font, PAGE_X + 12, PAGE_Y + 9, "Notifications", 220);
image.drawText(font, width - 96, PAGE_Y + 9, `${selectedIndex + 1}/${notifications.length}`, 150);
if (!notifications.length) {
image.drawText(font, TITLE_X, TITLE_Y, "Notifications", 220);
const message = isNotificationListenerEnabled()
? "No current Android notifications."
: "Grant permission on your phone to view notifications on the glasses.";
@@ -90,13 +90,19 @@ export class NotificationsListLayer implements Layer {
for (let index = 0; index < messageLines.length; index++) {
image.drawText(font, 24, 72 + index * lineStep(font), messageLines[index]!, 190);
}
image.drawText(font, 24, height - 36, `${GESTURE_DOUBLE_CLICK} back`, 110);
return image;
}
const focused = ctx.stack.isFocused();
const listBottom = height;
const scrollY = scrollForSelected(layouts, selectedIndex, listBottom - LIST_TOP);
// The title scrolls away with the list. Card text is drawn as deferred
// glyphs (always composited above raster fills), so a fixed title would
// show through cards scrolled over it; moving it with the content keeps
// it above the first card instead.
if (TITLE_Y - scrollY + font.lineHeight > 0) {
image.drawText(font, TITLE_X, TITLE_Y - scrollY, "Notifications", 220);
}
let cursorY = LIST_TOP - scrollY;
for (let index = 0; index < layouts.length; index++) {
const layout = layouts[index]!;