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),