Unify vertical position and display mode settings; add to onboarding

This commit is contained in:
James Babcock committed 2026-10-10 22:48:26 -07:00
1 parent 6b1e64c5ac
commit 5a9ca08921
36 files changed
+810 -574

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ const PANEL_X = 230;
/**
* Height the layout above is drawn for: a min-height window's viewport under
* the standard top bar. A taller viewport (the status bar folded into the
* switcher row, a full-panel display) centers it vertically.
* switcher row, a Tall or Full Screen display) centers it vertically.
*/
const LAYOUT_HEIGHT = 260;
+3 -3
View File
@@ -29,9 +29,9 @@ class EvenHubAppLayer implements Layer {
paint(ctx: LayerContext): GrayImage {
const size = ctx.stack.getBaseSize();
// EvenHub apps lay out for the stock 576-wide surface. In the full-panel
// display mode the window is 640 wide; paint at stock width and centre
// it rather than leaving all the slack on the right.
// EvenHub apps lay out for the stock 576-wide surface. In the Full
// Screen display mode the window is 640 wide; paint at stock width and
// centre it rather than leaving all the slack on the right.
if (size.width > EVENHUB_SCREEN_WIDTH) {
const content = this.session.paint({ width: EVENHUB_SCREEN_WIDTH, height: size.height }, ctx.stack.isFocused());
const image = new GrayImage(size.width, size.height, 0);
+2 -6
View File
@@ -33,8 +33,7 @@ import {
navigateDestinationAddressDraftSetting,
navigateDestinationNameDraftSetting,
navigateRememberRecentSetting,
navigateDisplayModeSetting,
navigateVerticalPositionSetting,
navigateDisplayLayoutSetting,
mapboxApiKeySetting,
enumSettingMenuItem,
type ConfigSettingString,
@@ -935,10 +934,7 @@ function windowMenuItems(): MenuItem[] {
},
});
}
items.push(
enumSettingMenuItem(navigateDisplayModeSetting),
enumSettingMenuItem(navigateVerticalPositionSetting),
);
items.push(enumSettingMenuItem(navigateDisplayLayoutSetting));
items.push(submenuItem("Saved destinations", (ctx) => {
ctx.stack.push(new WindowMenuLayer("Saved destinations", savedDestinationMenuItems()));
}));
+1 -1
View File
@@ -13,7 +13,7 @@ const LABEL_GAP = 24;
/** None / Minimal / Full, each with a one-line summary; a tap saves the selected level. */
export class DataCollectionPage implements OnboardingPage {
readonly fullscreen = true;
readonly immersive = true;
/** Width of the level-name column, measured each paint. */
private labelColumnWidth = 0;
private readonly menu = new Menu<DataCollectionLevel>({
+1 -1
View File
@@ -13,7 +13,7 @@ const COLUMN_WIDTH = 220;
/**
* The whole display's stereo depth, after a layout that has one (Bottom or
* Popup). Not fullscreen, so the page sits in the chosen layout, and the
* Popup). Not immersive, so the page sits in the chosen layout, and the
* depth is saved as the selection moves: the shell shifts everything with
* it, which is the only way to see the difference.
*/
+94
View File
@@ -0,0 +1,94 @@
import type { GrayImage } from "../../graphics/image";
import { wrapText } from "../../graphics/textwrap";
import { displayLayoutSetting, type DisplayLayout } from "../../ui/dashboard-settings";
import type { InputEvent } from "../../ui/gestures";
import { Menu, type MenuDrawArgs } from "../../ui/menu-core";
import { LIST_ROW_TEXT_INSET, listRowHeight } from "../../ui/metrics";
import { onboardingFont } from "./onboarding-fonts";
import { drawPageHeading, PAGE_X, type OnboardingNav, type OnboardingPage } from "./onboarding-page";
const CONTENT_GAP = 10;
const BOTTOM_MARGIN = 8;
const COLUMN_GAP = 16;
const DESCRIPTIONS = {
band: "The stock 288px band, at this height in your view, leaving the rest of it clear.",
tall: "Windows use the display's full height.",
fullscreen: "Full height, and the display's whole width. Depth is turned off, since windows reach its edges.",
};
/**
* The display mode: how much of the display windows use (a band at one of
* five heights, Tall, or Full Screen where the layout allows it), with a
* line about the selected one. Not immersive, and the mode is saved as the
* selection moves, so this window itself shows each mode as it really is
* (the dashboard controller moves or resizes it, and every other window).
*/
export class DisplayModePage implements OnboardingPage {
private readonly menu = new Menu<DisplayLayout>({
wrap: false,
rowGap: 2,
highlight: { radius: 8 },
getHeight: () => listRowHeight(onboardingFont("body")),
draw: (args) => this.drawRow(args),
});
enter(): void {
// Full Screen comes and goes with the layout; where the layout doesn't
// allow it, a saved Full Screen shows as Tall, as the shell does.
const values = displayLayoutSetting.values.filter((value) => !displayLayoutSetting.isDisabled(value));
const index = values.indexOf(displayLayoutSetting.get());
this.menu.setItems(values, index >= 0 ? index : values.indexOf("tall"));
}
paint(image: GrayImage, focused: boolean): void {
const top = drawPageHeading(
image,
"Display mode",
"Swipe to choose how much of the display windows use; it changes as you go. Tap to continue.",
) + CONTENT_GAP;
const body = onboardingFont("body");
const columnWidth = 20 + Math.max(...this.menu.items.map((value) => body.measureText(displayLayoutSetting.displayValue(value))));
const menuBox = { x: PAGE_X - 10, y: top, width: columnWidth, height: image.height - top - BOTTOM_MARGIN };
this.menu.paint(image, menuBox, focused);
const layout = this.menu.selectedItem;
if (layout === null) return;
const detail = onboardingFont("detail");
const left = menuBox.x + columnWidth + COLUMN_GAP;
let y = top + LIST_ROW_TEXT_INSET;
for (const line of wrapText(detail, description(layout), image.width - PAGE_X - left)) {
if (y + detail.lineHeight > image.height - BOTTOM_MARGIN) break;
image.drawText(detail, left, y, line, 170);
y += detail.lineHeight;
}
}
handleInput(event: InputEvent, nav: OnboardingNav): void {
switch (event.type) {
case "scroll-up":
case "scroll-down":
void this.menu.handleInput(event);
this.apply();
return;
case "click":
this.apply();
nav.next();
return;
default:
return;
}
}
private apply(): void {
const layout = this.menu.selectedItem;
if (layout !== null && layout !== displayLayoutSetting.get()) displayLayoutSetting.set(layout);
}
private drawRow({ image, item: layout, x, y, selected }: MenuDrawArgs<DisplayLayout>): void {
image.drawText(onboardingFont("body"), x + 10, y + LIST_ROW_TEXT_INSET, displayLayoutSetting.displayValue(layout), selected ? 255 : 190);
}
}
function description(layout: DisplayLayout): string {
return layout === "tall" || layout === "fullscreen" ? DESCRIPTIONS[layout] : DESCRIPTIONS.band;
}
+2 -2
View File
@@ -4,8 +4,8 @@ import { ONBOARDING_APP_ID } from "./onboarding-progress";
/**
* First-run setup on the glasses: welcome, text size, data-collection
* preference, layout (app switcher position) and, for layouts that have
* one, depth. The connection controllers open it on their own when it is
* preference, layout (app switcher position), depth for layouts that have
* one, and display mode. The connection controllers open it on their own when it is
* due (claimGlassesOnboardingAutoLaunch); the launcher entry reruns it.
*/
const onboardingApp: AppDefinition = {
+1 -1
View File
@@ -7,7 +7,7 @@ import { drawPageHeading, PAGE_X, type OnboardingNav, type OnboardingPage } from
/** Paginate the notice so no disclosure is silently clipped on a short glasses viewport. */
export class IosPrivacyPage implements OnboardingPage {
readonly fullscreen = true;
readonly immersive = true;
private page = 0;
private pageCount = 1;
+177
View File
@@ -0,0 +1,177 @@
/**
* Schematic diagrams of the shell's layouts for the onboarding's Layout
* page: to scale in real-display pixels, simplified, and drawn brighter
* than the real chrome, which they shrink to a few pixels.
*/
import { G2_LENS_WIDTH, type GrayImage } from "../../graphics/image";
import { statusBarPositionSetting, type AppSwitcherPosition } from "../../ui/dashboard-settings";
import { SIDEBAR_WIDTH, SWITCHER_ROW_HEIGHT, MIN_WINDOW_HEIGHT, TOP_BAR_HEIGHT } from "../../ui/shell/geometry";
export const AREA_OUTLINE = 30;
const CHROME_LINE = 100;
const WINDOW_FRAME = 140;
const ICON = 160;
const SELECTED_ICON = 230;
const STATUS = 140;
const CONTENT = 110;
const CONTENT_TITLE = 170;
/** Window content under a popup switcher, which dims it. */
const DIM = 0.5;
/** Draws in real-display pixels, scaled into an image at (x, y). */
export class Diagram {
constructor(
private readonly image: GrayImage,
private readonly x: number,
private readonly y: number,
private readonly scale: number,
) {}
private box(x: number, y: number, width: number, height: number) {
const left = this.x + Math.round(x * this.scale), top = this.y + Math.round(y * this.scale);
return {
x: left,
y: top,
width: Math.max(1, this.x + Math.round((x + width) * this.scale) - left),
height: Math.max(1, this.y + Math.round((y + height) * this.scale) - top),
};
}
fill(x: number, y: number, width: number, height: number, value: number, radius = 0): void {
const box = this.box(x, y, width, height);
if (radius) this.image.fillRoundedRect(box.x, box.y, box.width, box.height, value, Math.max(1, Math.round(radius * this.scale)));
else this.image.fillRect(box.x, box.y, box.width, box.height, value);
}
outline(x: number, y: number, width: number, height: number, value: number, radius = 0): void {
const box = this.box(x, y, width, height);
this.image.drawRoundedRect(box.x, box.y, box.width, box.height, value, Math.max(0, Math.round(radius * this.scale)));
}
/** A one-pixel line along a real-pixel row (horizontal) or column. */
hline(x: number, y: number, width: number, value: number): void {
const box = this.box(x, y, width, 1);
this.image.fillRect(box.x, box.y, box.width, 1, value);
}
vline(x: number, y: number, height: number, value: number): void {
const box = this.box(x, y, 1, height);
this.image.fillRect(box.x, box.y, 1, box.height, value);
}
}
/**
* The foreground window's band, in real-display rows: its top and height
* (header and content; a bottom switcher row hangs under it), and whether
* it spans the panel's whole width (Full Screen; never beside a side strip).
*/
export type DiagramBand = { top: number; height: number; fullWidth: boolean };
/**
* A layout as the real chrome lays it out (geometry.ts, chrome-layer.ts):
* the window band with its status bar and frame, and the switcher with a
* few icons, the first selected. A popup switcher shows only with
* `popupOpen`, dimming the window as it does. Status bar placement follows
* the current setting.
*/
export function drawLayout(d: Diagram, position: AppSwitcherPosition, band: DiagramBand, popupOpen: boolean): void {
const statusAtBottom = statusBarPositionSetting.get() === "bottom";
const { top, height } = band;
switch (position) {
case "left":
case "right": {
const stripLeft = position === "left" ? 0 : G2_LENS_WIDTH - SIDEBAR_WIDTH;
const contentLeft = position === "left" ? SIDEBAR_WIDTH : 0;
const windowWidth = G2_LENS_WIDTH - SIDEBAR_WIDTH;
drawStatusBar(d, contentLeft, top, windowWidth, TOP_BAR_HEIGHT - 1);
drawContent(d, contentLeft, top + TOP_BAR_HEIGHT, windowWidth, height - TOP_BAR_HEIGHT, 1);
// The strip keeps to the 288px band's height, even beside taller windows.
const separator = position === "left" ? SIDEBAR_WIDTH - 1 : stripLeft;
d.vline(separator, top + TOP_BAR_HEIGHT, MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT, CHROME_LINE);
// One column of icons against the separator.
const column = position === "left" ? SIDEBAR_WIDTH - 36 : stripLeft;
for (let slot = 0; slot < 4; slot++) drawIcon(d, column + 2, top + TOP_BAR_HEIGHT + 10 + slot * 40, slot === 0);
return;
}
case "bottom": {
const { left, width, framed } = windowSpan(band);
// With the status bar in the row, the window's header is just the frame's top.
const header = !statusAtBottom ? TOP_BAR_HEIGHT : framed ? 1 : 0;
if (!statusAtBottom) drawStatusBar(d, left, top, width, framed ? null : TOP_BAR_HEIGHT - 1);
drawContent(d, left, top + header, width, height - header, 1);
if (framed) d.outline(left - 1, top + header - 1, width + 2, height - header + 2, WINDOW_FRAME, 8);
else d.hline(left, top + height, width, CHROME_LINE);
// The first cell starts at the frame's side, or inset like a scrolled row's (chrome-layer switcherLayout).
const cellsLeft = framed ? left - 1 : left + 8;
for (let slot = 0; slot < 4; slot++) drawIcon(d, cellsLeft + 2 + slot * 40, top + height + 2, slot === 0);
if (statusAtBottom) drawStatusItems(d, left + width, top + height + 4);
return;
}
case "popup": {
const { left, width, framed } = windowSpan(band);
const edge = framed ? 1 : 0;
const statusTop = statusAtBottom ? top + height - TOP_BAR_HEIGHT : top;
const contentTop = statusAtBottom ? top + edge : top + TOP_BAR_HEIGHT;
const contentHeight = height - TOP_BAR_HEIGHT - edge;
drawStatusBar(d, left, statusTop, width, framed ? null : statusAtBottom ? 0 : TOP_BAR_HEIGHT - 1);
drawContent(d, left, contentTop, width, contentHeight, popupOpen ? DIM : 1);
if (framed) d.outline(left - 1, contentTop - 1, width + 2, contentHeight + 2, WINDOW_FRAME, 8);
if (!popupOpen) return;
// The popup: a row of icons over the selected window's title, centred on the content.
const box = { width: 272, height: 98 };
const boxLeft = left + (width - box.width) / 2;
const boxTop = contentTop + (contentHeight - box.height) / 2;
d.fill(boxLeft, boxTop, box.width, box.height, 0);
d.outline(boxLeft, boxTop, box.width, box.height, WINDOW_FRAME);
const iconsLeft = boxLeft + (box.width - (3 * 48 - 4)) / 2;
for (let slot = 0; slot < 3; slot++) drawIcon(d, iconsLeft + slot * 48 + 6, boxTop + 18, slot === 0);
d.fill(boxLeft + box.width / 2 - 50, boxTop + 70, 100, 12, STATUS, 6);
return;
}
}
}
/** A bottom row or popup layout's window: centred at 576 wide and framed, or the panel's width without a frame. */
function windowSpan(band: DiagramBand): { left: number; width: number; framed: boolean } {
return band.fullWidth
? { left: 0, width: G2_LENS_WIDTH, framed: false }
: { left: SIDEBAR_WIDTH / 2, width: G2_LENS_WIDTH - SIDEBAR_WIDTH, framed: true };
}
/**
* A status bar's 28 rows from `y`; `divider` is the row (within them) of its
* line toward the window, if it draws one rather than meeting a frame.
*/
function drawStatusBar(d: Diagram, x: number, y: number, width: number, divider: number | null): void {
if (divider !== null) d.hline(x, y + divider, width, CHROME_LINE);
drawStatusItems(d, x + width, y);
}
/** Notification icons, a battery and the clock, ending at `right`, in a status bar's 28 rows from `top`. */
function drawStatusItems(d: Diagram, right: number, top: number): void {
d.fill(right - 64, top + 7, 56, 14, STATUS, 4);
d.outline(right - 108, top + 8, 32, 12, STATUS, 2);
d.outline(right - 148, top + 4, 20, 20, CHROME_LINE, 4);
d.outline(right - 176, top + 4, 20, 20, CHROME_LINE, 4);
}
/** A switcher icon (32px); the selected one filled, as the switcher's selection tab is. */
function drawIcon(d: Diagram, x: number, y: number, selected: boolean): void {
if (selected) d.fill(x, y, 32, 32, SELECTED_ICON, 6);
else d.outline(x, y, 32, 32, ICON, 6);
}
/** Stand-in window content: a title and as many list rows as fit, the first selected. */
function drawContent(d: Diagram, x: number, y: number, width: number, height: number, brightness: number): void {
const rowWidths = [width - 60, 300, 360, 240];
d.fill(x + 18, y + 14, 150, 18, Math.round(CONTENT_TITLE * brightness), 6);
d.outline(x + 8, y + 44, width - 16, 34, Math.round(CONTENT * brightness), 8);
for (let row = 0; ; row++) {
const rowTop = y + 52 + row * 44;
if (rowTop + 18 > y + height - 8) break;
d.fill(x + 18, rowTop, Math.min(rowWidths[row % rowWidths.length]!, width - 36), 18, Math.round(CONTENT * brightness), 6);
}
}
/** Real-display rows the Layout page's diagrams cover: a 288px band and a bottom switcher row under it. */
export const LAYOUT_AREA_HEIGHT = MIN_WINDOW_HEIGHT + SWITCHER_ROW_HEIGHT;
+14 -159
View File
@@ -1,8 +1,9 @@
import { G2_LENS_WIDTH, type GrayImage, type UiFont } from "../../graphics/image";
import { appSwitcherPositionSetting, statusBarPositionSetting, type AppSwitcherPosition } from "../../ui/dashboard-settings";
import { appSwitcherPositionSetting, type AppSwitcherPosition } from "../../ui/dashboard-settings";
import type { InputEvent } from "../../ui/gestures";
import { MENU_HIGHLIGHT_FILL, MENU_HIGHLIGHT_STROKE } from "../../ui/menu-core";
import { MIN_WINDOW_HEIGHT, SIDEBAR_WIDTH, SWITCHER_ROW_HEIGHT, TOP_BAR_HEIGHT } from "../../ui/shell/geometry";
import { MIN_WINDOW_HEIGHT } from "../../ui/shell/geometry";
import { AREA_OUTLINE, Diagram, drawLayout, LAYOUT_AREA_HEIGHT } from "./layout-diagram";
import { onboardingFont } from "./onboarding-fonts";
import { drawPageHeading, type OnboardingNav, type OnboardingPage } from "./onboarding-page";
@@ -10,8 +11,6 @@ const CONTENT_GAP = 10;
const BOTTOM_MARGIN = 8;
/** Diagram width as a fraction of the display's: the most a diagram is drawn at. */
const DIAGRAM_SCALE = 0.4;
/** The real-display area a diagram covers: a 288px window band and a bottom switcher row under it. */
const DIAGRAM_AREA_HEIGHT = MIN_WINDOW_HEIGHT + SWITCHER_ROW_HEIGHT;
/** Padding inside a cell's selection box, round the diagram and its caption. */
const CELL_PADDING = 8;
const CAPTION_GAP = 4;
@@ -32,12 +31,12 @@ export function layoutHasDepth(position: AppSwitcherPosition): boolean {
* The app switcher position, as a 2×2 grid of captioned diagrams of each
* layout, Bottom (recommended, and selected at first) and Popup on top;
* swipes move through them in reading order, a tap saves the selected one.
* The page is fullscreen, so the diagrams get 40% of the display's width
* The page is immersive, so the diagrams get 40% of the display's width
* each. Choosing a layout reflows open windows (the dashboard controller
* watches the setting).
*/
export class LayoutPage implements OnboardingPage {
readonly fullscreen = true;
readonly immersive = true;
/** Kept across visits, so going back returns to the last choice. */
private selected = LAYOUT_ORDER.indexOf(RECOMMENDED_LAYOUT);
@@ -54,11 +53,11 @@ export class LayoutPage implements OnboardingPage {
// Short of DIAGRAM_SCALE only where two rows of cells wouldn't fit.
const scale = Math.min(
DIAGRAM_SCALE,
((available - ROW_GAP) / 2 - 2 * CELL_PADDING - captionHeight) / DIAGRAM_AREA_HEIGHT,
((available - ROW_GAP) / 2 - 2 * CELL_PADDING - captionHeight) / LAYOUT_AREA_HEIGHT,
((image.width - COLUMN_GAP) / 2 - 2 * CELL_PADDING) / G2_LENS_WIDTH,
);
const diagramWidth = Math.round(G2_LENS_WIDTH * scale);
const diagramHeight = Math.round(DIAGRAM_AREA_HEIGHT * scale);
const diagramHeight = Math.round(LAYOUT_AREA_HEIGHT * scale);
const cellWidth = diagramWidth + 2 * CELL_PADDING;
const cellHeight = diagramHeight + 2 * CELL_PADDING + captionHeight;
const left = Math.round((image.width - 2 * cellWidth - COLUMN_GAP) / 2);
@@ -103,157 +102,13 @@ export class LayoutPage implements OnboardingPage {
}
}
// Diagram brightnesses: brighter than the real chrome's, which the diagrams
// shrink to a few pixels.
const AREA_OUTLINE = 30;
const CHROME_LINE = 100;
const WINDOW_FRAME = 140;
const ICON = 160;
const SELECTED_ICON = 230;
const STATUS = 140;
const CONTENT = 110;
const CONTENT_TITLE = 170;
/** Window content under a popup switcher, which dims it. */
const DIM = 0.5;
/**
* Draws in real-display pixels, scaled into a cell: the DIAGRAM_AREA_HEIGHT
* rows from the diagram's top, or from `top` rows down (see from).
* A layout's diagram: the 288px band, with the popup switcher open. Only a
* bottom switcher row takes rows under the band; without one, the band sits
* centred in their place, as the band and row share the screen's slack.
*/
class Diagram {
constructor(
private readonly image: GrayImage,
private readonly x: number,
private readonly y: number,
private readonly scale: number,
private readonly top = 0,
) {}
/** The same diagram with its row 0 `top` rows down. */
from(top: number): Diagram {
return new Diagram(this.image, this.x, this.y, this.scale, top);
}
private box(x: number, y: number, width: number, height: number) {
y += this.top;
const left = this.x + Math.round(x * this.scale), top = this.y + Math.round(y * this.scale);
return {
x: left,
y: top,
width: Math.max(1, this.x + Math.round((x + width) * this.scale) - left),
height: Math.max(1, this.y + Math.round((y + height) * this.scale) - top),
};
}
fill(x: number, y: number, width: number, height: number, value: number, radius = 0): void {
const box = this.box(x, y, width, height);
if (radius) this.image.fillRoundedRect(box.x, box.y, box.width, box.height, value, Math.max(1, Math.round(radius * this.scale)));
else this.image.fillRect(box.x, box.y, box.width, box.height, value);
}
outline(x: number, y: number, width: number, height: number, value: number, radius = 0): void {
const box = this.box(x, y, width, height);
this.image.drawRoundedRect(box.x, box.y, box.width, box.height, value, Math.max(0, Math.round(radius * this.scale)));
}
/** A one-pixel line along a real-pixel row (horizontal) or column. */
hline(x: number, y: number, width: number, value: number): void {
const box = this.box(x, y, width, 1);
this.image.fillRect(box.x, box.y, box.width, 1, value);
}
vline(x: number, y: number, height: number, value: number): void {
const box = this.box(x, y, 1, height);
this.image.fillRect(box.x, box.y, 1, box.height, value);
}
}
/**
* A layout as the real chrome lays it out (geometry.ts, chrome-layer.ts),
* to scale and simplified: the window band with its status bar and frame,
* and the switcher with a few icons, the first selected. Status bar
* placement follows the current setting. Only a bottom switcher row takes
* rows under the band; without one, the band sits centred in their place,
* as the band and row share the screen's slack.
*/
function drawLayoutDiagram(area: Diagram, position: AppSwitcherPosition): void {
area.outline(0, 0, G2_LENS_WIDTH, DIAGRAM_AREA_HEIGHT, AREA_OUTLINE, 12);
const d = position === "bottom" ? area : area.from((DIAGRAM_AREA_HEIGHT - MIN_WINDOW_HEIGHT) / 2);
const statusAtBottom = statusBarPositionSetting.get() === "bottom";
const windowLeft = SIDEBAR_WIDTH / 2, windowWidth = G2_LENS_WIDTH - SIDEBAR_WIDTH;
switch (position) {
case "left":
case "right": {
const stripLeft = position === "left" ? 0 : G2_LENS_WIDTH - SIDEBAR_WIDTH;
const contentLeft = position === "left" ? SIDEBAR_WIDTH : 0;
drawStatusBar(d, contentLeft, 0, windowWidth, true);
drawContent(d, contentLeft, TOP_BAR_HEIGHT, windowWidth, MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT, 1);
const separator = position === "left" ? SIDEBAR_WIDTH - 1 : stripLeft;
d.vline(separator, TOP_BAR_HEIGHT, MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT, CHROME_LINE);
// One column of icons against the separator.
const column = position === "left" ? SIDEBAR_WIDTH - 36 : stripLeft;
for (let slot = 0; slot < 4; slot++) drawIcon(d, column + 2, TOP_BAR_HEIGHT + 10 + slot * 40, slot === 0);
return;
}
case "bottom": {
// With the status bar in the row, the window's header is just the frame's top.
const contentTop = statusAtBottom ? 1 : TOP_BAR_HEIGHT;
if (!statusAtBottom) drawStatusBar(d, windowLeft, 0, windowWidth, false);
drawContent(d, windowLeft, contentTop, windowWidth, MIN_WINDOW_HEIGHT - contentTop, 1);
d.outline(windowLeft - 1, contentTop - 1, windowWidth + 2, MIN_WINDOW_HEIGHT - contentTop + 2, WINDOW_FRAME, 8);
for (let slot = 0; slot < 4; slot++) drawIcon(d, windowLeft + 1 + slot * 40, MIN_WINDOW_HEIGHT + 2, slot === 0);
if (statusAtBottom) drawStatusItems(d, windowLeft + windowWidth, MIN_WINDOW_HEIGHT + 4);
return;
}
case "popup": {
const statusTop = statusAtBottom ? MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT : 0;
const contentTop = statusAtBottom ? 1 : TOP_BAR_HEIGHT;
const contentHeight = MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT - 1;
drawStatusBar(d, windowLeft, statusTop, windowWidth, false);
drawContent(d, windowLeft, contentTop, windowWidth, contentHeight, DIM);
d.outline(windowLeft - 1, contentTop - 1, windowWidth + 2, contentHeight + 2, WINDOW_FRAME, 8);
// The popup: a row of icons over the selected window's title, centred on the content.
const box = { width: 272, height: 98 };
const boxLeft = (G2_LENS_WIDTH - box.width) / 2;
const boxTop = contentTop + (contentHeight - box.height) / 2;
d.fill(boxLeft, boxTop, box.width, box.height, 0);
d.outline(boxLeft, boxTop, box.width, box.height, WINDOW_FRAME);
const iconsLeft = boxLeft + (box.width - (3 * 48 - 4)) / 2;
for (let slot = 0; slot < 3; slot++) drawIcon(d, iconsLeft + slot * 48 + 6, boxTop + 18, slot === 0);
d.fill(G2_LENS_WIDTH / 2 - 50, boxTop + 70, 100, 12, STATUS, 6);
return;
}
}
}
/** A status bar along a window's top or bottom edge; `divider` draws its line toward the window. */
function drawStatusBar(d: Diagram, x: number, y: number, width: number, divider: boolean): void {
if (divider) d.hline(x, y + TOP_BAR_HEIGHT - 1, width, CHROME_LINE);
drawStatusItems(d, x + width, y);
}
/** Notification icons, a battery and the clock, ending at `right`, in a status bar's 28 rows from `top`. */
function drawStatusItems(d: Diagram, right: number, top: number): void {
d.fill(right - 64, top + 7, 56, 14, STATUS, 4);
d.outline(right - 108, top + 8, 32, 12, STATUS, 2);
d.outline(right - 148, top + 4, 20, 20, CHROME_LINE, 4);
d.outline(right - 176, top + 4, 20, 20, CHROME_LINE, 4);
}
/** A switcher icon (32px); the selected one filled, as the switcher's selection tab is. */
function drawIcon(d: Diagram, x: number, y: number, selected: boolean): void {
if (selected) d.fill(x, y, 32, 32, SELECTED_ICON, 6);
else d.outline(x, y, 32, 32, ICON, 6);
}
/** Stand-in window content: a title and list rows, the first selected. */
function drawContent(d: Diagram, x: number, y: number, width: number, height: number, brightness: number): void {
const rowWidths = [width - 60, 300, 360, 240];
d.fill(x + 18, y + 14, 150, 18, CONTENT_TITLE * brightness, 6);
d.outline(x + 8, y + 44, width - 16, 34, CONTENT * brightness, 8);
for (let row = 0; row < rowWidths.length; row++) {
const rowTop = y + 52 + row * 44;
if (rowTop + 18 > y + height) break;
d.fill(x + 18, rowTop, Math.min(rowWidths[row]!, width - 36), 18, CONTENT * brightness, 6);
}
function drawLayoutDiagram(d: Diagram, position: AppSwitcherPosition): void {
d.outline(0, 0, G2_LENS_WIDTH, LAYOUT_AREA_HEIGHT, AREA_OUTLINE, 12);
const top = position === "bottom" ? 0 : (LAYOUT_AREA_HEIGHT - MIN_WINDOW_HEIGHT) / 2;
drawLayout(d, position, { top, height: MIN_WINDOW_HEIGHT, fullWidth: false }, true);
}
+7 -6
View File
@@ -6,6 +6,7 @@ import { shell } from "../../ui/shell/shell";
import { findSoundEffect, playSoundEffect } from "../../ui/sound-effects";
import { DataCollectionPage } from "./data-collection-page";
import { DepthPage } from "./depth-page";
import { DisplayModePage } from "./display-mode-page";
import { IosPrivacyPage } from "./ios-privacy-page";
import { LayoutPage } from "./layout-page";
import { markGlassesOnboardingFinished, ONBOARDING_APP_ID } from "./onboarding-progress";
@@ -27,7 +28,7 @@ export function createOnboardingAppWindow(options: InProcessAppOptions): InProce
const pages: OnboardingPage[] = [
new WelcomePage(), new TextSizePage(),
...(global.isIOS ? [new IosPrivacyPage()] : []),
new DataCollectionPage(), new LayoutPage(), new DepthPage(),
new DataCollectionPage(), new LayoutPage(), new DepthPage(), new DisplayModePage(),
];
const app = createInProcessWindow({
appId: ONBOARDING_APP_ID,
@@ -36,12 +37,12 @@ export function createOnboardingAppWindow(options: InProcessAppOptions): InProce
iconLetter: "On",
icon: "sparkles",
closeable: true,
fullscreen: pages[0]!.fullscreen,
immersive: pages[0]!.immersive,
actions: options.actions,
baseLayer: new OnboardingLayer(
pages,
// Only called on page changes, by when `app` is set.
(fullscreen) => app.setFullscreen(fullscreen),
(immersive) => app.setImmersive(immersive),
() => {
markGlassesOnboardingFinished();
shell.closeWindow(ONBOARDING_WINDOW_ID);
@@ -69,7 +70,7 @@ function playWelcomeSound(actions: LayerActions): void {
}
/**
* Hosts the current page, fullscreen or not as it asks. Double-click steps
* Hosts the current page, immersive or not as it asks. Double-click steps
* back a page, or leaves the app from the first one (the standard yield to
* the app switcher); every other gesture goes to the page. Pages that don't
* apply (Depth beside a side-strip app switcher) are skipped either way.
@@ -79,7 +80,7 @@ export class OnboardingLayer implements Layer {
constructor(
private readonly pages: readonly OnboardingPage[],
private readonly setFullscreen: (fullscreen: boolean) => void,
private readonly setImmersive: (immersive: boolean) => void,
private readonly finish: () => void,
) {
pages[0]!.enter?.();
@@ -120,6 +121,6 @@ export class OnboardingLayer implements Layer {
this.index = index;
const page = this.pages[index]!;
page.enter?.();
this.setFullscreen(page.fullscreen ?? false);
this.setImmersive(page.immersive ?? false);
}
}
+4 -4
View File
@@ -16,11 +16,11 @@ export type OnboardingNav = {
*/
export interface OnboardingPage {
/**
* Show the page fullscreen: the whole 640×480 panel, with the app switcher
* and status bar hidden. Otherwise it is an ordinary window in the
* chosen layout.
* Show the page immersive (full-screen): the whole 640×480 panel, with
* the app switcher and status bar hidden. Otherwise it is an ordinary
* window in the chosen layout.
*/
readonly fullscreen?: boolean;
readonly immersive?: boolean;
/** Whether the page belongs in the flow right now; skipped both ways when false. */
applies?(): boolean;
/** The page became current, going forward or back. */
+1 -1
View File
@@ -48,7 +48,7 @@ type Face =
* while scrolling.
*/
export class TextSizePage implements OnboardingPage {
readonly fullscreen = true;
readonly immersive = true;
private face: Face = { kind: "fixed", label: "Terminus" };
private readonly sizeMenu = new Menu<number>({
wrap: false,
+1 -1
View File
@@ -16,7 +16,7 @@ type TextLine = { font: UiFont; text: string; value: number; spaceBefore: number
/** The splash: logo beside the name, version and how to go on, centred as one group. */
export class WelcomePage implements OnboardingPage {
readonly fullscreen = true;
readonly immersive = true;
paint(image: GrayImage): void {
const { width, height } = image;
+1 -1
View File
@@ -66,7 +66,7 @@ const PANEL_X = 310;
/**
* Height the table and panel are drawn for: a min-height window's viewport
* under the standard top bar. A taller viewport (the status bar folded into
* the switcher row, a full-panel display) centers the layout vertically.
* the switcher row, a Tall or Full Screen display) centers the layout vertically.
*/
const LAYOUT_HEIGHT = 260;
+2 -4
View File
@@ -55,10 +55,9 @@ import { clamp } from "../../util/numeric-util";
import {
enumSettingMenuItem,
terminalAutoReconnectSetting,
terminalDisplayModeSetting,
terminalDisplayLayoutSetting,
terminalLaunchPresetsSetting,
terminalNewConnectionSetting,
terminalVerticalPositionSetting,
terminalWakeOnBellSetting,
textSettingMenuItem,
toggleSettingMenuItem,
@@ -1118,8 +1117,7 @@ function windowMenuItems(window: TerminalWindow): MenuItem[] {
*/
function settingsMenuItems(): MenuItem[] {
return [
enumSettingMenuItem(terminalDisplayModeSetting),
enumSettingMenuItem(terminalVerticalPositionSetting),
enumSettingMenuItem(terminalDisplayLayoutSetting),
terminalFontPickerMenuItem(),
// Opens the phone text editor; the settings listener repaints its page.
textSettingMenuItem(terminalLaunchPresetsSetting),
+17 -15
View File
@@ -72,7 +72,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type WindowHeightMode } from "../ui/shell/geometry";
import { type LayerActions, type TextSettingsEditToggle } from "../ui/layers";
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
import { appSwitcherPositionSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayModeSetting, navigateDisplayModeSetting, navigateVerticalPositionSetting, terminalDisplayModeSetting, terminalVerticalPositionSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, verticalPositionSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
import { appSwitcherPositionSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
import {
getInstalledEvenHubAppById,
@@ -184,24 +184,26 @@ const EVEN_APP_DETECTED_MESSAGE =
const LAUNCHABLE_APPS = ALL_APPS.filter((app) => app.showInLauncher !== false);
/**
* The global settings window viewport sizes depend on: the display mode,
* whether the app switcher takes width beside windows, height below them
* or neither (a popup), and the chrome rows each window loses to it: below
* them, whether the status bar joins the row (dropping the top bar); with a
* popup, whether the status bar keeps rows of its own and the window frame
* (where the status bar goes only moves windows).
* The global settings window viewport sizes depend on: the display mode's
* size (a band's position only moves windows), whether the app switcher
* takes width beside windows, height below them or neither (a popup), and
* the chrome rows each window loses to it: below them, whether the status
* bar joins the row (dropping the top bar); with a popup, whether the
* status bar keeps rows of its own and the window frame (where the status
* bar goes only moves windows).
*/
function viewportSizesKey(): string {
const position = appSwitcherPositionSetting.get();
const switcher = position === "bottom" ? `row|${statusBarPositionSetting.get()}`
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`
: "strip";
return `${displayModeSetting.get()}|${switcher}`;
const layout = displayLayoutSetting.get();
return `${layout.startsWith("band-") ? "band" : layout}|${switcher}`;
}
/** The global settings that move window surfaces without resizing them. */
function windowPlacementKey(): string {
return `${verticalPositionSetting.get()}|${appSwitcherPositionSetting.get()}|${statusBarPositionSetting.get()}`;
return `${displayLayoutSetting.get()}|${appSwitcherPositionSetting.get()}|${statusBarPositionSetting.get()}`;
}
function createInitialDisplayPreview(): ImageSource | null {
@@ -449,8 +451,8 @@ class DashboardController {
this.pushFirmwareDebugFlags();
this.pushBrightness();
this.syncEvenHubScreenOffSetting();
// Display mode first: a reflow repositions every surface too, so the
// vertical-position check after it then has nothing left to do.
// Display mode size first: a reflow repositions every surface too, so
// the band-position check after it then has nothing left to do.
this.applyDisplayModeIfChanged();
this.applyVerticalPositionIfChanged();
this.applyAppLayoutsIfChanged();
@@ -530,7 +532,7 @@ class DashboardController {
});
}
// Vertical-position changes (and moving the app switcher between the left
// Band position changes (and moving the app switcher between the left
// and right edges, or a popup switcher's status bar between the top and
// bottom) move every window surface and the chrome that aligns with them;
// the values are tracked so unrelated setting changes don't trigger a full
@@ -540,7 +542,7 @@ class DashboardController {
private lastViewportSizes = viewportSizesKey();
/**
* Display mode changed (Settings > Display, or the phone page's picker),
* Display mode size changed (Settings > Display, or the phone page's picker),
* or the app switcher or its chrome changed what windows lose to them
* (see viewportSizesKey): every window's viewport size changes. In-process windows re-measure in place; workers
* that support resizing receive the new viewport. Other worker windows are
@@ -586,8 +588,8 @@ class DashboardController {
private appLayouts(): Record<string, string> {
return {
navigate: `${navigateDisplayModeSetting.get()}:${navigateVerticalPositionSetting.get()}`,
terminal: `${terminalDisplayModeSetting.get()}:${terminalVerticalPositionSetting.get()}`,
navigate: navigateDisplayLayoutSetting.get(),
terminal: terminalDisplayLayoutSetting.get(),
};
}
+1 -6
View File
@@ -44,7 +44,7 @@ import { noopLayerActions, type LayerActions } from '../ui/layers'
import { TextViewerLayer } from '../apps/files/text-viewer'
import { shell, rawInputEventToInputEvent, type ShellWindow } from '../ui/shell/shell'
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible } from '../ui/shell/geometry'
import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, onAnySettingChanged,
import { onAnySettingChanged,
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
nightscoutSiteUrlSetting, nightscoutApiTokenSetting } from '../ui/dashboard-settings'
import type { PhoneGesture } from '../phone-ui/phone-gestures'
@@ -658,11 +658,6 @@ export class IosPreviewController {
this.appHosts.set(appId, host)
return host
}
cycleDisplayMode(): void {
const values = DISPLAY_MODE_VALUES
displayModeSetting.set(values[(values.indexOf(displayModeSetting.get()) + 1) % values.length])
}
get displayModeLabel(): string { return displayModeLabel(displayModeSetting.get()) }
get connectionState(): SessionState | null { return this.sessionCreated ? this.state : null }
get connectionDetails(): string {
const state = this.connectionState
-15
View File
@@ -28,8 +28,6 @@ import { type AppDefinition } from "../apps/app-definition";
import { getInstalledEvenHubApps, installedEvenHubAppId } from "../apps/evenhub/installed-apps";
import { WEAR_PATHS, wearBridge, type WearMessage } from "../native/wear-bridge";
import {
DISPLAY_MODE_VALUES,
displayModeSetting,
onAnySettingChanged,
watchCanUnlockSetting,
watchCrownClockwiseNextSetting,
@@ -88,7 +86,6 @@ const COMMANDS = [
"connect",
"disconnect",
"close-assistant",
"display-mode",
] as const;
type WearCommand = (typeof COMMANDS)[number];
@@ -277,7 +274,6 @@ export class WearRemote {
acceptsText: typeof window.receiveTextInput === "function",
})),
apps: this.listApps(),
displayMode: displayModeSetting.get(),
remoteEnabled: watchRemoteEnabledSetting.get(),
crownClockwiseNext: watchCrownClockwiseNextSetting.get(),
canUnlock: watchCanUnlockSetting.get(),
@@ -522,17 +518,6 @@ export class WearRemote {
// but tell the watch which of the two happened.
ack(true, shell.closeAssistant() ? "" : "The assistant was not open.");
return;
case "display-mode": {
const value = String(payload.value ?? "");
if (!(DISPLAY_MODE_VALUES as readonly string[]).includes(value)) {
ack(false, `Unknown display mode: ${value}`);
return;
}
displayModeSetting.set(value as (typeof DISPLAY_MODE_VALUES)[number]);
this.schedulePublish();
ack(true, `Display mode: ${value}`);
return;
}
default:
ack(false, `Unhandled command: ${command}`);
}
+8 -9
View File
@@ -1,8 +1,5 @@
import { Dialogs, Observable } from '@nativescript/core';
import {
brightnessSetting, DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting,
type BrightnessSetting, type DisplayModeSetting,
} from '../ui/dashboard-settings';
import { brightnessSetting, displayLayoutSetting, type BrightnessSetting } from '../ui/dashboard-settings';
type ControlsTab = 'settings' | 'watch' | 'ring';
// Remember the tab across navigation on both platforms, without persisting it.
@@ -65,17 +62,19 @@ export class RemoteControlsViewModel extends Observable {
// ---- display mode and brightness, on the Settings tab ----
get displayModeLabel(): string {
return displayModeLabel(displayModeSetting.get()) + " ▾";
return displayLayoutSetting.displayValue() + " ▾";
}
async onDisplayModeTap(): Promise<void> {
const current = displayModeSetting.get();
const options = DISPLAY_MODE_VALUES.map((value) => displayModeLabel(value) + (value === current ? " ✓" : ""));
const current = displayLayoutSetting.get();
// Full Screen is offered only with a bottom or popup app switcher.
const values = displayLayoutSetting.values.filter((value) => !displayLayoutSetting.isDisabled(value));
const options = values.map((value) => displayLayoutSetting.displayValue(value) + (value === current ? " ✓" : ""));
const picked = await Dialogs.action({ title: "Display mode", cancelButtonText: "Cancel", actions: options });
const index = options.indexOf(picked);
if (index < 0) return;
const value = DISPLAY_MODE_VALUES[index] as DisplayModeSetting;
if (value !== current) displayModeSetting.set(value);
const value = values[index]!;
if (value !== current) displayLayoutSetting.set(value);
this.notifyPropertyChange("displayModeLabel", this.displayModeLabel);
}
+1 -1
View File
@@ -38,7 +38,7 @@
<!-- Settings tab -->
<StackLayout visibility="{{ settingsTabVisibility }}">
<GridLayout rows="auto" columns="auto,*" class="settings-row">
<Label col="0" text="Screen size" class="settings-row-label" verticalAlignment="center" />
<Label col="0" text="Display mode" class="settings-row-label" verticalAlignment="center" />
<Button col="1" text="{{ displayModeLabel }}" tap="{{ onDisplayModeTap }}" class="mode-button" horizontalAlignment="left" />
</GridLayout>
<GridLayout rows="auto" columns="auto,*,auto" class="settings-row">
+109 -93
View File
@@ -329,49 +329,6 @@ export const timeFormatSetting = new ConfigSettingEnum<TimeFormat>({
description: "Whether the top-bar clock shows 24-hour or 12-hour time.",
});
/**
* How much of the 640x480 panel the UI uses. "576x288" is the stock band
* (sidebar + a 288px-tall window at the vertical position); "576x480" keeps
* the sidebar and gives every window the full height; "640x480" is the whole
* panel, with the sidebar an overlay that shows only while it has focus. The
* values name the sizes beside a side strip; with the app switcher along the
* bottom, the tall height loses the switcher row (displayModeLabel shows the
* actual size).
*/
export const DISPLAY_MODE_VALUES = ["576x288", "576x480", "640x480"] as const;
export type DisplayModeSetting = (typeof DISPLAY_MODE_VALUES)[number];
const DISPLAY_MODE_NAMES: Record<DisplayModeSetting, string> = {
"576x288": "Band",
"576x480": "Tall",
"640x480": "Full panel",
};
/** Window size per mode with the app switcher along the bottom (see geometry.ts). */
const BOTTOM_SWITCHER_SIZES: Record<DisplayModeSetting, string> = {
"576x288": "576×288",
"576x480": "576×444",
"640x480": "640×480",
};
export function displayModeLabel(value: DisplayModeSetting): string {
const name = DISPLAY_MODE_NAMES[value];
if (!name) return value;
const size = appSwitcherPositionSetting.get() === "bottom" ? BOTTOM_SWITCHER_SIZES[value] : value.replace("x", "×");
return `${name} · ${size}`;
}
export const displayModeSetting = new ConfigSettingEnum<DisplayModeSetting>({
id: "display-mode",
label: "Display mode",
storageKey: "display.mode",
defaultValue: "576x288",
values: DISPLAY_MODE_VALUES,
formatValue: displayModeLabel,
description:
"Band: the stock 288px-tall window beside the app switcher. Tall: the app switcher plus full-height windows. Full panel: the whole 640×480 display; the app switcher overlays the app only while you are in it. Open apps reopen in the new size.",
});
/**
* Where the app switcher (the open-window icons) sits: a strip along the
* left or right edge of the display, a row under the window, or a popup box
@@ -397,6 +354,83 @@ export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosit
"Where the open-app icons go. Left and right take a column beside windows; bottom puts a row beneath the window, which makes full-height windows a little shorter; popup shows them only while you're in the app switcher, in a box over the dimmed window. Bottom and popup leave room at the sides to set the display's depth. Open apps reopen at their new size when a change resizes windows.",
});
/**
* An enum setting that took over from older settings: until it is first
* set, its value is derived from theirs.
*/
class ConfigSettingEnumWithLegacy<TValue extends string> extends ConfigSettingEnum<TValue> {
constructor(options: ConfigSettingEnumOptions<TValue, string>, private readonly legacyValue: () => TValue) {
super(options);
}
get(): TValue {
return getStringSetting(this.storageKey, "") === "" ? this.legacyValue() : super.get();
}
}
/**
* How much of the 640x480 panel windows use, and where: the stock
* 288px-tall band, at one of five heights in the field of view; Tall, every
* window the full height; or Full Screen, Tall at the panel's whole 640px
* width. The app switcher keeps its own room in every mode. Full Screen
* needs a bottom row or popup app switcher (a side strip leaves no width to
* spare; there it is Tall), has no window frame, and plays at depth 0,
* since its windows reach the panel's edges (geometry.ts).
*/
export const DISPLAY_LAYOUT_VALUES = [
"band-top", "band-high", "band-middle", "band-low", "band-bottom", "tall", "fullscreen",
] as const;
export type DisplayLayout = (typeof DISPLAY_LAYOUT_VALUES)[number];
const DISPLAY_LAYOUT_LABELS: Record<DisplayLayout, string> = {
"band-top": "Band · Top",
"band-high": "Band · High",
"band-middle": "Band · Middle",
"band-low": "Band · Low",
"band-bottom": "Band · Bottom",
tall: "Tall",
fullscreen: "Full Screen",
};
export function displayLayoutLabel(value: DisplayLayout): string {
return DISPLAY_LAYOUT_LABELS[value] ?? value;
}
/** Whether the Full Screen display mode is available: with a bottom row or popup app switcher. */
export function fullScreenAvailable(): boolean {
const position = appSwitcherPositionSetting.get();
return position === "bottom" || position === "popup";
}
// Until 2026-10-10 the display mode ("576x288" band, "576x480" tall,
// "640x480" full panel) and the band's vertical position were separate
// settings, globally and per app.
const LEGACY_MODE_LAYOUTS: Record<string, DisplayLayout> = { "576x480": "tall", "640x480": "fullscreen" };
const LEGACY_POSITION_LAYOUTS: Record<string, DisplayLayout> = {
top: "band-top", upper: "band-high", middle: "band-middle", lower: "band-low", bottom: "band-bottom",
};
function legacyBand(position: string): DisplayLayout {
return LEGACY_POSITION_LAYOUTS[position] ?? "band-middle";
}
function legacyDisplayLayout(): DisplayLayout {
const mode = getStringSetting("display.mode", "576x288");
return LEGACY_MODE_LAYOUTS[mode] ?? legacyBand(getStringSetting("display.verticalPosition", "middle"));
}
export const displayLayoutSetting = new ConfigSettingEnumWithLegacy<DisplayLayout>({
id: "display-mode",
label: "Display mode",
storageKey: "display.layout",
defaultValue: "band-middle",
values: DISPLAY_LAYOUT_VALUES,
formatValue: displayLayoutLabel,
isDisabled: (value) => value === "fullscreen" && !fullScreenAvailable(),
description:
"Band: the stock 288px-tall window, at the height in your field of view you choose. Tall: full-height windows. Full Screen: full-height windows across the display's whole width; it needs the app switcher at the bottom or as a popup, and turns depth off, since windows reach the display's edges. Navigate and Terminal can override this. Open apps reopen in the new size.",
}, legacyDisplayLayout);
const UI_DEPTH_VALUES = ["-62", "-48", "-32", "-16", "0", "16", "32", "48", "62"] as const;
export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
@@ -406,8 +440,9 @@ export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
* directions. Only applies with the app switcher at the bottom or a popup,
* where the windows' 576px width leaves 32px at each side: one for the side
* of the window's frame and 31 to shift into, hence ±62 (see geometry.ts
* uiDepth and windowFramed); values stay even so the per-lens halves of
* nested depths add exactly.
* uiDepth and windowFramed); not to Full Screen windows, which have no such
* margins. Values stay even so the per-lens halves of nested depths add
* exactly.
*/
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
id: "ui-depth",
@@ -420,7 +455,7 @@ export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
},
description:
"Moves the whole display nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses. Available with the app switcher at the bottom or as a popup. Full-panel windows lose a sliver at the edges.",
"Moves the whole display nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses. Available with the app switcher at the bottom or as a popup; not applied in the Full Screen display mode, whose windows reach the display's edges.",
});
/**
@@ -443,7 +478,7 @@ export const statusBarPositionSetting = new ConfigSettingEnum<StatusBarPosition>
formatValue: (value) => value === "top" ? "Top"
: appSwitcherPositionSetting.get() === "bottom" ? "With app switcher" : "Bottom",
description:
"Where the clock, notification icons, app widgets and battery indicators go. With the app switcher at the bottom, With app switcher puts them at the right end of its row, and windows grow into the top bar's space; with a popup app switcher, Bottom puts them under the window. Available with the app switcher at the bottom or as a popup; with a bottom app switcher, the full-panel display mode keeps the top bar. Changing it reopens open apps in the new size.",
"Where the clock, notification icons, app widgets and battery indicators go. With the app switcher at the bottom, With app switcher puts them at the right end of its row, and windows grow into the top bar's space; with a popup app switcher, Bottom puts them under the window. Available with the app switcher at the bottom or as a popup. Changing it reopens open apps in the new size.",
});
/**
@@ -629,60 +664,41 @@ export const watchMirrorAssistantSetting = new ConfigSettingBoolean({
description: "Stream assistant replies and on-glasses alerts to the watch so they can be read from the wrist.",
});
export type VerticalPosition = "top" | "upper" | "middle" | "lower" | "bottom";
/**
* A per-app display mode (Navigate, Terminal): the global one ("global"),
* Terminal's own default ("default": tall sessions, the sessions list at
* the global mode), or a mode of its own.
*/
export type AppDisplayLayout = "default" | "global" | DisplayLayout;
const VERTICAL_POSITION_LABELS: Record<VerticalPosition, string> = {
top: "Top",
upper: "Upper",
middle: "Middle",
lower: "Lower",
bottom: "Bottom",
};
function legacyAppDisplayLayout(appId: string, defaultValue: AppDisplayLayout): AppDisplayLayout {
const mode = getStringSetting(`${appId}.displayMode`, defaultValue);
const position = getStringSetting(`${appId}.verticalPosition`, "global");
if (LEGACY_MODE_LAYOUTS[mode]) return LEGACY_MODE_LAYOUTS[mode];
const global = displayLayoutSetting.get();
if (mode === "576x288") return position === "global" ? (global.startsWith("band-") ? global : legacyDisplayLayout()) : legacyBand(position);
// Following the global mode at a band position of its own.
if (mode === "global" && position !== "global" && global.startsWith("band-")) return legacyBand(position);
return mode === "default" || mode === "global" ? mode : defaultValue;
}
export const verticalPositionSetting = new ConfigSettingEnum<VerticalPosition>({
id: "vertical-position",
label: "Vertical position",
storageKey: "display.verticalPosition",
defaultValue: "middle",
values: ["top", "upper", "middle", "lower", "bottom"],
formatValue: (value) => VERTICAL_POSITION_LABELS[value] ?? value,
description:
"Where standard (reduced-height) windows sit vertically within the display area, to position them within your field of view. Full-height windows use the whole screen. Navigate and Terminal can override these display settings.",
});
/** Per-app layouts can inherit the display preferences or choose their own size. */
export type AppDisplayMode = "default" | "global" | DisplayModeSetting;
function appDisplayModeSetting(appId: string, defaultValue: AppDisplayMode): ConfigSettingEnum<AppDisplayMode> {
return new ConfigSettingEnum<AppDisplayMode>({
function appDisplayLayoutSetting(appId: string, defaultValue: AppDisplayLayout): ConfigSettingEnum<AppDisplayLayout> {
return new ConfigSettingEnumWithLegacy<AppDisplayLayout>({
id: `${appId}-display-mode`,
label: "Display mode",
storageKey: `${appId}.displayMode`,
storageKey: `${appId}.displayLayout`,
defaultValue,
values: appId === "terminal" ? ["default", "global", ...DISPLAY_MODE_VALUES] : ["global", ...DISPLAY_MODE_VALUES],
formatValue: (value) => value === "default" ? "Tall sessions (default)" : value === "global" ? "Use global" : displayModeLabel(value),
values: appId === "terminal" ? ["default", "global", ...DISPLAY_LAYOUT_VALUES] : ["global", ...DISPLAY_LAYOUT_VALUES],
formatValue: (value) => value === "default" ? "Tall sessions (default)" : value === "global" ? "Use global" : displayLayoutLabel(value),
isDisabled: (value) => value === "fullscreen" && !fullScreenAvailable(),
description: appId === "terminal"
? "Screen size for Terminal. The default keeps session windows tall and the terminals list at the global size. Use global follows Display settings for all Terminal windows. Resizing an open session reconnects its view at the new size."
: "Screen size for Navigate. Choose Band to leave more of your field of view clear, or Use global to follow Display settings. Applies to the current route too.",
});
? "Display mode for Terminal. The default keeps session windows tall and the terminals list in the global mode. Use global follows Display settings for all Terminal windows. Resizing an open session reconnects its view at the new size."
: "Display mode for Navigate. Choose a Band to leave more of your field of view clear, or Use global to follow Display settings. Applies to the current route too.",
}, () => legacyAppDisplayLayout(appId, defaultValue));
}
function appVerticalPositionSetting(appId: string): ConfigSettingEnum<"global" | VerticalPosition> {
return new ConfigSettingEnum<"global" | VerticalPosition>({
id: `${appId}-vertical-position`,
label: "Vertical position",
storageKey: `${appId}.verticalPosition`,
defaultValue: "global",
values: ["global", "top", "upper", "middle", "lower", "bottom"],
formatValue: (value) => value === "global" ? "Use global" : VERTICAL_POSITION_LABELS[value],
description: "Where reduced-height windows for this app sit in your field of view. Use global follows Display settings. Full-height windows fill the display vertically.",
});
}
export const navigateDisplayModeSetting = appDisplayModeSetting("navigate", "global");
export const navigateVerticalPositionSetting = appVerticalPositionSetting("navigate");
export const terminalDisplayModeSetting = appDisplayModeSetting("terminal", "default");
export const terminalVerticalPositionSetting = appVerticalPositionSetting("terminal");
export const navigateDisplayLayoutSetting = appDisplayLayoutSetting("navigate", "global");
export const terminalDisplayLayoutSetting = appDisplayLayoutSetting("terminal", "default");
export type { DataCollectionLevel };
+4 -7
View File
@@ -51,7 +51,7 @@ import {
phoneBatteryVisibilitySetting,
ringBatteryVisibilitySetting,
watchBatteryVisibilitySetting,
displayModeSetting,
displayLayoutSetting,
elevenLabsApiKeySetting,
mapboxApiKeySetting,
mirrorTouchSetting,
@@ -72,7 +72,6 @@ import {
timeFormatSetting,
toggleSettingMenuItem,
useMicControlSetting,
verticalPositionSetting,
voiceProviderSetting,
screenTimeoutSetting,
wakeWordActionSetting,
@@ -106,11 +105,9 @@ function settingsSections(): SettingsSection[] {
},
}),
toggleSettingMenuItem(lockScreenEnabledSetting),
// Where min-height windows (and the sidebar) sit vertically on the
// screen; the dashboard controller repositions surfaces on change.
enumSettingMenuItem(verticalPositionSetting),
// Band / tall / full-panel; the dashboard controller reflows windows.
enumSettingMenuItem(displayModeSetting),
// A band (at one of five heights) / Tall / Full Screen; the
// dashboard controller moves or reflows windows on change.
enumSettingMenuItem(displayLayoutSetting),
],
},
{
+8 -8
View File
@@ -27,7 +27,7 @@ import { scrollToKeepSelectionVisible } from "../menu";
import { lineStep } from "../metrics";
import {
appViewportRect,
isFullscreen,
isImmersive,
MIN_WINDOW_HEIGHT,
minWindowTop,
SHELL_OPAQUE_BLACK,
@@ -251,7 +251,7 @@ export function sidebarContentSpan(windowCount: number): { left: number; right:
/**
* Horizontal extent of the top bar: the foreground window's, short of a side
* strip overlaid on it (full-panel mode, sidebar focused).
* strip overlaid on it (an immersive window, sidebar focused).
*/
function topBarSpan(state: ShellChromeState): { left: number; right: number } {
const viewport = appViewportRect(state.foregroundHeightMode, state.foregroundAppId);
@@ -276,7 +276,7 @@ type StatusBarPlacement = { left: number; right: number; top: number; contentTop
/**
* The status bar's placement for the foreground window, or null when it
* isn't drawn as a bar: when the window is fullscreen, when it shares a
* isn't drawn as a bar: when the window is immersive, when it shares a
* bottom switcher row, or when it overlays the window (geometry.ts
* statusBarOverlays) and the popup switcher isn't up. An overlaying bar
* sits inside a window frame, whose side runs along its outer row, so it
@@ -284,7 +284,7 @@ type StatusBarPlacement = { left: number; right: number; top: number; contentTop
*/
function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null {
const appId = state.foregroundAppId;
if (isFullscreen(appId) || statusInSwitcherRow(appId)) return null;
if (isImmersive(appId) || statusInSwitcherRow(appId)) return null;
const overlays = statusBarOverlays();
if (overlays && !sidebarStripVisible(state.focus, appId)) return null;
const { left, right } = topBarSpan(state);
@@ -433,9 +433,9 @@ export class ShellChromeLayer implements Layer {
this.notificationEntries = [];
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
const popup = switcherPosition() === "popup";
// Full-panel mode: the strip is an overlay, present only while the user
// is in it (the window underneath keeps its full width the rest of the
// time); a popup only ever shows then.
// Over an immersive window the strip is an overlay, present only while
// the user is in it (the window underneath keeps the whole panel the
// rest of the time); a popup only ever shows then.
const switcherShown = sidebarStripVisible(state.focus, state.foregroundAppId);
if (switcherShown && !popup) {
this.drawSidebar(image, state, statusInRow ? image : undefined);
@@ -744,7 +744,7 @@ export class ShellChromeLayer implements Layer {
// edge of the foreground window's band, wherever its height mode puts
// that (screen top for max height). It moves when the foreground
// switches to a window of a different height. It spans the app viewport;
// with a side strip overlaid (full-panel mode, sidebar focused) it still
// with a side strip overlaid (an immersive window, sidebar focused) it still
// stops at the strip.
const { left: barLeft, right: barRight } = bar;
image.fillRect(barLeft, bar.top, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
+94 -86
View File
@@ -2,13 +2,10 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../../graphics/image";
import {
appSwitcherPositionSetting,
type AppSwitcherPosition,
displayModeSetting,
type DisplayModeSetting,
verticalPositionSetting,
navigateDisplayModeSetting,
navigateVerticalPositionSetting,
terminalDisplayModeSetting,
terminalVerticalPositionSetting,
displayLayoutSetting,
type DisplayLayout,
navigateDisplayLayoutSetting,
terminalDisplayLayoutSetting,
statusBarPositionSetting,
statusBarVisibilitySetting,
uiDepthSetting,
@@ -21,9 +18,10 @@ export const TOP_BAR_HEIGHT = 28;
* Width of the sidebar strip as painted (the app switcher on the left or
* right edge). App windows get the other 576px — the surface width EvenHub
* apps expect — and keep that width with the switcher at the bottom or a
* popup too, except in the full-panel display mode, where the switcher
* overlays the app (see sidebarWidth). Icon column layout within the strip
* (one wide column vs. two narrow ones) is the chrome layer's business.
* popup too, except in the Full Screen display mode (640 wide; never beside
* a strip) and immersive windows, which the switcher overlays (see
* sidebarWidth). Icon column layout within the strip (one wide column vs.
* two narrow ones) is the chrome layer's business.
*/
export const SIDEBAR_WIDTH = 64;
@@ -34,7 +32,8 @@ export const SIDEBAR_WIDTH = 64;
* two-column icons. It comes out of the height available to windows; their
* width stays 576, centred, leaving SIDEBAR_WIDTH / 2 at each side: one
* pixel for the side of the window's frame (windowFramed), the rest for the
* whole display's stereo shift (uiDepth).
* whole display's stereo shift (uiDepth). Full Screen windows take those
* margins too, giving up both.
*/
export const SWITCHER_ROW_HEIGHT = 36;
@@ -49,72 +48,89 @@ function sideStrip(): boolean {
return position === "left" || position === "right";
}
/** The Display > Display mode setting (see dashboard-settings.ts). */
function appDisplayMode(appId?: string) {
return appId === "navigate" ? navigateDisplayModeSetting.get()
: appId === "terminal" ? terminalDisplayModeSetting.get() : "default";
}
export function displayMode(appId?: string): DisplayModeSetting {
const mode = appDisplayMode(appId);
return mode === "global" || mode === "default" ? displayModeSetting.get() : mode;
/** An app's own Display mode setting (Navigate, Terminal); "default" for the rest. */
function appDisplayLayout(appId?: string) {
return appId === "navigate" ? navigateDisplayLayoutSetting.get()
: appId === "terminal" ? terminalDisplayLayoutSetting.get() : "default";
}
/**
* Apps whose windows are fullscreen right now: the whole panel, with no
* status bar, window frame or room kept for the switcher (which overlays
* them only while it has focus, as in the full-panel mode), at depth 0. An
* app switches it at runtime (InProcessWindow.setFullscreen; the onboarding's
* first pages), so it is per app, like the per-app display modes.
* The display mode an app's windows use (see dashboard-settings.ts
* DisplayLayout): its own, or the global one. Full Screen needs the width a
* side strip takes, so beside one it is Tall.
*/
const fullscreenApps = new Set<string>();
export function displayLayout(appId?: string): DisplayLayout {
const own = appDisplayLayout(appId);
const layout = own === "global" || own === "default" ? displayLayoutSetting.get() : own;
return layout === "fullscreen" && sideStrip() ? "tall" : layout;
}
/** Mark an app's windows fullscreen or not; true if that changed anything. */
export function setAppFullscreen(appId: string, fullscreen: boolean): boolean {
if (fullscreenApps.has(appId) === fullscreen) return false;
if (fullscreen) fullscreenApps.add(appId);
else fullscreenApps.delete(appId);
/** Fraction of the slack above a window band in each band display mode. */
const BAND_FRACTIONS: Partial<Record<DisplayLayout, number>> = {
"band-top": 0,
"band-high": 0.25,
"band-middle": 0.5,
"band-low": 0.75,
"band-bottom": 1,
};
/** A band display mode's fraction of the slack above the band; undefined for Tall and Full Screen. */
function bandFraction(layout: DisplayLayout): number | undefined {
return BAND_FRACTIONS[layout];
}
/**
* Apps whose windows are immersive right now: the whole panel, with no
* status bar, window frame or room kept for the switcher (which overlays
* them only while it has focus), at depth 0. An app switches it at runtime
* (InProcessWindow.setImmersive; the onboarding's first pages), so it is
* per app, like the per-app display modes.
*/
const immersiveApps = new Set<string>();
/** Mark an app's windows immersive or not; true if that changed anything. */
export function setAppImmersive(appId: string, immersive: boolean): boolean {
if (immersiveApps.has(appId) === immersive) return false;
if (immersive) immersiveApps.add(appId);
else immersiveApps.delete(appId);
return true;
}
export function isFullscreen(appId?: string): boolean {
return appId !== undefined && fullscreenApps.has(appId);
export function isImmersive(appId?: string): boolean {
return appId !== undefined && immersiveApps.has(appId);
}
/**
* The full-panel mode (or a fullscreen app): windows fill the panel; the
* switcher overlays them only while it has focus.
*/
function fullPanel(appId?: string): boolean {
return isFullscreen(appId) || displayMode(appId) === "640x480";
/** Whether an app's windows span the panel's whole width: Full Screen, or immersive. */
function fullWidth(appId?: string): boolean {
return isImmersive(appId) || displayLayout(appId) === "fullscreen";
}
/**
* How much of the screen's width the sidebar takes away from app windows:
* the strip, or nothing when the switcher is a bottom row or a popup or in
* the full-panel mode (where the chrome paints the strip over the window
* the strip, or nothing when the switcher is a bottom row or a popup or the
* window is immersive (where the chrome paints the strip over the window
* while the sidebar has focus).
*/
export function sidebarWidth(appId?: string): number {
return !fullPanel(appId) && sideStrip() ? SIDEBAR_WIDTH : 0;
return !isImmersive(appId) && sideStrip() ? SIDEBAR_WIDTH : 0;
}
/**
* How much of the screen's height a bottom switcher row takes away from app
* windows: the row, or nothing beside a side strip or in the full-panel mode
* (where the row overlays the window's bottom edge while it has focus).
* windows: the row, or nothing beside a side strip or under an immersive
* window (where the row overlays the window's bottom edge while it has
* focus).
*/
export function switcherRowHeight(appId?: string): number {
return !fullPanel(appId) && switcherPosition() === "bottom" ? SWITCHER_ROW_HEIGHT : 0;
return !isImmersive(appId) && switcherPosition() === "bottom" ? SWITCHER_ROW_HEIGHT : 0;
}
/**
* Whether the switcher is on screen: always when it reserves room; as a
* popup, or in the full-panel mode (where it overlays the window), only
* while it has focus.
* popup, or over an immersive window, only while it has focus.
*/
export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string): boolean {
return (!fullPanel(appId) && switcherPosition() !== "popup") || focus === "sidebar";
return (!isImmersive(appId) && switcherPosition() !== "popup") || focus === "sidebar";
}
/**
@@ -122,8 +138,8 @@ export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string)
* band (like the shell overlays). A bottom row sits right under the given
* (foreground) window and spans its width, so a band shorter than the
* screen has no gap below it; it moves when the foreground switches to a
* window of another height, as the top bar does. In the full-panel mode the
* row overlays the bottom edge of the screen. A popup's is the area it
* window of another height, as the top bar does. Over an immersive window
* the row overlays the bottom edge of the screen. A popup's is the area it
* centres in, the foreground window's content (the chrome layer sizes the
* box itself).
*/
@@ -150,9 +166,9 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
/**
* Whether the foreground window's content gets a rounded frame (drawn by
* the chrome layer). Its left and right sides take the pixel just outside
* the 576-wide window; there's no room in the full-panel mode, nor need
* beside a side strip. With a reserved bottom switcher row it always has
* one: the row's top edge is the frame's bottom side, as the window
* the 576-wide window; there's no room around a Full Screen or immersive
* window, nor need beside a side strip. With a reserved bottom switcher row
* it otherwise always has one: the row's top edge is the frame's bottom side, as the window
* header's last row is its top. With a popup switcher it's the Window
* border setting's choice, and its top and bottom take a header or footer
* row of their own, except where the status bar's row next to the window
@@ -161,9 +177,9 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
export function windowFramed(appId?: string): boolean {
switch (switcherPosition()) {
case "bottom":
return switcherRowHeight(appId) > 0;
return switcherRowHeight(appId) > 0 && !fullWidth(appId);
case "popup":
return !fullPanel(appId) && windowBorderSetting.get();
return !fullWidth(appId) && windowBorderSetting.get();
default:
return false;
}
@@ -172,7 +188,8 @@ export function windowFramed(appId?: string): boolean {
/**
* Whether the status bar shares the bottom switcher row instead of topping
* each window (Settings > Customization > Status bar position): only beside
* a reserved row, as the full-panel mode's row shows just while it has focus.
* a reserved row, as the row over an immersive window shows just while it
* has focus.
*/
export function statusInSwitcherRow(appId?: string): boolean {
return switcherRowHeight(appId) > 0 && statusBarPositionSetting.get() === "bottom";
@@ -200,12 +217,13 @@ export function statusBarOverlays(): boolean {
* Rows the shell draws along one edge of each window's content: the status
* bar's (the top bar, as a header), the frame's side, or none. A bottom
* switcher row's band has no footer: the frame's bottom side is the row's
* top edge. A fullscreen window has neither.
* top edge. An immersive window has neither.
*/
function windowEdgeHeight(edge: "top" | "bottom", appId?: string): number {
if (isFullscreen(appId)) return 0;
if (isImmersive(appId)) return 0;
if (switcherPosition() !== "popup") {
return edge === "bottom" ? 0 : statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
if (edge === "bottom") return 0;
return !statusInSwitcherRow(appId) ? TOP_BAR_HEIGHT : windowFramed(appId) ? 1 : 0;
}
if (!statusBarOverlays() && statusBarEdge() === edge) return TOP_BAR_HEIGHT;
return windowFramed(appId) ? 1 : 0;
@@ -258,9 +276,9 @@ export function isOnSwitcherEdge(x: number, y: number, heightMode: WindowHeightM
}
}
/** Width of app windows: the panel's in the full-panel mode, else 576 (see SIDEBAR_WIDTH). */
/** Width of app windows: the panel's when Full Screen or immersive, else 576 (see SIDEBAR_WIDTH). */
function appViewportWidth(appId?: string): number {
return fullPanel(appId) ? G2_LENS_WIDTH : G2_LENS_WIDTH - SIDEBAR_WIDTH;
return fullWidth(appId) ? G2_LENS_WIDTH : G2_LENS_WIDTH - SIDEBAR_WIDTH;
}
/**
@@ -269,7 +287,7 @@ function appViewportWidth(appId?: string): number {
* edge.
*/
export function appViewportLeft(appId?: string): number {
if (fullPanel(appId)) return 0;
if (fullWidth(appId)) return 0;
switch (switcherPosition()) {
case "left":
return SIDEBAR_WIDTH;
@@ -287,20 +305,22 @@ export function appViewportLeft(appId?: string): number {
* which shifts the screen and everything drawn over it per lens. Only with
* the switcher at the bottom or a popup, where the windows' side margins,
* less the window frame's pixel, leave room for the shift; not while the
* given (foreground) app is fullscreen, which has no margins.
* given (foreground) app's windows are Full Screen or immersive, which have
* no margins.
*/
export function uiDepth(appId?: string): number {
return sideStrip() || isFullscreen(appId) ? 0 : Number(uiDepthSetting.get());
return sideStrip() || fullWidth(appId) ? 0 : Number(uiDepthSetting.get());
}
/**
* Explicit app sizes (including Use global) replace the requested height.
* The default keeps legacy per-window heights, such as tall terminal sessions.
* A fullscreen app is always the whole height.
* In a band display mode, explicit app modes (including Use global) replace
* the requested height; the default keeps legacy per-window heights, such
* as tall terminal sessions. Tall, Full Screen and immersive windows are
* always the whole height.
*/
export function effectiveHeightMode(mode: WindowHeightMode, appId?: string): WindowHeightMode {
if (isFullscreen(appId)) return "max";
return displayMode(appId) === "576x288" ? (appDisplayMode(appId) === "default" ? mode : "min") : "max";
if (isImmersive(appId) || bandFraction(displayLayout(appId)) === undefined) return "max";
return appDisplayLayout(appId) === "default" ? mode : "min";
}
/**
@@ -355,25 +375,13 @@ export function windowBandHeight(mode: WindowHeightMode, appId?: string): number
}
/**
* Fraction of the slack above a window band, from the Display > Vertical
* position setting: each band height distributes its own free space by the
* same fraction, so all heights sit consistently within the screen.
* Fraction of the slack above a window band, from the band display mode's
* position: each band height distributes its own free space by the same
* fraction, so all heights sit consistently within the screen. Tall and
* Full Screen windows leave no slack.
*/
function verticalPositionFraction(appId?: string): number {
const position = appId === "navigate" ? navigateVerticalPositionSetting.get()
: appId === "terminal" ? terminalVerticalPositionSetting.get() : "global";
switch (position === "global" ? verticalPositionSetting.get() : position) {
case "top":
return 0;
case "upper":
return 0.25;
case "lower":
return 0.75;
case "bottom":
return 1;
default:
return 0.5;
}
return bandFraction(displayLayout(appId)) ?? 0.5;
}
/**
+11 -11
View File
@@ -8,7 +8,7 @@ import { type MenuItem } from "../menu";
import { WindowMenuLayer } from "../window-menu";
import { windowIcon } from "./chrome-layer";
import { type IconName } from "../../graphics/icons";
import { appViewportSize, setAppFullscreen, type WindowHeightMode } from "./geometry";
import { appViewportSize, setAppImmersive, type WindowHeightMode } from "./geometry";
import { shell, type ShellWindow } from "./shell";
/**
@@ -30,8 +30,8 @@ export type InProcessWindowOptions = {
closeable: boolean;
/** Window height: the standard 288px band ("min", default) or full screen ("max"). */
heightMode?: WindowHeightMode;
/** Open fullscreen: the whole panel, without the status bar (see geometry.ts isFullscreen). */
fullscreen?: boolean;
/** Open immersive: the whole panel, without the status bar (see geometry.ts isImmersive). */
immersive?: boolean;
/**
* The window's tap-then-hold context menu: app-specific entries only (the
* shared Focus app switcher / Voice input / Close window entries live in
@@ -76,11 +76,11 @@ export type InProcessWindow = {
/** Change the window's height band at runtime (resizes the viewport + surface). */
setHeightMode: (mode: WindowHeightMode) => void;
/**
* Enter or leave fullscreen at runtime (resizes the viewport + surface).
* It is per app (geometry.ts isFullscreen), so an app with several
* Enter or leave immersive mode at runtime (resizes the viewport +
* surface). It is per app (geometry.ts isImmersive), so an app with several
* windows switches them all.
*/
setFullscreen: (fullscreen: boolean) => void;
setImmersive: (immersive: boolean) => void;
};
/** The controller-provided plumbing common to every in-process app window. */
@@ -110,7 +110,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
// Handed to app code as a bare callback, so it takes no arguments.
const requestRender = () => renderInNewFrame(0);
let heightMode = options.heightMode ?? "min";
setAppFullscreen(options.appId, options.fullscreen ?? false);
setAppImmersive(options.appId, options.immersive ?? false);
const viewportSize = () => appViewportSize(heightMode, options.appId);
const stack = new LayerStack(
options.baseLayer,
@@ -182,7 +182,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
hasAppMenu: () => appMenuItems().length > 0,
close: () => {
closed = true;
setAppFullscreen(options.appId, false);
setAppImmersive(options.appId, false);
// Fire onRemoved for any pushed layers so they release resources (e.g. a
// demo that enabled a hardware stream) even when closed from within.
stack.clearToBase();
@@ -248,10 +248,10 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
window.heightMode = mode;
resize();
};
const setFullscreen = (fullscreen: boolean) => {
if (!closed && setAppFullscreen(options.appId, fullscreen)) resize();
const setImmersive = (immersive: boolean) => {
if (!closed && setAppImmersive(options.appId, immersive)) resize();
};
return { window, stack, requestRender, setHeightMode, setFullscreen };
return { window, stack, requestRender, setHeightMode, setImmersive };
}
/**
+2 -2
View File
@@ -271,7 +271,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
// Aligned to the min-height window band (like the sidebar), wherever the
// vertical position setting currently puts it; centered over the
// application area, i.e. the part of the screen beside a side strip
// (the whole width with a bottom row, or in the full-panel mode, where
// (the whole width with a bottom row, or over an immersive window, where
// the strip overlays).
const width = 272;
const area = appViewportRect("min");
@@ -832,7 +832,7 @@ class Shell {
/**
* Paint the shell surface: transparent chrome, or all-transparent when
* asleep. The scene also carries the whole display's stereo depth (none
* under a fullscreen window).
* under a Full Screen or immersive window).
*/
paintScene(): Uint8Array {
return this.screenOn
+1 -1
View File
@@ -271,7 +271,7 @@ function shellEnv({ wakeAction = 'voice-input', skipConfirmation = false } = {})
'../../graphics/image': images, '../../native/frame-timings': timings,
'../../util/render-freshness': { beginRenderPass() {}, endRenderPass: () => false },
'../layers': layers, '../window-menu': { WindowMenuLayer: Menu },
'./chrome-layer': { windowIcon: () => () => null }, './geometry': { appViewportSize: () => ({ width: 576, height: 260 }), setAppFullscreen: () => false },
'./chrome-layer': { windowIcon: () => () => null }, './geometry': { appViewportSize: () => ({ width: 576, height: 260 }), setAppImmersive: () => false },
'./shell': { shell },
});
const input = [], menus = [];
+111 -79
View File
@@ -11,9 +11,7 @@ const js = (source) => ts.transpileModule(source, {
function geometry() {
const settings = Object.fromEntries(Object.entries({
displayModeSetting: '576x288', verticalPositionSetting: 'middle',
navigateDisplayModeSetting: 'global', navigateVerticalPositionSetting: 'global',
terminalDisplayModeSetting: 'default', terminalVerticalPositionSetting: 'global',
displayLayoutSetting: 'band-middle', navigateDisplayLayoutSetting: 'global', terminalDisplayLayoutSetting: 'default',
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
statusBarVisibilitySetting: 'always', windowBorderSetting: true,
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
@@ -27,46 +25,79 @@ function geometry() {
return { ...context.exports, settings, rect };
}
const LAYOUTS = ['band-top', 'band-high', 'band-middle', 'band-low', 'band-bottom', 'tall', 'fullscreen'];
test('defaults preserve normal windows, EvenHub height and tall terminal sessions', () => {
const g = geometry();
assert.deepEqual(g.rect('min', 'navigate'), { x: 64, y: 124, width: 576, height: 260 });
assert.deepEqual(g.rect('min', 'terminal'), g.rect('min'));
assert.deepEqual(g.rect('max', 'terminal'), { x: 64, y: 28, width: 576, height: 452 });
assert.equal(g.windowBandHeight('medium', 'evenhub'), 316);
g.settings.displayModeSetting.value = '640x480';
assert.deepEqual(g.rect('max', 'terminal'), { x: 0, y: 28, width: 640, height: 452 });
// Tall: every window the whole height, beside the strip.
g.settings.displayLayoutSetting.value = 'tall';
assert.deepEqual(g.rect('min'), { x: 64, y: 28, width: 576, height: 452 });
});
test('Navigate can use a small bottom band while other apps fill the panel', () => {
test('Navigate can use a small bottom band while other apps are tall', () => {
const g = geometry();
g.settings.displayModeSetting.value = '640x480';
g.settings.navigateDisplayModeSetting.value = '576x288';
g.settings.navigateVerticalPositionSetting.value = 'bottom';
g.settings.displayLayoutSetting.value = 'tall';
g.settings.navigateDisplayLayoutSetting.value = 'band-bottom';
assert.deepEqual(g.rect('min', 'navigate'), { x: 64, y: 220, width: 576, height: 260 });
assert.equal(g.minWindowTop('navigate'), 192);
assert.equal(g.sidebarStripVisible('window', 'navigate'), true);
assert.equal(g.sidebarStripVisible('window', 'other'), false);
assert.deepEqual(g.rect('min', 'other'), { x: 0, y: 28, width: 640, height: 452 });
assert.deepEqual(g.rect('min', 'other'), { x: 64, y: 28, width: 576, height: 452 });
});
test('Terminal can disable its tall default, inherit position or override both dimensions', () => {
test('Terminal can disable its tall default, follow the global band or choose a mode of its own', () => {
const g = geometry();
g.settings.terminalDisplayModeSetting.value = 'global';
g.settings.terminalDisplayLayoutSetting.value = 'global';
assert.deepEqual(g.rect('max', 'terminal'), g.rect('min'));
g.settings.verticalPositionSetting.value = 'top';
g.settings.displayLayoutSetting.value = 'band-top';
assert.equal(g.windowTop('max', 'terminal'), 0);
g.settings.terminalVerticalPositionSetting.value = 'lower';
g.settings.terminalDisplayLayoutSetting.value = 'band-low';
assert.equal(g.windowTop('max', 'terminal'), 144);
g.settings.terminalDisplayModeSetting.value = '640x480';
assert.deepEqual(g.rect('max', 'terminal'), { x: 0, y: 28, width: 640, height: 452 });
assert.equal(g.sidebarStripVisible('window', 'terminal'), false);
assert.equal(g.sidebarStripVisible('sidebar', 'terminal'), true);
g.settings.terminalDisplayModeSetting.value = '576x480';
g.settings.terminalDisplayLayoutSetting.value = 'tall';
assert.deepEqual(g.rect('min', 'terminal'), { x: 64, y: 28, width: 576, height: 452 });
// The default keeps sessions tall and the sessions list in the global band.
g.settings.terminalDisplayLayoutSetting.value = 'default';
assert.deepEqual(g.rect('max', 'terminal'), { x: 64, y: 28, width: 576, height: 452 });
assert.equal(g.windowTop('min', 'terminal'), 0);
});
test('all explicit size/position combinations stay within the display and align content below the bar', () => {
test('Full Screen widens Tall windows to the panel and drops depth, beside a bottom row or popup only', () => {
const g = geometry();
g.settings.displayLayoutSetting.value = 'fullscreen';
g.settings.uiDepthSetting.value = '48';
// A side strip leaves no width to spare: there it is Tall.
assert.equal(g.displayLayout(), 'tall');
assert.deepEqual(g.rect('min'), { x: 64, y: 28, width: 576, height: 452 });
g.settings.appSwitcherPositionSetting.value = 'bottom';
assert.equal(g.displayLayout(), 'fullscreen');
// Tall's height and the panel's width, the row still reserved under it,
// always shown; no room for a frame, nor for depth.
assert.deepEqual(g.rect('min'), { x: 0, y: 28, width: 640, height: 416 });
assert.deepEqual({ ...g.switcherRect('min') }, { x: 0, y: 444, width: 640, height: 36 });
assert.equal(g.sidebarStripVisible('window'), true);
assert.equal(g.windowFramed(), false);
assert.equal(g.uiDepth(), 0);
// With the status bar in the row, there's no frame top for a header either.
g.settings.statusBarPositionSetting.value = 'bottom';
assert.equal(g.statusInSwitcherRow(), true);
assert.deepEqual(g.rect('min'), { x: 0, y: 0, width: 640, height: 444 });
// A popup's status bar keeps its edge.
g.settings.appSwitcherPositionSetting.value = 'popup';
assert.deepEqual(g.rect('max'), { x: 0, y: 0, width: 640, height: 452 });
assert.equal(g.statusBarTop('max'), 452);
assert.equal(g.windowFramed(), false);
// Per app: depth follows the foreground app's mode.
g.settings.displayLayoutSetting.value = 'band-middle';
g.settings.navigateDisplayLayoutSetting.value = 'fullscreen';
assert.deepEqual([g.uiDepth('navigate'), g.uiDepth('launcher'), g.uiDepth()], [0, 48, 48]);
assert.deepEqual([g.rect('min', 'navigate').width, g.rect('min', 'launcher').width], [640, 576]);
});
test('all display modes and layouts stay within the display and align content below the bar', () => {
const g = geometry();
g.settings.uiDepthSetting.value = '48';
const combos = [['left', 'top'], ['right', 'top'], ['bottom', 'top'], ['bottom', 'bottom'], ['left', 'bottom']];
for (const statusBar of ['top', 'bottom']) {
for (const visibility of ['always', 'switcher']) {
@@ -78,42 +109,43 @@ test('all explicit size/position combinations stay within the display and align
g.settings.statusBarPositionSetting.value = statusBar;
g.settings.statusBarVisibilitySetting.value = visibility;
g.settings.windowBorderSetting.value = border;
for (const globalMode of ['576x288', '576x480', '640x480']) {
g.settings.displayModeSetting.value = globalMode;
const side = switcher === 'left' || switcher === 'right';
for (const globalMode of LAYOUTS) {
g.settings.displayLayoutSetting.value = globalMode;
for (const appId of ['navigate', 'terminal']) {
for (const mode of ['global', '576x288', '576x480', '640x480']) {
g.settings[`${appId}DisplayModeSetting`].value = mode;
for (const position of ['global', 'top', 'upper', 'middle', 'lower', 'bottom']) {
g.settings[`${appId}VerticalPositionSetting`].value = position;
for (const heightMode of ['min', 'medium', 'max']) {
const rect = g.rect(heightMode, appId);
const fullPanel = g.displayMode(appId) === '640x480';
assert.equal(rect.x + rect.width, fullPanel ? 640 : { left: 640, right: 576, bottom: 608, popup: 608 }[switcher]);
const header = g.windowHeaderHeight(appId), footer = g.windowFooterHeight(appId);
assert.equal(g.statusInSwitcherRow(appId), statusBar === 'bottom' && g.switcherRowHeight(appId) > 0);
if (switcher === 'popup') {
// Each edge has the status bar's rows (unless it only
// overlays), else the frame's side, else nothing.
assert.equal(g.windowFramed(appId), border && !fullPanel);
const edge = (side) => visibility === 'always' && statusBar === side ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0;
assert.deepEqual([header, footer], [edge('top'), edge('bottom')]);
// The status bar's rows lie within the band, at its edge.
const top = g.windowTop(heightMode, appId), band = g.windowBandHeight(heightMode, appId);
assert.equal(g.statusBarTop(heightMode, appId), statusBar === 'top' ? top : top + band - g.TOP_BAR_HEIGHT);
} else {
assert.deepEqual([header, footer], [g.statusInSwitcherRow(appId) ? 1 : g.TOP_BAR_HEIGHT, 0]);
}
assert.equal(rect.y, g.windowTop(heightMode, appId) + header);
assert.equal(rect.height + header + footer, g.windowBandHeight(heightMode, appId));
assert.ok(rect.y >= header && rect.y + rect.height + footer <= 480 - g.switcherRowHeight(appId));
const row = g.switcherRect(heightMode, appId);
assert.ok(row.y + row.height <= 480);
// A reserved bottom row hangs right under the window, as wide as it.
if (g.switcherRowHeight(appId)) assert.deepEqual([row.x, row.y, row.width], [rect.x, rect.y + rect.height, rect.width]);
// The frame's sides, just outside the window, survive the
// deepest shift (±62 moves each lens 31px).
if (g.windowFramed(appId)) assert.ok(rect.x - 1 - 31 >= 0 && rect.x + rect.width + 31 < 640);
for (const mode of ['default', 'global', ...LAYOUTS]) {
g.settings[`${appId}DisplayLayoutSetting`].value = mode;
const wide = g.displayLayout(appId) === 'fullscreen';
if (wide) assert.equal(side, false, 'Full Screen only beside a bottom row or popup');
assert.equal(g.uiDepth(appId), side || wide ? 0 : 48);
for (const heightMode of ['min', 'medium', 'max']) {
const rect = g.rect(heightMode, appId);
assert.equal(rect.x + rect.width, wide ? 640 : { left: 640, right: 576, bottom: 608, popup: 608 }[switcher]);
const header = g.windowHeaderHeight(appId), footer = g.windowFooterHeight(appId);
assert.equal(g.statusInSwitcherRow(appId), statusBar === 'bottom' && g.switcherRowHeight(appId) > 0);
if (switcher === 'popup') {
// Each edge has the status bar's rows (unless it only
// overlays), else the frame's side, else nothing.
assert.equal(g.windowFramed(appId), border && !wide);
const edge = (side) => visibility === 'always' && statusBar === side ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0;
assert.deepEqual([header, footer], [edge('top'), edge('bottom')]);
// The status bar's rows lie within the band, at its edge.
const top = g.windowTop(heightMode, appId), band = g.windowBandHeight(heightMode, appId);
assert.equal(g.statusBarTop(heightMode, appId), statusBar === 'top' ? top : top + band - g.TOP_BAR_HEIGHT);
} else {
assert.equal(g.windowFramed(appId), switcher === 'bottom' && !wide);
assert.deepEqual([header, footer], [!g.statusInSwitcherRow(appId) ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0, 0]);
}
assert.equal(rect.y, g.windowTop(heightMode, appId) + header);
assert.equal(rect.height + header + footer, g.windowBandHeight(heightMode, appId));
assert.ok(rect.y >= header && rect.y + rect.height + footer <= 480 - g.switcherRowHeight(appId));
const row = g.switcherRect(heightMode, appId);
assert.ok(row.y + row.height <= 480);
// A reserved bottom row hangs right under the window, as wide as it.
if (g.switcherRowHeight(appId)) assert.deepEqual([row.x, row.y, row.width], [rect.x, rect.y + rect.height, rect.width]);
// The frame's sides, just outside the window, survive the
// deepest shift (±62 moves each lens 31px).
if (g.windowFramed(appId)) assert.ok(rect.x - 1 - 31 >= 0 && rect.x + rect.width + 31 < 640);
}
}
}
@@ -133,8 +165,9 @@ test('the app switcher can sit on the right edge', () => {
// Depth needs the bottom row's side margins.
g.settings.uiDepthSetting.value = '32';
assert.equal(g.uiDepth(), 0);
g.settings.displayModeSetting.value = '640x480';
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
// Full Screen needs the width a strip takes: beside one it is Tall.
g.settings.displayLayoutSetting.value = 'fullscreen';
assert.deepEqual(g.rect('min'), { x: 0, y: 28, width: 576, height: 452 });
});
test('a popup app switcher centres 576-wide windows, whose edges the status bar and frame decide', () => {
@@ -167,10 +200,10 @@ test('a popup app switcher centres 576-wide windows, whose edges the status bar
assert.equal(g.windowFramed(), false);
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 0, width: 576, height: 480 });
assert.deepEqual(g.rect('medium'), { x: 32, y: 96, width: 576, height: 288 });
// Full panel: the status bar keeps its edge, but there's no room for a frame.
// Full Screen: the status bar keeps its edge, but there's no room for a frame.
g.settings.windowBorderSetting.value = true;
g.settings.statusBarVisibilitySetting.value = 'always';
g.settings.displayModeSetting.value = '640x480';
g.settings.displayLayoutSetting.value = 'fullscreen';
assert.equal(g.windowFramed(), false);
assert.deepEqual(g.rect('max'), { x: 0, y: 0, width: 640, height: 452 });
assert.equal(g.statusBarTop('max'), 452);
@@ -187,7 +220,7 @@ test('a bottom app switcher centres 576-wide windows and hangs one tall tab unde
assert.deepEqual({ ...g.switcherRect('min') }, { x: 32, y: 366, width: 576, height: 36 });
assert.equal(g.isOnSwitcherEdge(10, 370, 'min'), true);
assert.equal(g.isOnSwitcherEdge(10, 360, 'min'), false);
g.settings.verticalPositionSetting.value = 'bottom';
g.settings.displayLayoutSetting.value = 'band-bottom';
assert.equal(g.switcherRect('min').y, 444);
// The true centre is the viewport's own with the window centred.
assert.equal(g.screenCenterInViewportX(), 288);
@@ -195,28 +228,27 @@ test('a bottom app switcher centres 576-wide windows and hangs one tall tab unde
g.settings.uiDepthSetting.value = '-48';
assert.equal(g.uiDepth(), -48);
assert.equal(g.windowFramed(), true);
// Full panel: windows fill the panel and the row overlays the bottom edge while focused.
g.settings.displayModeSetting.value = '640x480';
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
// Full Screen: windows take the panel's width over the row, which stays.
g.settings.displayLayoutSetting.value = 'fullscreen';
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 416 });
assert.deepEqual({ ...g.switcherRect('max') }, { x: 0, y: 444, width: 640, height: 36 });
assert.equal(g.sidebarStripVisible('window'), false);
assert.equal(g.sidebarStripVisible('sidebar'), true);
assert.equal(g.sidebarStripVisible('window'), true);
assert.equal(g.windowFramed(), false);
});
test('a fullscreen app fills the panel without chrome rows, frame or depth, in any layout', () => {
test('an immersive app fills the panel without chrome rows, frame or depth, in any layout', () => {
const panel = { x: 0, y: 0, width: 640, height: 480 };
for (const position of ['left', 'right', 'bottom', 'popup']) {
const g = geometry();
g.settings.appSwitcherPositionSetting.value = position;
g.settings.statusBarPositionSetting.value = 'bottom';
g.settings.uiDepthSetting.value = '48';
assert.equal(g.setAppFullscreen('onboarding', true), true);
assert.equal(g.setAppFullscreen('onboarding', true), false);
assert.equal(g.setAppImmersive('onboarding', true), true);
assert.equal(g.setAppImmersive('onboarding', true), false);
for (const mode of ['min', 'medium', 'max']) assert.deepEqual(g.rect(mode, 'onboarding'), panel, position);
assert.equal(g.windowFramed('onboarding'), false);
assert.equal(g.statusInSwitcherRow('onboarding'), false);
// The switcher overlays it while focused, as in the full-panel mode.
// The switcher overlays it while focused.
assert.equal(g.sidebarStripVisible('window', 'onboarding'), false);
assert.equal(g.sidebarStripVisible('sidebar', 'onboarding'), true);
assert.equal(g.uiDepth('onboarding'), 0);
@@ -225,7 +257,7 @@ test('a fullscreen app fills the panel without chrome rows, frame or depth, in a
assert.equal(g.uiDepth('launcher'), depth);
assert.equal(g.uiDepth(), depth);
assert.notDeepEqual(g.rect('min', 'launcher'), panel);
assert.equal(g.setAppFullscreen('onboarding', false), true);
assert.equal(g.setAppImmersive('onboarding', false), true);
assert.deepEqual(g.rect('min', 'onboarding'), g.rect('min', 'launcher'));
assert.equal(g.uiDepth('onboarding'), depth);
}
@@ -318,17 +350,17 @@ test('a bottom app switcher frames the foreground window\'s content in a rounded
// The flat paint carries the same frame.
const image = chrome.paint();
assert.deepEqual(frames(image).map((d) => [d.x, d.y]), [[31, 105]]);
// No frame in the full-panel mode.
g.settings.displayModeSetting.value = '640x480';
// No frame in the Full Screen mode.
g.settings.displayLayoutSetting.value = 'fullscreen';
assert.equal(chrome.paintParts().flatMap((p) => frames(p.image)).length, 0);
});
test('over a fullscreen window the chrome draws only the switcher, and only while it has focus', () => {
test('over an immersive window the chrome draws only the switcher, and only while it has focus', () => {
for (const position of ['bottom', 'popup', 'left']) {
const g = geometry();
g.settings.appSwitcherPositionSetting.value = position;
g.settings.statusBarPositionSetting.value = position === 'left' ? 'top' : 'bottom';
g.setAppFullscreen('onboarding', true);
g.setAppImmersive('onboarding', true);
const { chrome, state } = chromeLayer(g, { windows: 2, notifications: 1 });
state.foregroundAppId = 'onboarding';
assert.equal(chrome.paintParts().length, 0, position);
@@ -396,10 +428,10 @@ test('the status bar can join a bottom app switcher, and windows grow into the t
assert.deepEqual(g.rect('medium'), { x: 32, y: 79, width: 576, height: 288 });
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 1, width: 576, height: 443 });
assert.deepEqual({ ...g.switcherRect('min') }, { x: 32, y: 366, width: 576, height: 36 });
// The full-panel mode keeps the top bar: its row shows only while focused.
g.settings.displayModeSetting.value = '640x480';
assert.equal(g.statusInSwitcherRow(), false);
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
// Full Screen keeps the row, and the status bar in it, but has no frame.
g.settings.displayLayoutSetting.value = 'fullscreen';
assert.equal(g.statusInSwitcherRow(), true);
assert.deepEqual(g.rect('max'), { x: 0, y: 0, width: 640, height: 444 });
});
test('the switcher row lays out windows, free space, notifications, widgets, batteries and the clock', () => {
+66
View File
@@ -0,0 +1,66 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs'), vm = require('node:vm'), ts = require('typescript');
// dashboard-settings.ts over an in-memory settings store (as in brightness-curve.test.cjs).
function settingsFixture(store = new Map()) {
const context = { exports: {}, global: { isIOS: false }, require: id => {
if (id.includes('settings-store')) return {
onSettingsStoreChanged() {}, getStringSetting: (k, d) => store.get(k) ?? d,
setStringSetting: (k, v) => store.set(k, v),
getBooleanSetting: (k, d) => store.get(k) ?? d, setBooleanSetting: (k, v) => store.set(k, v),
};
if (id.includes('brightness-curve')) return require('../.test-build/app/g2/brightness-curve.js');
if (id.includes('animation-speed')) return require('../.test-build/app/ui/animation-speed.js');
return { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] };
}};
vm.runInNewContext(ts.transpileModule(fs.readFileSync('app/ui/dashboard-settings.ts', 'utf8'), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
return context.exports;
}
test('the display mode starts as the middle band, or carries over the old mode and vertical position', () => {
const layout = (entries) => settingsFixture(new Map(entries)).displayLayoutSetting.get();
assert.equal(layout([]), 'band-middle');
assert.equal(layout([['display.verticalPosition', 'upper']]), 'band-high');
assert.equal(layout([['display.mode', '576x288'], ['display.verticalPosition', 'lower']]), 'band-low');
assert.equal(layout([['display.mode', '576x480'], ['display.verticalPosition', 'top']]), 'tall');
assert.equal(layout([['display.mode', '640x480']]), 'fullscreen');
// Once set, the merged setting is its own.
const store = new Map([['display.mode', '576x480']]);
const api = settingsFixture(store);
api.displayLayoutSetting.set('band-bottom');
assert.equal(store.get('display.layout'), 'band-bottom');
assert.equal(api.displayLayoutSetting.get(), 'band-bottom');
});
test('per-app display modes carry over their old mode and position where the merged values can say it', () => {
const app = (appId, entries) => settingsFixture(new Map(entries))[`${appId}DisplayLayoutSetting`].get();
assert.equal(app('navigate', []), 'global');
assert.equal(app('terminal', []), 'default');
assert.equal(app('navigate', [['navigate.displayMode', '576x288'], ['navigate.verticalPosition', 'bottom']]), 'band-bottom');
// A band at the global position takes the global band.
assert.equal(app('navigate', [['navigate.displayMode', '576x288'], ['display.verticalPosition', 'top']]), 'band-top');
assert.equal(app('navigate', [['navigate.displayMode', '576x288'], ['display.layout', 'band-low']]), 'band-low');
// Following the global band at a position of its own.
assert.equal(app('navigate', [['navigate.verticalPosition', 'top']]), 'band-top');
assert.equal(app('navigate', [['navigate.verticalPosition', 'top'], ['display.mode', '576x480']]), 'global');
assert.equal(app('terminal', [['terminal.displayMode', '640x480']]), 'fullscreen');
assert.equal(app('terminal', [['terminal.displayMode', 'global']]), 'global');
assert.equal(app('terminal', [['terminal.verticalPosition', 'lower']]), 'default');
});
test('Full Screen is offered only with a bottom or popup app switcher', () => {
const store = new Map();
const api = settingsFixture(store);
for (const [position, available] of [['left', false], ['right', false], ['bottom', true], ['popup', true]]) {
api.appSwitcherPositionSetting.set(position);
assert.equal(api.fullScreenAvailable(), available, position);
assert.equal(api.displayLayoutSetting.isDisabled('fullscreen'), !available, position);
assert.equal(api.navigateDisplayLayoutSetting.isDisabled('fullscreen'), !available, position);
assert.equal(api.displayLayoutSetting.isDisabled('tall'), false);
}
assert.deepEqual(Array.from(api.DISPLAY_LAYOUT_VALUES, (value) => api.displayLayoutLabel(value)),
['Band · Top', 'Band · High', 'Band · Middle', 'Band · Low', 'Band · Bottom', 'Tall', 'Full Screen']);
});
+1 -1
View File
@@ -182,7 +182,7 @@ test('iOS bandwidth footer toggles live, polls only in foreground and resets its
'./phone-gestures': { PhoneGestureRecognizer: class { cancel() {} } },
'./ble-bandwidth-meter': require('../.test-build/app/phone-ui/ble-bandwidth-meter.js'),
'../native/ble-traffic': { sampleBleTraffic: () => totals },
'../ui/dashboard-settings': { brightnessSetting: { get: () => 'auto' }, displayModeSetting: { get: () => 'full' }, displayModeLabel: () => 'Full', showBleBandwidthSetting: { get: () => enabled },
'../ui/dashboard-settings': { brightnessSetting: { get: () => 'auto' }, displayLayoutSetting: { displayValue: () => 'Tall' }, showBleBandwidthSetting: { get: () => enabled },
onAnySettingChanged: fn => { settingListeners.add(fn); return () => settingListeners.delete(fn); } },
'../g2/device-addresses': { loadDeviceAddresses: () => ({}) },
'../g2/ios-peripheral-identity': { deviceAddressError: () => 'no test devices' },
+56 -10
View File
@@ -44,11 +44,11 @@ function recorder(width, height) {
};
}
test('the layout page fits four 40%-wide diagrams with captions on the fullscreen panel', () => {
test('the layout page fits four 40%-wide diagrams with captions on the immersive panel', () => {
const { load } = harness();
const { LayoutPage } = load('app/apps/onboarding/layout-page.ts');
const page = new LayoutPage();
assert.equal(page.fullscreen, true);
assert.equal(page.immersive, true);
const image = recorder(640, 480);
page.paint(image, true);
// Each diagram's outline spans the display's width at 40%.
@@ -162,7 +162,7 @@ test('the depth page follows layouts that have depth, sits in the layout, and ap
});
const { DepthPage } = mocks('app/apps/onboarding/depth-page.ts');
const page = new DepthPage();
assert.equal(page.fullscreen, undefined);
assert.equal(page.immersive, undefined);
for (const [position, applies] of [['left', false], ['right', false], ['bottom', true], ['popup', true]]) {
settings.appSwitcherPositionSetting.value = position;
assert.equal(page.applies(), applies, position);
@@ -178,12 +178,12 @@ test('the depth page follows layouts that have depth, sits in the layout, and ap
assert.equal(next, 1);
});
test('the flow switches fullscreen per page and skips pages that do not apply, both ways', async () => {
test('the flow switches immersive mode per page and skips pages that do not apply, both ways', async () => {
const shell = { yields: 0, yieldFocusToSidebar() { this.yields++; } };
const load = loader({}, {
'../../graphics/image': { GrayImage: class {} },
'../../ui/shell/in-process-window': {}, '../../ui/shell/shell': { shell }, '../../ui/sound-effects': {},
'./data-collection-page': {}, './depth-page': {}, './ios-privacy-page': {}, './layout-page': {},
'./data-collection-page': {}, './depth-page': {}, './display-mode-page': {}, './ios-privacy-page': {}, './layout-page': {},
'./onboarding-progress': {}, './text-size-page': {}, './welcome-page': {},
});
const { OnboardingLayer } = load('app/apps/onboarding/onboarding-app.ts');
@@ -191,27 +191,73 @@ test('the flow switches fullscreen per page and skips pages that do not apply, b
const entered = [];
const page = (name, extra) => ({ ...extra, enter: () => entered.push(name),
handleInput: (event, nav) => { if (event.type === 'click') nav.next(); } });
const fullscreen = [];
const immersive = [];
let finished = 0;
const layer = new OnboardingLayer([
page('welcome', { fullscreen: true }), page('layout', { fullscreen: true }),
page('welcome', { immersive: true }), page('layout', { immersive: true }),
page('depth', { applies: () => depthApplies }), page('voice', {}),
], (value) => fullscreen.push(value), () => finished++);
], (value) => immersive.push(value), () => finished++);
const input = (type) => layer.handleInput({ type });
await input('click');
await input('click');
assert.deepEqual(entered, ['welcome', 'layout', 'voice'], 'depth skipped going forward');
assert.deepEqual(fullscreen, [true, false]);
assert.deepEqual(immersive, [true, false]);
await input('double-click');
assert.deepEqual(entered.at(-1), 'layout', 'and going back');
depthApplies = true;
await input('click');
await input('click');
assert.deepEqual(entered.slice(-2), ['depth', 'voice']);
assert.deepEqual(fullscreen, [true, false, true, false, false]);
assert.deepEqual(immersive, [true, false, true, false, false]);
await input('click');
assert.equal(finished, 1);
for (let i = 0; i < 4; i++) await input('double-click');
assert.equal(entered.at(-1), 'welcome');
assert.equal(shell.yields, 1, 'double-click on the first page leaves the app');
});
test('the display mode page offers Full Screen only where the layout allows it, and applies the mode as it scrolls', () => {
const values = ['band-top', 'band-high', 'band-middle', 'band-low', 'band-bottom', 'tall', 'fullscreen'];
const settings = {
appSwitcherPositionSetting: setting('bottom', ['left', 'right', 'bottom', 'popup']),
displayLayoutSetting: { ...setting('fullscreen', values), displayValue: (v) => v,
isDisabled: (v) => v === 'fullscreen' && ['left', 'right'].includes(settings.appSwitcherPositionSetting.value) },
};
const menu = { selected: null, items: [], setItems(items, index) { this.items = items; this.selected = index; },
get selectedItem() { return this.items[this.selected] ?? null; }, paint(image, box) { this.box = box; },
async handleInput(event) { this.selected = Math.max(0, Math.min(this.items.length - 1, this.selected + (event.type === 'scroll-down' ? 1 : -1))); } };
const load = loader({}, {
'./onboarding-fonts': { onboardingFont: font },
'../../ui/dashboard-settings': settings,
'../../ui/menu-core': { Menu: class { constructor() { return menu; } } },
'../../ui/metrics': { LIST_ROW_TEXT_INSET: 4, listRowHeight: (f) => f.lineHeight + 8 },
});
const { DisplayModePage } = load('app/apps/onboarding/display-mode-page.ts');
const page = new DisplayModePage();
// An ordinary window, which the mode being applied resizes.
assert.equal(page.immersive, undefined);
page.enter();
assert.deepEqual(Array.from(menu.items), values);
assert.equal(menu.selectedItem, 'fullscreen');
// The selected mode's description sits beside the list, within the window (a band's).
const image = recorder(576, 260);
page.paint(image, true);
const description = image.calls.filter((call) => call.kind === 'text' && call.x >= menu.box.x + menu.box.width);
assert.match(description.map((call) => call.text).join(' '), /Depth is turned off/);
let next = 0;
const nav = { next: () => next++ };
page.handleInput({ type: 'scroll-up' }, nav);
page.handleInput({ type: 'scroll-up' }, nav);
assert.deepEqual(settings.displayLayoutSetting.writes, ['tall', 'band-bottom'], 'applied as it scrolls');
page.handleInput({ type: 'click' }, nav);
assert.equal(next, 1);
assert.deepEqual(settings.displayLayoutSetting.writes, ['tall', 'band-bottom']);
// Beside a side strip, a saved Full Screen shows as Tall, and is saved as such on a tap.
settings.displayLayoutSetting.value = 'fullscreen';
settings.appSwitcherPositionSetting.value = 'left';
page.enter();
assert.deepEqual(Array.from(menu.items), values.slice(0, 6));
assert.equal(menu.selectedItem, 'tall');
page.handleInput({ type: 'click' }, nav);
assert.equal(settings.displayLayoutSetting.value, 'tall');
});
+6 -3
View File
@@ -10,8 +10,8 @@ function fixture() {
}
const settings = {
brightnessSetting: { get: () => brightness, set: value => { brightness = value; writes.push(value); } },
displayModeSetting: { get: () => mode, set: value => { mode = value; } },
DISPLAY_MODE_VALUES: ['small', 'large'], displayModeLabel: value => value === 'small' ? 'Small' : 'Large',
displayLayoutSetting: { get: () => mode, set: value => { mode = value; }, values: ['small', 'large', 'huge'],
isDisabled: value => value === 'huge', displayValue(value = mode) { return value[0].toUpperCase() + value.slice(1); } },
};
const { RemoteControlsViewModel } = loader({}, {
'@nativescript/core': { Observable, Dialogs: { action: async () => picked } },
@@ -51,10 +51,13 @@ test('shared brightness controls snap manual levels and restore the manual value
assert.equal(h.brightness(), '2');
});
test('shared screen-size picker preserves cancellation and applies the selected mode', async () => {
test('shared display-mode picker preserves cancellation and applies the selected mode', async () => {
const h = fixture();
h.pick('Cancel'); await h.model.onDisplayModeTap();
assert.equal(h.mode(), 'small');
// Unavailable modes (Full Screen beside a side strip) are not offered.
h.pick('Huge'); await h.model.onDisplayModeTap();
assert.equal(h.mode(), 'small');
h.pick('Large'); await h.model.onDisplayModeTap();
assert.equal(h.mode(), 'large');
assert.equal(h.model.displayModeLabel, 'Large ▾');
+2 -4
View File
@@ -20,7 +20,7 @@ carries `seq` (monotonic per watch process) and is answered on `/faceclaw/ack`.
| --- | --- | --- |
| `/faceclaw/input` | `{gesture, steps?}` | A ring gesture through the same path as the phone UI's test buttons. `gesture` ∈ `click`, `double-click`, `scroll-up`, `scroll-down`, `long-press` (complete short hold), `long-press-start`, `long-press-release`, `short-then-long-press` (tap then hold: the app's context menu; a plain `long-press` is the glasses' system menu), `wakeword` ("Hey Even"), `swipe-up`, `swipe-down`, `swipe-left`, `swipe-right` (spatial input only a watch can produce: delivered to the glasses UI as `swipe-*` events for components that navigate spatially — launcher grid, settings columns, sidebar, Music — with a scroll / click / double-click fallback elsewhere). `steps` (1–12) repeats a scroll. Refused while the glasses are disconnected. The lock screen is honoured exactly as for the ring. While the display is off, a double-click wakes the display, a `click` shows the phone's Glanceboard for a few seconds, and `long-press-start`/`long-press-release` hold it up; everything else is ignored. |
| `/faceclaw/press` | none | A finger landed on the pad (each first-finger touch-down, the second tap of a double-tap included) or the stem button went down: delivered on the glasses as a `ring-press` from source `watch`, exactly like the R1 ring's touch-down, ahead of whatever gesture the touch becomes (which is still sent on `/faceclaw/input`). Components that act on touch-down (Flappy, Pinball) then ignore the gesture that follows. Sent only while the mirrored state says the glasses are connected with the display on. Carries no `seq` and is never acked; the phone drops it silently wherever the following gesture would be refused. |
| `/faceclaw/command` | `{command, …}` | `launch-app {appId}`, `focus-window {windowId}`, `close-window {windowId}`, `sidebar`, `wake`, `sleep`, `lock`, `unlock`, `connect`, `disconnect`, `close-assistant`, `display-mode {value}` (`value` ∈ `576x288`, `576x480`, `640x480`; sets the phone's Display > Display mode). Everything but connect/disconnect needs a connection; everything but lock/unlock is refused while locked; `unlock` also needs the phone's "Watch can unlock glasses" setting. |
| `/faceclaw/command` | `{command, …}` | `launch-app {appId}`, `focus-window {windowId}`, `close-window {windowId}`, `sidebar`, `wake`, `sleep`, `lock`, `unlock`, `connect`, `disconnect`, `close-assistant`. Everything but connect/disconnect needs a connection; everything but lock/unlock is refused while locked; `unlock` also needs the phone's "Watch can unlock glasses" setting. |
| `/faceclaw/assistant` | `{text}` | Send a query to the assistant (`shell.sendToAssistant`) — the reply shows on the glasses and streams back to the watch as events. |
| `/faceclaw/text` | `{text}` | Type text into the foreground window (`receiveTextInput`, e.g. the terminal). Refused when the window doesn't take text. |
| `/faceclaw/state/request` | `{}` | Re-publish the state item even if unchanged. |
@@ -61,7 +61,6 @@ dashboard state, re-sent whenever it changes (and at least every 30 s):
"foreground": {"appId": "music", "title": "Music"},
"windows": [{"windowId": "…", "title": "…", "appId": "…", "focused": true, "closeable": true, "acceptsText": false}],
"apps": [{"appId": "timer", "title": "Timer"}],
"displayMode": "576x288",
"remoteEnabled": true, "crownClockwiseNext": false,
"canUnlock": true, "mirrorAssistant": true,
"assistantAvailable": true
@@ -73,8 +72,7 @@ dashboard state, re-sent whenever it changes (and at least every 30 s):
visible even though the BLE session remains available.
`protocol` is reserved for incompatible revisions of this format (nothing
checks it yet); `displayMode` mirrors the phone's Display > Display mode and
is what the `display-mode` command changes. `crownClockwiseNext` mirrors the
checks it yet). `crownClockwiseNext` mirrors the
on-glasses Settings > Watch toggle; when false (the default), clockwise crown
rotation sends previous/up, and when true it sends next/down.
@@ -69,20 +69,6 @@ object Command {
const val CONNECT = "connect"
const val DISCONNECT = "disconnect"
const val CLOSE_ASSISTANT = "close-assistant"
const val DISPLAY_MODE = "display-mode"
}
/** The glasses' display modes, mirroring the phone's Display > Display mode. */
enum class DisplayMode(val wire: String, val label: String) {
BAND("576x288", "Band · 576×288"),
TALL("576x480", "Tall · 576×480"),
FULL("640x480", "Full panel · 640×480");
fun next(): DisplayMode = entries[(ordinal + 1) % entries.size]
companion object {
fun fromWire(value: String): DisplayMode? = entries.firstOrNull { it.wire == value }
}
}
data class AppEntry(val appId: String, val title: String)
@@ -106,8 +92,6 @@ data class PhoneState(
val locked: Boolean,
val worn: Boolean?,
val listening: Boolean,
/** Display mode wire value ("576x288" | "576x480" | "640x480"). */
val displayMode: String,
/** Current or last-known G2 charge percentage. */
val battery: Int?,
val charging: Boolean,
@@ -137,7 +121,6 @@ data class PhoneState(
locked = o.optBoolean("locked", false),
worn = if (o.isNull("worn")) null else o.optBoolean("worn"),
listening = o.optBoolean("listening", false),
displayMode = o.optString("displayMode", "576x288"),
battery = if (o.isNull("battery")) null else o.optInt("battery", -1).takeIf { it in 0..100 },
charging = o.optBoolean("charging", false),
silentMode = o.optBoolean("silentMode", false),
@@ -21,7 +21,6 @@ import androidx.wear.compose.material.Scaffold
import androidx.wear.compose.material.Text
import androidx.wear.compose.material.TimeText
import com.faceclaw.wear.Command
import com.faceclaw.wear.DisplayMode
import com.faceclaw.wear.Haptics
import com.faceclaw.wear.PhoneLink
import com.faceclaw.wear.R
@@ -101,20 +100,6 @@ fun StatusScreen(link: PhoneLink, haptics: Haptics, onOpenSettings: () -> Unit)
enabled = connected && !(locked && state?.canUnlock == false),
)
}
item {
val mode = DisplayMode.fromWire(state?.displayMode ?: "") ?: DisplayMode.BAND
Chip(
onClick = {
haptics.click()
link.sendCommand(Command.DISPLAY_MODE, "value" to mode.next().wire)
},
label = { Text("Display mode") },
secondaryLabel = { Text(mode.label) },
colors = ChipDefaults.secondaryChipColors(),
modifier = Modifier.fillMaxWidth(),
enabled = connected,
)
}
state?.foreground?.let { foreground ->
item {
Chip(