forked from Blendman974/faceclaw
Add centered/popup version of app switcher; plus various UI tweaks
This commit is contained in:
1 parent
295922effd
commit
96e155ebb0
12 files changed
+810
-190
No files matched your search
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
## 0.8.2 - Future
|
## 0.8.2 - Future
|
||||||
|
|
||||||
* Add an option to move the app switcher to the right or bottom, and adjust screen depth if bottom
|
* Customizable app switcher: put it on the left, right, bottom, or make it a popup
|
||||||
|
* Add Dense style for battery indicators
|
||||||
|
* Terminal app lists every configured host, including ones that are still connecting
|
||||||
|
* Music app shows its library-browsing app picker on the front page when nothing is playing
|
||||||
|
|
||||||
## 0.8.1 - 2026-09-30
|
## 0.8.1 - 2026-09-30
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ const TOP_PAD = 2;
|
|||||||
const BOTTOM_PAD = 4;
|
const BOTTOM_PAD = 4;
|
||||||
/** Clearance between the rose's widest point and the viewport edge. */
|
/** Clearance between the rose's widest point and the viewport edge. */
|
||||||
const EDGE_PAD = 8;
|
const EDGE_PAD = 8;
|
||||||
|
/** Inset of the top-right magnetometer calibration readout from the window edges. */
|
||||||
|
const ACCURACY_TOP_PAD = TOP_PAD + 4;
|
||||||
|
const ACCURACY_RIGHT_PAD = EDGE_PAD + 4;
|
||||||
/** Cap on the rose's radius, so a tall window doesn't get a comical one. */
|
/** Cap on the rose's radius, so a tall window doesn't get a comical one. */
|
||||||
const MAX_ROSE_RADIUS = 98;
|
const MAX_ROSE_RADIUS = 98;
|
||||||
|
|
||||||
@@ -197,7 +200,7 @@ class CompassLayer implements Layer {
|
|||||||
y += smallStep;
|
y += smallStep;
|
||||||
}
|
}
|
||||||
const accuracyText = magneticAccuracyText(this.diagnostics);
|
const accuracyText = magneticAccuracyText(this.diagnostics);
|
||||||
image.drawText(small, width - EDGE_PAD - small.measureText(accuracyText), TOP_PAD, accuracyText, 175);
|
image.drawText(small, width - ACCURACY_RIGHT_PAD - small.measureText(accuracyText), ACCURACY_TOP_PAD, accuracyText, 175);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
+80
-26
@@ -1,5 +1,5 @@
|
|||||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/ui-fonts";
|
import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||||
import { GrayImage } from "../../graphics/image";
|
import { GrayImage, type UiFont } from "../../graphics/image";
|
||||||
import { wrapText, truncateText } from "../../graphics/textwrap";
|
import { wrapText, truncateText } from "../../graphics/textwrap";
|
||||||
import { clamp } from "../../util/numeric-util";
|
import { clamp } from "../../util/numeric-util";
|
||||||
import { directionalFallback, GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL_DOWN, GESTURE_SCROLL_UP, type InputEvent, isDirectionalInput } from "../../ui/gestures";
|
import { directionalFallback, GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL_DOWN, GESTURE_SCROLL_UP, type InputEvent, isDirectionalInput } from "../../ui/gestures";
|
||||||
@@ -20,8 +20,9 @@ const ART_SIZE = 112;
|
|||||||
const ART_X = 8; // left margin matches the top margin
|
const ART_X = 8; // left margin matches the top margin
|
||||||
const ART_Y = 8;
|
const ART_Y = 8;
|
||||||
const META_X = ART_X + ART_SIZE + 14;
|
const META_X = ART_X + ART_SIZE + 14;
|
||||||
const PROGRESS_TIME_Y = ART_Y + 100;
|
|
||||||
const PROGRESS_BAR_Y = ART_Y + 116;
|
const PROGRESS_BAR_Y = ART_Y + 116;
|
||||||
|
/** Clear rows between the time labels' baseline (digits have no descenders) and the bar. */
|
||||||
|
const PROGRESS_TIME_GAP = 3;
|
||||||
const LIST_TOP = 136;
|
const LIST_TOP = 136;
|
||||||
/** Gap between the menus' last row band and the viewport bottom. */
|
/** Gap between the menus' last row band and the viewport bottom. */
|
||||||
const LIST_BOTTOM_MARGIN = 4;
|
const LIST_BOTTOM_MARGIN = 4;
|
||||||
@@ -47,6 +48,8 @@ type FocusColumn = "actions" | "playlist";
|
|||||||
* Music controller app: metadata + album art + transport controls for the
|
* Music controller app: metadata + album art + transport controls for the
|
||||||
* active Android media session (any player that publishes one), plus the
|
* active Android media session (any player that publishes one), plus the
|
||||||
* player's queue when it exposes one (scroll to a track, click to jump).
|
* player's queue when it exposes one (scroll to a track, click to jump).
|
||||||
|
* With no session, the front page lists the apps whose library can be
|
||||||
|
* browsed (click one to open its MediaBrowseLayer).
|
||||||
*/
|
*/
|
||||||
class MusicAppLayer implements Layer {
|
class MusicAppLayer implements Layer {
|
||||||
// Watch swipes skip tracks: right = next, left = previous.
|
// Watch swipes skip tracks: right = next, left = previous.
|
||||||
@@ -66,6 +69,19 @@ class MusicAppLayer implements Layer {
|
|||||||
getHeight: () => tightRowHeight(getDefaultSmallFont()),
|
getHeight: () => tightRowHeight(getDefaultSmallFont()),
|
||||||
draw: (args) => this.drawQueueItem(args),
|
draw: (args) => this.drawQueueItem(args),
|
||||||
});
|
});
|
||||||
|
/** The no-session front page's picker of apps whose library can be browsed. */
|
||||||
|
private readonly libraryMenu = new Menu<MediaBrowserApp>({
|
||||||
|
wrap: false,
|
||||||
|
rowGap: 1,
|
||||||
|
highlight: { radius: 4 },
|
||||||
|
getHeight: () => tightRowHeight(getDefaultSmallFont()),
|
||||||
|
draw: (args) => this.drawLibraryApp(args),
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Whether the browsable-app list has been re-queried since the no-session
|
||||||
|
* page last appeared (apps installed since the cached query then show up).
|
||||||
|
*/
|
||||||
|
private libraryAppsFresh = false;
|
||||||
private art: GrayImage | null = null;
|
private art: GrayImage | null = null;
|
||||||
private artKey = "";
|
private artKey = "";
|
||||||
|
|
||||||
@@ -93,16 +109,31 @@ class MusicAppLayer implements Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!media.available) {
|
if (!media.available) {
|
||||||
|
const apps = mediaBrowserBridge.listBrowsableApps(!this.libraryAppsFresh);
|
||||||
|
this.libraryAppsFresh = true;
|
||||||
|
this.libraryMenu.setItems(apps);
|
||||||
image.drawText(font, 24, 16, "No active media session.", 180);
|
image.drawText(font, 24, 16, "No active media session.", 180);
|
||||||
if (mediaBrowserBridge.listBrowsableApps().length) {
|
const prompt = apps.length
|
||||||
image.drawText(font, 24, 22 + lineStep(font), "Click to browse a music app's library,", 150);
|
? "Browse a music app's library, or start playback on the phone."
|
||||||
image.drawText(font, 24, 22 + 2 * lineStep(font), "or start playback on the phone.", 150);
|
: "Start playback in another app on the phone.";
|
||||||
image.drawText(font, 20, height - 16, `${GESTURE_CLICK} browse`, 110);
|
let y = 22 + lineStep(font);
|
||||||
} else {
|
for (const line of wrapText(font, prompt, width - 48)) {
|
||||||
image.drawText(font, 24, 22 + lineStep(font), "Start playback in another app on the phone.", 150);
|
image.drawText(font, 24, y, line, 150);
|
||||||
|
y += lineStep(font);
|
||||||
|
}
|
||||||
|
if (apps.length) {
|
||||||
|
const listTop = y + 6;
|
||||||
|
const listHeight = height - listTop - LIST_BOTTOM_MARGIN;
|
||||||
|
this.libraryMenu.paint(
|
||||||
|
image,
|
||||||
|
{ x: 24 - LIST_TEXT_INSET, y: listTop - 1, width: width - 48 + 2 * LIST_TEXT_INSET - 4, height: listHeight },
|
||||||
|
ctx.stack.isFocused(),
|
||||||
|
);
|
||||||
|
this.libraryMenu.drawScrollbar(image, width - 12, listTop, listHeight - 4);
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
this.libraryAppsFresh = false;
|
||||||
|
|
||||||
this.drawArt(image, media);
|
this.drawArt(image, media);
|
||||||
|
|
||||||
@@ -113,7 +144,7 @@ class MusicAppLayer implements Layer {
|
|||||||
// (title, second title line, artist, album, player app); when the font is
|
// (title, second title line, artist, album, player app); when the font is
|
||||||
// too large for all five, the title gets one truncated line instead of
|
// too large for all five, the title gets one truncated line instead of
|
||||||
// wrapping to two, and the rest shift up a slot.
|
// wrapping to two, and the rest shift up a slot.
|
||||||
const maxLines = Math.floor((PROGRESS_TIME_Y - metaTop - 4 - font.lineHeight) / metaStep) + 1;
|
const maxLines = Math.floor((progressTimeY(font) - metaTop - 4 - font.lineHeight) / metaStep) + 1;
|
||||||
const titleSlots = maxLines >= 5 ? 2 : 1;
|
const titleSlots = maxLines >= 5 ? 2 : 1;
|
||||||
const title = media.title || "Unknown title";
|
const title = media.title || "Unknown title";
|
||||||
const titleLines =
|
const titleLines =
|
||||||
@@ -171,6 +202,13 @@ class MusicAppLayer implements Layer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private drawLibraryApp({ image, item: app, x, y, width, height, selected }: MenuDrawArgs<MediaBrowserApp>): void {
|
||||||
|
const font = getDefaultSmallFont();
|
||||||
|
const value = selected ? 255 : 200;
|
||||||
|
image.drawText(font, x + LIST_TEXT_INSET, centeredTextY(font, y, height), truncateText(font, app.appName, width - 2 * LIST_TEXT_INSET - 16), value);
|
||||||
|
drawSubmenuIndicator(image, font, x, y, width, height, value);
|
||||||
|
}
|
||||||
|
|
||||||
private drawQueueItem({ image, item, x, y, width, height, selected }: MenuDrawArgs<MediaQueueItem>): void {
|
private drawQueueItem({ image, item, x, y, width, height, selected }: MenuDrawArgs<MediaQueueItem>): void {
|
||||||
const font = getDefaultSmallFont();
|
const font = getDefaultSmallFont();
|
||||||
const label = `${item.active ? "> " : " "}${item.title || "(untitled)"}`;
|
const label = `${item.active ? "> " : " "}${item.title || "(untitled)"}`;
|
||||||
@@ -197,8 +235,12 @@ class MusicAppLayer implements Layer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!media.available) {
|
if (!media.available) {
|
||||||
if (event.type === "click") {
|
this.libraryMenu.setItems(mediaBrowserBridge.listBrowsableApps());
|
||||||
this.openBrowse(ctx);
|
if (event.type === "scroll-up" || event.type === "scroll-down") {
|
||||||
|
await this.libraryMenu.handleInput(event);
|
||||||
|
} else if (event.type === "click") {
|
||||||
|
const app = this.libraryMenu.selectedItem;
|
||||||
|
if (app) this.pushLibraryBrowser(ctx, app);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -252,23 +294,15 @@ class MusicAppLayer implements Layer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the media-library browser (the Android Auto MediaBrowserService
|
* Open the media-library browser (the Android Auto MediaBrowserService
|
||||||
* path): with one browsable player installed go straight to its library,
|
* path) from the now-playing page: with one browsable player installed go
|
||||||
* otherwise offer a picker first.
|
* straight to its library, otherwise offer a picker first. (With no session
|
||||||
|
* the picker is the front page itself.)
|
||||||
*/
|
*/
|
||||||
private openBrowse(ctx: LayerContext): void {
|
private openBrowse(ctx: LayerContext): void {
|
||||||
const apps = mediaBrowserBridge.listBrowsableApps(true);
|
const apps = mediaBrowserBridge.listBrowsableApps(true);
|
||||||
if (!apps.length) return;
|
if (!apps.length) return;
|
||||||
const pushBrowser = (target: LayerContext, app: MediaBrowserApp) => {
|
|
||||||
target.stack.push(
|
|
||||||
new MediaBrowseLayer({
|
|
||||||
app,
|
|
||||||
onPlayed: (browseCtx) => browseCtx.stack.pop(),
|
|
||||||
onLeave: (browseCtx) => browseCtx.stack.pop(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
if (apps.length === 1) {
|
if (apps.length === 1) {
|
||||||
pushBrowser(ctx, apps[0]!);
|
this.pushLibraryBrowser(ctx, apps[0]!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctx.stack.push(
|
ctx.stack.push(
|
||||||
@@ -278,13 +312,23 @@ class MusicAppLayer implements Layer {
|
|||||||
label: app.appName,
|
label: app.appName,
|
||||||
onSelect: (menuCtx: LayerContext) => {
|
onSelect: (menuCtx: LayerContext) => {
|
||||||
menuCtx.stack.pop();
|
menuCtx.stack.pop();
|
||||||
pushBrowser(menuCtx, app);
|
this.pushLibraryBrowser(menuCtx, app);
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private pushLibraryBrowser(ctx: LayerContext, app: MediaBrowserApp): void {
|
||||||
|
ctx.stack.push(
|
||||||
|
new MediaBrowseLayer({
|
||||||
|
app,
|
||||||
|
onPlayed: (browseCtx) => browseCtx.stack.pop(),
|
||||||
|
onLeave: (browseCtx) => browseCtx.stack.pop(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private buildActions(media: MediaControllerState, queue: MediaQueueItem[]): MusicAction[] {
|
private buildActions(media: MediaControllerState, queue: MediaQueueItem[]): MusicAction[] {
|
||||||
const volume = mediaControllerBridge.getMediaVolumePercent();
|
const volume = mediaControllerBridge.getMediaVolumePercent();
|
||||||
return [
|
return [
|
||||||
@@ -316,8 +360,9 @@ class MusicAppLayer implements Layer {
|
|||||||
const font = getDefaultSmallFont();
|
const font = getDefaultSmallFont();
|
||||||
const elapsed = formatMediaTime(media.positionMs);
|
const elapsed = formatMediaTime(media.positionMs);
|
||||||
const duration = formatMediaTime(media.durationMs);
|
const duration = formatMediaTime(media.durationMs);
|
||||||
image.drawText(font, META_X, PROGRESS_TIME_Y, elapsed, 140);
|
const timeY = progressTimeY(font);
|
||||||
image.drawText(font, META_X + width - font.measureText(duration), PROGRESS_TIME_Y, duration, 140);
|
image.drawText(font, META_X, timeY, elapsed, 140);
|
||||||
|
image.drawText(font, META_X + width - font.measureText(duration), timeY, duration, 140);
|
||||||
|
|
||||||
const barY = PROGRESS_BAR_Y;
|
const barY = PROGRESS_BAR_Y;
|
||||||
image.drawRect(META_X, barY, width, 5, 55);
|
image.drawRect(META_X, barY, width, 5, 55);
|
||||||
@@ -481,6 +526,15 @@ export function createMusicAppWindow(options: InProcessAppOptions): InProcessWin
|
|||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line top of the elapsed/duration labels: their baseline sits a fixed gap
|
||||||
|
* above the progress bar, so the labels hug the bar whatever the font's
|
||||||
|
* height (a taller face grows upward into the metadata's line budget).
|
||||||
|
*/
|
||||||
|
function progressTimeY(font: UiFont): number {
|
||||||
|
return PROGRESS_BAR_Y - PROGRESS_TIME_GAP - font.ascent;
|
||||||
|
}
|
||||||
|
|
||||||
function formatMediaTime(milliseconds: number): string {
|
function formatMediaTime(milliseconds: number): string {
|
||||||
const totalSeconds = Math.max(0, Math.floor(milliseconds / 1_000));
|
const totalSeconds = Math.max(0, Math.floor(milliseconds / 1_000));
|
||||||
const seconds = totalSeconds % 60;
|
const seconds = totalSeconds % 60;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* Terminal app, hosted in its own worker thread. Window model:
|
* Terminal app, hosted in its own worker thread. Window model:
|
||||||
* - "terminal:hub": the window opened from the launcher; shows the list of
|
* - "terminal:hub": the window opened from the launcher; shows the list of
|
||||||
* live g2mirror sessions across every connected host (grouped by host when
|
* live g2mirror sessions grouped under a heading per configured host
|
||||||
* more than one is connected; selecting a host's heading launches a shell
|
* (unconnected hosts show their state and a Connect row; selecting a
|
||||||
* there), and hosts the Manage Connections section
|
* connected host's heading launches a shell there), and hosts the Manage
|
||||||
|
* Connections section
|
||||||
* where g2mirror:// connections are added, removed, and toggled.
|
* where g2mirror:// connections are added, removed, and toggled.
|
||||||
* - "terminal:view:N": opened by selecting a session in the hub; each has
|
* - "terminal:view:N": opened by selecting a session in the hub; each has
|
||||||
* its own websocket connection (the protocol allows one attached session
|
* its own websocket connection (the protocol allows one attached session
|
||||||
@@ -1042,12 +1043,15 @@ function windowMenu(window: TerminalWindow): WindowMenu {
|
|||||||
return window.menu;
|
return window.menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether a control's handshake has been accepted (it can list and launch sessions). */
|
||||||
|
function isControlConnected(control: ControlConnection): boolean {
|
||||||
|
const phase = control.state?.phase;
|
||||||
|
return phase === "connected" || phase === "attached";
|
||||||
|
}
|
||||||
|
|
||||||
/** Controls currently connected (handshake accepted), in stored order. */
|
/** Controls currently connected (handshake accepted), in stored order. */
|
||||||
function connectedControls(): ControlConnection[] {
|
function connectedControls(): ControlConnection[] {
|
||||||
return [...controls.values()].filter((control) => {
|
return [...controls.values()].filter(isControlConnected);
|
||||||
const phase = control.state?.phase;
|
|
||||||
return phase === "connected" || phase === "attached";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function windowMenuItems(window: TerminalWindow): MenuItem[] {
|
function windowMenuItems(window: TerminalWindow): MenuItem[] {
|
||||||
@@ -1220,7 +1224,7 @@ type HubItem = {
|
|||||||
*/
|
*/
|
||||||
heading?: boolean;
|
heading?: boolean;
|
||||||
/**
|
/**
|
||||||
* Top-level action (Manage Connections, Settings, Connect <host>): drawn
|
* Top-level action (Manage Connections, Settings): drawn
|
||||||
* unindented like a heading but at full brightness, rather than as an
|
* unindented like a heading but at full brightness, rather than as an
|
||||||
* indented session row.
|
* indented session row.
|
||||||
*/
|
*/
|
||||||
@@ -1338,17 +1342,31 @@ function hubSessionItems(window: HubWindow): HubItem[] {
|
|||||||
onSelect: () => windowMenu(window).open(settingsMenuItems(), "Terminal settings"),
|
onSelect: () => windowMenu(window).open(settingsMenuItems(), "Terminal settings"),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const connected = connectedControls();
|
const multiHost = controls.size > 1;
|
||||||
const multiHost = connected.length > 1;
|
|
||||||
const canLaunch = launchPresetNames().length > 0;
|
const canLaunch = launchPresetNames().length > 0;
|
||||||
for (const control of connected) {
|
// Every configured host is listed under its own heading, in stored order,
|
||||||
if (multiHost) {
|
// whatever its connection state: a connected host lists its sessions, any
|
||||||
items.push({
|
// other shows its state on the heading plus a Connect row (unless it is
|
||||||
label: connectionDisplayName(control.config),
|
// already connecting). Full management (remove, add) lives in Manage
|
||||||
heading: true,
|
// Connections.
|
||||||
onSelect: canLaunch ? () => launchOnHost(window, control) : undefined,
|
for (const control of controls.values()) {
|
||||||
});
|
const name = connectionDisplayName(control.config);
|
||||||
|
if (!isControlConnected(control)) {
|
||||||
|
items.push({ label: `${name} (${controlStatusWord(control)})`, heading: true });
|
||||||
|
const connecting = control.config.enabled && control.state?.phase === "connecting";
|
||||||
|
if (!connecting && clientOptionsFor(control.config)) {
|
||||||
|
items.push({
|
||||||
|
label: control.reconnectTimer ? "Connect now" : "Connect",
|
||||||
|
onSelect: () => connectControl(control),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
items.push({
|
||||||
|
label: name,
|
||||||
|
heading: true,
|
||||||
|
onSelect: canLaunch ? () => launchOnHost(window, control) : undefined,
|
||||||
|
});
|
||||||
const sessions = orderedSessions(window, control);
|
const sessions = orderedSessions(window, control);
|
||||||
for (const session of sessions) {
|
for (const session of sessions) {
|
||||||
items.push({
|
items.push({
|
||||||
@@ -1372,17 +1390,6 @@ function hubSessionItems(window: HubWindow): HubItem[] {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Disconnected/failed connections get a one-click Connect shortcut here;
|
|
||||||
// full management (remove, add) lives in Manage Connections.
|
|
||||||
for (const control of controls.values()) {
|
|
||||||
if (connected.includes(control)) continue;
|
|
||||||
if (control.config.enabled && control.state?.phase === "connecting") continue;
|
|
||||||
items.push({
|
|
||||||
label: `Connect ${connectionDisplayName(control.config)}`,
|
|
||||||
topLevel: true,
|
|
||||||
onSelect: () => connectControl(control),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
|
|||||||
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type WindowHeightMode } from "../ui/shell/geometry";
|
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type WindowHeightMode } from "../ui/shell/geometry";
|
||||||
import { type LayerActions, type TextSettingsEditToggle } from "../ui/layers";
|
import { type LayerActions, type TextSettingsEditToggle } from "../ui/layers";
|
||||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||||
import { appSwitcherPositionSetting, statusBarPositionSetting, 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, 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 { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||||
import {
|
import {
|
||||||
getInstalledEvenHubAppById,
|
getInstalledEvenHubAppById,
|
||||||
@@ -183,18 +183,23 @@ const LAUNCHABLE_APPS = ALL_APPS.filter((app) => app.showInLauncher !== false);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The global settings window viewport sizes depend on: the display mode,
|
* The global settings window viewport sizes depend on: the display mode,
|
||||||
* whether the app switcher takes width beside windows or height below them,
|
* whether the app switcher takes width beside windows, height below them
|
||||||
* and, below them, whether the status bar joins it (dropping the top bar).
|
* 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 {
|
function viewportSizesKey(): string {
|
||||||
const switcher = appSwitcherPositionSetting.get() !== "bottom" ? "strip"
|
const position = appSwitcherPositionSetting.get();
|
||||||
: statusBarPositionSetting.get() === "switcher" ? "row+status" : "row";
|
const switcher = position === "bottom" ? `row|${statusBarPositionSetting.get()}`
|
||||||
|
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`
|
||||||
|
: "strip";
|
||||||
return `${displayModeSetting.get()}|${switcher}`;
|
return `${displayModeSetting.get()}|${switcher}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The global settings that move window surfaces without resizing them. */
|
/** The global settings that move window surfaces without resizing them. */
|
||||||
function windowPlacementKey(): string {
|
function windowPlacementKey(): string {
|
||||||
return `${verticalPositionSetting.get()}|${appSwitcherPositionSetting.get()}`;
|
return `${verticalPositionSetting.get()}|${appSwitcherPositionSetting.get()}|${statusBarPositionSetting.get()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createInitialDisplayPreview(): ImageSource | null {
|
function createInitialDisplayPreview(): ImageSource | null {
|
||||||
@@ -525,17 +530,18 @@ class DashboardController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vertical-position changes (and moving the app switcher between the left
|
// Vertical-position changes (and moving the app switcher between the left
|
||||||
// and right edges) move every window surface and the chrome that aligns
|
// and right edges, or a popup switcher's status bar between the top and
|
||||||
// with them; the values are tracked so unrelated setting changes don't
|
// bottom) move every window surface and the chrome that aligns with them;
|
||||||
// trigger a full reposition.
|
// the values are tracked so unrelated setting changes don't trigger a full
|
||||||
|
// reposition.
|
||||||
private lastWindowPlacement = windowPlacementKey();
|
private lastWindowPlacement = windowPlacementKey();
|
||||||
|
|
||||||
private lastViewportSizes = viewportSizesKey();
|
private lastViewportSizes = viewportSizesKey();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display mode changed (Settings > Display, or the phone page's picker),
|
* Display mode changed (Settings > Display, or the phone page's picker),
|
||||||
* or the app switcher moved to or from the bottom edge: every window's
|
* or the app switcher or its chrome changed what windows lose to them
|
||||||
* viewport size changes. In-process windows re-measure in place; workers
|
* (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
|
* that support resizing receive the new viewport. Other worker windows are
|
||||||
* closed and launched again at the new size.
|
* closed and launched again at the new size.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -347,13 +347,18 @@ export const displayModeSetting = new ConfigSettingEnum<DisplayModeSetting>({
|
|||||||
"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.",
|
"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.",
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Which edge of the display the app switcher (the strip of open-window icons) sits on. */
|
/**
|
||||||
export type AppSwitcherPosition = "left" | "right" | "bottom";
|
* 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
|
||||||
|
* over the middle of the window that shows only while it has focus.
|
||||||
|
*/
|
||||||
|
export type AppSwitcherPosition = "left" | "right" | "bottom" | "popup";
|
||||||
|
|
||||||
const APP_SWITCHER_POSITION_LABELS: Record<AppSwitcherPosition, string> = {
|
const APP_SWITCHER_POSITION_LABELS: Record<AppSwitcherPosition, string> = {
|
||||||
left: "Left",
|
left: "Left",
|
||||||
right: "Right",
|
right: "Right",
|
||||||
bottom: "Bottom",
|
bottom: "Bottom",
|
||||||
|
popup: "Popup",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosition>({
|
export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosition>({
|
||||||
@@ -361,10 +366,10 @@ export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosit
|
|||||||
label: "App switcher position",
|
label: "App switcher position",
|
||||||
storageKey: "display.appSwitcherPosition",
|
storageKey: "display.appSwitcherPosition",
|
||||||
defaultValue: "left",
|
defaultValue: "left",
|
||||||
values: ["left", "right", "bottom"],
|
values: ["left", "right", "bottom", "popup"],
|
||||||
formatValue: (value) => APP_SWITCHER_POSITION_LABELS[value] ?? value,
|
formatValue: (value) => APP_SWITCHER_POSITION_LABELS[value] ?? value,
|
||||||
description:
|
description:
|
||||||
"Which edge of the display the strip of open-app icons sits on. Left and right take a column beside windows; bottom puts a row beneath the window, which leaves room at the sides to set the display's depth, and makes full-height windows a little shorter. Moving it to or from the bottom reopens open apps in the new size.",
|
"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.",
|
||||||
});
|
});
|
||||||
|
|
||||||
const UI_DEPTH_VALUES = ["-62", "-48", "-32", "-16", "0", "16", "32", "48", "62"] as const;
|
const UI_DEPTH_VALUES = ["-62", "-48", "-32", "-16", "0", "16", "32", "48", "62"] as const;
|
||||||
@@ -373,11 +378,11 @@ export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
|
|||||||
/**
|
/**
|
||||||
* Stereo depth of the whole display, in the firmware's depth units: the
|
* Stereo depth of the whole display, in the firmware's depth units: the
|
||||||
* lenses shift everything by half this many pixels each, in opposite
|
* lenses shift everything by half this many pixels each, in opposite
|
||||||
* directions. Only applies with the app switcher at the bottom, where the
|
* directions. Only applies with the app switcher at the bottom or a popup,
|
||||||
* windows' 576px width leaves 32px at each side: one for the side of the
|
* where the windows' 576px width leaves 32px at each side: one for the side
|
||||||
* window's frame and 31 to shift into, hence ±62 (see geometry.ts uiDepth
|
* of the window's frame and 31 to shift into, hence ±62 (see geometry.ts
|
||||||
* and windowFramed); values stay even so the per-lens halves of nested
|
* uiDepth and windowFramed); values stay even so the per-lens halves of
|
||||||
* depths add exactly.
|
* nested depths add exactly.
|
||||||
*/
|
*/
|
||||||
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
||||||
id: "ui-depth",
|
id: "ui-depth",
|
||||||
@@ -390,26 +395,62 @@ export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
|||||||
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
|
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
|
||||||
},
|
},
|
||||||
description:
|
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. 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. Full-panel windows lose a sliver at the edges.",
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where the status bar (clock, notification icons, app widgets, batteries)
|
* Where the status bar (clock, notification icons, app widgets, batteries)
|
||||||
* goes: the top bar over each window, or the right end of a bottom app
|
* goes: the top bar over each window, or its bottom. With a bottom app
|
||||||
* switcher's row (geometry.ts statusInSwitcherRow), where windows grow into
|
* switcher, the bottom is the right end of the switcher's row (geometry.ts
|
||||||
* the top bar's height.
|
* statusInSwitcherRow), where windows grow into the top bar's height; with a
|
||||||
|
* popup switcher, a bar under the window (geometry.ts statusBarEdge).
|
||||||
*/
|
*/
|
||||||
export type StatusBarPosition = "top" | "switcher";
|
export type StatusBarPosition = "top" | "bottom";
|
||||||
|
|
||||||
export const statusBarPositionSetting = new ConfigSettingEnum<StatusBarPosition>({
|
export const statusBarPositionSetting = new ConfigSettingEnum<StatusBarPosition>({
|
||||||
id: "status-bar-position",
|
id: "status-bar-position",
|
||||||
label: "Status bar",
|
label: "Status bar position",
|
||||||
storageKey: "display.statusBarPosition",
|
storageKey: "display.statusBarPosition",
|
||||||
defaultValue: "top",
|
defaultValue: "top",
|
||||||
values: ["top", "switcher"],
|
values: ["top", "bottom"],
|
||||||
formatValue: (value) => value === "switcher" ? "With app switcher" : "Top",
|
// "switcher" was the bottom value's name while only a bottom row had one.
|
||||||
|
normalize: (value) => value === "bottom" || value === "switcher" ? "bottom" : "top",
|
||||||
|
formatValue: (value) => value === "top" ? "Top"
|
||||||
|
: appSwitcherPositionSetting.get() === "bottom" ? "With app switcher" : "Bottom",
|
||||||
description:
|
description:
|
||||||
"Where the clock, notification icons, app widgets and battery indicators go. With app switcher puts them at the right end of the app switcher's row, and windows grow into the top bar's space. Available with the app switcher at the bottom; 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; with a bottom app switcher, the full-panel display mode keeps the top bar. Changing it reopens open apps in the new size.",
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the status bar always takes its rows along the window's edge, or
|
||||||
|
* shows only while the popup app switcher is up, over the window's edge
|
||||||
|
* (geometry.ts statusBarOverlays); the windows then grow into its rows.
|
||||||
|
*/
|
||||||
|
export type StatusBarVisibility = "always" | "switcher";
|
||||||
|
|
||||||
|
export const statusBarVisibilitySetting = new ConfigSettingEnum<StatusBarVisibility>({
|
||||||
|
id: "status-bar-visibility",
|
||||||
|
label: "Status bar visibility",
|
||||||
|
storageKey: "display.statusBarVisibility",
|
||||||
|
defaultValue: "always",
|
||||||
|
values: ["always", "switcher"],
|
||||||
|
formatValue: (value) => value === "switcher" ? "In app switcher" : "Always",
|
||||||
|
description:
|
||||||
|
"Always keeps the clock, notification icons, app widgets and battery indicators beside the window. In app switcher shows them only while the app switcher is open, over the edge of the window, and windows grow into their space. Available with a popup app switcher. Changing it reopens open apps in the new size.",
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the foreground window gets a rounded border with a popup app
|
||||||
|
* switcher (geometry.ts windowFramed); without one, a line divides the
|
||||||
|
* window from the status bar.
|
||||||
|
*/
|
||||||
|
export const windowBorderSetting = new ConfigSettingBoolean({
|
||||||
|
id: "window-border",
|
||||||
|
label: "Window border",
|
||||||
|
storageKey: "display.windowBorder",
|
||||||
|
defaultValue: true,
|
||||||
|
description:
|
||||||
|
"Draw a rounded border around the window. Without it, a line separates the window from the status bar. Available with a popup app switcher. Changing it reopens open apps in the new size.",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
|
export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
|
||||||
@@ -1002,7 +1043,7 @@ export const nightscoutMaxLoopAgeSetting = nightscoutThresholdSetting(
|
|||||||
);
|
);
|
||||||
export const nightscoutAlwaysShowInTopBarSetting = new ConfigSettingBoolean({
|
export const nightscoutAlwaysShowInTopBarSetting = new ConfigSettingBoolean({
|
||||||
id: "nightscout-always-show-in-top-bar",
|
id: "nightscout-always-show-in-top-bar",
|
||||||
label: "Always show in top bar",
|
label: "Always show in status bar",
|
||||||
storageKey: "integrations.nightscout.alwaysShowInTopBar",
|
storageKey: "integrations.nightscout.alwaysShowInTopBar",
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
description: "Keep the Nightscout glucose graph and warnings in the top bar even when all Nightscout windows are closed.",
|
description: "Keep the Nightscout glucose graph and warnings in the top bar even when all Nightscout windows are closed.",
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import {
|
|||||||
anthropicApiKeySetting,
|
anthropicApiKeySetting,
|
||||||
appSwitcherPositionSetting,
|
appSwitcherPositionSetting,
|
||||||
statusBarPositionSetting,
|
statusBarPositionSetting,
|
||||||
|
statusBarVisibilitySetting,
|
||||||
|
windowBorderSetting,
|
||||||
uiDepthSetting,
|
uiDepthSetting,
|
||||||
assistantAllowProactiveSetting,
|
assistantAllowProactiveSetting,
|
||||||
assistantBackendSetting,
|
assistantBackendSetting,
|
||||||
@@ -239,14 +241,19 @@ function settingsSections(): SettingsSection[] {
|
|||||||
* stable list between paints.
|
* stable list between paints.
|
||||||
*/
|
*/
|
||||||
function customizationRows(): () => MenuItem[] {
|
function customizationRows(): () => MenuItem[] {
|
||||||
// Left / right / bottom edge; the dashboard controller moves (or, to and
|
// Left / right / bottom edge, or popup; the dashboard controller moves or
|
||||||
// from the bottom, resizes) windows on change.
|
// resizes windows on change.
|
||||||
const position = enumSettingMenuItem(appSwitcherPositionSetting);
|
const position = enumSettingMenuItem(appSwitcherPositionSetting);
|
||||||
// The whole display's stereo depth; the shell sends it with its scene.
|
// The whole display's stereo depth; the shell sends it with its scene.
|
||||||
const depth = enumSettingMenuItem(uiDepthSetting);
|
const depth = enumSettingMenuItem(uiDepthSetting);
|
||||||
// Top bar, or the right end of the switcher row; the dashboard controller
|
// Top bar, or the bottom: the right end of a bottom switcher's row, or a
|
||||||
// resizes windows on change.
|
// bar under the window with a popup switcher; the dashboard controller
|
||||||
|
// resizes or moves windows on change.
|
||||||
const statusBar = enumSettingMenuItem(statusBarPositionSetting);
|
const statusBar = enumSettingMenuItem(statusBarPositionSetting);
|
||||||
|
// Popup switcher only: whether the status bar shows only in the switcher
|
||||||
|
// (windows then grow into its rows), and the foreground window's border.
|
||||||
|
const statusBarVisibility = enumSettingMenuItem(statusBarVisibilitySetting);
|
||||||
|
const windowBorder = toggleSettingMenuItem(windowBorderSetting);
|
||||||
const rest = [
|
const rest = [
|
||||||
// Submenu: top-bar battery indicator style plus per-device visibility.
|
// Submenu: top-bar battery indicator style plus per-device visibility.
|
||||||
batteryIndicatorsMenuItem(),
|
batteryIndicatorsMenuItem(),
|
||||||
@@ -257,8 +264,19 @@ function customizationRows(): () => MenuItem[] {
|
|||||||
// Opens the modal font picker (face, weight, size) for UI text.
|
// Opens the modal font picker (face, weight, size) for UI text.
|
||||||
uiFontPickerMenuItem(),
|
uiFontPickerMenuItem(),
|
||||||
];
|
];
|
||||||
const withDepth = [position, depth, statusBar, ...rest], withoutDepth = [position, ...rest];
|
const bottomRows = [position, depth, statusBar, ...rest];
|
||||||
return () => appSwitcherPositionSetting.get() === "bottom" ? withDepth : withoutDepth;
|
const popupRows = [position, depth, statusBar, statusBarVisibility, windowBorder, ...rest];
|
||||||
|
const sideRows = [position, ...rest];
|
||||||
|
return () => {
|
||||||
|
switch (appSwitcherPositionSetting.get()) {
|
||||||
|
case "bottom":
|
||||||
|
return bottomRows;
|
||||||
|
case "popup":
|
||||||
|
return popupRows;
|
||||||
|
default:
|
||||||
|
return sideRows;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoBrightnessMenuItem(): MenuItem {
|
function autoBrightnessMenuItem(): MenuItem {
|
||||||
|
|||||||
+233
-46
@@ -32,11 +32,15 @@ import {
|
|||||||
SHELL_OPAQUE_BLACK,
|
SHELL_OPAQUE_BLACK,
|
||||||
SIDEBAR_WIDTH,
|
SIDEBAR_WIDTH,
|
||||||
sidebarStripVisible,
|
sidebarStripVisible,
|
||||||
|
statusBarEdge,
|
||||||
|
statusBarOverlays,
|
||||||
|
statusBarTop,
|
||||||
statusInSwitcherRow,
|
statusInSwitcherRow,
|
||||||
SWITCHER_ROW_HEIGHT,
|
SWITCHER_ROW_HEIGHT,
|
||||||
switcherPosition,
|
switcherPosition,
|
||||||
switcherRect,
|
switcherRect,
|
||||||
TOP_BAR_HEIGHT,
|
TOP_BAR_HEIGHT,
|
||||||
|
windowFooterHeight,
|
||||||
windowFramed,
|
windowFramed,
|
||||||
windowHeaderHeight,
|
windowHeaderHeight,
|
||||||
windowTop,
|
windowTop,
|
||||||
@@ -80,6 +84,30 @@ const ROW_STATUS_GAP = 8;
|
|||||||
// all of them, when there are fewer); the windows take whatever is left.
|
// all of them, when there are fewer); the windows take whatever is left.
|
||||||
const ROW_MIN_WINDOW_SLOTS = 3;
|
const ROW_MIN_WINDOW_SLOTS = 3;
|
||||||
|
|
||||||
|
// The popup switcher (geometry.ts "popup"): a box centred over the
|
||||||
|
// foreground window's content, holding a row of window icons above the
|
||||||
|
// selected window's title. Each icon sits in a square cell, which the
|
||||||
|
// selection fills white (the popup only shows while it has focus).
|
||||||
|
const POPUP_ICON_SIZE = ROW_ICON_SIZE;
|
||||||
|
const POPUP_CELL = POPUP_ICON_SIZE + 12;
|
||||||
|
const POPUP_STEP = POPUP_CELL + 4;
|
||||||
|
const POPUP_PADDING = 12;
|
||||||
|
// Room at each end of the icons for a scroll chevron, once they scroll.
|
||||||
|
const POPUP_CHEVRON_ROOM = 12;
|
||||||
|
const POPUP_TITLE_GAP = 6;
|
||||||
|
// The box keeps this far from the window's sides, and is at least this
|
||||||
|
// wide, leaving a few windows' titles room.
|
||||||
|
const POPUP_MARGIN = 16;
|
||||||
|
const POPUP_MIN_WIDTH = 272;
|
||||||
|
// The system menu's border.
|
||||||
|
const POPUP_BORDER_VALUE = 72;
|
||||||
|
// Nearer than the window, as the system menu is.
|
||||||
|
const POPUP_DEPTH = 4;
|
||||||
|
// Brightness of everything under the chrome (the windows) while the popup
|
||||||
|
// shows: lighter than a context menu's dim, since the dimmed window is the
|
||||||
|
// selected one, which the wearer may be looking for.
|
||||||
|
const POPUP_DIM = 0.5;
|
||||||
|
|
||||||
/** Icon rows that fit in one sidebar column. */
|
/** Icon rows that fit in one sidebar column. */
|
||||||
function rowsPerColumn(variant: SidebarVariant): number {
|
function rowsPerColumn(variant: SidebarVariant): number {
|
||||||
return Math.max(1, ((LIST_HEIGHT + ICON_SPACING) / (variant.iconSize + ICON_SPACING)) | 0);
|
return Math.max(1, ((LIST_HEIGHT + ICON_SPACING) / (variant.iconSize + ICON_SPACING)) | 0);
|
||||||
@@ -173,6 +201,40 @@ function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Popup switcher geometry for the foreground window: its box, centred over
|
||||||
|
* the window's content (geometry.ts switcherRect), as wide as the icons
|
||||||
|
* need up to the window's width less margins (at least POPUP_MIN_WIDTH),
|
||||||
|
* the cells of the visible icons by slot (as switcherLayout's), and the
|
||||||
|
* title's top. Past what fits, the icons scroll, with room for a chevron at
|
||||||
|
* either end.
|
||||||
|
*/
|
||||||
|
function popupLayout(windowCount: number, state: ShellChromeState): SwitcherLayout & { box: Rect; titleTop: number } {
|
||||||
|
const area = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
|
||||||
|
const room = area.width - 2 * (POPUP_MARGIN + POPUP_PADDING);
|
||||||
|
const fits = (width: number) => Math.max(1, ((width + POPUP_STEP - POPUP_CELL) / POPUP_STEP) | 0);
|
||||||
|
const scrolls = windowCount > fits(room);
|
||||||
|
const visibleCount = scrolls ? fits(room - 2 * POPUP_CHEVRON_ROOM) : Math.max(1, windowCount);
|
||||||
|
const iconsWidth = visibleCount * POPUP_STEP - (POPUP_STEP - POPUP_CELL);
|
||||||
|
const width = 2 * POPUP_PADDING + Math.max(iconsWidth + (scrolls ? 2 * POPUP_CHEVRON_ROOM : 0), POPUP_MIN_WIDTH - 2 * POPUP_PADDING);
|
||||||
|
const height = 2 * POPUP_PADDING + POPUP_CELL + POPUP_TITLE_GAP + getDefaultMediumFont().lineHeight;
|
||||||
|
const box = {
|
||||||
|
x: area.x + ((area.width - width) >> 1),
|
||||||
|
y: area.y + Math.max(0, (area.height - height) >> 1),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
};
|
||||||
|
const iconsLeft = box.x + ((width - iconsWidth) >> 1), cellTop = box.y + POPUP_PADDING;
|
||||||
|
return {
|
||||||
|
position: "popup",
|
||||||
|
iconSize: POPUP_ICON_SIZE,
|
||||||
|
visibleCount,
|
||||||
|
cell: (slot) => ({ x: iconsLeft + slot * POPUP_STEP, y: cellTop, width: POPUP_CELL, height: POPUP_CELL, atSeparator: false }),
|
||||||
|
box,
|
||||||
|
titleTop: cellTop + POPUP_CELL + POPUP_TITLE_GAP,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Horizontal extent of the sidebar region that actually holds icons: the
|
* Horizontal extent of the sidebar region that actually holds icons: the
|
||||||
* one-column variant leaves a dead strip on the outer side of its single
|
* one-column variant leaves a dead strip on the outer side of its single
|
||||||
@@ -200,6 +262,36 @@ function topBarSpan(state: ShellChromeState): { left: number; right: number } {
|
|||||||
}
|
}
|
||||||
return { left, right };
|
return { left, right };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where the status bar is drawn for the foreground window: TOP_BAR_HEIGHT
|
||||||
|
* rows from `top`, across `left`..`right`. `contentTop` is where the top
|
||||||
|
* bar's layout starts in them: a row lower at the window's bottom, where
|
||||||
|
* the bar's first row is the one next to the window. `divider` is the row
|
||||||
|
* of the line between bar and window, or null where the window frame's side
|
||||||
|
* runs along it instead.
|
||||||
|
*/
|
||||||
|
type StatusBarPlacement = { left: number; right: number; top: number; contentTop: number; divider: number | null };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status bar's placement for the foreground window, or null when it
|
||||||
|
* isn't drawn as a bar: 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 keeps its divider.
|
||||||
|
*/
|
||||||
|
function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null {
|
||||||
|
const appId = state.foregroundAppId;
|
||||||
|
if (statusInSwitcherRow(appId)) return null;
|
||||||
|
const overlays = statusBarOverlays();
|
||||||
|
if (overlays && !sidebarStripVisible(state.focus, appId)) return null;
|
||||||
|
const { left, right } = topBarSpan(state);
|
||||||
|
const top = statusBarTop(state.foregroundHeightMode, appId);
|
||||||
|
const atBottom = statusBarEdge() === "bottom";
|
||||||
|
const divider = windowFramed(appId) && !overlays ? null : atBottom ? top : top + TOP_BAR_HEIGHT - 1;
|
||||||
|
return { left, right, top, contentTop: atBottom ? top + 1 : top, divider };
|
||||||
|
}
|
||||||
|
|
||||||
const NOTIFICATION_ICON_SIZE = 24;
|
const NOTIFICATION_ICON_SIZE = 24;
|
||||||
const BORDER_VALUE = 40;
|
const BORDER_VALUE = 40;
|
||||||
|
|
||||||
@@ -309,6 +401,8 @@ export function makeImageWindowIcon(
|
|||||||
export class ShellChromeLayer implements Layer {
|
export class ShellChromeLayer implements Layer {
|
||||||
// First switcher icon shown; adjusted each paint to keep the selection visible.
|
// First switcher icon shown; adjusted each paint to keep the selection visible.
|
||||||
private scrollRow = 0;
|
private scrollRow = 0;
|
||||||
|
// The popup switcher's shell surface.
|
||||||
|
private popupKey: number | undefined;
|
||||||
// Where the last paint ended a bottom row's window icons, for hit testing.
|
// Where the last paint ended a bottom row's window icons, for hit testing.
|
||||||
private rowWindowsRight: number | undefined;
|
private rowWindowsRight: number | undefined;
|
||||||
// Whether the last paint's selection tab carries the window frame's left
|
// Whether the last paint's selection tab carries the window frame's left
|
||||||
@@ -321,15 +415,20 @@ export class ShellChromeLayer implements Layer {
|
|||||||
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
const state = this.getState();
|
const state = this.getState();
|
||||||
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
|
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
|
||||||
|
const popup = switcherPosition() === "popup";
|
||||||
// Full-panel mode: the strip is an overlay, present only while the user
|
// 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).
|
// is in it (the window underneath keeps its full width the rest of the
|
||||||
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
|
// time); a popup only ever shows then.
|
||||||
|
const switcherShown = sidebarStripVisible(state.focus, state.foregroundAppId);
|
||||||
|
if (switcherShown && !popup) {
|
||||||
this.drawSidebar(image, state, statusInRow ? image : undefined);
|
this.drawSidebar(image, state, statusInRow ? image : undefined);
|
||||||
}
|
}
|
||||||
if (!statusInRow) this.drawTopBar(image, state);
|
const bar = statusBarPlacement(state);
|
||||||
|
if (bar) this.drawTopBar(image, state, bar);
|
||||||
const frame = windowFrameRect(state);
|
const frame = windowFrameRect(state);
|
||||||
if (frame) drawWindowFrame(image, frame, this.frameCornerSquare);
|
if (frame) drawWindowFrame(image, frame, this.frameCornerSquare, popup);
|
||||||
drawAmbientCards(image, topBarSpan(state).right);
|
drawAmbientCards(image, topBarSpan(state).right);
|
||||||
|
if (switcherShown && popup) this.drawPopup(image, state);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,12 +436,18 @@ export class ShellChromeLayer implements Layer {
|
|||||||
const state = this.getState(), parts: Plane[] = [];
|
const state = this.getState(), parts: Plane[] = [];
|
||||||
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
|
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
|
||||||
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
const bar = topBarSpan(state);
|
const span = topBarSpan(state);
|
||||||
if (!statusInRow) {
|
const bar = statusBarPlacement(state);
|
||||||
this.drawTopBar(canvas, state);
|
if (bar) {
|
||||||
parts.push({ ...shellCrop(canvas, bar.left, windowTop(state.foregroundHeightMode, state.foregroundAppId), bar.right - bar.left, TOP_BAR_HEIGHT, 2), depth: -2 });
|
this.drawTopBar(canvas, state, bar);
|
||||||
|
parts.push({ ...shellCrop(canvas, bar.left, bar.top, bar.right - bar.left, TOP_BAR_HEIGHT, 2), depth: -2 });
|
||||||
}
|
}
|
||||||
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
|
const switcherShown = sidebarStripVisible(state.focus, state.foregroundAppId);
|
||||||
|
if (switcherPosition() === "popup") {
|
||||||
|
this.paintPopupParts(state, parts, canvas, switcherShown);
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
if (switcherShown) {
|
||||||
const stripCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
const stripCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
const statusLeft = this.drawSidebar(stripCanvas, state, statusInRow ? canvas : undefined);
|
const statusLeft = this.drawSidebar(stripCanvas, state, statusInRow ? canvas : undefined);
|
||||||
// The window frame rides on the switcher row, whose top edge is its
|
// The window frame rides on the switcher row, whose top edge is its
|
||||||
@@ -355,8 +460,8 @@ export class ShellChromeLayer implements Layer {
|
|||||||
// Under a framed window the row's surface spans the frame, whose left
|
// Under a framed window the row's surface spans the frame, whose left
|
||||||
// side the first selection tab continues.
|
// side the first selection tab continues.
|
||||||
const strip = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
|
const strip = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
|
||||||
const span = frame ?? strip;
|
const rowSpan = frame ?? strip;
|
||||||
parts.push(shellCrop(stripCanvas, span.x, strip.y, span.width, strip.height, 1));
|
parts.push(shellCrop(stripCanvas, rowSpan.x, strip.y, rowSpan.width, strip.height, 1));
|
||||||
if (statusLeft !== null) {
|
if (statusLeft !== null) {
|
||||||
// The status bar keeps the top bar's surface and its depth, -2, over
|
// The status bar keeps the top bar's surface and its depth, -2, over
|
||||||
// the row's right end below its separator line, so the clock ticking
|
// the row's right end below its separator line, so the clock ticking
|
||||||
@@ -365,10 +470,37 @@ export class ShellChromeLayer implements Layer {
|
|||||||
parts.push({ ...shellCrop(canvas, statusLeft, strip.y + 1, right - statusLeft, strip.height - 1, 2), depth: -2 });
|
parts.push({ ...shellCrop(canvas, statusLeft, strip.y + 1, right - statusLeft, strip.height - 1, 2), depth: -2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawAmbientCards(canvas, bar.right, parts);
|
drawAmbientCards(canvas, span.right, parts);
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The popup switcher mode's parts after the status bar's: the window
|
||||||
|
* frame, ambient cards, then, while the switcher has focus, the popup. Its
|
||||||
|
* dim rides on the first part, so it dims the windows beneath the chrome
|
||||||
|
* and none of the chrome.
|
||||||
|
*/
|
||||||
|
private paintPopupParts(state: ShellChromeState, parts: Plane[], canvas: GrayImage, switcherShown: boolean): void {
|
||||||
|
const frame = windowFrameRect(state);
|
||||||
|
if (frame) {
|
||||||
|
// A shell surface is an opaque rectangle and needs a pixel of its own
|
||||||
|
// to be sent at all, so the frame rides on one at its top-left corner,
|
||||||
|
// outside its curve, which it paints black anyway. As in the bottom
|
||||||
|
// row's case, it plays at the screen's own depth.
|
||||||
|
const frameCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
|
frameCanvas.fillRect(frame.x, frame.y, 1, 1, SHELL_OPAQUE_BLACK);
|
||||||
|
drawWindowFrame(frameCanvas, frame, false, true);
|
||||||
|
parts.push(shellCrop(frameCanvas, frame.x, frame.y, 1, 1, 1));
|
||||||
|
}
|
||||||
|
drawAmbientCards(canvas, topBarSpan(state).right, parts);
|
||||||
|
if (!switcherShown) return;
|
||||||
|
const popupCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
|
const box = this.drawPopup(popupCanvas, state);
|
||||||
|
this.popupKey ??= LayerStack.allocateShellKey();
|
||||||
|
parts.push({ ...shellCrop(popupCanvas, box.x, box.y, box.width, box.height, this.popupKey), depth: POPUP_DEPTH });
|
||||||
|
parts[0] = { ...parts[0]!, dimUnderneath: POPUP_DIM };
|
||||||
|
}
|
||||||
|
|
||||||
handleInput(): void {
|
handleInput(): void {
|
||||||
// Shell input is handled by the shell state machine before it reaches the
|
// Shell input is handled by the shell state machine before it reaches the
|
||||||
// layer stack; the chrome itself never consumes events.
|
// layer stack; the chrome itself never consumes events.
|
||||||
@@ -382,7 +514,8 @@ export class ShellChromeLayer implements Layer {
|
|||||||
windowIndexAt(x: number, y: number, windowCount: number): number | null {
|
windowIndexAt(x: number, y: number, windowCount: number): number | null {
|
||||||
if (windowCount === 0) return null;
|
if (windowCount === 0) return null;
|
||||||
const state = this.getState();
|
const state = this.getState();
|
||||||
const layout = switcherLayout(windowCount, state.foregroundHeightMode, state.foregroundAppId, this.rowWindowsRight, this.scrollRow);
|
const layout = switcherPosition() === "popup" ? popupLayout(windowCount, state)
|
||||||
|
: switcherLayout(windowCount, state.foregroundHeightMode, state.foregroundAppId, this.rowWindowsRight, this.scrollRow);
|
||||||
const lastVisible = Math.min(windowCount, this.scrollRow + layout.visibleCount);
|
const lastVisible = Math.min(windowCount, this.scrollRow + layout.visibleCount);
|
||||||
for (let index = this.scrollRow; index < lastVisible; index++) {
|
for (let index = this.scrollRow; index < lastVisible; index++) {
|
||||||
const cell = layout.cell(index - this.scrollRow);
|
const cell = layout.cell(index - this.scrollRow);
|
||||||
@@ -525,20 +658,70 @@ export class ShellChromeLayer implements Layer {
|
|||||||
return iconsLeft;
|
return iconsLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
private drawTopBar(image: GrayImage, state: ShellChromeState): void {
|
/**
|
||||||
const font = getDefaultMediumFont();
|
* The popup switcher: its box centred over the foreground window's
|
||||||
// The bar sits at the top edge of the foreground window's band, wherever
|
* content, the visible window icons in a row with the selected one's cell
|
||||||
// its height mode puts that (screen top for max height). It moves when
|
* filled white (and its icon inverted), chevrons where more scroll, and
|
||||||
// the foreground switches to a window of a different height.
|
* the selected window's title underneath. Returns the box.
|
||||||
const barTop = windowTop(state.foregroundHeightMode, state.foregroundAppId);
|
*/
|
||||||
// The bar spans the app viewport; with a side strip overlaid (full-panel
|
private drawPopup(image: GrayImage, state: ShellChromeState): Rect {
|
||||||
// mode, sidebar focused) it still stops at the strip.
|
const count = state.windows.length;
|
||||||
const { left: barLeft, right: barRight } = topBarSpan(state);
|
const layout = popupLayout(count, state);
|
||||||
image.fillRect(barLeft, barTop, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, state.selectedIndex, layout.visibleCount, count);
|
||||||
// A framed window's frame draws this line as its top (drawWindowFrame).
|
const { box } = layout;
|
||||||
if (!windowFramed(state.foregroundAppId)) {
|
image.fillRect(box.x, box.y, box.width, box.height, SHELL_OPAQUE_BLACK);
|
||||||
image.drawLine(barLeft, barTop + TOP_BAR_HEIGHT - 1, barRight - 1, barTop + TOP_BAR_HEIGHT - 1, BORDER_VALUE);
|
image.drawRect(box.x, box.y, box.width, box.height, POPUP_BORDER_VALUE);
|
||||||
|
const lastVisible = Math.min(count, this.scrollRow + layout.visibleCount);
|
||||||
|
for (let index = this.scrollRow; index < lastVisible; index++) {
|
||||||
|
const window = state.windows[index]!;
|
||||||
|
const cell = layout.cell(index - this.scrollRow);
|
||||||
|
const x = cell.x + ((cell.width - POPUP_ICON_SIZE) >> 1);
|
||||||
|
const y = cell.y + ((cell.height - POPUP_ICON_SIZE) >> 1);
|
||||||
|
const selected = index === state.selectedIndex;
|
||||||
|
if (selected) image.fillRoundedRect(cell.x, cell.y, cell.width, cell.height, 255, TAB_RADIUS);
|
||||||
|
// As in the sidebar: unselected icons are resources of their own, so
|
||||||
|
// moving the selection resends only the box.
|
||||||
|
const icon = selected ? image : new GrayImage(POPUP_ICON_SIZE, POPUP_ICON_SIZE + 1);
|
||||||
|
const iconX = selected ? x : 0, iconY = selected ? y : 1;
|
||||||
|
window.drawIcon(icon, iconX, iconY, POPUP_ICON_SIZE, selected);
|
||||||
|
if (window.attention) {
|
||||||
|
icon.drawImage(attentionDot(selected ? SHELL_OPAQUE_BLACK : 255), iconX + POPUP_ICON_SIZE - 7, iconY - 1);
|
||||||
|
}
|
||||||
|
if (!selected) image.drawDepthImage(icon, x, y - 1, -2);
|
||||||
}
|
}
|
||||||
|
// Chevrons sit in the room either side of the icons, pointing off them.
|
||||||
|
const first = layout.cell(0), chevronY = first.y + (first.height >> 1);
|
||||||
|
if (this.scrollRow > 0) {
|
||||||
|
drawChevron(image, first.x - 5, chevronY, "left");
|
||||||
|
}
|
||||||
|
if (lastVisible < count) {
|
||||||
|
const last = layout.cell(lastVisible - 1 - this.scrollRow);
|
||||||
|
drawChevron(image, last.x + last.width + 4, chevronY, "right");
|
||||||
|
}
|
||||||
|
const selectedWindow = state.windows[state.selectedIndex];
|
||||||
|
if (selectedWindow) {
|
||||||
|
const font = getDefaultMediumFont();
|
||||||
|
const title = truncateText(font, selectedWindow.title, box.width - 2 * POPUP_PADDING);
|
||||||
|
image.drawText(font, box.x + ((box.width - font.measureText(title)) >> 1), layout.titleTop, title, 210);
|
||||||
|
}
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
private drawTopBar(image: GrayImage, state: ShellChromeState, bar: StatusBarPlacement): void {
|
||||||
|
const font = getDefaultMediumFont();
|
||||||
|
// The bar sits at the top (or, with a popup switcher, maybe the bottom)
|
||||||
|
// 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
|
||||||
|
// stops at the strip.
|
||||||
|
const { left: barLeft, right: barRight } = bar;
|
||||||
|
image.fillRect(barLeft, bar.top, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
||||||
|
// A framed window's frame draws this line as its side (drawWindowFrame).
|
||||||
|
if (bar.divider !== null) {
|
||||||
|
image.drawLine(barLeft, bar.divider, barRight - 1, bar.divider, BORDER_VALUE);
|
||||||
|
}
|
||||||
|
const barTop = bar.contentTop;
|
||||||
|
|
||||||
const clock = clockText();
|
const clock = clockText();
|
||||||
const clockX = barLeft + 10;
|
const clockX = barLeft + 10;
|
||||||
@@ -726,9 +909,9 @@ const AMBIENT_MAX_LINES_PER_CARD = 3;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint the active ambient cards bottom-up: the oldest card sits at the very
|
* Paint the active ambient cards bottom-up: the oldest card sits at the very
|
||||||
* bottom of the window band and newer ones stack above it. Cards that would
|
* bottom of the window band (above any footer) and newer ones stack above
|
||||||
* cross into the window header are dropped rather than clipped. `right` is the
|
* it. Cards that would cross into the window header are dropped rather than
|
||||||
* top bar's right edge, which the cards align to.
|
* clipped. `right` is the top bar's right edge, which the cards align to.
|
||||||
*/
|
*/
|
||||||
const ambientKeys = new Map<string, number>();
|
const ambientKeys = new Map<string, number>();
|
||||||
function drawAmbientCards(image: GrayImage, right: number, parts?: Plane[]): void {
|
function drawAmbientCards(image: GrayImage, right: number, parts?: Plane[]): void {
|
||||||
@@ -736,7 +919,7 @@ function drawAmbientCards(image: GrayImage, right: number, parts?: Plane[]): voi
|
|||||||
if (!cards.length) return;
|
if (!cards.length) return;
|
||||||
const font = getDefaultSmallFont();
|
const font = getDefaultSmallFont();
|
||||||
const bandTop = minWindowTop();
|
const bandTop = minWindowTop();
|
||||||
const bandBottom = bandTop + MIN_WINDOW_HEIGHT;
|
const bandBottom = bandTop + MIN_WINDOW_HEIGHT - windowFooterHeight();
|
||||||
// Right-aligned with the top bar: clear of a right-hand sidebar.
|
// Right-aligned with the top bar: clear of a right-hand sidebar.
|
||||||
const x = right - AMBIENT_CARD_WIDTH - AMBIENT_CARD_MARGIN;
|
const x = right - AMBIENT_CARD_WIDTH - AMBIENT_CARD_MARGIN;
|
||||||
const textWidth = AMBIENT_CARD_WIDTH - 2 * AMBIENT_CARD_PADDING_X;
|
const textWidth = AMBIENT_CARD_WIDTH - 2 * AMBIENT_CARD_PADDING_X;
|
||||||
@@ -799,13 +982,15 @@ type Rect = { x: number; y: number; width: number; height: number };
|
|||||||
const FRAME_RADIUS = 8;
|
const FRAME_RADIUS = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rounded frame around the foreground window's content (below its
|
* The rounded frame around the foreground window's content (between its
|
||||||
* header), when it has one (geometry.ts windowFramed): one pixel all round.
|
* header and footer), when it has one (geometry.ts windowFramed): one pixel
|
||||||
* Its sides run down the pixel just outside each side of the window, and
|
* all round. Its sides run down the pixel just outside each side of the
|
||||||
* its top is the header's last row: the top bar's, in place of the bar's
|
* window, and its top is the header's last row: the top bar's, in place of
|
||||||
* divider, or the whole one-row header with the status bar in the switcher
|
* the bar's divider, or the whole one-row header with the status bar
|
||||||
* row. Its bottom is the switcher row's top edge, where drawSeparator draws
|
* elsewhere. Its bottom is a bottom switcher row's top edge, where
|
||||||
* it so the selection tab can divert it.
|
* drawSeparator draws it so the selection tab can divert it; with a popup
|
||||||
|
* switcher, the footer's first row, likewise a bottom status bar's or the
|
||||||
|
* whole one-row footer.
|
||||||
*/
|
*/
|
||||||
function windowFrameRect(state: ShellChromeState): Rect | null {
|
function windowFrameRect(state: ShellChromeState): Rect | null {
|
||||||
if (!windowFramed(state.foregroundAppId)) return null;
|
if (!windowFramed(state.foregroundAppId)) return null;
|
||||||
@@ -817,19 +1002,21 @@ function windowFrameRect(state: ShellChromeState): Rect | null {
|
|||||||
* Draw the window frame (see windowFrameRect) as a retained firmware rounded
|
* Draw the window frame (see windowFrameRect) as a retained firmware rounded
|
||||||
* rect over whatever lies beneath it: no fill, so the window's content shows
|
* rect over whatever lies beneath it: no fill, so the window's content shows
|
||||||
* through, and black outside the curve, cutting the content's square
|
* through, and black outside the curve, cutting the content's square
|
||||||
* corners to it. It is clipped short of its bottom row, which drawSeparator
|
* corners to it. Over a bottom switcher row it is clipped short of its
|
||||||
* draws with the selection tab's gap. With `squareBottomLeft` (a selection
|
* bottom row, which drawSeparator draws with the selection tab's gap; with
|
||||||
* tab continuing its left side down), the rect is clipped away from that
|
* `withBottom` (a popup switcher's frame) it is drawn whole. With
|
||||||
* corner's box too, and the side runs straight through it as a one-pixel
|
* `squareBottomLeft` (a selection tab continuing its left side down), the
|
||||||
* clipped clear, leaving the content's corner whole.
|
* rect is clipped away from that corner's box too, and the side runs
|
||||||
|
* straight through it as a one-pixel clipped clear, leaving the content's
|
||||||
|
* corner whole.
|
||||||
*/
|
*/
|
||||||
function drawWindowFrame(image: GrayImage, frame: Rect, squareBottomLeft: boolean): void {
|
function drawWindowFrame(image: GrayImage, frame: Rect, squareBottomLeft: boolean, withBottom = false): void {
|
||||||
const border = grayToNibble(BORDER_VALUE), above = frame.height - 1;
|
const border = grayToNibble(BORDER_VALUE), above = frame.height - 1;
|
||||||
const rounded = (clip: ListClip): ListCall => ({
|
const rounded = (clip?: ListClip): ListCall => ({
|
||||||
op: DrawOp.ROUNDED_RECT, x: 0, y: 0, width: frame.width, height: frame.height, radius: FRAME_RADIUS,
|
op: DrawOp.ROUNDED_RECT, x: 0, y: 0, width: frame.width, height: frame.height, radius: FRAME_RADIUS,
|
||||||
background: 0, border, outside: 0, clip,
|
background: 0, border, outside: 0, ...(clip ? { clip } : {}),
|
||||||
});
|
});
|
||||||
const calls = squareBottomLeft ? [
|
const calls = withBottom ? [rounded()] : squareBottomLeft ? [
|
||||||
rounded({ x: FRAME_RADIUS, y: 0, width: frame.width - FRAME_RADIUS, height: above }),
|
rounded({ x: FRAME_RADIUS, y: 0, width: frame.width - FRAME_RADIUS, height: above }),
|
||||||
rounded({ x: 0, y: 0, width: FRAME_RADIUS, height: above - FRAME_RADIUS }),
|
rounded({ x: 0, y: 0, width: FRAME_RADIUS, height: above - FRAME_RADIUS }),
|
||||||
{ op: DrawOp.CLEAR, color: border, clip: { x: 0, y: above - FRAME_RADIUS, width: 1, height: FRAME_RADIUS } },
|
{ op: DrawOp.CLEAR, color: border, clip: { x: 0, y: above - FRAME_RADIUS, width: 1, height: FRAME_RADIUS } },
|
||||||
|
|||||||
+118
-37
@@ -10,7 +10,9 @@ import {
|
|||||||
terminalDisplayModeSetting,
|
terminalDisplayModeSetting,
|
||||||
terminalVerticalPositionSetting,
|
terminalVerticalPositionSetting,
|
||||||
statusBarPositionSetting,
|
statusBarPositionSetting,
|
||||||
|
statusBarVisibilitySetting,
|
||||||
uiDepthSetting,
|
uiDepthSetting,
|
||||||
|
windowBorderSetting,
|
||||||
} from "../dashboard-settings";
|
} from "../dashboard-settings";
|
||||||
|
|
||||||
/** Top bar: 24px notification icons plus a little padding. */
|
/** Top bar: 24px notification icons plus a little padding. */
|
||||||
@@ -18,10 +20,10 @@ export const TOP_BAR_HEIGHT = 28;
|
|||||||
/**
|
/**
|
||||||
* Width of the sidebar strip as painted (the app switcher on the left or
|
* 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
|
* right edge). App windows get the other 576px — the surface width EvenHub
|
||||||
* apps expect — and keep that width with the switcher at the bottom too,
|
* apps expect — and keep that width with the switcher at the bottom or a
|
||||||
* except in the full-panel display mode, where the switcher overlays the
|
* popup too, except in the full-panel display mode, where the switcher
|
||||||
* app (see sidebarWidth). Icon column layout within the strip (one wide
|
* overlays the app (see sidebarWidth). Icon column layout within the strip
|
||||||
* column vs. two narrow ones) is the chrome layer's business.
|
* (one wide column vs. two narrow ones) is the chrome layer's business.
|
||||||
*/
|
*/
|
||||||
export const SIDEBAR_WIDTH = 64;
|
export const SIDEBAR_WIDTH = 64;
|
||||||
|
|
||||||
@@ -36,11 +38,17 @@ export const SIDEBAR_WIDTH = 64;
|
|||||||
*/
|
*/
|
||||||
export const SWITCHER_ROW_HEIGHT = 36;
|
export const SWITCHER_ROW_HEIGHT = 36;
|
||||||
|
|
||||||
/** Which edge the app switcher is on (Settings > Customization). */
|
/** Which edge the app switcher is on, or a popup (Settings > Customization). */
|
||||||
export function switcherPosition(): AppSwitcherPosition {
|
export function switcherPosition(): AppSwitcherPosition {
|
||||||
return appSwitcherPositionSetting.get();
|
return appSwitcherPositionSetting.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether the app switcher is a strip down the left or right edge. */
|
||||||
|
function sideStrip(): boolean {
|
||||||
|
const position = switcherPosition();
|
||||||
|
return position === "left" || position === "right";
|
||||||
|
}
|
||||||
|
|
||||||
/** The Display > Display mode setting (see dashboard-settings.ts). */
|
/** The Display > Display mode setting (see dashboard-settings.ts). */
|
||||||
function appDisplayMode(appId?: string) {
|
function appDisplayMode(appId?: string) {
|
||||||
return appId === "navigate" ? navigateDisplayModeSetting.get()
|
return appId === "navigate" ? navigateDisplayModeSetting.get()
|
||||||
@@ -59,12 +67,12 @@ function fullPanel(appId?: string): boolean {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* How much of the screen's width the sidebar takes away from app windows:
|
* 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 in the
|
* the strip, or nothing when the switcher is a bottom row or a popup or in
|
||||||
* full-panel mode (where the chrome paints the strip over the window while
|
* the full-panel mode (where the chrome paints the strip over the window
|
||||||
* the sidebar has focus).
|
* while the sidebar has focus).
|
||||||
*/
|
*/
|
||||||
export function sidebarWidth(appId?: string): number {
|
export function sidebarWidth(appId?: string): number {
|
||||||
return fullPanel(appId) || switcherPosition() === "bottom" ? 0 : SIDEBAR_WIDTH;
|
return !fullPanel(appId) && sideStrip() ? SIDEBAR_WIDTH : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,11 +85,12 @@ export function switcherRowHeight(appId?: string): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the switcher strip is on screen: always when it reserves room; in
|
* Whether the switcher is on screen: always when it reserves room; as a
|
||||||
* the full-panel mode (where it overlays the window) only while it has focus.
|
* popup, or in the full-panel mode (where it overlays the window), only
|
||||||
|
* while it has focus.
|
||||||
*/
|
*/
|
||||||
export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string): boolean {
|
export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string): boolean {
|
||||||
return !fullPanel(appId) || focus === "sidebar";
|
return (!fullPanel(appId) && switcherPosition() !== "popup") || focus === "sidebar";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,10 +99,14 @@ export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string)
|
|||||||
* (foreground) window and spans its width, so a band shorter than the
|
* (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
|
* 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
|
* window of another height, as the top bar does. In the full-panel mode the
|
||||||
* row overlays the bottom edge of the screen.
|
* 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).
|
||||||
*/
|
*/
|
||||||
export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x: number; y: number; width: number; height: number } {
|
export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x: number; y: number; width: number; height: number } {
|
||||||
switch (switcherPosition()) {
|
switch (switcherPosition()) {
|
||||||
|
case "popup":
|
||||||
|
return appViewportRect(heightMode, appId);
|
||||||
case "bottom":
|
case "bottom":
|
||||||
return {
|
return {
|
||||||
x: appViewportLeft(appId),
|
x: appViewportLeft(appId),
|
||||||
@@ -112,40 +125,105 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the foreground window's content gets a rounded frame (drawn by
|
* Whether the foreground window's content gets a rounded frame (drawn by
|
||||||
* the chrome layer): with a reserved bottom switcher row, whose top edge is
|
* the chrome layer). Its left and right sides take the pixel just outside
|
||||||
* the frame's bottom side, as the window header's last row is its top. Its
|
* the 576-wide window; there's no room in the full-panel mode, nor need
|
||||||
* left and right sides take the pixel just outside the 576-wide window;
|
* beside a side strip. With a reserved bottom switcher row it always has
|
||||||
* there's no room in the full-panel mode, nor need beside a side strip.
|
* 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
|
||||||
|
* serves.
|
||||||
*/
|
*/
|
||||||
export function windowFramed(appId?: string): boolean {
|
export function windowFramed(appId?: string): boolean {
|
||||||
return switcherRowHeight(appId) > 0;
|
switch (switcherPosition()) {
|
||||||
|
case "bottom":
|
||||||
|
return switcherRowHeight(appId) > 0;
|
||||||
|
case "popup":
|
||||||
|
return !fullPanel(appId) && windowBorderSetting.get();
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the status bar shares the bottom switcher row instead of topping
|
* Whether the status bar shares the bottom switcher row instead of topping
|
||||||
* each window (Settings > Customization > Status bar): only beside a
|
* each window (Settings > Customization > Status bar position): only beside
|
||||||
* reserved row, as the full-panel mode's row shows just while it has focus.
|
* a reserved row, as the full-panel mode's row shows just while it has focus.
|
||||||
*/
|
*/
|
||||||
export function statusInSwitcherRow(appId?: string): boolean {
|
export function statusInSwitcherRow(appId?: string): boolean {
|
||||||
return windowFramed(appId) && statusBarPositionSetting.get() === "switcher";
|
return switcherRowHeight(appId) > 0 && statusBarPositionSetting.get() === "bottom";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which edge of the foreground window's band the status bar runs along
|
||||||
|
* (outside the switcher row): the top, or, with a popup switcher, the
|
||||||
|
* bottom too (Settings > Customization > Status bar position).
|
||||||
|
*/
|
||||||
|
export function statusBarEdge(): "top" | "bottom" {
|
||||||
|
return switcherPosition() === "popup" && statusBarPositionSetting.get() === "bottom" ? "bottom" : "top";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the status bar shows only while a popup switcher is up, over the
|
||||||
|
* edge of the window's content, rather than always in rows of the band's
|
||||||
|
* own (Settings > Customization > Status bar visibility).
|
||||||
|
*/
|
||||||
|
export function statusBarOverlays(): boolean {
|
||||||
|
return switcherPosition() === "popup" && statusBarVisibilitySetting.get() === "switcher";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
function windowEdgeHeight(edge: "top" | "bottom", appId?: string): number {
|
||||||
|
if (switcherPosition() !== "popup") {
|
||||||
|
return edge === "bottom" ? 0 : statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
|
||||||
|
}
|
||||||
|
if (!statusBarOverlays() && statusBarEdge() === edge) return TOP_BAR_HEIGHT;
|
||||||
|
return windowFramed(appId) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height of the header the shell draws over each window's content: the top
|
* Height of the header the shell draws over each window's content: the top
|
||||||
* bar, or, with the status bar in the switcher row, just the row the
|
* bar; with the status bar elsewhere, just the row the window frame's top
|
||||||
* window frame's top runs along.
|
* runs along, or nothing without a frame.
|
||||||
*/
|
*/
|
||||||
export function windowHeaderHeight(appId?: string): number {
|
export function windowHeaderHeight(appId?: string): number {
|
||||||
return statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
|
return windowEdgeHeight("top", appId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Height of the footer the shell draws under each window's content, within
|
||||||
|
* its band: with a popup switcher, the status bar at the bottom, or the row
|
||||||
|
* the window frame's bottom runs along; else nothing.
|
||||||
|
*/
|
||||||
|
export function windowFooterHeight(appId?: string): number {
|
||||||
|
return windowEdgeHeight("bottom", appId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Top edge (y) of the status bar's TOP_BAR_HEIGHT rows for a window: the
|
||||||
|
* band's first rows, or its last with the status bar at the bottom. Over
|
||||||
|
* the content when the status bar overlays (statusBarOverlays).
|
||||||
|
*/
|
||||||
|
export function statusBarTop(heightMode: WindowHeightMode, appId?: string): number {
|
||||||
|
const top = windowTop(heightMode, appId);
|
||||||
|
return statusBarEdge() === "bottom" ? top + windowBandHeight(heightMode, appId) - TOP_BAR_HEIGHT : top;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether a screen point lies on the switcher's side of the screen, for
|
* Whether a screen point lies on the switcher's side of the screen, for
|
||||||
* touches on the phone's mirror: anywhere in a side strip's column, or from
|
* touches on the phone's mirror: anywhere in a side strip's column, or from
|
||||||
* the top of a bottom row (under the given foreground window) down.
|
* the top of a bottom row (under the given foreground window) down. A popup
|
||||||
|
* is modal: while it shows, the whole screen is the switcher's.
|
||||||
*/
|
*/
|
||||||
export function isOnSwitcherEdge(x: number, y: number, heightMode: WindowHeightMode, appId?: string): boolean {
|
export function isOnSwitcherEdge(x: number, y: number, heightMode: WindowHeightMode, appId?: string): boolean {
|
||||||
switch (switcherPosition()) {
|
switch (switcherPosition()) {
|
||||||
|
case "popup":
|
||||||
|
return true;
|
||||||
case "bottom":
|
case "bottom":
|
||||||
return y >= switcherRect(heightMode, appId).y;
|
return y >= switcherRect(heightMode, appId).y;
|
||||||
case "right":
|
case "right":
|
||||||
@@ -162,7 +240,8 @@ function appViewportWidth(appId?: string): number {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Left edge (x) of app windows: past a left strip, centred above a bottom
|
* Left edge (x) of app windows: past a left strip, centred above a bottom
|
||||||
* row (see SWITCHER_ROW_HEIGHT), else the screen edge.
|
* row (see SWITCHER_ROW_HEIGHT) or under a popup switcher, else the screen
|
||||||
|
* edge.
|
||||||
*/
|
*/
|
||||||
export function appViewportLeft(appId?: string): number {
|
export function appViewportLeft(appId?: string): number {
|
||||||
if (fullPanel(appId)) return 0;
|
if (fullPanel(appId)) return 0;
|
||||||
@@ -170,6 +249,7 @@ export function appViewportLeft(appId?: string): number {
|
|||||||
case "left":
|
case "left":
|
||||||
return SIDEBAR_WIDTH;
|
return SIDEBAR_WIDTH;
|
||||||
case "bottom":
|
case "bottom":
|
||||||
|
case "popup":
|
||||||
return SIDEBAR_WIDTH / 2;
|
return SIDEBAR_WIDTH / 2;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
@@ -180,11 +260,11 @@ export function appViewportLeft(appId?: string): number {
|
|||||||
* Stereo depth of the whole display (Settings > Customization > Depth), in
|
* Stereo depth of the whole display (Settings > Customization > Depth), in
|
||||||
* the firmware's depth units; the shell scene carries it to the compositor,
|
* the firmware's depth units; the shell scene carries it to the compositor,
|
||||||
* which shifts the screen and everything drawn over it per lens. Only with
|
* which shifts the screen and everything drawn over it per lens. Only with
|
||||||
* the switcher at the bottom, where the windows' side margins, less the
|
* the switcher at the bottom or a popup, where the windows' side margins,
|
||||||
* window frame's pixel, leave room for the shift.
|
* less the window frame's pixel, leave room for the shift.
|
||||||
*/
|
*/
|
||||||
export function uiDepth(): number {
|
export function uiDepth(): number {
|
||||||
return switcherPosition() === "bottom" ? Number(uiDepthSetting.get()) : 0;
|
return sideStrip() ? 0 : Number(uiDepthSetting.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,10 +295,11 @@ export const SHELL_OPAQUE_BLACK = 1;
|
|||||||
/**
|
/**
|
||||||
* Windows come in three heights. "min" covers the same 288px band the stock
|
* Windows come in three heights. "min" covers the same 288px band the stock
|
||||||
* firmware uses, leaving most of the field of view clear; "medium" is one
|
* firmware uses, leaving most of the field of view clear; "medium" is one
|
||||||
* header taller, so the content area below the header is a full 288px (the
|
* header (and footer) taller, so the content area between them is a full
|
||||||
* EvenHub app surface height); "max" uses the whole 480px screen (terminal
|
* 288px (the EvenHub app surface height); "max" uses the whole 480px screen
|
||||||
* views), less a bottom switcher row. All include a header drawn by the
|
* (terminal views), less a bottom switcher row. All include the header the
|
||||||
* shell at the window's top edge (windowHeaderHeight).
|
* shell draws at the window's top edge (windowHeaderHeight) and any footer
|
||||||
|
* at its bottom (windowFooterHeight).
|
||||||
*/
|
*/
|
||||||
export type WindowHeightMode = "min" | "medium" | "max";
|
export type WindowHeightMode = "min" | "medium" | "max";
|
||||||
|
|
||||||
@@ -233,13 +314,13 @@ function windowAreaHeight(appId?: string): number {
|
|||||||
return G2_LENS_HEIGHT - switcherRowHeight(appId);
|
return G2_LENS_HEIGHT - switcherRowHeight(appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Total height (header + content) of a window's band in the given mode. */
|
/** Total height (header + content + footer) of a window's band in the given mode. */
|
||||||
export function windowBandHeight(mode: WindowHeightMode, appId?: string): number {
|
export function windowBandHeight(mode: WindowHeightMode, appId?: string): number {
|
||||||
switch (effectiveHeightMode(mode, appId)) {
|
switch (effectiveHeightMode(mode, appId)) {
|
||||||
case "max":
|
case "max":
|
||||||
return windowAreaHeight(appId);
|
return windowAreaHeight(appId);
|
||||||
case "medium":
|
case "medium":
|
||||||
return MIN_WINDOW_HEIGHT + windowHeaderHeight(appId);
|
return MIN_WINDOW_HEIGHT + windowHeaderHeight(appId) + windowFooterHeight(appId);
|
||||||
default:
|
default:
|
||||||
return MIN_WINDOW_HEIGHT;
|
return MIN_WINDOW_HEIGHT;
|
||||||
}
|
}
|
||||||
@@ -288,11 +369,11 @@ export function windowTop(mode: WindowHeightMode, appId?: string): number {
|
|||||||
export function appViewportSize(mode: WindowHeightMode, appId?: string): { width: number; height: number } {
|
export function appViewportSize(mode: WindowHeightMode, appId?: string): { width: number; height: number } {
|
||||||
return {
|
return {
|
||||||
width: appViewportWidth(appId),
|
width: appViewportWidth(appId),
|
||||||
height: windowBandHeight(mode, appId) - windowHeaderHeight(appId),
|
height: windowBandHeight(mode, appId) - windowHeaderHeight(appId) - windowFooterHeight(appId),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Screen rect of a window's app-content viewport (below its header). */
|
/** Screen rect of a window's app-content viewport (between its header and footer). */
|
||||||
export function appViewportRect(mode: WindowHeightMode, appId?: string): {
|
export function appViewportRect(mode: WindowHeightMode, appId?: string): {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
|||||||
+11
-5
@@ -42,8 +42,10 @@ import {
|
|||||||
onAnySettingChanged,
|
onAnySettingChanged,
|
||||||
openAiApiKeySetting,
|
openAiApiKeySetting,
|
||||||
statusBarPositionSetting,
|
statusBarPositionSetting,
|
||||||
|
statusBarVisibilitySetting,
|
||||||
timeFormatSetting,
|
timeFormatSetting,
|
||||||
wakeWordActionSetting,
|
wakeWordActionSetting,
|
||||||
|
windowBorderSetting,
|
||||||
} from "../dashboard-settings";
|
} from "../dashboard-settings";
|
||||||
import { onAmbientCardsChanged } from "./ambient-cards";
|
import { onAmbientCardsChanged } from "./ambient-cards";
|
||||||
import { ShellChromeLayer, sidebarContentSpan, type ShellChromeState, type ShellChromeWindow } from "./chrome-layer";
|
import { ShellChromeLayer, sidebarContentSpan, type ShellChromeState, type ShellChromeWindow } from "./chrome-layer";
|
||||||
@@ -321,7 +323,8 @@ class ShellAlertLayer implements Layer {
|
|||||||
* What a watch swipe means while the app switcher has focus, as the ring
|
* What a watch swipe means while the app switcher has focus, as the ring
|
||||||
* gesture it stands for. Swipes are spatial: along the strip they move the
|
* gesture it stands for. Swipes are spatial: along the strip they move the
|
||||||
* selection, toward the app area they enter the selected window, and away
|
* selection, toward the app area they enter the selected window, and away
|
||||||
* from it there is nowhere further to go (ignored).
|
* from it there is nowhere further to go (ignored). A popup's row of icons
|
||||||
|
* lies over the window, so either way across it enters the window.
|
||||||
*/
|
*/
|
||||||
const SWITCHER_SWIPES: Record<
|
const SWITCHER_SWIPES: Record<
|
||||||
AppSwitcherPosition,
|
AppSwitcherPosition,
|
||||||
@@ -330,15 +333,17 @@ const SWITCHER_SWIPES: Record<
|
|||||||
left: { "swipe-up": "scroll-up", "swipe-down": "scroll-down", "swipe-right": "click" },
|
left: { "swipe-up": "scroll-up", "swipe-down": "scroll-down", "swipe-right": "click" },
|
||||||
right: { "swipe-up": "scroll-up", "swipe-down": "scroll-down", "swipe-left": "click" },
|
right: { "swipe-up": "scroll-up", "swipe-down": "scroll-down", "swipe-left": "click" },
|
||||||
bottom: { "swipe-left": "scroll-up", "swipe-right": "scroll-down", "swipe-up": "click" },
|
bottom: { "swipe-left": "scroll-up", "swipe-right": "scroll-down", "swipe-up": "click" },
|
||||||
|
popup: { "swipe-left": "scroll-up", "swipe-right": "scroll-down", "swipe-up": "click", "swipe-down": "click" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every setting the shell's paint depends on that nothing else repaints it
|
* Every setting the shell's paint depends on that nothing else repaints it
|
||||||
* for (the top bar's contents, the scene's stereo depth), as one comparable
|
* for (the top bar's contents and placement, the window frame, the scene's
|
||||||
* string.
|
* stereo depth), as one comparable string.
|
||||||
*/
|
*/
|
||||||
function chromeSettingsKey(): string {
|
function chromeSettingsKey(): string {
|
||||||
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}|${uiDepth()}|${statusBarPositionSetting.get()}`;
|
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}|${uiDepth()}|${statusBarPositionSetting.get()}`
|
||||||
|
+ `|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Shell {
|
class Shell {
|
||||||
@@ -940,7 +945,8 @@ class Shell {
|
|||||||
* foreground window's band (full height for a max-height window, the
|
* foreground window's band (full height for a max-height window, the
|
||||||
* vertical-position-dependent 288px band otherwise) plus the switcher: a
|
* vertical-position-dependent 288px band otherwise) plus the switcher: a
|
||||||
* side strip's icon columns (minus the outer dead strip the one-column
|
* side strip's icon columns (minus the outer dead strip the one-column
|
||||||
* variant leaves), or the row under it and the window frame's sides.
|
* variant leaves), or the row under it, and the window frame's sides. A
|
||||||
|
* popup switcher lies within the band.
|
||||||
*/
|
*/
|
||||||
screenshotCropRect(): { x: number; y: number; width: number; height: number } {
|
screenshotCropRect(): { x: number; y: number; width: number; height: number } {
|
||||||
const appId = this.foregroundWindow()?.appId;
|
const appId = this.foregroundWindow()?.appId;
|
||||||
|
|||||||
+153
-10
@@ -15,6 +15,7 @@ function geometry() {
|
|||||||
navigateDisplayModeSetting: 'global', navigateVerticalPositionSetting: 'global',
|
navigateDisplayModeSetting: 'global', navigateVerticalPositionSetting: 'global',
|
||||||
terminalDisplayModeSetting: 'default', terminalVerticalPositionSetting: 'global',
|
terminalDisplayModeSetting: 'default', terminalVerticalPositionSetting: 'global',
|
||||||
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
|
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
|
||||||
|
statusBarVisibilitySetting: 'always', windowBorderSetting: true,
|
||||||
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
|
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
|
||||||
const context = { exports: {}, require: (name) => {
|
const context = { exports: {}, require: (name) => {
|
||||||
if (name === '../../graphics/image') return { G2_LENS_WIDTH: 640, G2_LENS_HEIGHT: 480 };
|
if (name === '../../graphics/image') return { G2_LENS_WIDTH: 640, G2_LENS_HEIGHT: 480 };
|
||||||
@@ -66,9 +67,17 @@ test('Terminal can disable its tall default, inherit position or override both d
|
|||||||
|
|
||||||
test('all explicit size/position combinations stay within the display and align content below the bar', () => {
|
test('all explicit size/position combinations stay within the display and align content below the bar', () => {
|
||||||
const g = geometry();
|
const g = geometry();
|
||||||
for (const [switcher, statusBar] of [['left', 'top'], ['right', 'top'], ['bottom', 'top'], ['bottom', 'switcher'], ['left', 'switcher']]) {
|
const combos = [['left', 'top'], ['right', 'top'], ['bottom', 'top'], ['bottom', 'bottom'], ['left', 'bottom']];
|
||||||
|
for (const statusBar of ['top', 'bottom']) {
|
||||||
|
for (const visibility of ['always', 'switcher']) {
|
||||||
|
for (const border of [true, false]) combos.push(['popup', statusBar, visibility, border]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [switcher, statusBar, visibility = 'always', border = true] of combos) {
|
||||||
g.settings.appSwitcherPositionSetting.value = switcher;
|
g.settings.appSwitcherPositionSetting.value = switcher;
|
||||||
g.settings.statusBarPositionSetting.value = statusBar;
|
g.settings.statusBarPositionSetting.value = statusBar;
|
||||||
|
g.settings.statusBarVisibilitySetting.value = visibility;
|
||||||
|
g.settings.windowBorderSetting.value = border;
|
||||||
for (const globalMode of ['576x288', '576x480', '640x480']) {
|
for (const globalMode of ['576x288', '576x480', '640x480']) {
|
||||||
g.settings.displayModeSetting.value = globalMode;
|
g.settings.displayModeSetting.value = globalMode;
|
||||||
for (const appId of ['navigate', 'terminal']) {
|
for (const appId of ['navigate', 'terminal']) {
|
||||||
@@ -79,12 +88,24 @@ test('all explicit size/position combinations stay within the display and align
|
|||||||
for (const heightMode of ['min', 'medium', 'max']) {
|
for (const heightMode of ['min', 'medium', 'max']) {
|
||||||
const rect = g.rect(heightMode, appId);
|
const rect = g.rect(heightMode, appId);
|
||||||
const fullPanel = g.displayMode(appId) === '640x480';
|
const fullPanel = g.displayMode(appId) === '640x480';
|
||||||
assert.equal(rect.x + rect.width, fullPanel ? 640 : { left: 640, right: 576, bottom: 608 }[switcher]);
|
assert.equal(rect.x + rect.width, fullPanel ? 640 : { left: 640, right: 576, bottom: 608, popup: 608 }[switcher]);
|
||||||
const header = g.windowHeaderHeight(appId);
|
const header = g.windowHeaderHeight(appId), footer = g.windowFooterHeight(appId);
|
||||||
assert.equal(header, g.statusInSwitcherRow(appId) ? 1 : g.TOP_BAR_HEIGHT);
|
assert.equal(g.statusInSwitcherRow(appId), statusBar === 'bottom' && g.switcherRowHeight(appId) > 0);
|
||||||
assert.equal(g.statusInSwitcherRow(appId), statusBar === 'switcher' && 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.y, g.windowTop(heightMode, appId) + header);
|
||||||
assert.ok(rect.y >= header && rect.y + rect.height <= 480 - g.switcherRowHeight(appId));
|
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);
|
const row = g.switcherRect(heightMode, appId);
|
||||||
assert.ok(row.y + row.height <= 480);
|
assert.ok(row.y + row.height <= 480);
|
||||||
// A reserved bottom row hangs right under the window, as wide as it.
|
// A reserved bottom row hangs right under the window, as wide as it.
|
||||||
@@ -116,6 +137,45 @@ test('the app switcher can sit on the right edge', () => {
|
|||||||
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
|
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a popup app switcher centres 576-wide windows, whose edges the status bar and frame decide', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'popup';
|
||||||
|
// Nothing is reserved for the switcher: it shows only while focused, and
|
||||||
|
// is modal while it does.
|
||||||
|
assert.equal(g.sidebarStripVisible('window'), false);
|
||||||
|
assert.equal(g.sidebarStripVisible('sidebar'), true);
|
||||||
|
assert.equal(g.isOnSwitcherEdge(5, 5, 'min'), true);
|
||||||
|
assert.equal(g.screenCenterInViewportX(), 288);
|
||||||
|
g.settings.uiDepthSetting.value = '-48';
|
||||||
|
assert.equal(g.uiDepth(), -48);
|
||||||
|
// The top bar above the content and the frame's bottom side below it.
|
||||||
|
assert.equal(g.windowFramed(), true);
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 124, width: 576, height: 259 });
|
||||||
|
assert.deepEqual(g.rect('medium'), { x: 32, y: 110, width: 576, height: 288 });
|
||||||
|
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 28, width: 576, height: 451 });
|
||||||
|
// At the bottom, the bar takes the band's last rows, and the frame's top a row of its own.
|
||||||
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 97, width: 576, height: 259 });
|
||||||
|
assert.equal(g.statusBarTop('min'), 356);
|
||||||
|
// Shown only in the switcher, the bar overlays the content, which grows into its rows.
|
||||||
|
g.settings.statusBarVisibilitySetting.value = 'switcher';
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 97, width: 576, height: 286 });
|
||||||
|
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 1, width: 576, height: 478 });
|
||||||
|
assert.equal(g.statusBarTop('min'), 356);
|
||||||
|
// Without the frame too, windows have no chrome rows at all.
|
||||||
|
g.settings.windowBorderSetting.value = false;
|
||||||
|
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.
|
||||||
|
g.settings.windowBorderSetting.value = true;
|
||||||
|
g.settings.statusBarVisibilitySetting.value = 'always';
|
||||||
|
g.settings.displayModeSetting.value = '640x480';
|
||||||
|
assert.equal(g.windowFramed(), false);
|
||||||
|
assert.deepEqual(g.rect('max'), { x: 0, y: 0, width: 640, height: 452 });
|
||||||
|
assert.equal(g.statusBarTop('max'), 452);
|
||||||
|
});
|
||||||
|
|
||||||
test('a bottom app switcher centres 576-wide windows and hangs one tall tab under them', () => {
|
test('a bottom app switcher centres 576-wide windows and hangs one tall tab under them', () => {
|
||||||
const g = geometry();
|
const g = geometry();
|
||||||
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
@@ -159,6 +219,7 @@ function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, t
|
|||||||
const modules = {
|
const modules = {
|
||||||
'../../graphics/shell-scene': shellScene, '../../graphics/image': graphics,
|
'../../graphics/shell-scene': shellScene, '../../graphics/image': graphics,
|
||||||
'../../graphics/display-list': displayList, '../../graphics/ui-fonts': { getDefaultSmallFont: () => font, getDefaultMediumFont: () => font },
|
'../../graphics/display-list': displayList, '../../graphics/ui-fonts': { getDefaultSmallFont: () => font, getDefaultMediumFont: () => font },
|
||||||
|
'../../graphics/textwrap': require('../.test-build/app/graphics/textwrap.js'),
|
||||||
'../../graphics/battery': require('../.test-build/app/graphics/battery.js'),
|
'../../graphics/battery': require('../.test-build/app/graphics/battery.js'),
|
||||||
'./ambient-cards': { activeAmbientCards: () => [] },
|
'./ambient-cards': { activeAmbientCards: () => [] },
|
||||||
'../../native/notification-icons': { readActiveNotificationIcons: (max) => {
|
'../../native/notification-icons': { readActiveNotificationIcons: (max) => {
|
||||||
@@ -179,7 +240,8 @@ function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, t
|
|||||||
const context = { exports: {}, require: (name) => modules[name] ?? {} };
|
const context = { exports: {}, require: (name) => modules[name] ?? {} };
|
||||||
vm.runInNewContext(js(read('app/ui/shell/chrome-layer.ts')), context);
|
vm.runInNewContext(js(read('app/ui/shell/chrome-layer.ts')), context);
|
||||||
const state = {
|
const state = {
|
||||||
windows: Array.from({ length: windows }, () => ({ attention: false, drawIcon: (image, x, y, size) => image.fillRect(x, y, size, size, 120) })),
|
windows: Array.from({ length: windows }, (_, i) => ({ title: `Window ${i}`, attention: false,
|
||||||
|
drawIcon: (image, x, y, size) => image.fillRect(x, y, size, size, 120) })),
|
||||||
selectedIndex: 0, focus: 'window', foregroundHeightMode: 'min',
|
selectedIndex: 0, focus: 'window', foregroundHeightMode: 'min',
|
||||||
battery: { headset: null, ring: null, watch: null }, trayIcons,
|
battery: { headset: null, ring: null, watch: null }, trayIcons,
|
||||||
};
|
};
|
||||||
@@ -273,7 +335,7 @@ test('the launcher\'s tab lines up with the window frame, whose corner squares t
|
|||||||
|
|
||||||
test('the status bar can join a bottom app switcher, and windows grow into the top bar', () => {
|
test('the status bar can join a bottom app switcher, and windows grow into the top bar', () => {
|
||||||
const g = geometry();
|
const g = geometry();
|
||||||
g.settings.statusBarPositionSetting.value = 'switcher';
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
// Only beside a reserved bottom row.
|
// Only beside a reserved bottom row.
|
||||||
assert.equal(g.statusInSwitcherRow(), false);
|
assert.equal(g.statusInSwitcherRow(), false);
|
||||||
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
@@ -294,7 +356,7 @@ test('the status bar can join a bottom app switcher, and windows grow into the t
|
|||||||
test('the switcher row lays out windows, free space, notifications, widgets, batteries and the clock', () => {
|
test('the switcher row lays out windows, free space, notifications, widgets, batteries and the clock', () => {
|
||||||
const g = geometry();
|
const g = geometry();
|
||||||
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
g.settings.statusBarPositionSetting.value = 'switcher';
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
const tray = new graphics.GrayImage(30, 20, 180);
|
const tray = new graphics.GrayImage(30, 20, 180);
|
||||||
const { chrome, requested } = chromeLayer(g, { notifications: 2, phoneBattery: 80, trayIcons: [tray] });
|
const { chrome, requested } = chromeLayer(g, { notifications: 2, phoneBattery: 80, trayIcons: [tray] });
|
||||||
const parts = chrome.paintParts();
|
const parts = chrome.paintParts();
|
||||||
@@ -327,7 +389,7 @@ test('the switcher row lays out windows, free space, notifications, widgets, bat
|
|||||||
test('many windows scroll in what the notification icons leave them', () => {
|
test('many windows scroll in what the notification icons leave them', () => {
|
||||||
const g = geometry();
|
const g = geometry();
|
||||||
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
g.settings.statusBarPositionSetting.value = 'switcher';
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
const { chrome, requested } = chromeLayer(g, { notifications: 40, windows: 12 });
|
const { chrome, requested } = chromeLayer(g, { notifications: 40, windows: 12 });
|
||||||
const [row, status] = chrome.paintParts();
|
const [row, status] = chrome.paintParts();
|
||||||
// Clock only (no batteries or widgets): notifications end 8px before its
|
// Clock only (no batteries or widgets): notifications end 8px before its
|
||||||
@@ -346,6 +408,87 @@ test('many windows scroll in what the notification icons leave them', () => {
|
|||||||
assert.equal(chevron % row.image.width + row.x, windowsRight - 6);
|
assert.equal(chevron % row.image.width + row.x, windowsRight - 6);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a popup app switcher shows a box of window icons over the dimmed window while focused', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'popup';
|
||||||
|
const { chrome, state } = chromeLayer(g, { windows: 3 });
|
||||||
|
const summary = (parts) => Array.from(parts, (p) => [p.shellKey, p.depth ?? 0, p.dimUnderneath ?? 1]);
|
||||||
|
const at = (p, x, y) => p.image.pixels[(y - p.y) * p.image.width + x - p.x];
|
||||||
|
// In the window: the top bar, then the frame, which rides on a pixel of
|
||||||
|
// its own at its top-left corner (outside its curve).
|
||||||
|
let parts = chrome.paintParts();
|
||||||
|
assert.deepEqual(summary(parts), [[2, -2, 1], [1, 0, 1]]);
|
||||||
|
const [bar, carrier] = parts;
|
||||||
|
assert.deepEqual([carrier.x, carrier.y, carrier.image.width, carrier.image.height], [31, 123, 1, 1]);
|
||||||
|
// The whole rounded rect, from the bar's last row (in place of its
|
||||||
|
// divider) round the content (32,124 576×259) to the footer row under it.
|
||||||
|
const [frame] = carrier.image.draws.filter((d) => d.presentation?.displayList);
|
||||||
|
assert.deepEqual([carrier.x + frame.x, carrier.y + frame.y, frame.presentation.depth], [31, 123, 0]);
|
||||||
|
assert.deepEqual(JSON.parse(JSON.stringify(frame.presentation.displayList.calls)), [{ op: displayList.DrawOp.ROUNDED_RECT,
|
||||||
|
x: 0, y: 0, width: 578, height: 261, radius: 8, background: 0, border: 3, outside: 0 }]);
|
||||||
|
assert.equal(at(bar, 300, 123), 1);
|
||||||
|
// Focused: the box, nearer than the window, last. Its dim rides on the
|
||||||
|
// first part, so it dims the windows and none of the chrome.
|
||||||
|
state.focus = 'sidebar';
|
||||||
|
parts = chrome.paintParts();
|
||||||
|
assert.deepEqual(summary(parts), [[2, -2, 0.5], [1, 0, 1], [100, 4, 1]]);
|
||||||
|
const encoded = shellScene.encodeShellScene(parts, g.uiDepth());
|
||||||
|
assert.equal(new DataView(encoded.buffer).getUint16(12, true), 128, 'first layer dims to half');
|
||||||
|
// Three 44px cells 4px apart, in the minimum 272px width, centred over the
|
||||||
|
// content; 12px padding round the cells and the 12px title line under them.
|
||||||
|
let popup = parts[2];
|
||||||
|
assert.deepEqual([popup.x, popup.y, popup.image.width, popup.image.height], [184, 210, 272, 86]);
|
||||||
|
assert.equal(at(popup, 184, 210), 72, 'border');
|
||||||
|
// The selected (first) cell is filled white around its icon; the others'
|
||||||
|
// icons are depth images of their own over the black box.
|
||||||
|
assert.deepEqual([at(popup, 252, 240), at(popup, 260, 240), at(popup, 310, 240)], [255, 120, 1]);
|
||||||
|
assert.deepEqual(popup.image.draws.filter((d) => d.presentation).map((d) => [popup.x + d.x, popup.y + d.y]), [[304, 227], [352, 227]]);
|
||||||
|
// The selected window's title, centred under the icons.
|
||||||
|
assert.equal(at(popup, 184 + (272 - 32) / 2, 222 + 44 + 6 + 2), 210);
|
||||||
|
assert.deepEqual([chrome.windowIndexAt(260, 240, 3), chrome.windowIndexAt(300, 240, 3), chrome.windowIndexAt(296, 240, 3),
|
||||||
|
chrome.windowIndexAt(10, 10, 3)], [0, 1, null, null]);
|
||||||
|
// The flat paint shows it too.
|
||||||
|
assert.equal(chrome.paint().pixels[210 * 640 + 184], 72);
|
||||||
|
// Many windows scroll, with a chevron at either end of the icons.
|
||||||
|
const many = chromeLayer(g, { windows: 20 });
|
||||||
|
many.state.focus = 'sidebar';
|
||||||
|
many.state.selectedIndex = 15;
|
||||||
|
popup = many.chrome.paintParts()[2];
|
||||||
|
assert.deepEqual([popup.x, popup.image.width], [58, 524]);
|
||||||
|
assert.equal(many.chrome.windowIndexAt(90, 240, 20), 6);
|
||||||
|
assert.deepEqual([at(popup, 74, 244), at(popup, 565, 244)], [140, 140]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a popup switcher\'s status bar can sit at the bottom, show only in the switcher, or go without the frame', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'popup';
|
||||||
|
g.settings.statusBarVisibilitySetting.value = 'switcher';
|
||||||
|
const { chrome, state } = chromeLayer(g);
|
||||||
|
const at = (p, x, y) => p.image.pixels[(y - p.y) * p.image.width + x - p.x];
|
||||||
|
// Outside the switcher there's only the frame.
|
||||||
|
assert.deepEqual(Array.from(chrome.paintParts(), (p) => p.shellKey), [1]);
|
||||||
|
// In it, the bar overlays the content's top inside the frame, whose top
|
||||||
|
// runs along the bar's first row, so it keeps its divider on its last.
|
||||||
|
state.focus = 'sidebar';
|
||||||
|
let [bar, carrier] = chrome.paintParts();
|
||||||
|
assert.deepEqual([bar.x, bar.y, bar.image.width, bar.image.height, carrier.y], [32, 96, 576, 28, 96]);
|
||||||
|
assert.equal(at(bar, 300, 123), 40);
|
||||||
|
// At the bottom, its divider is its first row, and the frame's bottom its last.
|
||||||
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
|
[bar] = chrome.paintParts();
|
||||||
|
assert.deepEqual([bar.y, at(bar, 300, 356), at(bar, 300, 383)], [356, 40, 1]);
|
||||||
|
// Always shown without a frame, a divider still separates bar and window.
|
||||||
|
g.settings.statusBarVisibilitySetting.value = 'always';
|
||||||
|
g.settings.windowBorderSetting.value = false;
|
||||||
|
state.focus = 'window';
|
||||||
|
const parts = chrome.paintParts();
|
||||||
|
assert.deepEqual(Array.from(parts, (p) => p.shellKey), [2]);
|
||||||
|
assert.deepEqual([parts[0].y, at(parts[0], 300, 356)], [356, 40]);
|
||||||
|
g.settings.statusBarPositionSetting.value = 'top';
|
||||||
|
[bar] = chrome.paintParts();
|
||||||
|
assert.deepEqual([bar.y, at(bar, 300, 123)], [96, 40]);
|
||||||
|
});
|
||||||
|
|
||||||
// Exercise the real worker message handler with platform work stubbed out.
|
// Exercise the real worker message handler with platform work stubbed out.
|
||||||
function resizeHandler(file, globals) {
|
function resizeHandler(file, globals) {
|
||||||
const source = ts.createSourceFile(file, read(file), ts.ScriptTarget.Latest, true);
|
const source = ts.createSourceFile(file, read(file), ts.ScriptTarget.Latest, true);
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const vm = require('node:vm');
|
||||||
|
const ts = require('typescript');
|
||||||
|
|
||||||
|
// Run the worker's actual hub session-list builder with its collaborators stubbed.
|
||||||
|
function hub({ presets = [] } = {}) {
|
||||||
|
const file = 'app/apps/terminal/terminal-app.worker.ts';
|
||||||
|
const source = ts.createSourceFile(file, fs.readFileSync(path.join(__dirname, '..', file), 'utf8'), ts.ScriptTarget.Latest, true);
|
||||||
|
const functions = new Set(['hubSessionItems', 'isControlConnected', 'controlStatusWord', 'orderedSessions', 'recencyKey', 'sessionLabel']);
|
||||||
|
const selected = source.statements.filter((s) => ts.isFunctionDeclaration(s) && functions.has(s.name?.text));
|
||||||
|
const connected = [];
|
||||||
|
const context = {
|
||||||
|
controls: new Map(), sessionRecency: new Map(),
|
||||||
|
launchPresetNames: () => presets,
|
||||||
|
connectionDisplayName: (config) => config.name,
|
||||||
|
clientOptionsFor: (config) => (config.url === 'bad' ? null : {}),
|
||||||
|
isSessionActive: () => false, viewGlyphForSocket: () => null, viewWindowIdForSocket: () => null,
|
||||||
|
connectControl: (control) => connected.push(control.config.name),
|
||||||
|
};
|
||||||
|
vm.runInNewContext(ts.transpileModule(selected.map((s) => s.getText(source)).join('\n'), {
|
||||||
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
||||||
|
}).outputText, context);
|
||||||
|
const window = { sessionOrder: [] };
|
||||||
|
return {
|
||||||
|
connected,
|
||||||
|
add(name, { enabled = true, phase = null, sessions = [], retrying = false, url = 'ok' } = {}) {
|
||||||
|
context.controls.set(name, {
|
||||||
|
config: { id: name, name, url, enabled },
|
||||||
|
state: phase && { phase, sessions: sessions.map((title) => ({ socket: title, title, command: title })) },
|
||||||
|
reconnectTimer: retrying ? 1 : null,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: () => context.hubSessionItems(window).slice(2), // past Manage Connections + Settings
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Array.from: the items are arrays from the vm realm.
|
||||||
|
const rows = (items) => Array.from(items, (item) => `${item.heading ? '# ' : ''}${item.label}${item.onSelect ? '' : ' [x]'}`);
|
||||||
|
|
||||||
|
test('every configured host gets a heading in stored order, whatever its state', () => {
|
||||||
|
const h = hub();
|
||||||
|
h.add('alpha', { phase: 'connecting' });
|
||||||
|
h.add('beta', { phase: 'connected', sessions: ['vim'] });
|
||||||
|
h.add('gamma', { phase: 'failed', retrying: true });
|
||||||
|
h.add('delta', { enabled: false });
|
||||||
|
h.add('epsilon', { url: 'bad' });
|
||||||
|
assert.deepEqual(rows(h.items()), [
|
||||||
|
'# alpha (connecting) [x]',
|
||||||
|
'# beta [x]',
|
||||||
|
'vim',
|
||||||
|
'# gamma (retrying) [x]',
|
||||||
|
'Connect now',
|
||||||
|
'# delta (off) [x]',
|
||||||
|
'Connect',
|
||||||
|
'# epsilon (bad connection string) [x]',
|
||||||
|
]);
|
||||||
|
h.items().find((item) => item.label === 'Connect').onSelect();
|
||||||
|
assert.deepEqual(h.connected, ['delta']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a lone host still shows its heading; connected headings launch when presets exist', () => {
|
||||||
|
const h = hub({ presets: ['shell'] });
|
||||||
|
h.add('solo', { phase: 'connected' });
|
||||||
|
assert.deepEqual(rows(h.items()), ['# solo', '(no live sessions; run g2mirror <command>)']);
|
||||||
|
const lone = hub();
|
||||||
|
lone.add('solo', { phase: 'connecting' });
|
||||||
|
assert.deepEqual(rows(lone.items()), ['# solo (connecting) [x]']);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user