forked from Blendman974/faceclaw
Onboarding: Add layout and depth pages
This commit is contained in:
1 parent
1d257e8bb6
commit
6b1e64c5ac
17 files changed
+766
-74
No files matched your search
@@ -27,6 +27,7 @@ import { scrollToKeepSelectionVisible } from "../menu";
|
||||
import { lineStep } from "../metrics";
|
||||
import {
|
||||
appViewportRect,
|
||||
isFullscreen,
|
||||
MIN_WINDOW_HEIGHT,
|
||||
minWindowTop,
|
||||
SHELL_OPAQUE_BLACK,
|
||||
@@ -275,14 +276,15 @@ type StatusBarPlacement = { left: number; right: number; top: number; contentTop
|
||||
|
||||
/**
|
||||
* The status bar's placement for the foreground window, or null when it
|
||||
* isn't drawn as a bar: when it shares a bottom switcher row, or when it
|
||||
* overlays the window (geometry.ts statusBarOverlays) and the popup
|
||||
* switcher isn't up. An overlaying bar sits inside a window frame, whose
|
||||
* side runs along its outer row, so it keeps its divider.
|
||||
* isn't drawn as a bar: when the window is fullscreen, when it shares a
|
||||
* bottom switcher row, or when it overlays the window (geometry.ts
|
||||
* statusBarOverlays) and the popup switcher isn't up. An overlaying bar
|
||||
* sits inside a window frame, whose side runs along its outer row, so it
|
||||
* keeps its divider.
|
||||
*/
|
||||
function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null {
|
||||
const appId = state.foregroundAppId;
|
||||
if (statusInSwitcherRow(appId)) return null;
|
||||
if (isFullscreen(appId) || statusInSwitcherRow(appId)) return null;
|
||||
const overlays = statusBarOverlays();
|
||||
if (overlays && !sidebarStripVisible(state.focus, appId)) return null;
|
||||
const { left, right } = topBarSpan(state);
|
||||
|
||||
@@ -60,9 +60,33 @@ export function displayMode(appId?: string): DisplayModeSetting {
|
||||
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. */
|
||||
/**
|
||||
* Apps whose windows are fullscreen right now: the whole panel, with no
|
||||
* status bar, window frame or room kept for the switcher (which overlays
|
||||
* them only while it has focus, as in the full-panel mode), at depth 0. An
|
||||
* app switches it at runtime (InProcessWindow.setFullscreen; the onboarding's
|
||||
* first pages), so it is per app, like the per-app display modes.
|
||||
*/
|
||||
const fullscreenApps = new Set<string>();
|
||||
|
||||
/** Mark an app's windows fullscreen or not; true if that changed anything. */
|
||||
export function setAppFullscreen(appId: string, fullscreen: boolean): boolean {
|
||||
if (fullscreenApps.has(appId) === fullscreen) return false;
|
||||
if (fullscreen) fullscreenApps.add(appId);
|
||||
else fullscreenApps.delete(appId);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function isFullscreen(appId?: string): boolean {
|
||||
return appId !== undefined && fullscreenApps.has(appId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The full-panel mode (or a fullscreen app): windows fill the panel; the
|
||||
* switcher overlays them only while it has focus.
|
||||
*/
|
||||
function fullPanel(appId?: string): boolean {
|
||||
return displayMode(appId) === "640x480";
|
||||
return isFullscreen(appId) || displayMode(appId) === "640x480";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,9 +200,10 @@ export function statusBarOverlays(): boolean {
|
||||
* Rows the shell draws along one edge of each window's content: the status
|
||||
* bar's (the top bar, as a header), the frame's side, or none. A bottom
|
||||
* switcher row's band has no footer: the frame's bottom side is the row's
|
||||
* top edge.
|
||||
* top edge. A fullscreen window has neither.
|
||||
*/
|
||||
function windowEdgeHeight(edge: "top" | "bottom", appId?: string): number {
|
||||
if (isFullscreen(appId)) return 0;
|
||||
if (switcherPosition() !== "popup") {
|
||||
return edge === "bottom" ? 0 : statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
|
||||
}
|
||||
@@ -261,17 +286,20 @@ export function appViewportLeft(appId?: string): number {
|
||||
* 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 or a popup, where the windows' side margins,
|
||||
* less the window frame's pixel, leave room for the shift.
|
||||
* less the window frame's pixel, leave room for the shift; not while the
|
||||
* given (foreground) app is fullscreen, which has no margins.
|
||||
*/
|
||||
export function uiDepth(): number {
|
||||
return sideStrip() ? 0 : Number(uiDepthSetting.get());
|
||||
export function uiDepth(appId?: string): number {
|
||||
return sideStrip() || isFullscreen(appId) ? 0 : Number(uiDepthSetting.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicit app sizes (including Use global) replace the requested height.
|
||||
* The default keeps legacy per-window heights, such as tall terminal sessions.
|
||||
* A fullscreen app is always the whole height.
|
||||
*/
|
||||
export function effectiveHeightMode(mode: WindowHeightMode, appId?: string): WindowHeightMode {
|
||||
if (isFullscreen(appId)) return "max";
|
||||
return displayMode(appId) === "576x288" ? (appDisplayMode(appId) === "default" ? mode : "min") : "max";
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { type MenuItem } from "../menu";
|
||||
import { WindowMenuLayer } from "../window-menu";
|
||||
import { windowIcon } from "./chrome-layer";
|
||||
import { type IconName } from "../../graphics/icons";
|
||||
import { appViewportSize, type WindowHeightMode } from "./geometry";
|
||||
import { appViewportSize, setAppFullscreen, type WindowHeightMode } from "./geometry";
|
||||
import { shell, type ShellWindow } from "./shell";
|
||||
|
||||
/**
|
||||
@@ -30,6 +30,8 @@ export type InProcessWindowOptions = {
|
||||
closeable: boolean;
|
||||
/** Window height: the standard 288px band ("min", default) or full screen ("max"). */
|
||||
heightMode?: WindowHeightMode;
|
||||
/** Open fullscreen: the whole panel, without the status bar (see geometry.ts isFullscreen). */
|
||||
fullscreen?: boolean;
|
||||
/**
|
||||
* The window's tap-then-hold context menu: app-specific entries only (the
|
||||
* shared Focus app switcher / Voice input / Close window entries live in
|
||||
@@ -73,6 +75,12 @@ export type InProcessWindow = {
|
||||
requestRender: () => void;
|
||||
/** Change the window's height band at runtime (resizes the viewport + surface). */
|
||||
setHeightMode: (mode: WindowHeightMode) => void;
|
||||
/**
|
||||
* Enter or leave fullscreen at runtime (resizes the viewport + surface).
|
||||
* It is per app (geometry.ts isFullscreen), so an app with several
|
||||
* windows switches them all.
|
||||
*/
|
||||
setFullscreen: (fullscreen: boolean) => void;
|
||||
};
|
||||
|
||||
/** The controller-provided plumbing common to every in-process app window. */
|
||||
@@ -102,10 +110,12 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
// Handed to app code as a bare callback, so it takes no arguments.
|
||||
const requestRender = () => renderInNewFrame(0);
|
||||
let heightMode = options.heightMode ?? "min";
|
||||
setAppFullscreen(options.appId, options.fullscreen ?? false);
|
||||
const viewportSize = () => appViewportSize(heightMode, options.appId);
|
||||
const stack = new LayerStack(
|
||||
options.baseLayer,
|
||||
{ ...options.actions, requestRender },
|
||||
appViewportSize(heightMode),
|
||||
viewportSize(),
|
||||
() => shell.isWindowFocused(options.windowId),
|
||||
);
|
||||
|
||||
@@ -172,6 +182,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
hasAppMenu: () => appMenuItems().length > 0,
|
||||
close: () => {
|
||||
closed = true;
|
||||
setAppFullscreen(options.appId, false);
|
||||
// Fire onRemoved for any pushed layers so they release resources (e.g. a
|
||||
// demo that enabled a hardware stream) even when closed from within.
|
||||
stack.clearToBase();
|
||||
@@ -210,7 +221,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
},
|
||||
requestRender,
|
||||
relayout: () => {
|
||||
stack.setBaseSize(appViewportSize(heightMode));
|
||||
stack.setBaseSize(viewportSize());
|
||||
options.reconfigureSurface?.(heightMode);
|
||||
requestRender();
|
||||
},
|
||||
@@ -226,15 +237,21 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
options.onForegroundChanged?.(foreground);
|
||||
},
|
||||
};
|
||||
const resize = () => {
|
||||
stack.setBaseSize(viewportSize());
|
||||
options.reconfigureSurface?.(heightMode);
|
||||
requestRender();
|
||||
};
|
||||
const setHeightMode = (mode: WindowHeightMode) => {
|
||||
if (heightMode === mode) return;
|
||||
heightMode = mode;
|
||||
window.heightMode = mode;
|
||||
stack.setBaseSize(appViewportSize(mode));
|
||||
options.reconfigureSurface?.(mode);
|
||||
requestRender();
|
||||
resize();
|
||||
};
|
||||
return { window, stack, requestRender, setHeightMode };
|
||||
const setFullscreen = (fullscreen: boolean) => {
|
||||
if (!closed && setAppFullscreen(options.appId, fullscreen)) resize();
|
||||
};
|
||||
return { window, stack, requestRender, setHeightMode, setFullscreen };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -831,10 +831,13 @@ class Shell {
|
||||
|
||||
/**
|
||||
* Paint the shell surface: transparent chrome, or all-transparent when
|
||||
* asleep. The scene also carries the whole display's stereo depth.
|
||||
* asleep. The scene also carries the whole display's stereo depth (none
|
||||
* under a fullscreen window).
|
||||
*/
|
||||
paintScene(): Uint8Array {
|
||||
return this.screenOn ? encodeShellScene(this.stack.paintUndimmed(), uiDepth()) : encodeShellScene([]);
|
||||
return this.screenOn
|
||||
? encodeShellScene(this.stack.paintUndimmed(), uiDepth(this.foregroundWindow()?.appId))
|
||||
: encodeShellScene([]);
|
||||
}
|
||||
|
||||
paintSurface(): Plane[] {
|
||||
|
||||
Reference in new issue
Block a user