forked from Blendman974/faceclaw
Borderless modes have different padding inside the builtin apps
Most of the builtin apps had some padding between the window edge and their content, because they expect to be displayed with a line border on their edge. We added a customization option to remove the border, so, that padding is not always necessary. Make the layouts dynamically adjust, to omit the padding when it isn't needed.
This commit is contained in:
1 parent
e158452ba4
commit
a02b849200
115 files changed
+3600
-1583
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
type WindowBorder,
|
||||
windowBorderSetting,
|
||||
} from "../dashboard-settings";
|
||||
import { type EdgeKind, type Edges, uniformEdges, type Viewport, viewportWith } from "../viewport";
|
||||
|
||||
/** The paired glasses' screen, which the shell lays out in (graphics/screen-size.ts). */
|
||||
export { screenHeight, screenWidth };
|
||||
@@ -481,6 +482,37 @@ export function appViewportSize(mode: WindowHeightMode, appId?: string): { width
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* What each edge of an app's windows touches (see viewport.ts EdgeKind): a
|
||||
* line the chrome draws right outside it, or nothing. A framed window has a
|
||||
* line on every side. Otherwise the top or bottom has one where a status bar
|
||||
* with rows of its own, or a bottom switcher row, lies past it and the
|
||||
* Border setting divides the two; a side has one only beside a side strip,
|
||||
* whose separator it is. An immersive window has the whole panel, and so
|
||||
* none.
|
||||
*/
|
||||
export function windowEdges(appId?: string): Edges<EdgeKind> {
|
||||
if (isImmersive(appId)) return uniformEdges("offscreen");
|
||||
if (windowFramed(appId)) return uniformEdges("border");
|
||||
const position = switcherPosition();
|
||||
const line = (drawn: boolean): EdgeKind => (drawn ? "border" : "offscreen");
|
||||
const statusLine = (edge: "top" | "bottom") => windowEdgeHeight(edge, appId) === TOP_BAR_HEIGHT && statusBarDivider();
|
||||
return {
|
||||
top: line(statusLine("top")),
|
||||
right: line(position === "right"),
|
||||
bottom: line(position === "bottom" ? switcherRowHeight(appId) > 0 && switcherRowDivider(appId) : statusLine("bottom")),
|
||||
left: line(position === "left"),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A window's viewport as its layouts get it: the app-content size for its
|
||||
* height mode, what its edges touch, and the padding suggested for them.
|
||||
*/
|
||||
export function appViewport(mode: WindowHeightMode, appId?: string): Viewport {
|
||||
return viewportWith(appViewportSize(mode, appId), windowEdges(appId));
|
||||
}
|
||||
|
||||
/** Screen rect of a window's app-content viewport (between its header and footer). */
|
||||
export function appViewportRect(mode: WindowHeightMode, appId?: string): {
|
||||
x: number;
|
||||
|
||||
@@ -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, setAppImmersive, type WindowHeightMode } from "./geometry";
|
||||
import { appViewport, setAppImmersive, type WindowHeightMode } from "./geometry";
|
||||
import { shell, type ShellWindow } from "./shell";
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
const requestRender = () => renderInNewFrame(0);
|
||||
let heightMode = options.heightMode ?? "min";
|
||||
setAppImmersive(options.appId, options.immersive ?? false);
|
||||
const viewportSize = () => appViewportSize(heightMode, options.appId);
|
||||
const viewportSize = () => appViewport(heightMode, options.appId);
|
||||
const stack = new LayerStack(
|
||||
options.baseLayer,
|
||||
{ ...options.actions, requestRender },
|
||||
|
||||
@@ -3,6 +3,7 @@ import { flattenPlanes } from "../../graphics/plane";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
|
||||
import { uniformEdges, type Viewport, viewportWith } from "../viewport";
|
||||
|
||||
// The modal covers most of the min-height app viewport, leaving a little of
|
||||
// the foreground app visible around the edges. Both its size and position are
|
||||
@@ -11,13 +12,16 @@ import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry
|
||||
const MODAL_MARGIN = 14;
|
||||
const MODAL_PADDING = 4;
|
||||
|
||||
/** Content (inner layer stack) size of the modal box. */
|
||||
function modalInterior(): { width: number; height: number } {
|
||||
/**
|
||||
* The modal box's content (inner layer stack) viewport: every edge is just
|
||||
* inside the box's border.
|
||||
*/
|
||||
function modalInterior(): Viewport {
|
||||
const viewport = appViewportSize("min");
|
||||
return {
|
||||
return viewportWith({
|
||||
width: viewport.width - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
height: Math.min(viewport.height - 2 * MODAL_MARGIN, Math.floor(65530 / Math.ceil((viewport.width - 2 * MODAL_MARGIN) / 2))) - 2 * MODAL_PADDING,
|
||||
};
|
||||
}, uniformEdges("border"));
|
||||
}
|
||||
|
||||
/** Screen rect of the modal box, aligned to the min-height window band. */
|
||||
|
||||
@@ -89,6 +89,7 @@ import {
|
||||
screenWidth,
|
||||
} from "./geometry";
|
||||
import type { AppSwitcherPosition } from "../dashboard-settings";
|
||||
import type { Viewport } from "../viewport";
|
||||
|
||||
/**
|
||||
* The shell: owns the window registry, focus, screen on/off, and the shell
|
||||
@@ -169,11 +170,11 @@ export type ShellWindow = {
|
||||
*/
|
||||
relayout?: () => void;
|
||||
/**
|
||||
* The viewport size the window is laid out at (it changes on relayout), so
|
||||
* the controller can tell a window whose size fell behind the geometry from
|
||||
* one whose surface merely moved.
|
||||
* The viewport the window is laid out at (it changes on relayout), so the
|
||||
* controller can tell a window whose size, or whose edges, fell behind the
|
||||
* geometry from one whose surface merely moved.
|
||||
*/
|
||||
layoutSize?: () => { width: number; height: number };
|
||||
layoutSize?: () => Viewport;
|
||||
/**
|
||||
* A touch from the phone's mirror at (x, y) in app-viewport coordinates.
|
||||
* True if the window acted on it; otherwise the controller sends a select.
|
||||
|
||||
@@ -3,7 +3,8 @@ import { GrayImage } from "../../graphics/image";
|
||||
import { windowIcon } from "./chrome-layer";
|
||||
import { type IconActivity, type IconName } from "../../graphics/icons";
|
||||
import { toolRegistry, type ToolResult, type ToolSpec } from "../../assistant/tool-registry";
|
||||
import { appViewportSize, type WindowHeightMode } from "./geometry";
|
||||
import { appViewport, type WindowHeightMode } from "./geometry";
|
||||
import { type Viewport } from "../viewport";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { shell, type ShellWindow } from "./shell";
|
||||
import { publishWorkerState } from "./worker-state";
|
||||
@@ -20,8 +21,10 @@ export type WorkerAppMessage =
|
||||
/** Release app-wide resources, then acknowledge with worker-stopped. */
|
||||
| { type: "shutdown" }
|
||||
| { type: "navigation-sensors"; event: NavigationSensorEvent }
|
||||
| { type: "open-window"; windowId: string; surfaceId: string; title: string; viewport: { width: number; height: number } }
|
||||
| { type: "resize-window"; windowId: string; viewport: { width: number; height: number } }
|
||||
/** `viewport` carries what the window's edges touch and the padding suggested for them (viewport.ts). */
|
||||
| { type: "open-window"; windowId: string; surfaceId: string; title: string; viewport: Viewport }
|
||||
/** The window's size changed, or what its edges touch did (so its padding). */
|
||||
| { type: "resize-window"; windowId: string; viewport: Viewport }
|
||||
| { type: "close-window"; windowId: string }
|
||||
| { type: "input"; windowId: string; event: unknown; frameId: number; focused: boolean }
|
||||
| { type: "text-input"; windowId: string; text: string; submit?: boolean }
|
||||
@@ -462,7 +465,7 @@ export class WorkerAppHost {
|
||||
const surfaceId = `window:${spec.windowId}`;
|
||||
const heightMode = spec.heightMode ?? "min";
|
||||
this.openWindows.add(spec.windowId);
|
||||
let viewport = appViewportSize(heightMode, this.options.appId);
|
||||
let viewport = appViewport(heightMode, this.options.appId);
|
||||
this.post({
|
||||
type: "open-window",
|
||||
windowId: spec.windowId,
|
||||
@@ -482,7 +485,7 @@ export class WorkerAppHost {
|
||||
// (a game in progress, a route): the bottom switcher's height changes
|
||||
// with what it holds, and full-height windows give way to it.
|
||||
relayout: () => {
|
||||
viewport = appViewportSize(window.heightMode, this.options.appId);
|
||||
viewport = appViewport(window.heightMode, this.options.appId);
|
||||
this.post({ type: "resize-window", windowId: spec.windowId, viewport });
|
||||
},
|
||||
layoutSize: () => viewport,
|
||||
|
||||
Reference in new issue
Block a user