feat: notification adaptée au réveil écran et libellés sélectionnés défilants #14

Open
MasterControl wants to merge 2 commits from MasterControl/faceclaw:feat/notification-focus-marquee into main
pull from: MasterControl/faceclaw:feat/notification-focus-marquee
17 changed files with 640 additions and 34 deletions

No files matched your search

+6 -4
View File
@@ -4,7 +4,7 @@ import { wrapText } from "../../graphics/textwrap";
import { InputEvent } from "../gestures";
import { Layer, LayerContext, PaintBelow } from "../layers";
import { isMenuItemDisabled, MenuItem, MenuLayer, openModalMenu } from "../menu";
import { Menu } from "../menu-core";
import { Menu, drawMenuLabel } from "../menu-core";
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "../metrics";
import { shell } from "../shell/shell";
@@ -66,8 +66,9 @@ export class SettingsPanelLayer implements Layer {
rowGap: ROW_GAP,
highlight: { radius: 6 },
getHeight: () => listRowHeight(getDefaultSmallFont()),
draw: ({ image, item, x, y, selected }) => {
image.drawText(getDefaultSmallFont(), x + ROW_TEXT_X, y + LIST_ROW_TEXT_INSET, item.label, selected ? 255 : 200);
draw: ({ image, item, x, y, width, selected }) => {
drawMenuLabel(image, getDefaultSmallFont(), x + ROW_TEXT_X, y + LIST_ROW_TEXT_INSET,
width - ROW_TEXT_X - 8, item.label, selected ? 255 : 200);
},
});
this.rightMenu = new Menu<MenuItem>({
@@ -92,7 +93,8 @@ export class SettingsPanelLayer implements Layer {
ctx: this.paintCtx!,
});
} else {
image.drawText(getDefaultSmallFont(), x + ROW_TEXT_X, y + LIST_ROW_TEXT_INSET, item.label,
drawMenuLabel(image, getDefaultSmallFont(), x + ROW_TEXT_X, y + LIST_ROW_TEXT_INSET,
width - ROW_TEXT_X - 8, item.label,
disabled ? 70 : selected ? 255 : 200);
}
},
+46 -4
View File
@@ -2,6 +2,8 @@ import { DrawExpression as E } from "../graphics/draw-expression";
import { GrayImage } from "../graphics/image";
import { menuScrollList, slidingHighlightY, type MenuScrollHighlight } from "../graphics/menu-scroll-list";
import type { InputEvent } from "./gestures";
import { MenuLabelMotion, type MenuLabelPainter } from "./menu-label";
export { drawMenuLabel } from "./menu-label";
import { MenuHighlightMotion } from "./menu-highlight-motion";
import { MenuScrollMotion, scrollOffsetExpression, type MenuScrollAnimation } from "./menu-scroll-motion";
@@ -39,6 +41,8 @@ export type MenuDrawArgs<T> = {
selected: boolean;
/** Whether the menu owns input right now: the `focused` flag the host passed to paint. */
focused: boolean;
/** Clipped label; overflowing selected/focused labels get a retained reading pass. */
drawLabel: MenuLabelPainter;
};
export type MenuHighlightStyle = {
@@ -110,6 +114,7 @@ export class Menu<T> {
private lastBox: MenuBox | null = null;
private readonly motion = new MenuHighlightMotion();
private readonly scrollMotion = new MenuScrollMotion();
private readonly labelMotion = new MenuLabelMotion();
constructor(private readonly options: MenuOptions<T>) {
this.itemList = options.items ?? [];
@@ -160,7 +165,9 @@ export class Menu<T> {
: null;
this.itemList = items;
if (selectedIndex !== undefined) this.deselected = selectedIndex === null;
const previousSelection = this.selected;
this.selected = this.settle(selectedIndex === undefined ? this.selected : selectedIndex);
if (this.selected !== previousSelection) this.labelMotion.reset();
if (before !== null && this.selected !== null && width !== undefined) {
this.scrollY = Math.max(0, this.layout(width).tops[this.selected]! - before);
}
@@ -173,7 +180,9 @@ export class Menu<T> {
*/
select(index: number | null): void {
this.deselected = index === null;
this.selected = this.settle(index);
const next = this.settle(index);
if (next !== this.selected) this.labelMotion.reset();
this.selected = next;
}
/** Step the selection by one selectable row; handles wrap and the exit callbacks. */
@@ -184,6 +193,7 @@ export class Menu<T> {
if (next !== null) {
if (from !== null) this.motion.navigate(from, false);
this.scrollMotion.navigate(false);
this.labelMotion.reset();
this.selected = next;
this.deselected = false;
return;
@@ -194,6 +204,7 @@ export class Menu<T> {
if (wrapped !== null && wrapped !== from) {
if (from !== null) this.motion.navigate(from, true);
this.scrollMotion.navigate(true);
this.labelMotion.reset();
this.selected = wrapped;
this.deselected = false;
} else if (from === null && this.lastBox) {
@@ -247,6 +258,7 @@ export class Menu<T> {
paint(image: GrayImage, box: MenuBox, focused: boolean): void {
this.lastBox = box;
this.reconcile();
if (!focused || this.selected === null) this.labelMotion.reset();
const layout = this.layout(box.width);
this.ensureVisible(layout, box.height);
const now = Date.now();
@@ -277,9 +289,10 @@ export class Menu<T> {
}
// A selected row taller than the box is drawn whole, from its top.
const row = new GrayImage(box.width, height, 0);
this.options.draw({ image: row, item, index, x: 0, y: 0, width: box.width, height, selected, focused });
this.draw({ image: row, item, index, x: 0, y: 0, width: box.width, height, selected, focused });
image.drawMenuSelection(row, box.x, rowY, background, MENU_HIGHLIGHT_STROKE,
highlight?.radius ?? 8, highlight?.depth ?? 0, animation);
this.copyRowPresentations(row, image, box.x, rowY, box.y, box.y + box.height, highlight?.depth ?? 0);
} else {
this.drawRow(image, index, box.x, rowY, box.width, height, focused, box.y, box.y + box.height);
}
@@ -293,6 +306,31 @@ export class Menu<T> {
}
}
/** Retain row-local animations, intersecting their clips with the row and viewport. */
private copyRowPresentations(row: GrayImage, target: GrayImage, x: number, y: number,
clipTop: number, clipBottom: number, depth: number): void {
for (const draw of row.draws) {
if (draw.kind !== "image" || !draw.presentation?.displayList) continue;
const left = Math.max(0, -draw.x), right = Math.min(draw.source.width, row.width - draw.x);
const top = Math.max(0, -draw.y, clipTop - y - draw.y);
const bottom = Math.min(draw.source.height, row.height - draw.y, clipBottom - y - draw.y);
if (right <= left || bottom <= top) continue;
const list = draw.presentation.displayList;
target.drawDisplayList({ ...list, calls: list.calls.map(call => {
const c = call.clip ?? { x: 0, y: 0, width: draw.source.width, height: draw.source.height };
const cx = Math.max(left, c.x), cy = Math.max(top, c.y);
return { ...call, clip: { x: cx, y: cy,
width: Math.max(0, Math.min(right, c.x + c.width) - cx),
height: Math.max(0, Math.min(bottom, c.y + c.height) - cy) } };
}) }, x + draw.x, y + draw.y, draw.source.width, draw.source.height, depth);
}
}
private draw(args: Omit<MenuDrawArgs<T>, "drawLabel">): void {
this.labelMotion.row(args.image, args.index, args.selected && args.focused,
drawLabel => this.options.draw({ ...args, drawLabel }));
}
/** Draw a vertical scrollbar for the last painted box (no-op unless the content overflows it). */
drawScrollbar(image: GrayImage, x: number, y: number, height: number): void {
const box = this.lastBox;
@@ -317,11 +355,12 @@ export class Menu<T> {
const selected = index === this.selected;
const scratch = selected && this.options.highlight !== false;
if (!scratch && y >= clipTop && y + height <= clipBottom) {
this.options.draw({ image: target, item, index, x, y, width, height, selected, focused });
this.draw({ image: target, item, index, x, y, width, height, selected, focused });
return;
}
const row = new GrayImage(width, height, 0);
this.options.draw({ image: row, item, index, x: 0, y: 0, width, height, selected, focused });
this.draw({ image: row, item, index, x: 0, y: 0, width, height, selected, focused });
this.copyRowPresentations(row, target, x, y, clipTop, clipBottom, 0);
const skip = Math.max(0, clipTop - y);
target.bitBlt(row.withDrawsBaked(), x, y + skip,
{ sy: skip, height: Math.min(height, clipBottom - y) - skip, transparentZero: true });
@@ -352,6 +391,9 @@ export class Menu<T> {
if (rowTop + height <= top || rowTop >= bottom) continue;
this.drawRow(strip, index, 0, rowTop - top, box.width, height, focused, 0, strip.height);
}
// A reading pass has its own clipped timeline. Snap vertical motion rather
// than baking that pass into a strip or leaving it at the wrong row position.
if (strip.draws.some(d => d.kind === "image" && d.presentation)) return null;
// Crop to the columns with ink; the static paint shows the rest unchanged.
const baked = strip.withDrawsBaked();
let left = baked.width, right = -1;
+71
View File
@@ -0,0 +1,71 @@
import { DrawExpression as E } from "../graphics/draw-expression";
import { DrawOp, type ListCall } from "../graphics/display-list";
import { GrayImage, type UiFont } from "../graphics/image";
import { menuAnimationDurationMs } from "./menu-animation-pref";
export type MenuLabelPainter = (font: UiFont, x: number, y: number, width: number, text: string, value: number) => void;
const contexts = new WeakMap<GrayImage, { motion: MenuLabelMotion; index: number; active: boolean }>();
let nextToken = 0x40000000;
/** Shared row builders inherit their menu's focus and timeline without changing their public signature. */
export function drawMenuLabel(image: GrayImage, font: UiFont, x: number, y: number, width: number, text: string, value: number): void {
const context = contexts.get(image);
if (context) context.motion.draw(image, font, x, y, width, text, value, context.index, context.active);
else drawStatic(image, font, x, y, width, text, value);
}
function drawStatic(image: GrayImage, font: UiFont, x: number, y: number, width: number, text: string, value: number): void {
if (width <= 0) return;
if (font.measureText(text) <= width) image.drawText(font, x, y, text, value);
else {
const clip = new GrayImage(width, font.lineHeight);
clip.drawText(font, 0, 0, text, value);
image.bitBlt(clip.withDrawsBaked(), x, y, { transparentZero: true });
}
}
/** One bounded, firmware-driven reading pass per selection/content/geometry/focus change. No JS timers. */
export class MenuLabelMotion {
private key = "";
private timeline = { token: 0, startedAt: 0 };
row(image: GrayImage, index: number, active: boolean, draw: (drawLabel: MenuLabelPainter) => void): void {
contexts.set(image, { motion: this, index, active });
try { draw((font, x, y, width, text, value) => drawMenuLabel(image, font, x, y, width, text, value)); }
finally { contexts.delete(image); }
}
reset(): void { this.key = ""; }
draw(image: GrayImage, font: UiFont, x: number, y: number, width: number, text: string, value: number, index: number, active: boolean): void {
width = Math.max(0, Math.floor(width));
const measured = Math.ceil(font.measureText(text));
drawStatic(image, font, x, y, width, text, value);
if (!active) return;
const travel = menuAnimationDurationMs(Math.max(600, Math.ceil((measured - width) * 1000 / 30)));
if (!width || measured <= width || !travel || font.lineHeight > 480) { this.reset(); return; }
// Bounded tiles, never a label-wide BLE image. Extreme labels use the static fallback.
const tileWidth = Math.min(640, Math.floor(65530 / font.lineHeight) * 2);
if (tileWidth <= 0 || Math.ceil(measured / tileWidth) > 32) return;
const key = JSON.stringify([index, text, width, font.lineHeight, measured, x, y, value, travel]);
if (this.key !== key) {
this.key = key;
this.timeline = { token: nextToken++, startedAt: Date.now() };
}
const distance = measured - width;
// Hold the beginning, traverse at reading speed, hold the end, then return and stop.
const offset = E.progress(travel, 900).mul(E.f32(distance))
.sub(E.progress(travel, 1800 + travel).mul(E.f32(distance))).toInt();
const resources: GrayImage[] = [];
const calls: ListCall[] = [];
for (let left = 0; left < measured; left += tileWidth) {
const tile = new GrayImage(Math.min(tileWidth, measured - left), font.lineHeight, 16);
tile.drawText(font, -left, 0, text, value);
resources.push(tile.withDrawsBaked());
calls.push({ op: DrawOp.RECT_COPY, resource: resources.length - 1, x: 0, y: 0,
width: tile.width, height: tile.height, dx: E.i32(left).sub(offset), dy: 0,
clip: { x: 0, y: 0, width, height: font.lineHeight } });
}
image.drawDisplayList({ resources, calls, timeline: this.timeline }, x, y, width, font.lineHeight);
}
}
+6 -5
View File
@@ -7,7 +7,7 @@ import { clamp } from "../util/numeric-util";
import { normalizeAnimationSpeed } from "./animation-speed";
import { Layer, LayerContext, PaintBelow } from "./layers";
import { MENU_ANIMATION_KEY, setMenuAnimationReader } from "./menu-animation-pref";
import { Menu, MENU_HIGHLIGHT_FILL, MENU_HIGHLIGHT_STROKE } from "./menu-core";
import { Menu, drawMenuLabel, MENU_HIGHLIGHT_FILL, MENU_HIGHLIGHT_STROKE } from "./menu-core";
import { GESTURE_DOUBLE_CLICK, InputEvent } from "./gestures";
import { LIST_ROW_TEXT_INSET, centeredTextY, lineStep, listRowHeight, menuTitleHeight } from "./metrics";
@@ -179,7 +179,7 @@ export function submenuItem(
render: ({ image, x, y, width, height, selected, disabled, text }) => {
const font = getDefaultSmallFont();
const value = disabled ? 70 : selected ? 255 : 200;
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, text, value);
drawMenuLabel(image, font, x, y + LIST_ROW_TEXT_INSET, width - font.measureText("▶") - 12, text, value);
drawSubmenuIndicator(image, font, x, y, width, height, value);
},
};
@@ -200,7 +200,7 @@ export function drawToggleMenuItem(
const switchX = x + width - switchWidth - 2;
// Center the switch on the row's line box (legacy y+1 at the 12px default).
const switchY = y + Math.max(1, Math.round((listRowHeight(font) - 2 - switchHeight) / 2));
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, label, 200);
drawMenuLabel(image, font, x, y + LIST_ROW_TEXT_INSET, switchX - x - 8, label, 200);
const offFill = selected ? 1 : 18;
image.fillRoundedRect(switchX, switchY, switchWidth, switchHeight, enabled ? 70 : offFill, 8);
image.drawRoundedRect(switchX, switchY, switchWidth, switchHeight, enabled ? 130 : 55, 8);
@@ -218,8 +218,8 @@ export function drawRightValueMenuItem(
label: string,
value: string,
): void {
image.drawText(font, x, y + LIST_ROW_TEXT_INSET, label, 200);
const valueX = x + width - font.measureText(value) - 2;
drawMenuLabel(image, font, x, y + LIST_ROW_TEXT_INSET, valueX - x - 8, label, 200);
image.drawText(font, valueX, y + LIST_ROW_TEXT_INSET, value, 220);
}
@@ -268,7 +268,8 @@ export class MenuLayer implements Layer {
ctx: this.paintCtx!,
});
} else {
image.drawText(font, x + MENU_ROW_TEXT_INSET, y + LIST_ROW_TEXT_INSET, item.label,
drawMenuLabel(image, font, x + MENU_ROW_TEXT_INSET, y + LIST_ROW_TEXT_INSET,
width - 2 * MENU_ROW_TEXT_INSET, item.label,
disabled ? 70 : selected ? 255 : 200);
}
},
+33 -7
View File
@@ -1,11 +1,12 @@
import { GrayImage } from "../../graphics/image";
import { DrawOp } from "../../graphics/display-list";
import { flattenPlanes } from "../../graphics/plane";
import { InputEvent } from "../gestures";
import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
// The modal covers most of the min-height app viewport, leaving a little of
// the foreground app visible around the edges. Both its size and position are
// The modal box covers most of the min-height app viewport. Retained vector
// clears optionally hide the app outside its opaque rect. Size and position are
// computed per paint: the display-mode setting changes the viewport size at
// runtime, and the vertical position setting moves the band.
const MODAL_MARGIN = 14;
@@ -33,9 +34,11 @@ export function modalRect(): { x: number; y: number; width: number; height: numb
/**
* A shell overlay hosting an inner layer stack in a bordered box over the
* app viewport (used for new-notification popups). The inner stack paints at
* the modal's interior size; its pixels blit onto an opaque black backdrop,
* so inner value-0 pixels read as black, not transparent.
* app viewport (used for new-notification popups). Normally the shell's lower
* layers stay visible. For a wake popup, only the box is opaque (keeping its
* image within 64 KiB), and a resource-free retained list clears the outside
* margins over separate app surfaces. The inner stack paints at the modal's interior
* size; inner value-0 pixels read as black, not transparent.
*/
export class ShellModalLayer implements Layer {
private readonly stack: LayerStack;
@@ -44,6 +47,8 @@ export class ShellModalLayer implements Layer {
baseLayer: Layer,
actions: LayerActions,
private readonly hooks: {
/** Arrival-time screen state: mask the background only for a wake popup. */
hideBackground?: boolean;
/** The modal left the shell stack, however it went. */
removed?: () => void;
/** Input reached the modal (before its inner stack handles it). */
@@ -57,8 +62,15 @@ export class ShellModalLayer implements Layer {
this.hooks.removed?.();
}
paint(_ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
const image = paintBelow();
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
// Wake popups omit lower chrome, but ordinary popups keep the usual overlay.
if (!this.hooks.hideBackground) paintBelow();
// Leave the outer margins transparent so the
// scene encoder crops to the resource-sized modal, not the whole display.
// Native dim=0 still preserves a 1/0 halftone; clipped CLEAR calls below
// instead produce literal black without changing shared dimming semantics.
const { width, height } = ctx.stack.getBaseSize();
const image = new GrayImage(width, height);
// Track a display-mode switch while the modal is up, so the inner stack
// paints at the same size the box below is drawn with.
const interior = modalInterior();
@@ -78,6 +90,20 @@ export class ShellModalLayer implements Layer {
image.drawRect(rect.x, rect.y, rect.width, rect.height, 110);
image.bitBlt(inner, innerX, innerY, { transparentZero: true });
top.image.copyPresentationsInto(image, innerX + top.x, innerY + top.y);
if (!this.hooks.hideBackground) return image;
// ShellScene replays retained calls after the opaque box. Clear only the
// complement of that box, keeping the inner menu's presentation order.
// These are vector clips, not tiled image resources; no full-screen image
// is uploaded. Clips move with the scene's stereo depth just like the box.
const margins = [
{ x: 0, y: 0, width, height: rect.y },
{ x: 0, y: rect.y + rect.height, width, height: height - rect.y - rect.height },
{ x: 0, y: rect.y, width: rect.x, height: rect.height },
{ x: rect.x + rect.width, y: rect.y, width: width - rect.x - rect.width, height: rect.height },
];
image.drawDisplayList({ resources: [], calls: margins
.filter(clip => clip.width > 0 && clip.height > 0)
.map(clip => ({ op: DrawOp.CLEAR, color: 0, clip })) }, 0, 0, width, height);
return image;
}
+13 -4
View File
@@ -9,7 +9,7 @@
*/
export interface NotificationModalHost<M> {
/** Create and stack a modal showing this notification. */
open(notificationKey: string): M;
open(notificationKey: string, hideBackground: boolean): M;
/** Whether a queued notification is still worth opening (not dismissed, popups still on). */
isAvailable(notificationKey: string): boolean;
/** Put the screen back to sleep. */
@@ -20,6 +20,8 @@ interface Entry {
readonly notificationKey: string;
/** Whether this notification woke the screen, so closing the last modal sleeps again. */
readonly wokeScreen: boolean;
/** Arrival-time state, independent of the inherited return-to-sleep flag. */
readonly hideBackground: boolean;
}
export class NotificationModalQueue<M> {
@@ -37,11 +39,14 @@ export class NotificationModalQueue<M> {
if (this.current) {
if (this.current.notificationKey !== notificationKey
&& !this.queued.some((entry) => entry.notificationKey === notificationKey)) {
this.queued.push({ notificationKey, wokeScreen });
this.queued.push({ notificationKey, wokeScreen, hideBackground: wokeScreen });
}
return;
}
this.current = { modal: this.host.open(notificationKey), notificationKey, wokeScreen };
this.current = {
modal: this.host.open(notificationKey, wokeScreen),
notificationKey, wokeScreen, hideBackground: wokeScreen,
};
}
/**
@@ -94,7 +99,11 @@ export class NotificationModalQueue<M> {
while (this.queued.length > 0) {
const next = this.queued.shift()!;
if (!this.host.isAvailable(next.notificationKey)) continue;
this.post(next.notificationKey, wokeScreen || next.wokeScreen);
this.current = {
...next,
wokeScreen: wokeScreen || next.wokeScreen,
modal: this.host.open(next.notificationKey, next.hideBackground),
};
return true;
}
return false;
+3 -2
View File
@@ -482,7 +482,7 @@ class Shell {
// App-posted notifications that are open or queued, by key.
private readonly appNotifications = new Map<string, AppNotification>();
private readonly notificationModals = new NotificationModalQueue<NotificationPopup>({
open: (notificationKey) => this.pushNotificationModal(notificationKey),
open: (notificationKey, hideBackground) => this.pushNotificationModal(notificationKey, hideBackground),
isAvailable: (notificationKey) => {
if (this.appNotifications.has(notificationKey)) return true;
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
@@ -926,7 +926,7 @@ class Shell {
this.openNotificationModal(notification.key, wokeScreen);
}
private pushNotificationModal(notificationKey: string): NotificationPopup {
private pushNotificationModal(notificationKey: string, hideBackground: boolean): NotificationPopup {
const appNotification = this.appNotifications.get(notificationKey);
const close = () => this.closeNotificationModal(popup, notificationKey);
const content = appNotification
@@ -951,6 +951,7 @@ class Shell {
appNotification ? appNotification.createLayer(close) : content!,
this.config.actions,
{
hideBackground,
removed: () => {
timeout.stop();
this.appNotifications.delete(notificationKey);
@@ -0,0 +1,70 @@
# Notification focus and selected-label readability
Feature branch: `feat/notification-focus-marquee`.
## Notification backdrop
Notification popups hide the whole glasses interface only when the notification
arrived with the screen off and woke it. If the screen was already on, the usual
overlay keeps the app and chrome visible behind the box. This arrival-time choice
is preserved per queued notification, separately from the existing inherited
return-to-sleep state. For wake popups the shell omits lower chrome layers. The
box is an opaque cropped image below the firmware's 64 KiB resource limit;
resource-free retained CLEAR calls black out its outside margins over separate
app surfaces. No oversized full-screen image is uploaded. The notification's
contents and retained inner selection animations remain visible. Closing the
modal restores the existing interface; apps are not closed. The mask follows
display-size and window-band changes rather than assuming G2 dimensions.
Automated coverage crosses the real shell scene encoder and presentation replay,
checking external app pixels, chrome, margins, resource bounds, content, dismissal
restoration, resizing, band position and retained selection order.
## Selected menu labels
Common menu rows, submenu labels, toggle labels, right-value labels and Settings
panel section/option labels scroll when selected, focused and too wide. A reading
pass pauses for 900 ms, moves at approximately 30 pixels/second at Normal animation
speed, pauses at the end, returns, then stays still. Reselecting or changing the
label/geometry restarts the pass. No JavaScript frame timers are used.
The label is clipped to the available space; right-side values, arrows and toggles
stay fixed. Disabled menu animations use a static clipped fallback. Oversized
labels requiring more than 32 bounded image tiles also use the static fallback.
Custom application renderers that draw text directly are not automatically covered.
## Test baseline
The unmodified source branch at `b4a2b293` was tested separately with `npm test`:
1,218 tests, 1,213 passed, 2 failed, 3 skipped. Both existing failures are in
`tests/onboarding-devices.test.cjs`: its expectations still include the RayNeo iO
picker entry that upstream intentionally hid. Keep this independent feature free
of unrelated onboarding changes. The combined build integration updates those
assertions to the actual upstream UI.
## Feature validation
- Full standalone suite: 1,233 tests, 1,228 passed, 2 failed, 3 skipped. The only
failures are the same two independently reproduced onboarding baseline failures.
- New behavioral tests: 11 marquee tests and 4 production-encoding notification
backdrop tests passed.
- Existing menu display-list regression suite: 11 passed.
- TypeScript (`tsc --noEmit`) and lint passed; existing lint warnings remain.
## Wake-only backdrop correction
- A screen-off arrival masks app/chrome; an already-on arrival preserves them.
- Queued arrivals preserve their own mask flag, while the original wake still
restores sleep after the last popup. Closing a popup does not close its app.
- RED: the new overlay and queue assertions failed before implementation.
- GREEN: all 24 focused queue/backdrop/menu display-list tests passed.
- Full standalone suite: 1,235 tests, 1,230 passed, 2 known onboarding failures,
3 skipped. No new failures. TypeScript and lint passed.
- Combined build: 1,332 tests, 1,329 passed, 0 failed, 3 skipped; TypeScript and
lint passed. Independent review found no blocking issues.
## Hardware limitation
No phone, glasses or ring is attached to this development environment. No firmware
is flashed and no APK is installed. Automated renderer tests cannot establish
physical-glasses performance or perceived animation smoothness.
+1 -1
View File
@@ -33,7 +33,7 @@ const menu = load('app/ui/menu.ts', {
'../graphics/image': graphics, '../graphics/ui-fonts': fonts, '../graphics/textwrap': textwrap,
'../util/numeric-util': numeric, './gestures': gestures, './metrics': load('app/ui/metrics.ts'),
'./menu-core': load('app/ui/menu-core.ts', {
'../graphics/image': graphics, './menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
'../graphics/image': graphics, './menu-label': require('../.test-build/app/ui/menu-label.js'), './menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
}),
});
+1
View File
@@ -22,6 +22,7 @@ const bdf = (size) => BdfFont.parse(fs.readFileSync(path.join(__dirname, `../app
const font = bdf(14);
const textwrap = load('app/graphics/textwrap.ts', {});
const coreDeps = {
'./menu-label': build('ui/menu-label'),
'../graphics/image': graphics, './menu-highlight-motion': build('ui/menu-highlight-motion'),
'../graphics/menu-scroll-list': build('graphics/menu-scroll-list'), './menu-scroll-motion': build('ui/menu-scroll-motion'),
'../graphics/draw-expression': build('graphics/draw-expression'),
+3 -3
View File
@@ -15,7 +15,7 @@ function load(file,modules) {
const font={lineHeight:12,ascent:10,descent:2,measureText:text=>text.length*4,
drawText:(image,x,y,text,value)=>{for(let i=0;i<text.length;i++) image.fillRect(x+i*4,y+2,2,6,value);}};
const menuCore=load('app/ui/menu-core.ts',{
'../graphics/image':graphics,'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
'../graphics/image':graphics,'./menu-label': require('../.test-build/app/ui/menu-label.js'), './menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
});
const {MenuLayer,TextPageLayer}=load('app/ui/menu.ts',{
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback }, '../graphics/screen-size': { screenWidth: () => 640, screenHeight: () => 480 },
@@ -121,13 +121,13 @@ test('unselected sidebar icons retain -2 depth through shell cropping, including
});
test('shell modal carries its inner menu highlight animation instead of baking its first frame',async()=>{
const {ShellModalLayer}=load('app/ui/shell/modal-layer.ts',{
'../../graphics/image':graphics,'../../graphics/plane':planes,'../gestures':{},'../layers':load('app/ui/layers.ts',{
'../../graphics/image':graphics,'../../graphics/display-list':require('../.test-build/app/graphics/display-list.js'),'../../graphics/plane':planes,'../gestures':{},'../layers':load('app/ui/layers.ts',{
'../graphics/image':graphics,'../graphics/plane':planes,'../native/frame-timings':{spanCurrent:(_name,fn)=>fn()},'../graphics/screen-size':{screenWidth:()=>640,screenHeight:()=>480},
'./gestures':{isDirectionalInput:()=>false},
}),
'./geometry':{appViewportSize:()=>({width:120,height:110}),appViewportRect:()=>({x:10,y:20,width:120,height:110}),SHELL_OPAQUE_BLACK:1},
});
const modal=new ShellModalLayer(menu().layer,noopLayerActions),paint=()=>modal.paint({},()=>new graphics.GrayImage(200,200));
const modal=new ShellModalLayer(menu().layer,noopLayerActions),paint=()=>modal.paint({stack:{getBaseSize:()=>({width:200,height:200})}},()=>new graphics.GrayImage(200,200));
const bare=menu().paint().draws.find(d=>d.presentation),before=paint().draws.find(d=>d.presentation);
assert.equal(before.x,bare.x+28);assert.equal(before.y,bare.y+38); // translated into the box interior
await modal.handleInput({type:'scroll-down'},{});
+218
View File
@@ -0,0 +1,218 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { GrayImage } = require('../.test-build/app/graphics/image.js');
const { Menu } = require('../.test-build/app/ui/menu-core.js');
const { paintDisplayList } = require('../.test-build/app/graphics/display-list.js');
const pref = require('../.test-build/app/ui/menu-animation-pref.js');
// Distinctive ink at the tail proves the full label, not an ellipsis, is rasterized.
const font = { lineHeight: 8, measureText: s => s.length * 4,
drawText(image, x, y, text, value) {
for (let i = 0; i < text.length; i++) image.fillRect(x + i * 4, y, text[i] === 'Z' ? 3 : 1, 4, value);
} };
function fixture() {
const labels = ['abcdefghijkZ', 'short'];
const menu = new Menu({ items: labels, getHeight: () => 12,
draw: ({ image, item, x, y, width, drawLabel }) => {
if (drawLabel) drawLabel(font, x + 3, y + 2, width - 6, item, 240);
else image.drawText(font, x + 3, y + 2, item, 240);
} });
return { menu, labels, paint(focused = true, width = 30) {
const image = new GrayImage(50, 30); menu.paint(image, { x: 2, y: 1, width, height: 24 }, focused); return image;
} };
}
const fs = require('node:fs');
const vm = require('node:vm');
const ts = require('typescript');
function load(file, modules) {
const context = { exports: {}, require: name => { assert.ok(name in modules, name); return modules[name]; } };
vm.runInNewContext(ts.transpileModule(fs.readFileSync(file, 'utf8'), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
return context.exports;
}
const menuModule = load('app/ui/menu.ts', {
'../graphics/image': { GrayImage }, '../graphics/screen-size': { screenHeight: () => 480 },
'../graphics/textwrap': {}, '../graphics/ui-fonts': { getDefaultSmallFont: () => font },
'../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
'../util/numeric-util': { clamp: (n, lo, hi) => Math.max(lo, Math.min(hi, n)) },
'./animation-speed': require('../.test-build/app/ui/animation-speed.js'), './layers': {}, './gestures': {},
'./menu-animation-pref': pref, './menu-core': require('../.test-build/app/ui/menu-core.js'),
'./metrics': require('../.test-build/app/ui/metrics.js'),
});
const lists = image => image.draws.filter(d => d.presentation?.displayList?.timeline);
test('selected overflowing label is retained, initially paused, then reveals its tail inside its clip', () => {
const f = fixture();
const image = f.paint();
const moving = lists(image);
assert.equal(moving.length, 1);
const d = moving[0], list = d.presentation.displayList;
const render = ms => {
const pixels = new Uint8Array(50 * 30).fill(64);
paintDisplayList(pixels, pixels.slice(), 50, 30,
{ displayList: { ...list, presentedAt: list.timeline.startedAt }, x: d.x, y: d.y, width: d.source.width, height: d.source.height, depth: 0 }, false, list.timeline.startedAt + ms);
return pixels;
};
assert.deepEqual(render(0), render(700));
assert.notDeepEqual(render(0), render(1800));
assert.equal(render(1800)[3 * 50 + 27], 240, 'tail Z reaches the right edge');
assert.equal(render(1800)[3 * 50 + 29], 64, 'right inset is untouched');
assert.equal(render(1800)[13 * 50 + 8], 64, 'next row is untouched');
});
test('short, unselected, unfocused and disabled-animation labels stay clipped and static', () => {
const f = fixture();
assert.equal(lists(f.paint(false)).length, 0);
f.menu.select(1);
assert.equal(lists(f.paint()).length, 0);
pref.setMenuAnimationReader(() => 'disabled');
try {
f.menu.select(0);
const image = f.paint();
assert.equal(lists(image).length, 0);
const row = image.draws.find(d => d.presentation).source;
assert.ok(row.pixels.some(v => v === 240), 'static label remains readable');
for (let y = 0; y < row.height; y++) assert.equal(row.getPixel(28, y), 0, 'right inset stays clear');
} finally { pref.setMenuAnimationReader(() => 'normal'); }
});
test('same retained presentation keeps its clock across paints and resets on content, width and focus', () => {
const original = Date.now;
let now = 1000;
Date.now = () => now;
try {
const f = fixture();
const timeline = () => lists(f.paint())[0].presentation.displayList.timeline;
const first = timeline();
now = 1500;
assert.deepEqual(timeline(), first);
f.labels[0] += 'Z';
const content = timeline();
assert.equal(content.startedAt, 1500);
assert.notEqual(content.token, first.token);
const resized = lists(f.paint(true, 28))[0].presentation.displayList.timeline;
assert.notEqual(resized.token, content.token);
f.paint(false);
assert.notEqual(timeline().token, resized.token);
} finally { Date.now = original; }
});
test('retained label pauses at the end, returns, stops scheduling, and survives a later PRESENT', () => {
const { evaluate } = require('../.test-build/app/graphics/draw-expression.js');
const { encodeDisplayList, readDisplayList } = require('../.test-build/app/graphics/display-list.js');
const d = lists(fixture().paint())[0];
const list = d.presentation.displayList;
const offset = ms => evaluate(list.calls[0].dx, 0, ms);
assert.equal(offset(1700).value, -24);
assert.equal(offset(2400).value, -24);
assert.equal(offset(3400).value, 0);
assert.equal(offset(100000).pending, false, 'native refresh becomes idle after the bounded pass');
const placed = { displayList: list, x: d.x, y: d.y, width: d.source.width, height: d.source.height, depth: 0 };
const start = list.timeline.startedAt;
const bytes = encodeDisplayList(placed, start + 1400);
const replay = readDisplayList(bytes, 0, 10000).placed;
assert.equal(evaluate(replay.displayList.calls[0].dx, 1400, 0).value, offset(1400).value);
});
test('very long labels are tiled into firmware-valid resources rather than giant images', () => {
const { encodeDisplayList } = require('../.test-build/app/graphics/display-list.js');
const f = fixture(); f.labels[0] = 'a'.repeat(1000) + 'Z';
const d = lists(f.paint())[0];
const list = d.presentation.displayList;
assert.ok(list.resources.length > 1);
assert.equal(list.resources.reduce((n, r) => n + r.width, 0), 4004, 'the entire label is retained');
for (const r of list.resources) {
assert.ok(r.width <= 640);
assert.ok(5 + Math.ceil(r.width / 2) * r.height <= 65536);
}
assert.doesNotThrow(() => encodeDisplayList({ displayList: list, x: d.x, y: d.y, width: d.source.width, height: d.source.height, depth: 0 }));
});
test('selected marquee clips to a short menu viewport rather than painting below it', () => {
const f = fixture();
const image = new GrayImage(50, 30);
f.menu.paint(image, { x: 2, y: 1, width: 30, height: 5 }, true);
const d = lists(image)[0];
assert.ok(d);
const clip = d.presentation.displayList.calls[0].clip;
assert.ok(d.y + clip.y + clip.height <= 6);
});
test('setItems changing selection restarts the pass without restarting unchanged settings repaints', () => {
const f = fixture();
const first = lists(f.paint())[0].presentation.displayList.timeline.token;
f.menu.setItems(f.labels);
assert.equal(lists(f.paint())[0].presentation.displayList.timeline.token, first);
f.menu.setItems(f.labels, 1);
f.menu.setItems(f.labels, 0);
assert.notEqual(lists(f.paint())[0].presentation.displayList.timeline.token, first);
});
test('selection away and back restarts the reading pass even without an intermediate paint', () => {
const f = fixture();
const before = lists(f.paint())[0].presentation.displayList.timeline;
f.menu.select(1);
f.menu.select(0);
const after = lists(f.paint())[0].presentation.displayList.timeline;
assert.notEqual(after.token, before.token);
});
test('common row builders scroll only the label and reserve fixed right decorations', () => {
const label = 'abcdefghijklmnopqrstuvwxyzZ';
const items = [
menuModule.submenuItem(label, () => {}),
{ label, onSelect() {}, render: a => menuModule.drawToggleMenuItem(a.image, font, a.x, a.y, a.width, a.text, true, a.selected) },
{ label, onSelect() {}, render: a => menuModule.drawRightValueMenuItem(a.image, font, a.x, a.y, a.width, a.text, '42') },
];
for (const [i, item] of items.entries()) {
const layer = new menuModule.MenuLayer(null, [item], { x: 0, y: 0, width: 140, minHeight: 40, maxHeight: 50 });
const image = layer.paint({ stack: { getBaseSize: () => ({ width: 140, height: 60 }), isFocused: () => true } }, () => new GrayImage(140, 60));
const scrolling = lists(image);
assert.equal(scrolling.length, 1, `builder ${i}`);
assert.ok(scrolling[0].source.width < 140 - 44, 'right decoration has reserved space');
const render = ms => {
const pixels = image.withDrawsBaked(false).pixels.slice();
for (const d of image.draws) {
const list = d.presentation?.displayList;
if (!list) continue;
const origin = list.timeline?.startedAt ?? 0;
paintDisplayList(pixels, pixels.slice(), 140, 60,
{ displayList: { ...list, presentedAt: origin }, x: d.x, y: d.y,
width: d.source.width, height: d.source.height, depth: 0 }, false, origin + ms);
}
return pixels;
};
const before = render(0), during = render(1800);
assert.notDeepEqual(before, during, 'the selected label actually moves');
const decorationX = [110, 82, 108][i];
const decoration = pixels => Array.from({ length: 60 }, (_, y) =>
Array.from(pixels.slice(y * 140 + decorationX, y * 140 + 119))).flat();
assert.deepEqual(decoration(before), decoration(during), 'right decoration never moves or gets overwritten');
assert.ok(decoration(before).some(v => v > 100), 'the fixed decoration is visible');
}
});
test('SettingsPanel labels animate only in the focused column', async () => {
const { SettingsPanelLayer } = load('app/ui/dashboard/settings-panel.ts', {
'../../graphics/ui-fonts': { getDefaultSmallFont: () => font }, '../../graphics/image': { GrayImage },
'../../graphics/textwrap': { wrapText: () => [] }, '../gestures': {}, '../layers': {},
'../menu': menuModule, '../menu-core': require('../.test-build/app/ui/menu-core.js'),
'../metrics': require('../.test-build/app/ui/metrics.js'), '../shell/shell': { shell: {} },
});
const layer = new SettingsPanelLayer([{ label: 'very long section label beyond column width',
items: [{ label: 'very long option label beyond the right column width', onSelect() {} }] }]);
const ctx = { stack: { getBaseSize: () => ({ width: 360, height: 100 }), isFocused: () => true } };
const left = lists(layer.paint(ctx));
assert.equal(left.length, 1);
assert.ok(left[0].x < 150);
await layer.handleInput({ type: 'click' }, ctx);
const right = lists(layer.paint(ctx));
assert.equal(right.length, 1);
assert.ok(right[0].x > 150);
});
test('common MenuLayer default row retains the full overflowing label', () => {
const layer = new menuModule.MenuLayer(null, [{ label: 'abcdefghijklmnopZ', onSelect() {} }],
{ x: 0, y: 0, width: 80, minHeight: 40, maxHeight: 50 });
const image = layer.paint({ stack: { getBaseSize: () => ({ width: 80, height: 60 }), isFocused: () => true } }, () => new GrayImage(80, 60));
assert.equal(lists(image).length, 1);
});
+1 -1
View File
@@ -159,7 +159,7 @@ test('Music settings keeps toggles and selection when a new app arrives and supp
'../graphics/textwrap': textwrap,
'../graphics/ui-fonts': { getDefaultSmallFont: () => font },
'../util/numeric-util': { clamp: (n, lo, hi) => Math.max(lo, Math.min(hi, n)) },
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
'./menu-label': require('../.test-build/app/ui/menu-label.js'), './menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
'./metrics': load('app/ui/metrics.ts'), './gestures': {},
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback }, '../graphics/screen-size': { screenWidth: () => 640, screenHeight: () => 480 },
};
+150
View File
@@ -0,0 +1,150 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { loader } = require('./helpers/load-typescript.cjs');
const graphics = require('../.test-build/app/graphics/image.js');
const planes = require('../.test-build/app/graphics/plane.js');
const { encodeShellScene } = require('../.test-build/app/graphics/shell-scene.js');
const { readPresentation, paintPresentation } = require('../.test-build/app/graphics/presentation-wire.js');
const { DrawOp } = require('../.test-build/app/graphics/display-list.js');
function fixture(width = 640, height = 480, retained = false, hideBackground = true) {
const screen = { width, height, top: 0 };
const load = loader({}, {
'../graphics/image': graphics, '../graphics/plane': planes,
'../graphics/screen-size': { screenWidth: () => screen.width, screenHeight: () => screen.height },
'../native/frame-timings': { spanCurrent: (_name, action) => action() },
'./gestures': { isDirectionalInput: () => false },
'../../graphics/image': graphics, '../../graphics/plane': planes, '../gestures': {},
'./geometry': {
appViewportSize: () => ({ width: screen.width - 64, height: Math.min(288, screen.height) }),
appViewportRect: () => ({ x: 32, y: screen.top, width: screen.width - 64, height: Math.min(288, screen.height) }),
SHELL_OPAQUE_BLACK: 1,
},
});
const { LayerStack, noopLayerActions } = load('app/ui/layers.ts');
const { ShellModalLayer, modalRect } = load('app/ui/shell/modal-layer.ts');
let lowerPaints = 0, innerSize, removed = 0;
const background = { paint() {
lowerPaints++;
const image = new graphics.GrayImage(screen.width, screen.height);
image.fillRect(0, 0, 24, 100, 170);
return image;
} };
const stack = new LayerStack(background, noopLayerActions);
const inner = {
paint(ctx) {
innerSize = ctx.stack.getBaseSize();
const image = new graphics.GrayImage(innerSize.width, innerSize.height);
image.fillRect(6, 6, 8, 8, 240);
if (retained) image.drawMenuSelection(new graphics.GrayImage(20, 12, 255), 20, 18, 60, 120, 3, 0);
return image;
},
handleInput() {},
};
const modal = new ShellModalLayer(inner, noopLayerActions, { hideBackground, removed() { removed++; } });
return { screen, stack, modal, modalRect, innerSize: () => innerSize, lowerPaints: () => lowerPaints, removed: () => removed };
}
// Real shell encoder and presentation decoder, replayed over a separate app
// in native ShellScene.calls order: opaque cropped surface, then retained calls.
function sceneFrame(f, appValue = 200) {
const bytes = encodeShellScene(f.stack.paintUndimmed());
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
const frame = new graphics.GrayImage(f.screen.width, f.screen.height, appValue);
const original = frame.pixels.slice(), layers = [];
let p = 2;
for (let i = 0; i < view.getUint16(0, true); i++) {
const x = view.getInt16(p + 2, true), y = view.getInt16(p + 4, true);
const width = view.getUint16(p + 6, true), height = view.getUint16(p + 8, true);
const count = view.getUint16(p + 12, true);
assert.ok(5 + Math.ceil(width / 2) * height <= 65536);
assert.equal(view.getUint16(p + 10, true), 256, 'vector mask does not rely on zero dim keeping no halftone');
const image = new graphics.GrayImage(width, height);
image.pixels.set(bytes.subarray(p + 16, p + 16 + width * height));
frame.bitBlt(image, x, y);
p += 16 + width * height;
const selections = [];
for (let j = 0; j < count; j++) {
const record = readPresentation(bytes, p);
selections.push(record.selection);
paintPresentation(frame.pixels, original, frame.width, frame.height, record.selection);
p = record.end;
}
layers.push({ x, y, width, height, selections });
}
assert.equal(p + 2, bytes.length, 'complete scene decoded');
return { frame, layers, bytes };
}
test('G2 notification serializes through the production shell scene within one 64 KiB surface', () => {
const f = fixture();
f.stack.push(f.modal);
const { layers } = sceneFrame(f);
assert.equal(layers.length, 1);
assert.deepEqual({ ...layers[0], selections: undefined }, { ...f.modalRect(), selections: undefined });
assert.equal(f.lowerPaints(), 0, 'chrome must not enter the scene');
const mask = layers[0].selections[0].displayList;
assert.equal(mask.resources.length, 0, 'no full-screen image or image tiles');
assert.ok(mask.calls.every(call => call.op === DrawOp.CLEAR && call.color === 0 && call.clip));
});
test('an already-awake notification keeps app and chrome visible with no blackout presentation', () => {
const f = fixture(640, 480, false, false);
f.stack.push(f.modal);
const { frame, layers } = sceneFrame(f);
assert.equal(f.lowerPaints(), 1, 'chrome is painted underneath the popup');
assert.equal(layers.length, 2);
assert.equal(frame.getPixel(639, 479), 200, 'app is visible outside the popup');
assert.equal(frame.getPixel(0, 0), 170, 'chrome remains visible');
assert.ok(frame.pixels.includes(240), 'popup still appears above the app');
assert.ok(layers.every(layer => layer.selections.length === 0), 'no margin mask for an already-on screen');
});
test('notification omits chrome and blacks out a separate app until dismissed', () => {
const f = fixture(), before = sceneFrame(f).frame;
assert.equal(f.lowerPaints(), 1);
f.stack.push(f.modal);
const { frame, layers } = sceneFrame(f);
assert.equal(f.lowerPaints(), 1);
assert.equal(layers.length, 1);
assert.equal(frame.getPixel(0, 0), 0);
assert.equal(frame.getPixel(639, 479), 0);
assert.ok(!frame.pixels.includes(200), 'margins hide separate app surface');
assert.ok(!frame.pixels.includes(170), 'status bar and switcher hidden');
assert.ok(frame.pixels.includes(240), 'notification remains visible');
f.stack.pop();
assert.equal(f.removed(), 1);
const closed = sceneFrame(f);
assert.deepEqual(closed.frame.pixels, before.pixels);
assert.equal(closed.layers[0].selections.length, 0, 'dismiss removes blackout');
});
test('notification mask follows resize, band position and restore without covering content', () => {
const f = fixture();
f.stack.push(f.modal);
for (const [width, height, top] of [[640, 480, 0], [540, 220, 0], [640, 480, 192], [640, 480, 0]]) {
Object.assign(f.screen, { width, height, top });
const { frame, layers } = sceneFrame(f), rect = f.modalRect();
assert.equal(frame.getPixel(width - 1, height - 1), 0);
assert.equal(frame.getPixel(rect.x, rect.y), 110);
assert.equal(frame.getPixel(rect.x + 2, rect.y + 2), 1, 'interior opaque black');
assert.equal(frame.getPixel(rect.x + 10, rect.y + 10), 240);
assert.ok(!frame.pixels.includes(200), 'no app pixels survive');
assert.equal(layers[0].height, rect.height);
assert.deepEqual({ ...f.innerSize() }, { width: rect.width - 8, height: rect.height - 8 });
}
});
test('notification retains inner menu presentations after blackout with correct offsets', () => {
const f = fixture(640, 480, true);
f.stack.push(f.modal);
const { layers, frame } = sceneFrame(f), rect = f.modalRect();
const { selections } = layers[0];
assert.equal(selections.length, 2, 'mask and selection both cross real encoder');
const row = selections[0];
assert.ok(row.displayList, 'selection is retained, not a frozen raster');
assert.equal(row.x, rect.x + 4 + 20);
assert.equal(row.y, rect.y + 4 + 18);
assert.equal(frame.getPixel(row.x + 10, row.y + 6), 240);
assert.equal(frame.getPixel(0, 0), 0);
});
+1 -1
View File
@@ -120,7 +120,7 @@ function ui(fontSize = 12) {
'../native/notification-types': require('../.test-build/app/native/notification-types.js'),
'../native/notification-access': { isNotificationListenerEnabled: () => true },
'../util/render-freshness': { renderPassAllowsStaleData: () => false },
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
'./menu-label': require('../.test-build/app/ui/menu-label.js'), './menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
'./metrics': load('app/ui/metrics.ts'),
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback }, '../graphics/screen-size': { screenWidth: () => 640, screenHeight: () => 480 },
'./gestures': {},
+16 -2
View File
@@ -3,13 +3,27 @@ const assert = require("node:assert/strict");
const { NotificationModalQueue } = require("../.test-build/app/ui/shell/notification-modal-queue.js");
test('background visibility follows each arrival, independently of inherited return-to-sleep state', () => {
const host = makeHost();
const queue = new NotificationModalQueue(host);
queue.post('wake', true);
queue.post('already-on', false);
assert.equal(host.opened[0].hideBackground, true);
queue.closed(host.opened[0]);
assert.equal(host.opened[1].hideBackground, false, 'queued arrivals must not inherit the first popup mask');
queue.closed(host.opened[1]);
assert.equal(host.sleeps, 1, 'sleep restoration is still inherited across the queue');
queue.post('normal', false);
assert.equal(host.opened[2].hideBackground, false);
});
/** A host that records opened modals (one handle object each) and sleeps. */
function makeHost(unavailable = new Set()) {
const host = {
opened: [],
sleeps: 0,
open(notificationKey) {
const modal = { notificationKey };
open(notificationKey, hideBackground) {
const modal = { notificationKey, hideBackground };
host.opened.push(modal);
return modal;
},
+1
View File
@@ -15,6 +15,7 @@ function fakeImageModule() {
this.width = width;
this.height = height;
this.texts = [];
this.draws = [];
return new Proxy(this, { get: (target, key) => (key in target ? target[key] : () => {}) });
}
drawText(_font, _x, _y, text) { this.texts.push(text); }