forked from Blendman974/faceclaw
Add an option to move the app switcher to the right or bottom, and adjust screen depth if bottom
This commit is contained in:
1 parent
46fded856a
commit
8f99779f98
21 files changed
+827
-286
No files matched your search
@@ -80,7 +80,7 @@ export class CompassCalibrationLayer implements Layer {
|
|||||||
|
|
||||||
// The crosshair marks where the wearer is looking, so its horizontal
|
// The crosshair marks where the wearer is looking, so its horizontal
|
||||||
// position must be the true centre of the display, not of the app
|
// position must be the true centre of the display, not of the app
|
||||||
// viewport the sidebar has pushed to the right. Vertically it just sits in
|
// viewport a side strip has pushed off centre. Vertically it just sits in
|
||||||
// the free space between the instructions and the readouts; the window
|
// the free space between the instructions and the readouts; the window
|
||||||
// band's own placement on screen is the wearer's Display setting and
|
// band's own placement on screen is the wearer's Display setting and
|
||||||
// doesn't affect the heading being aimed.
|
// doesn't affect the heading being aimed.
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class CompassLayer implements Layer {
|
|||||||
const readoutHeight = headingFont.lineHeight;
|
const readoutHeight = headingFont.lineHeight;
|
||||||
|
|
||||||
// One column centred on the display's true centre, so the rose sits where
|
// One column centred on the display's true centre, so the rose sits where
|
||||||
// the wearer is looking rather than 32px right of it.
|
// the wearer is looking rather than 32px beside it (with a side strip).
|
||||||
const cx = screenCenterInViewportX();
|
const cx = screenCenterInViewportX();
|
||||||
|
|
||||||
// The rose is sized and placed first — it hangs off the bottom edge — and
|
// The rose is sized and placed first — it hangs off the bottom edge — and
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ import { ALL_APPS } from "../apps/all-apps";
|
|||||||
import { type AppContext, type AppDefinition, type AppLaunchParams, type TextEditorHost } from "../apps/app-definition";
|
import { type AppContext, type AppDefinition, type AppLaunchParams, type TextEditorHost } from "../apps/app-definition";
|
||||||
import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-process-window";
|
import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-process-window";
|
||||||
import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence";
|
import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence";
|
||||||
import { appViewportRect, SIDEBAR_WIDTH, 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 { 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, 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,
|
||||||
@@ -181,6 +181,19 @@ const EVEN_APP_DETECTED_MESSAGE =
|
|||||||
// The launcher grid's app list; also fixes the app ids apps.launch accepts.
|
// The launcher grid's app list; also fixes the app ids apps.launch accepts.
|
||||||
const LAUNCHABLE_APPS = ALL_APPS.filter((app) => app.showInLauncher !== false);
|
const LAUNCHABLE_APPS = ALL_APPS.filter((app) => app.showInLauncher !== false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The global settings window viewport sizes depend on: the display mode, and
|
||||||
|
* whether the app switcher takes width beside windows or height below them.
|
||||||
|
*/
|
||||||
|
function viewportSizesKey(): string {
|
||||||
|
return `${displayModeSetting.get()}|${appSwitcherPositionSetting.get() === "bottom" ? "row" : "strip"}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The global settings that move window surfaces without resizing them. */
|
||||||
|
function windowPlacementKey(): string {
|
||||||
|
return `${verticalPositionSetting.get()}|${appSwitcherPositionSetting.get()}`;
|
||||||
|
}
|
||||||
|
|
||||||
function createInitialDisplayPreview(): ImageSource | null {
|
function createInitialDisplayPreview(): ImageSource | null {
|
||||||
return grayImageToPreviewSource(new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0));
|
return grayImageToPreviewSource(new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0));
|
||||||
}
|
}
|
||||||
@@ -427,8 +440,10 @@ class DashboardController {
|
|||||||
this.pushFirmwareDebugFlags();
|
this.pushFirmwareDebugFlags();
|
||||||
this.pushBrightness();
|
this.pushBrightness();
|
||||||
this.syncEvenHubScreenOffSetting();
|
this.syncEvenHubScreenOffSetting();
|
||||||
this.applyVerticalPositionIfChanged();
|
// Display mode first: a reflow repositions every surface too, so the
|
||||||
|
// vertical-position check after it then has nothing left to do.
|
||||||
this.applyDisplayModeIfChanged();
|
this.applyDisplayModeIfChanged();
|
||||||
|
this.applyVerticalPositionIfChanged();
|
||||||
this.applyAppLayoutsIfChanged();
|
this.applyAppLayoutsIfChanged();
|
||||||
this.syncAssistantBridgeIfChanged();
|
this.syncAssistantBridgeIfChanged();
|
||||||
this.syncLockScreenSettingIfChanged();
|
this.syncLockScreenSettingIfChanged();
|
||||||
@@ -506,24 +521,28 @@ class DashboardController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertical-position changes move every window surface (and the chrome that
|
// Vertical-position changes (and moving the app switcher between the left
|
||||||
// aligns with them); the value is tracked so unrelated setting changes
|
// and right edges) move every window surface and the chrome that aligns
|
||||||
// don't trigger a full reposition.
|
// with them; the values are tracked so unrelated setting changes don't
|
||||||
private lastVerticalPosition = verticalPositionSetting.get();
|
// trigger a full reposition.
|
||||||
|
private lastWindowPlacement = windowPlacementKey();
|
||||||
|
|
||||||
private lastDisplayMode = displayModeSetting.get();
|
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),
|
||||||
* every window's viewport size changes. In-process windows re-measure in
|
* or the app switcher moved to or from the bottom edge: every window's
|
||||||
* place; workers that support resizing receive the new viewport. Other
|
* viewport size changes. In-process windows re-measure in place; workers
|
||||||
* worker windows are closed and launched again at the new size.
|
* that support resizing receive the new viewport. Other worker windows are
|
||||||
|
* closed and launched again at the new size.
|
||||||
*/
|
*/
|
||||||
private applyDisplayModeIfChanged(): void {
|
private applyDisplayModeIfChanged(): void {
|
||||||
const mode = displayModeSetting.get();
|
const sizes = viewportSizesKey();
|
||||||
if (mode === this.lastDisplayMode) return;
|
if (sizes === this.lastViewportSizes) return;
|
||||||
this.lastDisplayMode = mode;
|
this.lastViewportSizes = sizes;
|
||||||
this.appendLog(`display mode: ${mode}`);
|
// The reflow below reconfigures every surface, covering any move too.
|
||||||
|
this.lastWindowPlacement = windowPlacementKey();
|
||||||
|
this.appendLog(`display layout: ${sizes}`);
|
||||||
const foregroundWindowId = shell.foregroundWindow()?.windowId;
|
const foregroundWindowId = shell.foregroundWindow()?.windowId;
|
||||||
void (async () => {
|
void (async () => {
|
||||||
const relaunch: string[] = [];
|
const relaunch: string[] = [];
|
||||||
@@ -579,9 +598,9 @@ class DashboardController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private applyVerticalPositionIfChanged(): void {
|
private applyVerticalPositionIfChanged(): void {
|
||||||
const position = verticalPositionSetting.get();
|
const placement = windowPlacementKey();
|
||||||
if (position === this.lastVerticalPosition) return;
|
if (placement === this.lastWindowPlacement) return;
|
||||||
this.lastVerticalPosition = position;
|
this.lastWindowPlacement = placement;
|
||||||
void (async () => {
|
void (async () => {
|
||||||
for (const window of shell.getWindows()) {
|
for (const window of shell.getWindows()) {
|
||||||
await this.configureWindowSurface(
|
await this.configureWindowSurface(
|
||||||
@@ -1925,9 +1944,10 @@ class DashboardController {
|
|||||||
}
|
}
|
||||||
const x = Math.round(Math.min(1, Math.max(0, nx)) * G2_LENS_WIDTH);
|
const x = Math.round(Math.min(1, Math.max(0, nx)) * G2_LENS_WIDTH);
|
||||||
const y = Math.round(Math.min(1, Math.max(0, ny)) * G2_LENS_HEIGHT);
|
const y = Math.round(Math.min(1, Math.max(0, ny)) * G2_LENS_HEIGHT);
|
||||||
const stripShown = sidebarStripVisible(shell.getFocus(), shell.foregroundWindow()?.appId);
|
const foreground = shell.foregroundWindow();
|
||||||
|
const stripShown = sidebarStripVisible(shell.getFocus(), foreground?.appId);
|
||||||
this.appendLog(`mirror tap at ${x},${y}`);
|
this.appendLog(`mirror tap at ${x},${y}`);
|
||||||
if (!shell.hasOverlay() && stripShown && x < SIDEBAR_WIDTH) {
|
if (!shell.hasOverlay() && stripShown && isOnSwitcherEdge(x, y, foreground?.heightMode ?? "min", foreground?.appId)) {
|
||||||
const target = shell.windowAtSidebarPoint(x, y);
|
const target = shell.windowAtSidebarPoint(x, y);
|
||||||
if (target) {
|
if (target) {
|
||||||
this.appendLog(`mirror tap: sidebar -> ${target.title}`);
|
this.appendLog(`mirror tap: sidebar -> ${target.title}`);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import { makeInputEvent, type InputEvent, type InputEventPayload } from '../ui/g
|
|||||||
import { noopLayerActions, type LayerActions } from '../ui/layers'
|
import { noopLayerActions, type LayerActions } from '../ui/layers'
|
||||||
import { TextViewerLayer } from '../apps/files/text-viewer'
|
import { TextViewerLayer } from '../apps/files/text-viewer'
|
||||||
import { shell, rawInputEventToInputEvent, type ShellWindow } from '../ui/shell/shell'
|
import { shell, rawInputEventToInputEvent, type ShellWindow } from '../ui/shell/shell'
|
||||||
import { appViewportRect, SIDEBAR_WIDTH, sidebarStripVisible } from '../ui/shell/geometry'
|
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible } from '../ui/shell/geometry'
|
||||||
import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, onAnySettingChanged,
|
import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, onAnySettingChanged,
|
||||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
||||||
nightscoutSiteUrlSetting, nightscoutApiTokenSetting } from '../ui/dashboard-settings'
|
nightscoutSiteUrlSetting, nightscoutApiTokenSetting } from '../ui/dashboard-settings'
|
||||||
@@ -531,7 +531,8 @@ export class IosPreviewController {
|
|||||||
const x = Math.max(0, Math.min(639, Math.floor(nx * 640)))
|
const x = Math.max(0, Math.min(639, Math.floor(nx * 640)))
|
||||||
const y = Math.max(0, Math.min(479, Math.floor(ny * 480)))
|
const y = Math.max(0, Math.min(479, Math.floor(ny * 480)))
|
||||||
const window = shell.foregroundWindow()
|
const window = shell.foregroundWindow()
|
||||||
if (!shell.hasOverlay() && sidebarStripVisible(shell.getFocus(), window?.appId) && x < SIDEBAR_WIDTH) {
|
if (!shell.hasOverlay() && sidebarStripVisible(shell.getFocus(), window?.appId)
|
||||||
|
&& isOnSwitcherEdge(x, y, window?.heightMode ?? 'min', window?.appId)) {
|
||||||
const target = shell.windowAtSidebarPoint(x, y)
|
const target = shell.windowAtSidebarPoint(x, y)
|
||||||
if (target) { shell.focusWindow(target.windowId); target.requestRender(); this.requestShellRender() }
|
if (target) { shell.focusWindow(target.windowId); target.requestRender(); this.requestShellRender() }
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -10,8 +10,12 @@ export function shellCrop(image: GrayImage, x: number, y: number, width: number,
|
|||||||
return { image: crop, x, y, shellKey: key }
|
return { image: crop, x, y, shellKey: key }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shared Kotlin receives original 8-bit pixels and quantizes once, before composing. */
|
/**
|
||||||
export function encodeShellScene(planes: readonly Plane[]): Uint8Array {
|
* Shared Kotlin receives original 8-bit pixels and quantizes once, before
|
||||||
|
* composing. `screenDepth` is the whole display's stereo depth (geometry.ts
|
||||||
|
* uiDepth), trailing the layers.
|
||||||
|
*/
|
||||||
|
export function encodeShellScene(planes: readonly Plane[], screenDepth = 0): Uint8Array {
|
||||||
const layers: { image: GrayImage; x: number; y: number; key: number; depth: number; dim: number; selections: Uint8Array[] }[] = []
|
const layers: { image: GrayImage; x: number; y: number; key: number; depth: number; dim: number; selections: Uint8Array[] }[] = []
|
||||||
for (const plane of planes) {
|
for (const plane of planes) {
|
||||||
const image = plane.image.withDrawsBaked(false)
|
const image = plane.image.withDrawsBaked(false)
|
||||||
@@ -30,10 +34,11 @@ export function encodeShellScene(planes: readonly Plane[]): Uint8Array {
|
|||||||
presentation: { ...d.presentation!, depth: d.presentation!.depth + (plane.depth ?? 0) } }))
|
presentation: { ...d.presentation!, depth: d.presentation!.depth + (plane.depth ?? 0) } }))
|
||||||
layers.push({ depth: plane.depth ?? 0, selections, image: cropped.image, x: plane.x + left, y: plane.y + top, key: plane.shellKey!, dim: Math.round((plane.dimUnderneath ?? 1) * 256) })
|
layers.push({ depth: plane.depth ?? 0, selections, image: cropped.image, x: plane.x + left, y: plane.y + top, key: plane.shellKey!, dim: Math.round((plane.dimUnderneath ?? 1) * 256) })
|
||||||
}
|
}
|
||||||
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((sum, b) => sum + b.length, 0), 0))
|
const result = new Uint8Array(4 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((sum, b) => sum + b.length, 0), 0))
|
||||||
const view = new DataView(result.buffer); let p = 0
|
const view = new DataView(result.buffer); let p = 0
|
||||||
const word = (n: number) => { view.setUint16(p, n, true); p += 2 }
|
const word = (n: number) => { view.setUint16(p, n, true); p += 2 }
|
||||||
word(layers.length)
|
word(layers.length)
|
||||||
for (const l of layers) { word(l.key); word(l.x); word(l.y); word(l.image.width); word(l.image.height); word(l.dim); word(l.selections.length); word(l.depth); result.set(l.image.pixels, p); p += l.image.pixels.length; for (const selection of l.selections) { result.set(selection, p); p += selection.length } }
|
for (const l of layers) { word(l.key); word(l.x); word(l.y); word(l.image.width); word(l.image.height); word(l.dim); word(l.selections.length); word(l.depth); result.set(l.image.pixels, p); p += l.image.pixels.length; for (const selection of l.selections) { result.set(selection, p); p += selection.length } }
|
||||||
|
word(screenDepth)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -308,19 +308,32 @@ export const timeFormatSetting = new ConfigSettingEnum<TimeFormat>({
|
|||||||
* How much of the 640x480 panel the UI uses. "576x288" is the stock band
|
* How much of the 640x480 panel the UI uses. "576x288" is the stock band
|
||||||
* (sidebar + a 288px-tall window at the vertical position); "576x480" keeps
|
* (sidebar + a 288px-tall window at the vertical position); "576x480" keeps
|
||||||
* the sidebar and gives every window the full height; "640x480" is the whole
|
* the sidebar and gives every window the full height; "640x480" is the whole
|
||||||
* panel, with the sidebar an overlay that shows only while it has focus.
|
* panel, with the sidebar an overlay that shows only while it has focus. The
|
||||||
|
* values name the sizes beside a side strip; with the app switcher along the
|
||||||
|
* bottom, the tall height loses the switcher row (displayModeLabel shows the
|
||||||
|
* actual size).
|
||||||
*/
|
*/
|
||||||
export const DISPLAY_MODE_VALUES = ["576x288", "576x480", "640x480"] as const;
|
export const DISPLAY_MODE_VALUES = ["576x288", "576x480", "640x480"] as const;
|
||||||
export type DisplayModeSetting = (typeof DISPLAY_MODE_VALUES)[number];
|
export type DisplayModeSetting = (typeof DISPLAY_MODE_VALUES)[number];
|
||||||
|
|
||||||
const DISPLAY_MODE_LABELS: Record<DisplayModeSetting, string> = {
|
const DISPLAY_MODE_NAMES: Record<DisplayModeSetting, string> = {
|
||||||
"576x288": "Band · 576×288",
|
"576x288": "Band",
|
||||||
"576x480": "Tall · 576×480",
|
"576x480": "Tall",
|
||||||
"640x480": "Full panel · 640×480",
|
"640x480": "Full panel",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Window size per mode with the app switcher along the bottom (see geometry.ts). */
|
||||||
|
const BOTTOM_SWITCHER_SIZES: Record<DisplayModeSetting, string> = {
|
||||||
|
"576x288": "576×288",
|
||||||
|
"576x480": "576×444",
|
||||||
|
"640x480": "640×480",
|
||||||
};
|
};
|
||||||
|
|
||||||
export function displayModeLabel(value: DisplayModeSetting): string {
|
export function displayModeLabel(value: DisplayModeSetting): string {
|
||||||
return DISPLAY_MODE_LABELS[value] ?? value;
|
const name = DISPLAY_MODE_NAMES[value];
|
||||||
|
if (!name) return value;
|
||||||
|
const size = appSwitcherPositionSetting.get() === "bottom" ? BOTTOM_SWITCHER_SIZES[value] : value.replace("x", "×");
|
||||||
|
return `${name} · ${size}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const displayModeSetting = new ConfigSettingEnum<DisplayModeSetting>({
|
export const displayModeSetting = new ConfigSettingEnum<DisplayModeSetting>({
|
||||||
@@ -331,7 +344,52 @@ export const displayModeSetting = new ConfigSettingEnum<DisplayModeSetting>({
|
|||||||
values: DISPLAY_MODE_VALUES,
|
values: DISPLAY_MODE_VALUES,
|
||||||
formatValue: displayModeLabel,
|
formatValue: displayModeLabel,
|
||||||
description:
|
description:
|
||||||
"Band: the stock 576×288 window beside the sidebar. Tall: the sidebar plus full-height windows. Full panel: the whole 640×480 display; the sidebar 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";
|
||||||
|
|
||||||
|
const APP_SWITCHER_POSITION_LABELS: Record<AppSwitcherPosition, string> = {
|
||||||
|
left: "Left",
|
||||||
|
right: "Right",
|
||||||
|
bottom: "Bottom",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosition>({
|
||||||
|
id: "app-switcher-position",
|
||||||
|
label: "App switcher position",
|
||||||
|
storageKey: "display.appSwitcherPosition",
|
||||||
|
defaultValue: "left",
|
||||||
|
values: ["left", "right", "bottom"],
|
||||||
|
formatValue: (value) => APP_SWITCHER_POSITION_LABELS[value] ?? value,
|
||||||
|
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.",
|
||||||
|
});
|
||||||
|
|
||||||
|
const UI_DEPTH_VALUES = ["-64", "-48", "-32", "-16", "0", "16", "32", "48", "64"] as const;
|
||||||
|
export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stereo depth of the whole display, in the firmware's depth units: the
|
||||||
|
* lenses shift everything by half this many pixels each, in opposite
|
||||||
|
* directions. Only applies with the app switcher at the bottom, where the
|
||||||
|
* windows' 576px width leaves 32px at each side to shift into (see
|
||||||
|
* geometry.ts uiDepth); values stay even so the per-lens halves of nested
|
||||||
|
* depths add exactly.
|
||||||
|
*/
|
||||||
|
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
||||||
|
id: "ui-depth",
|
||||||
|
label: "Depth",
|
||||||
|
storageKey: "display.uiDepth",
|
||||||
|
defaultValue: "0",
|
||||||
|
values: UI_DEPTH_VALUES,
|
||||||
|
formatValue: (value) => {
|
||||||
|
const depth = Number(value);
|
||||||
|
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
|
||||||
|
},
|
||||||
|
description:
|
||||||
|
"Moves the whole display nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses. Available with the app switcher at the bottom. Full-panel windows lose a sliver at the edges.",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
|
export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import { drawRightValueMenuItem, openModalMenu, type MenuItem } from "../menu";
|
|||||||
import { shell } from "../shell/shell";
|
import { shell } from "../shell/shell";
|
||||||
import {
|
import {
|
||||||
anthropicApiKeySetting,
|
anthropicApiKeySetting,
|
||||||
|
appSwitcherPositionSetting,
|
||||||
|
uiDepthSetting,
|
||||||
assistantAllowProactiveSetting,
|
assistantAllowProactiveSetting,
|
||||||
assistantBackendSetting,
|
assistantBackendSetting,
|
||||||
assistantBridgeHostSetting,
|
assistantBridgeHostSetting,
|
||||||
@@ -84,6 +86,7 @@ export function createSettingsPanelLayer(): SettingsPanelLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function settingsSections(): SettingsSection[] {
|
function settingsSections(): SettingsSection[] {
|
||||||
|
const customizationItems = customizationRows();
|
||||||
const sections: SettingsSection[] = [
|
const sections: SettingsSection[] = [
|
||||||
{
|
{
|
||||||
label: "Display",
|
label: "Display",
|
||||||
@@ -107,16 +110,11 @@ function settingsSections(): SettingsSection[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Customization",
|
label: "Customization",
|
||||||
items: [
|
// Depth only applies (and only shows) with the app switcher at the
|
||||||
// Submenu: top-bar battery indicator style plus per-device visibility.
|
// bottom; the panel re-reads the rows each paint.
|
||||||
batteryIndicatorsMenuItem(),
|
get items() {
|
||||||
// Submenu: toggles for menu/icon-grid motion and the screen on/off fade.
|
return customizationItems();
|
||||||
animationsMenuItem(),
|
},
|
||||||
// Controls the top-bar clock (24-hour vs 12-hour).
|
|
||||||
enumSettingMenuItem(timeFormatSetting),
|
|
||||||
// Opens the modal font picker (face, weight, size) for UI text.
|
|
||||||
uiFontPickerMenuItem(),
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Voice",
|
label: "Voice",
|
||||||
@@ -234,6 +232,31 @@ function settingsSections(): SettingsSection[] {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Customization rows, as a function of the current settings: the same
|
||||||
|
* array while the switcher position stays put, so the panel's menu sees a
|
||||||
|
* stable list between paints.
|
||||||
|
*/
|
||||||
|
function customizationRows(): () => MenuItem[] {
|
||||||
|
// Left / right / bottom edge; the dashboard controller moves (or, to and
|
||||||
|
// from the bottom, resizes) windows on change.
|
||||||
|
const position = enumSettingMenuItem(appSwitcherPositionSetting);
|
||||||
|
// The whole display's stereo depth; the shell sends it with its scene.
|
||||||
|
const depth = enumSettingMenuItem(uiDepthSetting);
|
||||||
|
const rest = [
|
||||||
|
// Submenu: top-bar battery indicator style plus per-device visibility.
|
||||||
|
batteryIndicatorsMenuItem(),
|
||||||
|
// Submenu: toggles for menu/icon-grid motion and the screen on/off fade.
|
||||||
|
animationsMenuItem(),
|
||||||
|
// Controls the top-bar clock (24-hour vs 12-hour).
|
||||||
|
enumSettingMenuItem(timeFormatSetting),
|
||||||
|
// Opens the modal font picker (face, weight, size) for UI text.
|
||||||
|
uiFontPickerMenuItem(),
|
||||||
|
];
|
||||||
|
const withDepth = [position, depth, ...rest], withoutDepth = [position, ...rest];
|
||||||
|
return () => appSwitcherPositionSetting.get() === "bottom" ? withDepth : withoutDepth;
|
||||||
|
}
|
||||||
|
|
||||||
function autoBrightnessMenuItem(): MenuItem {
|
function autoBrightnessMenuItem(): MenuItem {
|
||||||
return {
|
return {
|
||||||
label: "Auto-brightness",
|
label: "Auto-brightness",
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import { shell } from "../shell/shell";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One left-column entry. `items` are the right-column rows (reusing the shared
|
* One left-column entry. `items` are the right-column rows (reusing the shared
|
||||||
* MenuItem builders). `renderDetail`, when set, draws custom informational
|
* MenuItem builders); it may be a getter for rows that come and go with other
|
||||||
|
* settings, since the panel re-reads it on every paint. `renderDetail`, when set, draws custom informational
|
||||||
* content (e.g. About) at the top of the pane and returns the pixel height it
|
* content (e.g. About) at the top of the pane and returns the pixel height it
|
||||||
* consumed; the row list renders below it. Returning nothing claims the whole
|
* consumed; the row list renders below it. Returning nothing claims the whole
|
||||||
* pane (an info-only section).
|
* pane (an info-only section).
|
||||||
|
|||||||
+286
-146
@@ -16,6 +16,7 @@ import {
|
|||||||
phoneBatteryVisibilitySetting,
|
phoneBatteryVisibilitySetting,
|
||||||
ringBatteryVisibilitySetting,
|
ringBatteryVisibilitySetting,
|
||||||
watchBatteryVisibilitySetting,
|
watchBatteryVisibilitySetting,
|
||||||
|
type AppSwitcherPosition,
|
||||||
type BatteryIndicatorVisibility,
|
type BatteryIndicatorVisibility,
|
||||||
} from "../dashboard-settings";
|
} from "../dashboard-settings";
|
||||||
import { formatClockDate, formatClockTime } from "../clock-format";
|
import { formatClockDate, formatClockTime } from "../clock-format";
|
||||||
@@ -24,34 +25,43 @@ import { Layer, LayerStack } from "../layers";
|
|||||||
import { scrollToKeepSelectionVisible } from "../menu";
|
import { scrollToKeepSelectionVisible } from "../menu";
|
||||||
import { lineStep } from "../metrics";
|
import { lineStep } from "../metrics";
|
||||||
import {
|
import {
|
||||||
|
appViewportRect,
|
||||||
MIN_WINDOW_HEIGHT,
|
MIN_WINDOW_HEIGHT,
|
||||||
minWindowTop,
|
minWindowTop,
|
||||||
SHELL_OPAQUE_BLACK,
|
SHELL_OPAQUE_BLACK,
|
||||||
SIDEBAR_WIDTH,
|
SIDEBAR_WIDTH,
|
||||||
sidebarStripVisible,
|
sidebarStripVisible,
|
||||||
|
SWITCHER_ROW_HEIGHT,
|
||||||
|
switcherPosition,
|
||||||
|
switcherRect,
|
||||||
TOP_BAR_HEIGHT,
|
TOP_BAR_HEIGHT,
|
||||||
windowTop,
|
windowTop,
|
||||||
type WindowHeightMode,
|
type WindowHeightMode,
|
||||||
} from "./geometry";
|
} from "./geometry";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sidebar icon layout comes in two variants. Few enough windows for a single
|
* Sidebar icon layout (the app switcher on the left or right edge) comes in
|
||||||
* column keeps the roomy 36px slots (32px icons) right-aligned against the
|
* two variants. Few enough windows for a single column keeps the roomy 36px
|
||||||
* separator; past one column's worth it switches to two 32px slots (28px
|
* slots (32px icons) aligned against the separator; past one column's worth
|
||||||
* icons) that exactly fill the 64px sidebar. In the two-column variant the
|
* it switches to two 32px slots (28px icons) that exactly fill the 64px
|
||||||
* right column (against the app area) fills first and windows past that
|
* sidebar. In the two-column variant the column against the app area fills
|
||||||
* overflow into the left column, so the common case keeps every icon next to
|
* first and windows past that overflow into the outer column, so the common
|
||||||
* the content it belongs to.
|
* case keeps every icon next to the content it belongs to. A bottom row
|
||||||
|
* always uses the roomy slots, laid out left to right.
|
||||||
*/
|
*/
|
||||||
type SidebarVariant = { columns: number; columnWidth: number; iconSize: number };
|
type SidebarVariant = { columns: number; columnWidth: number; iconSize: number };
|
||||||
const ONE_COLUMN: SidebarVariant = { columns: 1, columnWidth: 36, iconSize: 32 };
|
const ONE_COLUMN: SidebarVariant = { columns: 1, columnWidth: 36, iconSize: 32 };
|
||||||
const TWO_COLUMN: SidebarVariant = { columns: 2, columnWidth: 32, iconSize: 28 };
|
const TWO_COLUMN: SidebarVariant = { columns: 2, columnWidth: 32, iconSize: 28 };
|
||||||
|
|
||||||
const ICON_SPACING = 8;
|
const ICON_SPACING = 8;
|
||||||
/** Icon list top/bottom margins within the sidebar band, below the top bar. */
|
/** Icon list top/bottom margins within the sidebar band, below the top bar (and a bottom row's end margins). */
|
||||||
const LIST_MARGIN = 10;
|
const LIST_MARGIN = 10;
|
||||||
const LIST_HEIGHT = MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT - 2 * LIST_MARGIN;
|
const LIST_HEIGHT = MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT - 2 * LIST_MARGIN;
|
||||||
|
|
||||||
|
/** Bottom-row icons: one tall tab's worth of row, the icon inset 2px all round. */
|
||||||
|
const ROW_ICON_SIZE = SWITCHER_ROW_HEIGHT - 4;
|
||||||
|
const ROW_STEP = ROW_ICON_SIZE + ICON_SPACING;
|
||||||
|
|
||||||
/** 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);
|
||||||
@@ -61,23 +71,14 @@ function sidebarVariant(windowCount: number): SidebarVariant {
|
|||||||
return windowCount > rowsPerColumn(ONE_COLUMN) ? TWO_COLUMN : ONE_COLUMN;
|
return windowCount > rowsPerColumn(ONE_COLUMN) ? TWO_COLUMN : ONE_COLUMN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Left x of a sidebar column; columns pack rightward against the separator. */
|
|
||||||
function columnLeft(variant: SidebarVariant, column: number): number {
|
|
||||||
return SIDEBAR_WIDTH - (variant.columns - column) * variant.columnWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Column and top y of a visible sidebar slot; `position` counts from the
|
* Left x of a sidebar column. Column 0 sits against the separator (the
|
||||||
* first visible (scrolled-to) icon. Slots fill the rightmost column top to
|
* strip's inner edge, toward the app area); further columns pack outward.
|
||||||
* bottom, then overflow leftward. The single source of slot geometry for
|
|
||||||
* both drawing and hit testing.
|
|
||||||
*/
|
*/
|
||||||
function slotPosition(variant: SidebarVariant, listTop: number, position: number): { column: number; y: number } {
|
function columnLeft(variant: SidebarVariant, column: number, position: AppSwitcherPosition): number {
|
||||||
const rows = rowsPerColumn(variant);
|
return position === "right"
|
||||||
return {
|
? G2_LENS_WIDTH - SIDEBAR_WIDTH + column * variant.columnWidth
|
||||||
column: variant.columns - 1 - ((position / rows) | 0),
|
: SIDEBAR_WIDTH - (column + 1) * variant.columnWidth;
|
||||||
y: listTop + (position % rows) * (variant.iconSize + ICON_SPACING),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Top y of the sidebar's icon list (below the band's top bar). */
|
/** Top y of the sidebar's icon list (below the band's top bar). */
|
||||||
@@ -86,12 +87,88 @@ function sidebarListTop(appId?: string): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Left edge of the sidebar region that actually holds icons: the one-column
|
* One visible switcher icon's selection cell: the 2px-margined box around
|
||||||
* variant leaves a dead strip left of its single right-aligned column.
|
* the icon that a selection tab or box fills. `atSeparator` is whether the
|
||||||
* Screenshot cropping uses this to trim the unused part.
|
* cell touches the separator, so the selection can divert it (a tab) rather
|
||||||
|
* than sit apart from it (a box, for sidebar overflow-column icons).
|
||||||
*/
|
*/
|
||||||
export function sidebarContentLeft(windowCount: number): number {
|
type SwitcherCell = { x: number; y: number; width: number; height: number; atSeparator: boolean };
|
||||||
return columnLeft(sidebarVariant(windowCount), 0);
|
|
||||||
|
type SwitcherLayout = {
|
||||||
|
position: AppSwitcherPosition;
|
||||||
|
iconSize: number;
|
||||||
|
/** How many icons fit at once; the list scrolls to keep the selection among them. */
|
||||||
|
visibleCount: number;
|
||||||
|
/**
|
||||||
|
* Cell of the icon `slot` places past the first visible (scrolled-to) one.
|
||||||
|
* The single source of slot geometry for both drawing and hit testing.
|
||||||
|
*/
|
||||||
|
cell: (slot: number) => SwitcherCell;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Switcher geometry for the foreground window (a bottom row sits under it). */
|
||||||
|
function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId?: string): SwitcherLayout {
|
||||||
|
const position = switcherPosition();
|
||||||
|
if (position === "bottom") {
|
||||||
|
const row = switcherRect(heightMode, appId);
|
||||||
|
return {
|
||||||
|
position,
|
||||||
|
iconSize: ROW_ICON_SIZE,
|
||||||
|
visibleCount: Math.max(1, ((row.width - 2 * LIST_MARGIN + ICON_SPACING) / ROW_STEP) | 0),
|
||||||
|
cell: (slot) => ({
|
||||||
|
x: row.x + LIST_MARGIN - 2 + slot * ROW_STEP, y: row.y, width: ROW_ICON_SIZE + 4, height: SWITCHER_ROW_HEIGHT,
|
||||||
|
atSeparator: true,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Slots fill the column against the separator top to bottom, then
|
||||||
|
// overflow outward.
|
||||||
|
const variant = sidebarVariant(windowCount);
|
||||||
|
const rows = rowsPerColumn(variant);
|
||||||
|
const listTop = sidebarListTop(appId);
|
||||||
|
return {
|
||||||
|
position,
|
||||||
|
iconSize: variant.iconSize,
|
||||||
|
visibleCount: rows * variant.columns,
|
||||||
|
cell: (slot) => {
|
||||||
|
const column = (slot / rows) | 0;
|
||||||
|
return {
|
||||||
|
x: columnLeft(variant, column, position),
|
||||||
|
y: listTop + (slot % rows) * (variant.iconSize + ICON_SPACING) - 2,
|
||||||
|
width: variant.columnWidth,
|
||||||
|
height: variant.iconSize + 4,
|
||||||
|
atSeparator: column === 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* column. Screenshot cropping uses this to trim the unused part.
|
||||||
|
*/
|
||||||
|
export function sidebarContentSpan(windowCount: number): { left: number; right: number } {
|
||||||
|
const variant = sidebarVariant(windowCount);
|
||||||
|
const width = variant.columns * variant.columnWidth;
|
||||||
|
return switcherPosition() === "right"
|
||||||
|
? { left: G2_LENS_WIDTH - SIDEBAR_WIDTH, right: G2_LENS_WIDTH - SIDEBAR_WIDTH + width }
|
||||||
|
: { left: SIDEBAR_WIDTH - width, right: SIDEBAR_WIDTH };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Horizontal extent of the top bar: the foreground window's, short of a side
|
||||||
|
* strip overlaid on it (full-panel mode, sidebar focused).
|
||||||
|
*/
|
||||||
|
function topBarSpan(state: ShellChromeState): { left: number; right: number } {
|
||||||
|
const viewport = appViewportRect(state.foregroundHeightMode, state.foregroundAppId);
|
||||||
|
let left = viewport.x, right = viewport.x + viewport.width;
|
||||||
|
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
|
||||||
|
const position = switcherPosition();
|
||||||
|
if (position === "left") left = Math.max(left, SIDEBAR_WIDTH);
|
||||||
|
if (position === "right") right = Math.min(right, G2_LENS_WIDTH - SIDEBAR_WIDTH);
|
||||||
|
}
|
||||||
|
return { left, right };
|
||||||
}
|
}
|
||||||
const NOTIFICATION_ICON_SIZE = 24;
|
const NOTIFICATION_ICON_SIZE = 24;
|
||||||
const BORDER_VALUE = 40;
|
const BORDER_VALUE = 40;
|
||||||
@@ -195,12 +272,12 @@ export function makeImageWindowIcon(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base layer of the shell surface: the window sidebar on the left and the
|
* Base layer of the shell surface: the window sidebar (or bottom row) and
|
||||||
* status top bar. Everything not explicitly painted stays 0 (transparent on
|
* the status top bar. Everything not explicitly painted stays 0 (transparent
|
||||||
* the color-key shell surface), so the app viewport shows through.
|
* on the color-key shell surface), so the app viewport shows through.
|
||||||
*/
|
*/
|
||||||
export class ShellChromeLayer implements Layer {
|
export class ShellChromeLayer implements Layer {
|
||||||
// First sidebar row 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;
|
||||||
|
|
||||||
constructor(private readonly getState: () => ShellChromeState) {}
|
constructor(private readonly getState: () => ShellChromeState) {}
|
||||||
@@ -214,7 +291,7 @@ export class ShellChromeLayer implements Layer {
|
|||||||
this.drawSidebar(image, state);
|
this.drawSidebar(image, state);
|
||||||
}
|
}
|
||||||
this.drawTopBar(image, state);
|
this.drawTopBar(image, state);
|
||||||
drawAmbientCards(image);
|
drawAmbientCards(image, topBarSpan(state).right);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,13 +300,14 @@ export class ShellChromeLayer implements Layer {
|
|||||||
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
|
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
|
||||||
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
this.drawSidebar(canvas, state);
|
this.drawSidebar(canvas, state);
|
||||||
parts.push(shellCrop(canvas, 0, minWindowTop(state.foregroundAppId), SIDEBAR_WIDTH, MIN_WINDOW_HEIGHT, 1));
|
const strip = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
|
||||||
|
parts.push(shellCrop(canvas, strip.x, strip.y, strip.width, strip.height, 1));
|
||||||
}
|
}
|
||||||
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||||
this.drawTopBar(canvas, state);
|
this.drawTopBar(canvas, state);
|
||||||
const left = sidebarStripVisible(state.focus, state.foregroundAppId) ? SIDEBAR_WIDTH : 0;
|
const bar = topBarSpan(state);
|
||||||
parts.push({ ...shellCrop(canvas, left, windowTop(state.foregroundHeightMode, state.foregroundAppId), G2_LENS_WIDTH-left, TOP_BAR_HEIGHT, 2), depth: -2 });
|
parts.push({ ...shellCrop(canvas, bar.left, windowTop(state.foregroundHeightMode, state.foregroundAppId), bar.right - bar.left, TOP_BAR_HEIGHT, 2), depth: -2 });
|
||||||
drawAmbientCards(canvas, parts);
|
drawAmbientCards(canvas, bar.right, parts);
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,19 +317,18 @@ export class ShellChromeLayer implements Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Which window's sidebar icon is under (x, y) on screen, if any — the same
|
* Which window's switcher icon is under (x, y) on screen, if any — the
|
||||||
* slot geometry drawSidebar uses, so a touch on the phone's mirror lands on
|
* same slot geometry drawSidebar uses, so a touch on the phone's mirror
|
||||||
* the icon the mirror showed.
|
* lands on the icon the mirror showed.
|
||||||
*/
|
*/
|
||||||
windowIndexAt(x: number, y: number, windowCount: number): number | null {
|
windowIndexAt(x: number, y: number, windowCount: number): number | null {
|
||||||
if (x < 0 || x >= SIDEBAR_WIDTH || windowCount === 0) return null;
|
if (windowCount === 0) return null;
|
||||||
const variant = sidebarVariant(windowCount);
|
const state = this.getState();
|
||||||
const listTop = sidebarListTop(this.getState().foregroundAppId);
|
const layout = switcherLayout(windowCount, state.foregroundHeightMode, state.foregroundAppId);
|
||||||
const lastVisible = Math.min(windowCount, this.scrollRow + rowsPerColumn(variant) * variant.columns);
|
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 { column, y: slotY } = slotPosition(variant, listTop, index - this.scrollRow);
|
const cell = layout.cell(index - this.scrollRow);
|
||||||
const left = columnLeft(variant, column);
|
if (x >= cell.x && x < cell.x + cell.width && y >= cell.y && y < cell.y + cell.height) {
|
||||||
if (x >= left && x < left + variant.columnWidth && y >= slotY - 2 && y < slotY + variant.iconSize + 2) {
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,60 +336,48 @@ export class ShellChromeLayer implements Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private drawSidebar(image: GrayImage, state: ShellChromeState): void {
|
private drawSidebar(image: GrayImage, state: ShellChromeState): void {
|
||||||
// Align the sidebar with the app's preferred band. Legacy tall terminal
|
// A side strip aligns with the app's preferred band (legacy tall
|
||||||
// sessions keep the sidebar at the global band position.
|
// terminal sessions keep it at the global band position); a bottom row
|
||||||
const bandTop = minWindowTop(state.foregroundAppId);
|
// sits under the foreground window.
|
||||||
const bandBottom = bandTop + MIN_WINDOW_HEIGHT;
|
const strip = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
|
||||||
image.fillRect(0, bandTop, SIDEBAR_WIDTH, MIN_WINDOW_HEIGHT, SHELL_OPAQUE_BLACK);
|
image.fillRect(strip.x, strip.y, strip.width, strip.height, SHELL_OPAQUE_BLACK);
|
||||||
|
|
||||||
// Scroll the icon list to keep the selection visible; chevrons mark
|
// Scroll the icon list to keep the selection visible; chevrons mark
|
||||||
// windows off-screen above/below. Icons fill the right column top to
|
// windows off-screen before/after. Sidebar icons fill the column against
|
||||||
// bottom, then overflow into the left one, so a visible slot's column is
|
// the separator top to bottom, then overflow into the outer one, so a
|
||||||
// decided by its position within the scrolled window.
|
// visible slot's column is decided by its position within the scrolled
|
||||||
|
// window.
|
||||||
const count = state.windows.length;
|
const count = state.windows.length;
|
||||||
const variant = sidebarVariant(count);
|
const layout = switcherLayout(count, state.foregroundHeightMode, state.foregroundAppId);
|
||||||
const iconSize = variant.iconSize;
|
const { iconSize, position } = layout;
|
||||||
const iconMarginX = ((variant.columnWidth - iconSize) / 2) | 0;
|
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, state.selectedIndex, layout.visibleCount, count);
|
||||||
// Column index of the rightmost column (the one that fills first).
|
const lastVisible = Math.min(count, this.scrollRow + layout.visibleCount);
|
||||||
const firstColumn = variant.columns - 1;
|
const cellOf = (index: number) => layout.cell(index - this.scrollRow);
|
||||||
const listTop = sidebarListTop(state.foregroundAppId);
|
|
||||||
const visibleCount = rowsPerColumn(variant) * variant.columns;
|
|
||||||
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, state.selectedIndex, visibleCount, count);
|
|
||||||
const lastVisible = Math.min(count, this.scrollRow + visibleCount);
|
|
||||||
const slotOf = (index: number) => slotPosition(variant, listTop, index - this.scrollRow);
|
|
||||||
|
|
||||||
// The selection is a "diversion" of the sidebar/main separator line: the
|
// The selection is a "diversion" of the switcher/main separator line:
|
||||||
// line bulges right around the selected icon (rounded on the left, open
|
// the line bulges toward the main area around the selected icon (rounded
|
||||||
// to the main area on the right), so the separator is drawn with a gap
|
// on the outer side, open to the main area), so the separator is drawn
|
||||||
// there. When the sidebar has focus, the diversion is filled white and
|
// with a gap there. When the switcher has focus, the diversion is filled
|
||||||
// the icon drawn inverted. Only the right column touches the separator;
|
// white and the icon drawn inverted. Only the sidebar column against the
|
||||||
// a selected overflow icon gets a self-contained box instead.
|
// separator touches it; a selected overflow icon gets a self-contained
|
||||||
const sep = SIDEBAR_WIDTH - 1;
|
// box instead.
|
||||||
// Start beside the app content, leaving the area alongside the top bar open.
|
|
||||||
const sepTop = Math.max(bandTop, windowTop(state.foregroundHeightMode, state.foregroundAppId) + TOP_BAR_HEIGHT);
|
|
||||||
const selVisible = state.selectedIndex >= this.scrollRow && state.selectedIndex < lastVisible;
|
const selVisible = state.selectedIndex >= this.scrollRow && state.selectedIndex < lastVisible;
|
||||||
const selSlot = selVisible ? slotOf(state.selectedIndex) : null;
|
const selCell = selVisible ? cellOf(state.selectedIndex) : null;
|
||||||
const selTabTop = selSlot && selSlot.column === firstColumn ? selSlot.y - 2 : null;
|
drawSeparator(image, state, strip, selCell?.atSeparator ? selCell : null);
|
||||||
if (selTabTop !== null) {
|
|
||||||
image.drawLine(sep, sepTop, sep, selTabTop, BORDER_VALUE);
|
|
||||||
image.drawLine(sep, selTabTop + iconSize + 4, sep, bandBottom - 1, BORDER_VALUE);
|
|
||||||
} else {
|
|
||||||
image.drawLine(sep, sepTop, sep, bandBottom - 1, BORDER_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let index = this.scrollRow; index < lastVisible; index++) {
|
for (let index = this.scrollRow; index < lastVisible; index++) {
|
||||||
const window = state.windows[index]!;
|
const window = state.windows[index]!;
|
||||||
const { column, y } = slotOf(index);
|
const cell = cellOf(index);
|
||||||
const left = columnLeft(variant, column);
|
const x = cell.x + (((cell.width - iconSize) / 2) | 0);
|
||||||
const x = left + iconMarginX;
|
const y = cell.y + (((cell.height - iconSize) / 2) | 0);
|
||||||
const selected = index === state.selectedIndex;
|
const selected = index === state.selectedIndex;
|
||||||
const focused = selected && state.focus === "sidebar";
|
const focused = selected && state.focus === "sidebar";
|
||||||
if (selected && column === firstColumn) {
|
if (selected && cell.atSeparator) {
|
||||||
drawSelectionTab(image, left, y - 2, y + iconSize + 2, focused);
|
drawSelectionTab(image, cell, position, focused);
|
||||||
} else if (selected) {
|
} else if (selected) {
|
||||||
// Spans the full column: only 2px of margin flanks the icon in its
|
// Spans the full column: only 2px of margin flanks the icon in its
|
||||||
// slot, so anything wider would clip at the screen edge.
|
// slot, so anything wider would clip at the screen edge.
|
||||||
drawSelectionBox(image, left, y - 2, variant.columnWidth, iconSize + 4, focused);
|
drawSelectionBox(image, cell.x, cell.y, cell.width, cell.height, focused);
|
||||||
}
|
}
|
||||||
// Paint unselected icons into their own resource so only the replayed copy moves.
|
// Paint unselected icons into their own resource so only the replayed copy moves.
|
||||||
const icon = selected ? image : new GrayImage(iconSize, iconSize + 1);
|
const icon = selected ? image : new GrayImage(iconSize, iconSize + 1);
|
||||||
@@ -327,14 +392,26 @@ export class ShellChromeLayer implements Layer {
|
|||||||
if (!selected) image.drawDepthImage(icon, x, y - 1, -2);
|
if (!selected) image.drawDepthImage(icon, x, y - 1, -2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (position === "bottom") {
|
||||||
|
// Chevrons sit in the row's end margins, pointing off either end.
|
||||||
|
const chevronY = strip.y + ((strip.height / 2) | 0);
|
||||||
|
if (this.scrollRow > 0) {
|
||||||
|
drawChevron(image, strip.x + 6, chevronY, "left");
|
||||||
|
}
|
||||||
|
if (lastVisible < count) {
|
||||||
|
drawChevron(image, strip.x + strip.width - 6, chevronY, "right");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Chevrons center over the icon area, which in the one-column variant is
|
// Chevrons center over the icon area, which in the one-column variant is
|
||||||
// narrower than the sidebar strip.
|
// narrower than the sidebar strip.
|
||||||
const chevronX = ((columnLeft(variant, 0) + SIDEBAR_WIDTH) / 2) | 0;
|
const span = sidebarContentSpan(count);
|
||||||
|
const chevronX = ((span.left + span.right) / 2) | 0;
|
||||||
if (this.scrollRow > 0) {
|
if (this.scrollRow > 0) {
|
||||||
drawChevron(image, chevronX, bandTop + TOP_BAR_HEIGHT + 6, -1);
|
drawChevron(image, chevronX, strip.y + TOP_BAR_HEIGHT + 6, "up");
|
||||||
}
|
}
|
||||||
if (lastVisible < count) {
|
if (lastVisible < count) {
|
||||||
drawChevron(image, chevronX, bandBottom - 6, 1);
|
drawChevron(image, chevronX, strip.y + strip.height - 6, "down");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,11 +421,11 @@ export class ShellChromeLayer implements Layer {
|
|||||||
// its height mode puts that (screen top for max height). It moves when
|
// its height mode puts that (screen top for max height). It moves when
|
||||||
// the foreground switches to a window of a different height.
|
// the foreground switches to a window of a different height.
|
||||||
const barTop = windowTop(state.foregroundHeightMode, state.foregroundAppId);
|
const barTop = windowTop(state.foregroundHeightMode, state.foregroundAppId);
|
||||||
// The bar spans the app viewport; with the sidebar overlaid (full-panel
|
// The bar spans the app viewport; with a side strip overlaid (full-panel
|
||||||
// mode, sidebar focused) it still starts past the strip.
|
// mode, sidebar focused) it still stops at the strip.
|
||||||
const barLeft = sidebarStripVisible(state.focus, state.foregroundAppId) ? SIDEBAR_WIDTH : 0;
|
const { left: barLeft, right: barRight } = topBarSpan(state);
|
||||||
image.fillRect(barLeft, barTop, G2_LENS_WIDTH - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
image.fillRect(barLeft, barTop, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
||||||
image.drawLine(barLeft, barTop + TOP_BAR_HEIGHT - 1, G2_LENS_WIDTH - 1, barTop + TOP_BAR_HEIGHT - 1, BORDER_VALUE);
|
image.drawLine(barLeft, barTop + TOP_BAR_HEIGHT - 1, barRight - 1, barTop + TOP_BAR_HEIGHT - 1, BORDER_VALUE);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const clock = `${formatClockDate(now)} ${formatClockTime(now)}`;
|
const clock = `${formatClockDate(now)} ${formatClockTime(now)}`;
|
||||||
@@ -356,7 +433,7 @@ export class ShellChromeLayer implements Layer {
|
|||||||
const textY = barTop + Math.max(0, ((TOP_BAR_HEIGHT - font.lineHeight) / 2) | 0);
|
const textY = barTop + Math.max(0, ((TOP_BAR_HEIGHT - font.lineHeight) / 2) | 0);
|
||||||
image.drawText(font, clockX, textY, clock, 210);
|
image.drawText(font, clockX, textY, clock, 210);
|
||||||
|
|
||||||
const batteryLeft = this.drawTopBarBatteries(image, state, barTop);
|
const batteryLeft = this.drawTopBarBatteries(image, state, barTop, barRight);
|
||||||
const trayLeft = drawTrayIcons(image, state.trayIcons, batteryLeft, barTop);
|
const trayLeft = drawTrayIcons(image, state.trayIcons, batteryLeft, barTop);
|
||||||
|
|
||||||
const iconsX = clockX + font.measureText(clock) + 16;
|
const iconsX = clockX + font.measureText(clock) + 16;
|
||||||
@@ -379,9 +456,10 @@ export class ShellChromeLayer implements Layer {
|
|||||||
* running the Faceclaw watch app is reachable (no placeholder otherwise).
|
* running the Faceclaw watch app is reachable (no placeholder otherwise).
|
||||||
* The Settings > Customization > Battery indicators submenu picks the style (label beside a gauge icon or percentage, or stacked above
|
* The Settings > Customization > Battery indicators submenu picks the style (label beside a gauge icon or percentage, or stacked above
|
||||||
* either) and, per device, whether the indicator shows always, only below
|
* either) and, per device, whether the indicator shows always, only below
|
||||||
* 50%, or never. Returns the left edge of the battery block.
|
* 50%, or never. `barRight` is the bar's right edge (short of a right-hand
|
||||||
|
* sidebar). Returns the left edge of the battery block.
|
||||||
*/
|
*/
|
||||||
private drawTopBarBatteries(image: GrayImage, state: ShellChromeState, barTop: number): number {
|
private drawTopBarBatteries(image: GrayImage, state: ShellChromeState, barTop: number, barRight: number): number {
|
||||||
const mode = batteryDisplayModeSetting.get();
|
const mode = batteryDisplayModeSetting.get();
|
||||||
const items: BatteryItem[] = [];
|
const items: BatteryItem[] = [];
|
||||||
const phone = readPhoneBatteryState();
|
const phone = readPhoneBatteryState();
|
||||||
@@ -401,9 +479,9 @@ export class ShellChromeLayer implements Layer {
|
|||||||
pushBatteryItem(items, ringBatteryVisibilitySetting.get(), "R1", state.battery.ring,
|
pushBatteryItem(items, ringBatteryVisibilitySetting.get(), "R1", state.battery.ring,
|
||||||
Boolean(state.battery.ringCharging));
|
Boolean(state.battery.ringCharging));
|
||||||
}
|
}
|
||||||
if (!items.length) return G2_LENS_WIDTH;
|
if (!items.length) return barRight;
|
||||||
if (mode === "stacked" || mode === "stacked-percentage") {
|
if (mode === "stacked" || mode === "stacked-percentage") {
|
||||||
return drawStackedBatteries(image, items, barTop, mode === "stacked-percentage");
|
return drawStackedBatteries(image, items, barTop, barRight, mode === "stacked-percentage");
|
||||||
}
|
}
|
||||||
|
|
||||||
const font = getDefaultSmallFont();
|
const font = getDefaultSmallFont();
|
||||||
@@ -411,7 +489,7 @@ export class ShellChromeLayer implements Layer {
|
|||||||
const labelGap = 5;
|
const labelGap = 5;
|
||||||
const itemGap = 12;
|
const itemGap = 12;
|
||||||
const textY = barTop + Math.max(0, ((TOP_BAR_HEIGHT - font.lineHeight) / 2) | 0);
|
const textY = barTop + Math.max(0, ((TOP_BAR_HEIGHT - font.lineHeight) / 2) | 0);
|
||||||
let x = G2_LENS_WIDTH - BATTERY_BLOCK_RIGHT_MARGIN;
|
let x = barRight - BATTERY_BLOCK_RIGHT_MARGIN;
|
||||||
for (let index = items.length - 1; index >= 0; index--) {
|
for (let index = items.length - 1; index >= 0; index--) {
|
||||||
const item = items[index]!;
|
const item = items[index]!;
|
||||||
const percentText = `${item.percent}%`;
|
const percentText = `${item.percent}%`;
|
||||||
@@ -474,14 +552,14 @@ const STACKED_ITEM_GAP = 10;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stacked styles: each label centered above its gauge icon (or percentage
|
* Stacked styles: each label centered above its gauge icon (or percentage
|
||||||
* text), right-aligned in the bar. Returns the left edge of the battery
|
* text), right-aligned in the bar (ending at barRight). Returns the left edge
|
||||||
* block.
|
* of the battery block.
|
||||||
*/
|
*/
|
||||||
function drawStackedBatteries(image: GrayImage, items: BatteryItem[], barTop: number, percentage: boolean): number {
|
function drawStackedBatteries(image: GrayImage, items: BatteryItem[], barTop: number, barRight: number, percentage: boolean): number {
|
||||||
const font = getFont("terminusv12");
|
const font = getFont("terminusv12");
|
||||||
const labelTop = barTop + STACKED_LABEL_BASELINE - font.ascent;
|
const labelTop = barTop + STACKED_LABEL_BASELINE - font.ascent;
|
||||||
const percentTop = barTop + STACKED_PERCENT_BASELINE - font.ascent;
|
const percentTop = barTop + STACKED_PERCENT_BASELINE - font.ascent;
|
||||||
let x = G2_LENS_WIDTH - BATTERY_BLOCK_RIGHT_MARGIN;
|
let x = barRight - BATTERY_BLOCK_RIGHT_MARGIN;
|
||||||
for (let index = items.length - 1; index >= 0; index--) {
|
for (let index = items.length - 1; index >= 0; index--) {
|
||||||
const item = items[index]!;
|
const item = items[index]!;
|
||||||
const percentText = `${item.percent}%`;
|
const percentText = `${item.percent}%`;
|
||||||
@@ -521,16 +599,18 @@ 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 and newer ones stack above it. Cards that would
|
||||||
* cross into the top bar are dropped rather than clipped.
|
* cross into the top bar are dropped rather than 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, parts?: Plane[]): void {
|
function drawAmbientCards(image: GrayImage, right: number, parts?: Plane[]): void {
|
||||||
const cards = activeAmbientCards();
|
const cards = activeAmbientCards();
|
||||||
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;
|
||||||
const x = G2_LENS_WIDTH - AMBIENT_CARD_WIDTH - AMBIENT_CARD_MARGIN;
|
// Right-aligned with the top bar: clear of a right-hand sidebar.
|
||||||
|
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;
|
||||||
let bottom = bandBottom - AMBIENT_CARD_MARGIN;
|
let bottom = bandBottom - AMBIENT_CARD_MARGIN;
|
||||||
for (const card of cards) {
|
for (const card of cards) {
|
||||||
@@ -591,33 +671,81 @@ const TAB_EXTEND = 0;
|
|||||||
const TAB_STROKE = 150;
|
const TAB_STROKE = 150;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the selection "diversion" of the separator line around a sidebar icon
|
* Draw the switcher/main separator line along the strip's inner edge, with
|
||||||
* in the rightmost column: rounded on the left, square and open on the right,
|
* a gap where the selection tab `gap` diverts it.
|
||||||
* extending a few px past the separator into the main area. Focused = filled
|
|
||||||
* white; otherwise an outline. `left` is the column's left edge, which the
|
|
||||||
* rounded corners curve in from.
|
|
||||||
*/
|
*/
|
||||||
function drawSelectionTab(image: GrayImage, left: number, top: number, bottom: number, focused: boolean): void {
|
function drawSeparator(
|
||||||
const right = SIDEBAR_WIDTH - 1 + TAB_EXTEND;
|
image: GrayImage,
|
||||||
if (focused) {
|
state: ShellChromeState,
|
||||||
for (let yy = top; yy < bottom; yy++) {
|
strip: { x: number; y: number; width: number; height: number },
|
||||||
const x = left + tabLeftInset(yy, top, bottom, TAB_RADIUS);
|
gap: SwitcherCell | null,
|
||||||
image.fillRect(x, yy, right - x + 1, 1, 255);
|
): void {
|
||||||
|
if (switcherPosition() === "bottom") {
|
||||||
|
// Along the row's top edge, the full width of the row.
|
||||||
|
const y = strip.y, right = strip.x + strip.width - 1;
|
||||||
|
if (gap) {
|
||||||
|
image.drawLine(strip.x, y, gap.x, y, BORDER_VALUE);
|
||||||
|
image.drawLine(gap.x + gap.width, y, right, y, BORDER_VALUE);
|
||||||
|
} else {
|
||||||
|
image.drawLine(strip.x, y, right, y, BORDER_VALUE);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Outline: the tab shape minus the same shape inset by a pixel, row by row.
|
const sep = switcherPosition() === "right" ? strip.x : strip.x + strip.width - 1;
|
||||||
// Stroking the curve one pixel per row instead would leave gaps wherever the
|
const bottom = strip.y + strip.height - 1;
|
||||||
// corner steps in by more than one pixel, and the top/bottom edges have to
|
// Start beside the app content, leaving the area alongside the top bar open.
|
||||||
// start at the same inset the curve uses or they part company from it.
|
const top = Math.max(strip.y, windowTop(state.foregroundHeightMode, state.foregroundAppId) + TOP_BAR_HEIGHT);
|
||||||
for (let yy = top; yy < bottom; yy++) {
|
if (gap) {
|
||||||
const outer = left + tabLeftInset(yy, top, bottom, TAB_RADIUS);
|
image.drawLine(sep, top, sep, gap.y, BORDER_VALUE);
|
||||||
// The top and bottom rows are the horizontal edges: solid out to the open
|
image.drawLine(sep, gap.y + gap.height, sep, bottom, BORDER_VALUE);
|
||||||
// right side. In between only the left edge is stroked.
|
} else {
|
||||||
const inner = yy > top && yy < bottom - 1
|
image.drawLine(sep, top, sep, bottom, BORDER_VALUE);
|
||||||
? left + 1 + tabLeftInset(yy, top + 1, bottom - 1, TAB_RADIUS - 1)
|
}
|
||||||
: right + 1;
|
}
|
||||||
image.fillRect(outer, yy, Math.max(1, Math.min(inner, right + 1) - outer), 1, TAB_STROKE);
|
|
||||||
|
/**
|
||||||
|
* Draw the selection "diversion" of the separator line around a switcher
|
||||||
|
* icon whose cell touches the separator: rounded on the outer side, square
|
||||||
|
* and open on the side toward the main area, extending TAB_EXTEND px past
|
||||||
|
* the separator into it. Focused = filled white; otherwise an outline.
|
||||||
|
*
|
||||||
|
* Drawn in tab-local coordinates: `along` runs parallel to the separator,
|
||||||
|
* `across` from the rounded outer edge (0) to the open edge, and fillAcross
|
||||||
|
* maps a run of one along-line onto the screen for the strip's orientation.
|
||||||
|
*/
|
||||||
|
function drawSelectionTab(image: GrayImage, cell: SwitcherCell, position: AppSwitcherPosition, focused: boolean): void {
|
||||||
|
const vertical = position !== "bottom";
|
||||||
|
const along = vertical ? cell.height : cell.width;
|
||||||
|
const across = (vertical ? cell.width : cell.height) + TAB_EXTEND;
|
||||||
|
const fillAcross = (i: number, from: number, to: number, value: number) => {
|
||||||
|
switch (position) {
|
||||||
|
case "left":
|
||||||
|
image.fillRect(cell.x + from, cell.y + i, to - from, 1, value);
|
||||||
|
break;
|
||||||
|
case "right":
|
||||||
|
image.fillRect(cell.x + cell.width - to, cell.y + i, to - from, 1, value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
image.fillRect(cell.x + i, cell.y + cell.height - to, 1, to - from, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (focused) {
|
||||||
|
for (let i = 0; i < along; i++) {
|
||||||
|
fillAcross(i, tabInset(i, 0, along, TAB_RADIUS), across, 255);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Outline: the tab shape minus the same shape inset by a pixel, line by
|
||||||
|
// line. Stroking the curve one pixel per line instead would leave gaps
|
||||||
|
// wherever the corner steps in by more than one pixel, and the two edges
|
||||||
|
// running across have to start at the same inset the curve uses or they
|
||||||
|
// part company from it.
|
||||||
|
for (let i = 0; i < along; i++) {
|
||||||
|
const outer = tabInset(i, 0, along, TAB_RADIUS);
|
||||||
|
// The first and last lines are the edges running across: solid out to
|
||||||
|
// the open side. In between only the outer edge is stroked.
|
||||||
|
const inner = i > 0 && i < along - 1 ? 1 + tabInset(i, 1, along - 1, TAB_RADIUS - 1) : across;
|
||||||
|
fillAcross(i, outer, Math.max(outer + 1, Math.min(inner, across)), TAB_STROKE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,24 +762,36 @@ function drawSelectionBox(image: GrayImage, x: number, y: number, width: number,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Left boundary x of the tab at row yy: 0 in the middle, curving to the rounded left corners. */
|
/**
|
||||||
function tabLeftInset(yy: number, top: number, bottom: number, radius: number): number {
|
* How far the tab's outer edge is inset at along-line i (of the tab spanning
|
||||||
const cy = yy + 0.5;
|
* start..end): 0 in the middle, curving in toward the rounded corners.
|
||||||
let dy = 0;
|
*/
|
||||||
if (cy < top + radius) {
|
function tabInset(i: number, start: number, end: number, radius: number): number {
|
||||||
dy = top + radius - cy;
|
const c = i + 0.5;
|
||||||
} else if (cy > bottom - radius) {
|
let d = 0;
|
||||||
dy = cy - (bottom - radius);
|
if (c < start + radius) {
|
||||||
|
d = start + radius - c;
|
||||||
|
} else if (c > end - radius) {
|
||||||
|
d = c - (end - radius);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return Math.max(0, Math.round(radius - Math.sqrt(Math.max(0, radius * radius - dy * dy))));
|
return Math.max(0, Math.round(radius - Math.sqrt(Math.max(0, radius * radius - d * d))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Small triangle marker for sidebar overflow; direction -1 = up, 1 = down. */
|
/**
|
||||||
function drawChevron(image: GrayImage, centerX: number, y: number, direction: -1 | 1): void {
|
* Small triangle marker for switcher overflow, pointing the way the hidden
|
||||||
|
* icons are; (x, y) is the middle of its base.
|
||||||
|
*/
|
||||||
|
function drawChevron(image: GrayImage, x: number, y: number, direction: "up" | "down" | "left" | "right"): void {
|
||||||
const half = 5;
|
const half = 5;
|
||||||
const tipY = direction < 0 ? y - 3 : y + 3;
|
if (direction === "left" || direction === "right") {
|
||||||
image.drawLine(centerX - half, y, centerX, tipY, 140);
|
const tipX = direction === "left" ? x - 3 : x + 3;
|
||||||
image.drawLine(centerX, tipY, centerX + half, y, 140);
|
image.drawLine(x, y - half, tipX, y, 140);
|
||||||
|
image.drawLine(tipX, y, x, y + half, 140);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const tipY = direction === "up" ? y - 3 : y + 3;
|
||||||
|
image.drawLine(x - half, y, x, tipY, 140);
|
||||||
|
image.drawLine(x, tipY, x + half, y, 140);
|
||||||
}
|
}
|
||||||
+146
-27
@@ -1,5 +1,7 @@
|
|||||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../../graphics/image";
|
import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../../graphics/image";
|
||||||
import {
|
import {
|
||||||
|
appSwitcherPositionSetting,
|
||||||
|
type AppSwitcherPosition,
|
||||||
displayModeSetting,
|
displayModeSetting,
|
||||||
type DisplayModeSetting,
|
type DisplayModeSetting,
|
||||||
verticalPositionSetting,
|
verticalPositionSetting,
|
||||||
@@ -7,19 +9,36 @@ import {
|
|||||||
navigateVerticalPositionSetting,
|
navigateVerticalPositionSetting,
|
||||||
terminalDisplayModeSetting,
|
terminalDisplayModeSetting,
|
||||||
terminalVerticalPositionSetting,
|
terminalVerticalPositionSetting,
|
||||||
|
uiDepthSetting,
|
||||||
} from "../dashboard-settings";
|
} from "../dashboard-settings";
|
||||||
|
|
||||||
/** Top bar: 24px notification icons plus a little padding. */
|
/** Top bar: 24px notification icons plus a little padding. */
|
||||||
export const TOP_BAR_HEIGHT = 28;
|
export const TOP_BAR_HEIGHT = 28;
|
||||||
/**
|
/**
|
||||||
* Width of the sidebar strip as painted. Leaves the app viewport exactly
|
* Width of the sidebar strip as painted (the app switcher on the left or
|
||||||
* 576px wide — the surface width EvenHub apps expect — except in the
|
* right edge). App windows get the other 576px — the surface width EvenHub
|
||||||
* full-panel display mode, where the strip overlays the app (see
|
* apps expect — and keep that width with the switcher at the bottom too,
|
||||||
* sidebarWidth). Icon column layout within the strip (one wide column vs.
|
* except in the full-panel display mode, where the switcher overlays the
|
||||||
* two narrow ones) is the chrome layer's business.
|
* app (see sidebarWidth). Icon column layout within the strip (one wide
|
||||||
|
* column vs. two narrow ones) is the chrome layer's business.
|
||||||
*/
|
*/
|
||||||
export const SIDEBAR_WIDTH = 64;
|
export const SIDEBAR_WIDTH = 64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Height of the app switcher as a row under the window: one tall tab, the
|
||||||
|
* same 36px (a 32px icon plus 2px either side) as a one-column sidebar slot.
|
||||||
|
* The row is wide enough that it never needs the sidebar's smaller
|
||||||
|
* two-column icons. It comes out of the height available to windows; their
|
||||||
|
* width stays 576, centred, leaving SIDEBAR_WIDTH / 2 at each side for the
|
||||||
|
* whole display's stereo shift (uiDepth).
|
||||||
|
*/
|
||||||
|
export const SWITCHER_ROW_HEIGHT = 36;
|
||||||
|
|
||||||
|
/** Which edge the app switcher is on (Settings > Customization). */
|
||||||
|
export function switcherPosition(): AppSwitcherPosition {
|
||||||
|
return appSwitcherPositionSetting.get();
|
||||||
|
}
|
||||||
|
|
||||||
/** 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()
|
||||||
@@ -31,21 +50,110 @@ export function displayMode(appId?: string): DisplayModeSetting {
|
|||||||
return mode === "global" || mode === "default" ? displayModeSetting.get() : mode;
|
return mode === "global" || mode === "default" ? displayModeSetting.get() : mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** The full-panel mode: windows fill the panel; the switcher overlays them only while it has focus. */
|
||||||
* How much of the screen's width the sidebar takes away from app windows:
|
function fullPanel(appId?: string): boolean {
|
||||||
* the strip, or nothing in the full-panel mode (where the chrome paints the
|
return displayMode(appId) === "640x480";
|
||||||
* strip over the window while the sidebar has focus).
|
|
||||||
*/
|
|
||||||
export function sidebarWidth(appId?: string): number {
|
|
||||||
return displayMode(appId) === "640x480" ? 0 : SIDEBAR_WIDTH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the sidebar strip is on screen: always when it reserves width; in
|
* 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
|
||||||
|
* full-panel mode (where the chrome paints the strip over the window while
|
||||||
|
* the sidebar has focus).
|
||||||
|
*/
|
||||||
|
export function sidebarWidth(appId?: string): number {
|
||||||
|
return fullPanel(appId) || switcherPosition() === "bottom" ? 0 : SIDEBAR_WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much of the screen's height a bottom switcher row takes away from app
|
||||||
|
* windows: the row, or nothing beside a side strip or in the full-panel mode
|
||||||
|
* (where the row overlays the window's bottom edge while it has focus).
|
||||||
|
*/
|
||||||
|
export function switcherRowHeight(appId?: string): number {
|
||||||
|
return !fullPanel(appId) && switcherPosition() === "bottom" ? SWITCHER_ROW_HEIGHT : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the switcher strip is on screen: always when it reserves room; in
|
||||||
* the full-panel mode (where it overlays the window) only while it has focus.
|
* 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 sidebarWidth(appId) > 0 || focus === "sidebar";
|
return !fullPanel(appId) || focus === "sidebar";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Screen rect of the switcher strip. A side strip aligns to the min-height
|
||||||
|
* band (like the shell overlays). A bottom row sits right under the given
|
||||||
|
* (foreground) window and spans its width, so a band shorter than the
|
||||||
|
* screen has no gap below it; it moves when the foreground switches to a
|
||||||
|
* window of another height, as the top bar does. In the full-panel mode the
|
||||||
|
* row overlays the bottom edge of the screen.
|
||||||
|
*/
|
||||||
|
export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x: number; y: number; width: number; height: number } {
|
||||||
|
switch (switcherPosition()) {
|
||||||
|
case "bottom":
|
||||||
|
return {
|
||||||
|
x: appViewportLeft(appId),
|
||||||
|
y: switcherRowHeight(appId) > 0
|
||||||
|
? windowTop(heightMode, appId) + windowBandHeight(heightMode, appId)
|
||||||
|
: G2_LENS_HEIGHT - SWITCHER_ROW_HEIGHT,
|
||||||
|
width: appViewportWidth(appId),
|
||||||
|
height: SWITCHER_ROW_HEIGHT,
|
||||||
|
};
|
||||||
|
case "right":
|
||||||
|
return { x: G2_LENS_WIDTH - SIDEBAR_WIDTH, y: minWindowTop(appId), width: SIDEBAR_WIDTH, height: MIN_WINDOW_HEIGHT };
|
||||||
|
default:
|
||||||
|
return { x: 0, y: minWindowTop(appId), width: SIDEBAR_WIDTH, height: MIN_WINDOW_HEIGHT };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* the top of a bottom row (under the given foreground window) down.
|
||||||
|
*/
|
||||||
|
export function isOnSwitcherEdge(x: number, y: number, heightMode: WindowHeightMode, appId?: string): boolean {
|
||||||
|
switch (switcherPosition()) {
|
||||||
|
case "bottom":
|
||||||
|
return y >= switcherRect(heightMode, appId).y;
|
||||||
|
case "right":
|
||||||
|
return x >= G2_LENS_WIDTH - SIDEBAR_WIDTH;
|
||||||
|
default:
|
||||||
|
return x < SIDEBAR_WIDTH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Width of app windows: the panel's in the full-panel mode, else 576 (see SIDEBAR_WIDTH). */
|
||||||
|
function appViewportWidth(appId?: string): number {
|
||||||
|
return fullPanel(appId) ? G2_LENS_WIDTH : G2_LENS_WIDTH - SIDEBAR_WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Left edge (x) of app windows: past a left strip, centred above a bottom
|
||||||
|
* row (see SWITCHER_ROW_HEIGHT), else the screen edge.
|
||||||
|
*/
|
||||||
|
export function appViewportLeft(appId?: string): number {
|
||||||
|
if (fullPanel(appId)) return 0;
|
||||||
|
switch (switcherPosition()) {
|
||||||
|
case "left":
|
||||||
|
return SIDEBAR_WIDTH;
|
||||||
|
case "bottom":
|
||||||
|
return SIDEBAR_WIDTH / 2;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stereo depth of the whole display (Settings > Customization > Depth), in
|
||||||
|
* 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
|
||||||
|
* the switcher at the bottom, where the windows' side margins leave room for
|
||||||
|
* the shift.
|
||||||
|
*/
|
||||||
|
export function uiDepth(): number {
|
||||||
|
return switcherPosition() === "bottom" ? Number(uiDepthSetting.get()) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,13 +165,13 @@ export function effectiveHeightMode(mode: WindowHeightMode, appId?: string): Win
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X of the display's true horizontal centre, in app-viewport coordinates. The
|
* X of the display's true horizontal centre, in app-viewport coordinates. A
|
||||||
* sidebar pushes the viewport to the right, so UI the wearer physically aims
|
* side strip pushes the viewport off centre, so UI the wearer physically
|
||||||
* with — a compass rose, a calibration crosshair — has to offset by it rather
|
* aims with — a compass rose, a calibration crosshair — has to offset by it
|
||||||
* than use the viewport's own centre.
|
* rather than use the viewport's own centre.
|
||||||
*/
|
*/
|
||||||
export function screenCenterInViewportX(): number {
|
export function screenCenterInViewportX(): number {
|
||||||
return Math.round(G2_LENS_WIDTH / 2) - sidebarWidth();
|
return Math.round(G2_LENS_WIDTH / 2) - appViewportLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,20 +186,27 @@ export const SHELL_OPAQUE_BLACK = 1;
|
|||||||
* 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
|
||||||
* top bar taller, so the content area below the bar is a full 288px (the
|
* top bar taller, so the content area below the bar is a full 288px (the
|
||||||
* EvenHub app surface height); "max" uses the whole 480px screen (terminal
|
* EvenHub app surface height); "max" uses the whole 480px screen (terminal
|
||||||
* views). All include a top bar drawn by the shell at the window's top edge.
|
* views), less a bottom switcher row. All include a top bar drawn by the
|
||||||
|
* shell at the window's top edge.
|
||||||
*/
|
*/
|
||||||
export type WindowHeightMode = "min" | "medium" | "max";
|
export type WindowHeightMode = "min" | "medium" | "max";
|
||||||
|
|
||||||
/** Total height (top bar + content) of a min-height window. */
|
/** Total height (top bar + content) of a min-height window. */
|
||||||
export const MIN_WINDOW_HEIGHT = 288;
|
export const MIN_WINDOW_HEIGHT = 288;
|
||||||
/** Farthest down a min-height window can start. */
|
|
||||||
export const MIN_WINDOW_MAX_TOP = G2_LENS_HEIGHT - MIN_WINDOW_HEIGHT;
|
/**
|
||||||
|
* Height of the screen area windows are placed in: the whole screen, less
|
||||||
|
* a bottom switcher row's height.
|
||||||
|
*/
|
||||||
|
function windowAreaHeight(appId?: string): number {
|
||||||
|
return G2_LENS_HEIGHT - switcherRowHeight(appId);
|
||||||
|
}
|
||||||
|
|
||||||
/** Total height (top bar + content) of a window's band in the given mode. */
|
/** Total height (top bar + content) 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 G2_LENS_HEIGHT;
|
return windowAreaHeight(appId);
|
||||||
case "medium":
|
case "medium":
|
||||||
return MIN_WINDOW_HEIGHT + TOP_BAR_HEIGHT;
|
return MIN_WINDOW_HEIGHT + TOP_BAR_HEIGHT;
|
||||||
default:
|
default:
|
||||||
@@ -129,15 +244,19 @@ export function minWindowTop(appId?: string): number {
|
|||||||
return windowTop("min", appId);
|
return windowTop("min", appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Top edge (y) of a window's top bar; max-height windows pin to the screen top. */
|
/**
|
||||||
|
* Top edge (y) of a window's top bar; max-height windows pin to the screen
|
||||||
|
* top. A bottom switcher row hangs under the band, so the band and row
|
||||||
|
* together distribute the screen's slack.
|
||||||
|
*/
|
||||||
export function windowTop(mode: WindowHeightMode, appId?: string): number {
|
export function windowTop(mode: WindowHeightMode, appId?: string): number {
|
||||||
return Math.round((G2_LENS_HEIGHT - windowBandHeight(mode, appId)) * verticalPositionFraction(appId));
|
return Math.round((windowAreaHeight(appId) - windowBandHeight(mode, appId)) * verticalPositionFraction(appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** App-content viewport size for a height mode (independent of vertical position). */
|
/** App-content viewport size for a height mode (independent of vertical position). */
|
||||||
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: G2_LENS_WIDTH - sidebarWidth(appId),
|
width: appViewportWidth(appId),
|
||||||
height: windowBandHeight(mode, appId) - TOP_BAR_HEIGHT,
|
height: windowBandHeight(mode, appId) - TOP_BAR_HEIGHT,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -150,7 +269,7 @@ export function appViewportRect(mode: WindowHeightMode, appId?: string): {
|
|||||||
height: number;
|
height: number;
|
||||||
} {
|
} {
|
||||||
return {
|
return {
|
||||||
x: sidebarWidth(appId),
|
x: appViewportLeft(appId),
|
||||||
y: windowTop(mode, appId) + TOP_BAR_HEIGHT,
|
y: windowTop(mode, appId) + TOP_BAR_HEIGHT,
|
||||||
...appViewportSize(mode, appId),
|
...appViewportSize(mode, appId),
|
||||||
};
|
};
|
||||||
|
|||||||
+68
-37
@@ -7,6 +7,7 @@ import { acceptInput } from "../input-monitor";
|
|||||||
import type { RawInputEvent } from "../../native/faceclaw-communicator";
|
import type { RawInputEvent } from "../../native/faceclaw-communicator";
|
||||||
import {
|
import {
|
||||||
directionalFallback,
|
directionalFallback,
|
||||||
|
type DirectionalInputEvent,
|
||||||
GESTURE_SHORT_THEN_LONG_PRESS,
|
GESTURE_SHORT_THEN_LONG_PRESS,
|
||||||
gestureHints,
|
gestureHints,
|
||||||
InputEvent,
|
InputEvent,
|
||||||
@@ -44,19 +45,23 @@ import {
|
|||||||
wakeWordActionSetting,
|
wakeWordActionSetting,
|
||||||
} from "../dashboard-settings";
|
} from "../dashboard-settings";
|
||||||
import { onAmbientCardsChanged } from "./ambient-cards";
|
import { onAmbientCardsChanged } from "./ambient-cards";
|
||||||
import { ShellChromeLayer, sidebarContentLeft, type ShellChromeState, type ShellChromeWindow } from "./chrome-layer";
|
import { ShellChromeLayer, sidebarContentSpan, type ShellChromeState, type ShellChromeWindow } from "./chrome-layer";
|
||||||
import { ShellModalLayer } from "./modal-layer";
|
import { ShellModalLayer } from "./modal-layer";
|
||||||
import { ToolDebugMenuLayer } from "./tool-debug-layer";
|
import { ToolDebugMenuLayer } from "./tool-debug-layer";
|
||||||
import { BrightnessPickerLayer } from "./brightness-picker-layer";
|
import { BrightnessPickerLayer } from "./brightness-picker-layer";
|
||||||
import { toolRegistry } from "../../assistant/tool-registry";
|
import { toolRegistry } from "../../assistant/tool-registry";
|
||||||
import {
|
import {
|
||||||
|
appViewportRect,
|
||||||
minWindowTop,
|
minWindowTop,
|
||||||
sidebarWidth,
|
sidebarWidth,
|
||||||
TOP_BAR_HEIGHT,
|
switcherPosition,
|
||||||
|
switcherRowHeight,
|
||||||
|
uiDepth,
|
||||||
windowBandHeight,
|
windowBandHeight,
|
||||||
windowTop,
|
windowTop,
|
||||||
type WindowHeightMode,
|
type WindowHeightMode,
|
||||||
} from "./geometry";
|
} from "./geometry";
|
||||||
|
import type { AppSwitcherPosition } from "../dashboard-settings";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shell: owns the window registry, focus, screen on/off, and the shell
|
* The shell: owns the window registry, focus, screen on/off, and the shell
|
||||||
@@ -228,12 +233,14 @@ class ShellOverlayMenuLayer extends MenuLayer {
|
|||||||
constructor(items: MenuItem[], footer: string | undefined, private readonly onClosed: () => void) {
|
constructor(items: MenuItem[], footer: string | undefined, private readonly onClosed: () => void) {
|
||||||
// Aligned to the min-height window band (like the sidebar), wherever the
|
// Aligned to the min-height window band (like the sidebar), wherever the
|
||||||
// vertical position setting currently puts it; centered over the
|
// vertical position setting currently puts it; centered over the
|
||||||
// application area, i.e. the part of the screen past the sidebar strip
|
// application area, i.e. the part of the screen beside a side strip
|
||||||
// (the whole screen in the full-panel mode, where the strip overlays).
|
// (the whole width with a bottom row, or in the full-panel mode, where
|
||||||
|
// the strip overlays).
|
||||||
const width = 272;
|
const width = 272;
|
||||||
|
const area = appViewportRect("min");
|
||||||
super("System", items, {
|
super("System", items, {
|
||||||
x: sidebarWidth() + (((G2_LENS_WIDTH - sidebarWidth() - width) / 2) | 0),
|
x: area.x + (((area.width - width) / 2) | 0),
|
||||||
y: minWindowTop() + TOP_BAR_HEIGHT + 8,
|
y: area.y + 8,
|
||||||
width,
|
width,
|
||||||
minHeight: 150,
|
minHeight: 150,
|
||||||
squareCorners: true,
|
squareCorners: true,
|
||||||
@@ -308,9 +315,28 @@ class ShellAlertLayer implements Layer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every setting the top bar paints from, as one comparable string. */
|
/**
|
||||||
function topBarSettingsKey(): string {
|
* What a watch swipe means while the app switcher has focus, as the ring
|
||||||
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}`;
|
* 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
|
||||||
|
* from it there is nowhere further to go (ignored).
|
||||||
|
*/
|
||||||
|
const SWITCHER_SWIPES: Record<
|
||||||
|
AppSwitcherPosition,
|
||||||
|
Partial<Record<DirectionalInputEvent["type"], "scroll-up" | "scroll-down" | "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" },
|
||||||
|
bottom: { "swipe-left": "scroll-up", "swipe-right": "scroll-down", "swipe-up": "click" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* string.
|
||||||
|
*/
|
||||||
|
function chromeSettingsKey(): string {
|
||||||
|
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}|${uiDepth()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Shell {
|
class Shell {
|
||||||
@@ -373,8 +399,8 @@ class Shell {
|
|||||||
|
|
||||||
// Top-bar settings we mirror into the chrome; a change to any of them
|
// Top-bar settings we mirror into the chrome; a change to any of them
|
||||||
// repaints the shell surface so the top bar reflects it immediately.
|
// repaints the shell surface so the top bar reflects it immediately.
|
||||||
private topBarSettingsSubscribed = false;
|
private chromeSettingsSubscribed = false;
|
||||||
private lastTopBarSettingsKey: string | null = null;
|
private lastChromeSettingsKey: string | null = null;
|
||||||
|
|
||||||
configure(config: ShellConfig): void {
|
configure(config: ShellConfig): void {
|
||||||
// Nearly every state change ends in a shell render request, so it is
|
// Nearly every state change ends in a shell render request, so it is
|
||||||
@@ -387,7 +413,7 @@ class Shell {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.stack.setActions(config.actions);
|
this.stack.setActions(config.actions);
|
||||||
this.subscribeToTopBarSettings();
|
this.subscribeToChromeSettings();
|
||||||
this.subscribeToAmbientCards();
|
this.subscribeToAmbientCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,14 +431,14 @@ class Shell {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private subscribeToTopBarSettings(): void {
|
private subscribeToChromeSettings(): void {
|
||||||
if (this.topBarSettingsSubscribed) return;
|
if (this.chromeSettingsSubscribed) return;
|
||||||
this.topBarSettingsSubscribed = true;
|
this.chromeSettingsSubscribed = true;
|
||||||
this.lastTopBarSettingsKey = topBarSettingsKey();
|
this.lastChromeSettingsKey = chromeSettingsKey();
|
||||||
onAnySettingChanged(() => {
|
onAnySettingChanged(() => {
|
||||||
const key = topBarSettingsKey();
|
const key = chromeSettingsKey();
|
||||||
if (key === this.lastTopBarSettingsKey) return;
|
if (key === this.lastChromeSettingsKey) return;
|
||||||
this.lastTopBarSettingsKey = key;
|
this.lastChromeSettingsKey = key;
|
||||||
this.config.requestShellRender();
|
this.config.requestShellRender();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -701,8 +727,13 @@ class Shell {
|
|||||||
this.config.requestShellRender();
|
this.config.requestShellRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paint the shell surface: transparent chrome, or all-transparent when asleep. */
|
/**
|
||||||
paintScene(): Uint8Array { return encodeShellScene(this.screenOn ? this.stack.paintUndimmed() : []); }
|
* Paint the shell surface: transparent chrome, or all-transparent when
|
||||||
|
* asleep. The scene also carries the whole display's stereo depth.
|
||||||
|
*/
|
||||||
|
paintScene(): Uint8Array {
|
||||||
|
return this.screenOn ? encodeShellScene(this.stack.paintUndimmed(), uiDepth()) : encodeShellScene([]);
|
||||||
|
}
|
||||||
|
|
||||||
paintSurface(): Plane[] {
|
paintSurface(): Plane[] {
|
||||||
if (!this.screenOn) {
|
if (!this.screenOn) {
|
||||||
@@ -904,20 +935,24 @@ class Shell {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Screen rect actually occupied by content, for cropping screenshots: the
|
* Screen rect actually occupied by content, for cropping screenshots: the
|
||||||
* foreground window's band (full screen for a max-height window, the
|
* foreground window's band (full height for a max-height window, the
|
||||||
* vertical-position-dependent 288px band otherwise), minus the sidebar
|
* vertical-position-dependent 288px band otherwise) plus the switcher: a
|
||||||
* strip left of the icon columns when the one-column variant is active.
|
* side strip's icon columns (minus the outer dead strip the one-column
|
||||||
|
* variant leaves), or the row under it.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
const heightMode = this.foregroundWindow()?.heightMode ?? "min";
|
const heightMode = this.foregroundWindow()?.heightMode ?? "min";
|
||||||
const x = sidebarWidth(appId) === 0 ? 0 : sidebarContentLeft(this.windows.length);
|
const viewport = appViewportRect(heightMode, appId);
|
||||||
return {
|
let left = viewport.x, right = viewport.x + viewport.width;
|
||||||
x,
|
if (sidebarWidth(appId) > 0) {
|
||||||
y: windowTop(heightMode, appId),
|
const strip = sidebarContentSpan(this.windows.length);
|
||||||
width: G2_LENS_WIDTH - x,
|
left = Math.min(left, strip.left);
|
||||||
height: windowBandHeight(heightMode, appId),
|
right = Math.max(right, strip.right);
|
||||||
};
|
}
|
||||||
|
const y = windowTop(heightMode, appId);
|
||||||
|
const bottom = y + windowBandHeight(heightMode, appId) + switcherRowHeight(appId);
|
||||||
|
return { x: left, y, width: right - left, height: bottom - y };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -966,7 +1001,8 @@ class Shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleSidebarInput(event: InputEvent): ShellInputOutcome {
|
private handleSidebarInput(event: InputEvent): ShellInputOutcome {
|
||||||
switch (event.type) {
|
const type = isDirectionalInput(event) ? SWITCHER_SWIPES[switcherPosition()][event.type] : event.type;
|
||||||
|
switch (type) {
|
||||||
case "double-click":
|
case "double-click":
|
||||||
// A double-tap at the root (the app switcher selected) turns the
|
// A double-tap at the root (the app switcher selected) turns the
|
||||||
// display off — from the ring and the watch scheme alike; watch-scheme
|
// display off — from the ring and the watch scheme alike; watch-scheme
|
||||||
@@ -974,17 +1010,12 @@ class Shell {
|
|||||||
this.sleep();
|
this.sleep();
|
||||||
return { shell: true, window: false };
|
return { shell: true, window: false };
|
||||||
case "scroll-up":
|
case "scroll-up":
|
||||||
case "swipe-up":
|
|
||||||
this.moveSelection(-1);
|
this.moveSelection(-1);
|
||||||
return { shell: true, window: false };
|
return { shell: true, window: false };
|
||||||
case "scroll-down":
|
case "scroll-down":
|
||||||
case "swipe-down":
|
|
||||||
this.moveSelection(1);
|
this.moveSelection(1);
|
||||||
return { shell: true, window: false };
|
return { shell: true, window: false };
|
||||||
case "click":
|
case "click":
|
||||||
case "swipe-right":
|
|
||||||
// Right: into the selected window (spatially, the window is to the
|
|
||||||
// sidebar's right). Left has nowhere further to go and is ignored.
|
|
||||||
if (this.windows.length) {
|
if (this.windows.length) {
|
||||||
this.focus = "window";
|
this.focus = "window";
|
||||||
this.foregroundWindow()?.onFocus?.(this.lastInput);
|
this.foregroundWindow()?.onFocus?.(this.lastInput);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
import { GrayImage } from "../../graphics/image";
|
||||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||||
import { wrapText } from "../../graphics/textwrap";
|
import { wrapText } from "../../graphics/textwrap";
|
||||||
import { clamp } from "../../util/numeric-util";
|
import { clamp } from "../../util/numeric-util";
|
||||||
@@ -6,7 +6,7 @@ import type { ToolDebugEntry } from "../../assistant/tool-registry";
|
|||||||
import { InputEvent } from "../gestures";
|
import { InputEvent } from "../gestures";
|
||||||
import { Layer, LayerContext, PaintBelow } from "../layers";
|
import { Layer, LayerContext, PaintBelow } from "../layers";
|
||||||
import { MenuLayer, drawListScrollbar, type MenuItem } from "../menu";
|
import { MenuLayer, drawListScrollbar, type MenuItem } from "../menu";
|
||||||
import { minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
import { appViewportRect } from "./geometry";
|
||||||
import { lineStep } from "../metrics";
|
import { lineStep } from "../metrics";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,18 +21,19 @@ const DIALOG_WIDTH = 420;
|
|||||||
// the band below the top bar with an 8px margin on each side.
|
// the band below the top bar with an 8px margin on each side.
|
||||||
const DETAIL_HEIGHT = 208;
|
const DETAIL_HEIGHT = 208;
|
||||||
|
|
||||||
/** Dialog left edge: past the sidebar strip where one reserves width. */
|
/** Dialog left edge: inside the app area, clear of a left sidebar strip. */
|
||||||
function dialogX(): number {
|
function dialogX(): number {
|
||||||
return sidebarWidth() + 8;
|
return appViewportRect("min").x + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Detail box width: the app area (clear of a right sidebar strip) less margins. */
|
||||||
function detailWidth(): number {
|
function detailWidth(): number {
|
||||||
return G2_LENS_WIDTH - dialogX() - 8;
|
return appViewportRect("min").width - 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dialog top edge, aligned to the min-height band's content area. */
|
/** Dialog top edge, aligned to the min-height band's content area. */
|
||||||
function dialogY(): number {
|
function dialogY(): number {
|
||||||
return minWindowTop() + TOP_BAR_HEIGHT + 8;
|
return appViewportRect("min").y + 8;
|
||||||
}
|
}
|
||||||
const DETAIL_PADDING = 14;
|
const DETAIL_PADDING = 14;
|
||||||
|
|
||||||
|
|||||||
+21
@@ -62,6 +62,27 @@ object DrawProtocol {
|
|||||||
write: DrawWriter.() -> Unit): ByteArray =
|
write: DrawWriter.() -> Unit): ByteArray =
|
||||||
call(op, encode(write), target, depth, clip)
|
call(op, encode(write), target, depth, clip)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [call] moved [extra] depth units further, as if played from a list called at that depth:
|
||||||
|
* adds to its depth field, or inserts one (after any target override) when it has none. The
|
||||||
|
* sum saturates at the field's range rather than failing the whole presentation.
|
||||||
|
*/
|
||||||
|
fun withAddedDepth(call: ByteArray, extra: Int): ByteArray {
|
||||||
|
if (extra == 0) return call
|
||||||
|
val flags = call[1].toInt() and 255
|
||||||
|
val at = if (flags and DRAW_FLAG_RESOURCE_TARGET != 0) 4 else 2
|
||||||
|
val result = if (flags and DRAW_FLAG_DEPTH != 0) {
|
||||||
|
call.copyOf().also { it[at] = addDepth(call[at].toInt(), extra).toByte() }
|
||||||
|
} else {
|
||||||
|
call.copyOfRange(0, at) + byteArrayOf(addDepth(0, extra).toByte()) + call.copyOfRange(at, call.size)
|
||||||
|
}
|
||||||
|
result[1] = (flags or DRAW_FLAG_DEPTH).toByte()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Two depths combined, saturated to the s8 depth field. */
|
||||||
|
fun addDepth(depth: Int, extra: Int): Int = (depth + extra).coerceIn(-128, 127)
|
||||||
|
|
||||||
fun depthOffset(depth: Int, right: Boolean): Int =
|
fun depthOffset(depth: Int, right: Boolean): Int =
|
||||||
if (right) -floorHalf(depth + 1) else floorHalf(depth)
|
if (right) -floorHalf(depth + 1) else floorHalf(depth)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.faceclaw.app
|
package com.faceclaw.app
|
||||||
|
|
||||||
/** Immutable shell snapshot. Keys identify writable surfaces across repaints, not their pixels. */
|
/**
|
||||||
|
* Immutable shell snapshot. Keys identify writable surfaces across repaints, not their pixels.
|
||||||
|
* [screenDepth] is the stereo depth of the whole presentation: the screen copy and everything
|
||||||
|
* drawn over it shift together per lens (see [calls]).
|
||||||
|
*/
|
||||||
class ShellScene(val layers: List<Layer>, val selections: List<RetainedDrawing> = emptyList(), val screenDepth: Int = 0) {
|
class ShellScene(val layers: List<Layer>, val selections: List<RetainedDrawing> = emptyList(), val screenDepth: Int = 0) {
|
||||||
class Layer(val key: Int, val x: Int, val y: Int, val width: Int, val height: Int, val dim: Int, val packed: ByteArray, val selections: List<RetainedDrawing> = emptyList(), val depth: Int = 0) {
|
class Layer(val key: Int, val x: Int, val y: Int, val width: Int, val height: Int, val dim: Int, val packed: ByteArray, val selections: List<RetainedDrawing> = emptyList(), val depth: Int = 0) {
|
||||||
// Layers are reused by every composite until the shell repaints, and hashing packed
|
// Layers are reused by every composite until the shell repaints, and hashing packed
|
||||||
@@ -13,22 +17,32 @@ class ShellScene(val layers: List<Layer>, val selections: List<RetainedDrawing>
|
|||||||
val retainedResources = allSelections.flatMap { it.resources }
|
val retainedResources = allSelections.flatMap { it.resources }
|
||||||
init { require(retainedResources.size + layers.size < 511 && screenDepth in -128..127) }
|
init { require(retainedResources.size + layers.size < 511 && screenDepth in -128..127) }
|
||||||
val fingerprint: String = layers.joinToString(";") { it.fingerprint } + selections.joinToString { it.fingerprint } + "|depth:$screenDepth"
|
val fingerprint: String = layers.joinToString(";") { it.fingerprint } + selections.joinToString { it.fingerprint } + "|depth:$screenDepth"
|
||||||
|
/**
|
||||||
|
* The root list. A nonzero [screenDepth] adds to every positional call's own depth, so the
|
||||||
|
* scene moves as one; depths are even (see uiDepthSetting) so the per-lens halves add
|
||||||
|
* exactly. Dim LUTs stay put: they cover the whole target, and a shifted one would leave an
|
||||||
|
* undimmed strip at one edge.
|
||||||
|
*/
|
||||||
fun calls(width: Int, height: Int, surfaces: IntArray, selected: IntArray): List<ByteArray> {
|
fun calls(width: Int, height: Int, surfaces: IntArray, selected: IntArray): List<ByteArray> {
|
||||||
val calls = ArrayList<ByteArray>(); var rowId = 0
|
val calls = ArrayList<ByteArray>(); var rowId = 0
|
||||||
val now = drawAnimationTimeMs()
|
val now = drawAnimationTimeMs()
|
||||||
|
fun shifted(call: ByteArray) = DrawProtocol.withAddedDepth(call, screenDepth)
|
||||||
calls.addAll(DrawProtocol.screenCopy(width, height, screenDepth))
|
calls.addAll(DrawProtocol.screenCopy(width, height, screenDepth))
|
||||||
fun add(row: RetainedDrawing) {
|
fun add(row: RetainedDrawing) {
|
||||||
calls.addAll(row.calls(selected.copyOfRange(rowId, rowId + row.resources.size), now))
|
for (call in row.calls(selected.copyOfRange(rowId, rowId + row.resources.size), now)) calls.add(shifted(call))
|
||||||
rowId += row.resources.size
|
rowId += row.resources.size
|
||||||
}
|
}
|
||||||
for (row in selections) add(row)
|
for (row in selections) add(row)
|
||||||
for ((index, layer) in layers.withIndex()) {
|
for ((index, layer) in layers.withIndex()) {
|
||||||
if (layer.dim < 256) calls.add(DrawProtocol.lut(width, height, layer.dim))
|
if (layer.dim < 256) calls.add(DrawProtocol.lut(width, height, layer.dim))
|
||||||
calls.add(DrawProtocol.image(surfaces[index], layer.x, layer.y, depth = layer.depth))
|
calls.add(DrawProtocol.image(surfaces[index], layer.x, layer.y, depth = DrawProtocol.addDepth(layer.depth, screenDepth)))
|
||||||
for (row in layer.selections) add(row)
|
for (row in layer.selections) add(row)
|
||||||
}
|
}
|
||||||
return calls
|
return calls
|
||||||
}
|
}
|
||||||
|
/** This scene without its whole-presentation shift: the phone mirror's view (see SurfaceCompositor.previewScene). */
|
||||||
|
fun unshifted(): ShellScene = if (screenDepth == 0) this else ShellScene(layers, selections, 0)
|
||||||
|
|
||||||
fun preview(screenGray: ByteArray, width: Int, height: Int, rightLens: Boolean = false): ByteArray {
|
fun preview(screenGray: ByteArray, width: Int, height: Int, rightLens: Boolean = false): ByteArray {
|
||||||
val screen = BmpUtil.pack4bppFromGray8(screenGray, width, height)
|
val screen = BmpUtil.pack4bppFromGray8(screenGray, width, height)
|
||||||
val output = ByteArray(screen.size); val resources = HashMap<Int, ByteArray>()
|
val output = ByteArray(screen.size); val resources = HashMap<Int, ByteArray>()
|
||||||
@@ -89,10 +103,11 @@ class ShellScene(val layers: List<Layer>, val selections: List<RetainedDrawing>
|
|||||||
val selections = List(selectionCount) { readRetainedDrawing(reader, reader.get().toInt()) }
|
val selections = List(selectionCount) { readRetainedDrawing(reader, reader.get().toInt()) }
|
||||||
layers.add(Layer(key, x, y, w, h, dim, BmpUtil.pack4bppFromGray8(gray, w, h), selections, depth))
|
layers.add(Layer(key, x, y, w, h, dim, BmpUtil.pack4bppFromGray8(gray, w, h), selections, depth))
|
||||||
}
|
}
|
||||||
require(reader.remaining() == 0)
|
require(reader.remaining() == 2)
|
||||||
|
val screenDepth = reader.getShort().toInt()
|
||||||
require(layers.sumOf { layer -> layer.selections.sumOf { it.resources.size } } + layers.size < 511)
|
require(layers.sumOf { layer -> layer.selections.sumOf { it.resources.size } } + layers.size < 511)
|
||||||
require(layers.map { it.key }.toSet().size == layers.size)
|
require(layers.map { it.key }.toSet().size == layers.size)
|
||||||
return ShellScene(layers)
|
return ShellScene(layers, screenDepth = screenDepth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-4
@@ -316,10 +316,14 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
|
|||||||
private var lastScene: ShellScene? = null
|
private var lastScene: ShellScene? = null
|
||||||
private var previewKey: String? = null
|
private var previewKey: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The phone mirror's view of [scene]: without the whole-screen stereo shift, which would move
|
||||||
|
* it off centre by half the depth and put mirror touches that far from what they land on.
|
||||||
|
*/
|
||||||
private fun previewScene(scene: ShellScene, gray: ByteArray, key: String): ByteArray {
|
private fun previewScene(scene: ShellScene, gray: ByteArray, key: String): ByteArray {
|
||||||
if (previewKey != key) {
|
if (previewKey != key) {
|
||||||
animatedPreview?.player?.stop()
|
animatedPreview?.player?.stop()
|
||||||
animatedPreview = scene.animatedPreview(gray, screenWidth, screenHeight,
|
animatedPreview = scene.unshifted().animatedPreview(gray, screenWidth, screenHeight,
|
||||||
schedule = { delay, action -> scheduleDrawRedraw(delay) { lock.withLock(action) } })
|
schedule = { delay, action -> scheduleDrawRedraw(delay) { lock.withLock(action) } })
|
||||||
previewKey = key
|
previewKey = key
|
||||||
}
|
}
|
||||||
@@ -480,12 +484,16 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The screen's stereo depth: see setSurfaceDepth. */
|
/**
|
||||||
|
* The screen's stereo depth: a covering surface's own (see setSurfaceDepth), else the shell
|
||||||
|
* scene's depth for the whole display (the regular UI's Depth setting).
|
||||||
|
*/
|
||||||
private fun screenDepthLocked(ordered: List<Surface>): Int {
|
private fun screenDepthLocked(ordered: List<Surface>): Int {
|
||||||
val top = ordered.lastOrNull { it.visible } ?: return 0
|
val uiDepth = shellScene?.screenDepth ?: 0
|
||||||
|
val top = ordered.lastOrNull { it.visible } ?: return uiDepth
|
||||||
val covers = top.transparency == TRANSPARENCY_OPAQUE && top.x <= 0 && top.y <= 0 &&
|
val covers = top.transparency == TRANSPARENCY_OPAQUE && top.x <= 0 && top.y <= 0 &&
|
||||||
top.x + top.width >= screenWidth && top.y + top.height >= screenHeight
|
top.x + top.width >= screenWidth && top.y + top.height >= screenHeight
|
||||||
return if (covers) top.depth else 0
|
return if (covers) top.depth else uiDepth
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -261,7 +261,10 @@ function shellEnv({ wakeAction = 'voice-input', skipConfirmation = false } = {})
|
|||||||
'../notifications': {}, '../dashboard-settings': settings, './ambient-cards': {},
|
'../notifications': {}, '../dashboard-settings': settings, './ambient-cards': {},
|
||||||
'./chrome-layer': { ShellChromeLayer: class {} }, './modal-layer': {}, './tool-debug-layer': {},
|
'./chrome-layer': { ShellChromeLayer: class {} }, './modal-layer': {}, './tool-debug-layer': {},
|
||||||
'./brightness-picker-layer': {},
|
'./brightness-picker-layer': {},
|
||||||
'../../assistant/tool-registry': {}, './geometry': { sidebarWidth: () => 64, minWindowTop: () => 96, TOP_BAR_HEIGHT: 28 },
|
'../../assistant/tool-registry': {}, './geometry': {
|
||||||
|
sidebarWidth: () => 64, minWindowTop: () => 96, switcherPosition: () => 'left', uiDepth: () => 0,
|
||||||
|
appViewportRect: () => ({ x: 64, y: 124, width: 576, height: 260 }),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const { createInProcessWindow } = load('app/ui/shell/in-process-window.ts', {
|
const { createInProcessWindow } = load('app/ui/shell/in-process-window.ts', {
|
||||||
'../../graphics/image': images, '../../native/frame-timings': timings,
|
'../../graphics/image': images, '../../native/frame-timings': timings,
|
||||||
|
|||||||
+63
-11
@@ -14,6 +14,7 @@ function geometry() {
|
|||||||
displayModeSetting: '576x288', verticalPositionSetting: 'middle',
|
displayModeSetting: '576x288', verticalPositionSetting: 'middle',
|
||||||
navigateDisplayModeSetting: 'global', navigateVerticalPositionSetting: 'global',
|
navigateDisplayModeSetting: 'global', navigateVerticalPositionSetting: 'global',
|
||||||
terminalDisplayModeSetting: 'default', terminalVerticalPositionSetting: 'global',
|
terminalDisplayModeSetting: 'default', terminalVerticalPositionSetting: 'global',
|
||||||
|
appSwitcherPositionSetting: 'left', uiDepthSetting: '0',
|
||||||
}).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 };
|
||||||
@@ -65,23 +66,74 @@ 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 globalMode of ['576x288', '576x480', '640x480']) {
|
for (const switcher of ['left', 'right', 'bottom']) {
|
||||||
g.settings.displayModeSetting.value = globalMode;
|
g.settings.appSwitcherPositionSetting.value = switcher;
|
||||||
for (const appId of ['navigate', 'terminal']) {
|
for (const globalMode of ['576x288', '576x480', '640x480']) {
|
||||||
for (const mode of ['global', '576x288', '576x480', '640x480']) {
|
g.settings.displayModeSetting.value = globalMode;
|
||||||
g.settings[`${appId}DisplayModeSetting`].value = mode;
|
for (const appId of ['navigate', 'terminal']) {
|
||||||
for (const position of ['global', 'top', 'upper', 'middle', 'lower', 'bottom']) {
|
for (const mode of ['global', '576x288', '576x480', '640x480']) {
|
||||||
g.settings[`${appId}VerticalPositionSetting`].value = position;
|
g.settings[`${appId}DisplayModeSetting`].value = mode;
|
||||||
const rect = g.rect('max', appId);
|
for (const position of ['global', 'top', 'upper', 'middle', 'lower', 'bottom']) {
|
||||||
assert.equal(rect.x + rect.width, 640);
|
g.settings[`${appId}VerticalPositionSetting`].value = position;
|
||||||
assert.equal(rect.y, g.windowTop('max', appId) + g.TOP_BAR_HEIGHT);
|
for (const heightMode of ['min', 'medium', 'max']) {
|
||||||
assert.ok(rect.y >= 28 && rect.y + rect.height <= 480);
|
const rect = g.rect(heightMode, appId);
|
||||||
|
const fullPanel = g.displayMode(appId) === '640x480';
|
||||||
|
assert.equal(rect.x + rect.width, fullPanel ? 640 : { left: 640, right: 576, bottom: 608 }[switcher]);
|
||||||
|
assert.equal(rect.y, g.windowTop(heightMode, appId) + g.TOP_BAR_HEIGHT);
|
||||||
|
assert.ok(rect.y >= 28 && rect.y + rect.height <= 480 - g.switcherRowHeight(appId));
|
||||||
|
const row = g.switcherRect(heightMode, appId);
|
||||||
|
assert.ok(row.y + row.height <= 480);
|
||||||
|
// A reserved bottom row hangs right under the window, as wide as it.
|
||||||
|
if (g.switcherRowHeight(appId)) assert.deepEqual([row.x, row.y, row.width], [rect.x, rect.y + rect.height, rect.width]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('the app switcher can sit on the right edge', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'right';
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 0, y: 124, width: 576, height: 260 });
|
||||||
|
assert.deepEqual({ ...g.switcherRect('max') }, { x: 576, y: 96, width: 64, height: 288 });
|
||||||
|
assert.equal(g.screenCenterInViewportX(), 320);
|
||||||
|
assert.equal(g.isOnSwitcherEdge(600, 10, 'min'), true);
|
||||||
|
assert.equal(g.isOnSwitcherEdge(10, 200, 'min'), false);
|
||||||
|
// Depth needs the bottom row's side margins.
|
||||||
|
g.settings.uiDepthSetting.value = '32';
|
||||||
|
assert.equal(g.uiDepth(), 0);
|
||||||
|
g.settings.displayModeSetting.value = '640x480';
|
||||||
|
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a bottom app switcher centres 576-wide windows and hangs one tall tab under them', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
|
assert.equal(g.SWITCHER_ROW_HEIGHT, 36);
|
||||||
|
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 28, width: 576, height: 416 });
|
||||||
|
assert.deepEqual({ ...g.switcherRect('max', 'terminal') }, { x: 32, y: 444, width: 576, height: 36 });
|
||||||
|
// Band and row share the slack: no gap under a band shorter than the screen.
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 106, width: 576, height: 260 });
|
||||||
|
assert.deepEqual({ ...g.switcherRect('min') }, { x: 32, y: 366, width: 576, height: 36 });
|
||||||
|
assert.equal(g.isOnSwitcherEdge(10, 370, 'min'), true);
|
||||||
|
assert.equal(g.isOnSwitcherEdge(10, 360, 'min'), false);
|
||||||
|
g.settings.verticalPositionSetting.value = 'bottom';
|
||||||
|
assert.equal(g.switcherRect('min').y, 444);
|
||||||
|
// The true centre is the viewport's own with the window centred.
|
||||||
|
assert.equal(g.screenCenterInViewportX(), 288);
|
||||||
|
// Depth applies only here.
|
||||||
|
g.settings.uiDepthSetting.value = '-48';
|
||||||
|
assert.equal(g.uiDepth(), -48);
|
||||||
|
// Full panel: windows fill the panel and the row overlays the bottom edge while focused.
|
||||||
|
g.settings.displayModeSetting.value = '640x480';
|
||||||
|
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
|
||||||
|
assert.deepEqual({ ...g.switcherRect('max') }, { x: 0, y: 444, width: 640, height: 36 });
|
||||||
|
assert.equal(g.sidebarStripVisible('window'), false);
|
||||||
|
assert.equal(g.sidebarStripVisible('sidebar'), true);
|
||||||
|
});
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
@@ -299,6 +299,48 @@ class DisplayListTest {
|
|||||||
assertEquals(0, output.get(if (right) 639 else 0, 240)) // cleared, not stale
|
assertEquals(0, output.get(if (right) 639 else 0, 240)) // cleared, not stale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Test fun addedDepthJoinsOrInsertsTheDepthField() {
|
||||||
|
val copy = DrawProtocol.rectCopy(DrawProtocol.SCREEN, 0, 0, 4, 4, 0, 0)
|
||||||
|
assertContentEquals(DrawProtocol.rectCopy(DrawProtocol.SCREEN, 0, 0, 4, 4, 0, 0, depth = 8), DrawProtocol.withAddedDepth(copy, 8))
|
||||||
|
val targeted = DrawProtocol.image(3, 1, 2, target = 5, depth = -2)
|
||||||
|
assertContentEquals(DrawProtocol.image(3, 1, 2, target = 5, depth = 6), DrawProtocol.withAddedDepth(targeted, 8))
|
||||||
|
assertSame(copy, DrawProtocol.withAddedDepth(copy, 0))
|
||||||
|
assertContentEquals(DrawProtocol.image(3, 1, 2, depth = 127), DrawProtocol.withAddedDepth(DrawProtocol.image(3, 1, 2, depth = 120), 16))
|
||||||
|
}
|
||||||
|
/** The bottom switcher's Depth setting: the shell scene's depth moves the screen, shell layers and selections together. */
|
||||||
|
@Test fun shellSceneDepthShiftsTheWholePresentationButNotDimming() {
|
||||||
|
val c = SurfaceCompositor()
|
||||||
|
c.configureScreen(640, 480)
|
||||||
|
c.configureSurface("app", 32, 0, 576, 480, 0, 0)
|
||||||
|
c.submitSurface("app", ArrayByteReader(ByteArray(576 * 480) { if (it % 576 in 100 until 110) 255.toByte() else 0 }),
|
||||||
|
0, 0, 576, 480, "stripe")
|
||||||
|
// One white 2x1 shell layer at (200, 10), dimming what is under it, at layer depth -2; scene depth 8.
|
||||||
|
val header = listOf(1, 1, 200, 10, 2, 1, 128, 0, -2).flatMap { listOf(it.toByte(), (it shr 8).toByte()) }.toByteArray()
|
||||||
|
c.setShellScene(ArrayByteReader(header + byteArrayOf(-1, -1) + DrawProtocol.word(8)))
|
||||||
|
val composite = c.composite()
|
||||||
|
assertEquals(8, composite.shellScene.screenDepth)
|
||||||
|
val calls = composite.shellScene.calls(640, 480, intArrayOf(1), IntArray(0))
|
||||||
|
assertTrue(calls.any { it.contentEquals(DrawProtocol.lut(640, 480, 128)) }) // the dim stays whole-screen
|
||||||
|
val screen = BmpUtil.pack4bppFromGray8(composite.screenGray, 640, 480)
|
||||||
|
for (right in listOf(false, true)) {
|
||||||
|
val glasses = Glasses(right)
|
||||||
|
glasses.apply(ScenePlanner(ResourceCacheState()).plan(screen, 640, 480, null, composite.shellScene, 1).commands)
|
||||||
|
val output = DisplayListRenderer.Target(glasses.composition, 640, 480)
|
||||||
|
// Screen: half of 8 per lens. Layer: depth -2 + 8, so one pixel less than the screen's shift on each lens.
|
||||||
|
val shift = if (right) -4 else 4
|
||||||
|
val layerShift = if (right) -3 else 3
|
||||||
|
assertEquals(0, output.get(131 + shift, 200)); assertTrue(output.get(132 + shift, 200) > 0)
|
||||||
|
assertTrue(output.get(141 + shift, 200) > 0); assertEquals(0, output.get(142 + shift, 200))
|
||||||
|
assertEquals(15, output.get(200 + layerShift, 10)); assertEquals(15, output.get(201 + layerShift, 10))
|
||||||
|
}
|
||||||
|
// The phone mirror shows the scene unshifted, so touches land where they look.
|
||||||
|
val preview = assertNotNull(c.previewComposite()).gray
|
||||||
|
assertEquals(0, preview[131].toInt() and 255); assertTrue((preview[132].toInt() and 255) > 0)
|
||||||
|
// A covering surface's own depth still wins over the scene's.
|
||||||
|
c.configureSurface("glance", 0, 0, 640, 480, 900, 0)
|
||||||
|
c.setSurfaceDepth("glance", -16)
|
||||||
|
assertEquals(-16, c.composite().shellScene.screenDepth)
|
||||||
|
}
|
||||||
@Test fun noisyFramesRemainBoundedAndResourceBudgetIs192KiB() {
|
@Test fun noisyFramesRemainBoundedAndResourceBudgetIs192KiB() {
|
||||||
val cache=ResourceCacheState();val planner=ScenePlanner(cache);val glasses=Glasses()
|
val cache=ResourceCacheState();val planner=ScenePlanner(cache);val glasses=Glasses()
|
||||||
val app=ByteArray(640*480/2){(it*37).toByte()}
|
val app=ByteArray(640*480/2){(it*37).toByte()}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class FrameDisplayListTest {
|
|||||||
// One opaque 1x1 shell layer, with one generic list after its pixels.
|
// One opaque 1x1 shell layer, with one generic list after its pixels.
|
||||||
val layer = DrawProtocol.word(1) + DrawProtocol.word(1) + DrawProtocol.word(0) + DrawProtocol.word(0) +
|
val layer = DrawProtocol.word(1) + DrawProtocol.word(1) + DrawProtocol.word(0) + DrawProtocol.word(0) +
|
||||||
DrawProtocol.word(1) + DrawProtocol.word(1) + DrawProtocol.word(256) + DrawProtocol.word(1) +
|
DrawProtocol.word(1) + DrawProtocol.word(1) + DrawProtocol.word(256) + DrawProtocol.word(1) +
|
||||||
DrawProtocol.word(0) + byteArrayOf(32) + hex(multi)
|
DrawProtocol.word(0) + byteArrayOf(32) + hex(multi) + DrawProtocol.word(0)
|
||||||
val shell = ShellScene.decode(ArrayByteReader(layer))
|
val shell = ShellScene.decode(ArrayByteReader(layer))
|
||||||
assertEquals(2, shell.retainedResources.size)
|
assertEquals(2, shell.retainedResources.size)
|
||||||
assertEquals(240, shell.preview(ByteArray(64) { 32 }, 8, 8)[21].toInt() and 255)
|
assertEquals(240, shell.preview(ByteArray(64) { 32 }, 8, 8)[21].toInt() and 255)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class PreviewPackingTest {
|
|||||||
compositor.configureSurface("app", 0, 0, 3, 2, 0, SurfaceCompositor.TRANSPARENCY_OPAQUE)
|
compositor.configureSurface("app", 0, 0, 3, 2, 0, SurfaceCompositor.TRANSPARENCY_OPAQUE)
|
||||||
// One white 2x1 shell layer at (0,0), with no dimming or selection.
|
// One white 2x1 shell layer at (0,0), with no dimming or selection.
|
||||||
val header = listOf(1, 1, 0, 0, 2, 1, 256, 0, 0).flatMap { listOf(it.toByte(), (it shr 8).toByte()) }.toByteArray()
|
val header = listOf(1, 1, 0, 0, 2, 1, 256, 0, 0).flatMap { listOf(it.toByte(), (it shr 8).toByte()) }.toByteArray()
|
||||||
compositor.setShellScene(ArrayByteReader(header + byteArrayOf(-16, -16)))
|
compositor.setShellScene(ArrayByteReader(header + byteArrayOf(-16, -16) + DrawProtocol.word(0)))
|
||||||
val wire = compositor.applyAndComposite("app", ArrayByteReader(ByteArray(6) { 32 }), 0, 0, 3, 2, "first")
|
val wire = compositor.applyAndComposite("app", ArrayByteReader(ByteArray(6) { 32 }), 0, 0, 3, 2, "first")
|
||||||
assertSame(wire.screenGray, wire.gray) // ShellScene.preview allocates its own pixels.
|
assertSame(wire.screenGray, wire.gray) // ShellScene.preview allocates its own pixels.
|
||||||
assertContentEquals(ByteArray(6) { 32 }, wire.screenGray)
|
assertContentEquals(ByteArray(6) { 32 }, wire.screenGray)
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ test('unselected sidebar icons retain -2 depth through shell cropping, including
|
|||||||
'../../native/notification-icons':{},'../../native/phone-battery':{},'../../util/render-freshness':{},
|
'../../native/notification-icons':{},'../../native/phone-battery':{},'../../util/render-freshness':{},
|
||||||
'../../graphics/icons':{},'../dashboard-settings':{},'../clock-format':{},'../../graphics/bdffont':{},
|
'../../graphics/icons':{},'../dashboard-settings':{},'../clock-format':{},'../../graphics/bdffont':{},
|
||||||
'../layers':{LayerStack},'../menu':{scrollToKeepSelectionVisible:()=>0},'../metrics':{},
|
'../layers':{LayerStack},'../menu':{scrollToKeepSelectionVisible:()=>0},'../metrics':{},
|
||||||
'./geometry':{MIN_WINDOW_HEIGHT:280,minWindowTop:()=>0,windowTop:()=>0,SHELL_OPAQUE_BLACK:1,SIDEBAR_WIDTH:64,TOP_BAR_HEIGHT:24},
|
'./geometry':{MIN_WINDOW_HEIGHT:280,minWindowTop:()=>0,windowTop:()=>0,SHELL_OPAQUE_BLACK:1,SIDEBAR_WIDTH:64,TOP_BAR_HEIGHT:24,
|
||||||
|
SWITCHER_ROW_HEIGHT:36,switcherPosition:()=>'left',switcherRect:()=>({x:0,y:0,width:64,height:280})},
|
||||||
});
|
});
|
||||||
const state={selectedIndex:0,focus:'sidebar',windows:[0,1,2].map(n=>({attention:n===1,drawIcon:(image,x,y)=>image.fillRect(x,y,4,4,240)}))};
|
const state={selectedIndex:0,focus:'sidebar',windows:[0,1,2].map(n=>({attention:n===1,drawIcon:(image,x,y)=>image.fillRect(x,y,4,4,240)}))};
|
||||||
const chrome=new ShellChromeLayer(()=>state),image=new graphics.GrayImage(640,480);
|
const chrome=new ShellChromeLayer(()=>state),image=new graphics.GrayImage(640,480);
|
||||||
|
|||||||
Reference in new issue
Block a user