Migrate things into new UI design

This commit is contained in:
James Babcock committed 2026-07-07 00:52:47 -07:00
1 parent 1133f952e9
commit 68ab599856
21 files changed
+1262 -602

No files matched your search

+11 -44
View File
@@ -1,9 +1,9 @@
import { GrayImage } from "../../graphics/image";
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack } from "../layers";
import { LayerActions } from "../layers";
import { MenuLayer } from "../menu";
import { makeLetterWindowIcon } from "./chrome-layer";
import { APP_VIEWPORT } from "./geometry";
import { shell, type ShellWindow } from "./shell";
import { createInProcessWindow, YieldAtRootLayer } from "./in-process-window";
import { type ShellWindow } from "./shell";
export type LauncherAppEntry = {
appId: string;
@@ -23,24 +23,13 @@ export type LauncherOptions = {
export const LAUNCHER_WINDOW_ID = "launcher";
export const LAUNCHER_SURFACE_ID = "window:launcher";
/** The launcher's root menu; backing out of it yields to the sidebar. */
class LauncherMenuLayer extends MenuLayer {
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
if (event.type === "double-click") {
shell.yieldFocusToSidebar();
return;
}
await super.handleInput(event, ctx);
}
}
/**
* The launcher: a pinned, uncloseable in-process window listing launchable
* apps. Selecting an app asks the controller to launch it (new window,
* possibly in an existing app worker) and foregrounds the new window.
*/
export function createLauncherWindow(options: LauncherOptions): ShellWindow {
const baseLayer: Layer = new LauncherMenuLayer(
const menu = new MenuLayer(
"Apps",
options.apps.map((app) => ({
label: app.label,
@@ -56,37 +45,15 @@ export function createLauncherWindow(options: LauncherOptions): ShellWindow {
maxHeight: APP_VIEWPORT.height - 16,
},
);
const stack = new LayerStack(baseLayer, options.actions, {
width: APP_VIEWPORT.width,
height: APP_VIEWPORT.height,
});
async function render(frameId: number): Promise<void> {
const paintStartedAtMs = Date.now();
const image = stack.paint();
await options.submitFrame(image, Date.now() - paintStartedAtMs, frameId);
}
return {
return createInProcessWindow({
appId: "launcher",
windowId: LAUNCHER_WINDOW_ID,
title: "Apps",
surfaceId: LAUNCHER_SURFACE_ID,
iconLetter: "A",
closeable: false,
drawIcon: makeLetterWindowIcon("A"),
handleInput: async (event, frameId) => {
await stack.handleInput(event);
// Java-side dedup finishes no-change frames, so an unconditional
// resubmit keeps frame ownership simple.
await render(frameId);
},
requestRender: () => {
void render(0).catch((error) => {
console.error(`launcher render failed: ${error}`);
});
},
setForeground: (foreground) => {
options.setSurfaceVisible(foreground);
},
};
actions: options.actions,
baseLayer: new YieldAtRootLayer(menu),
submitFrame: options.submitFrame,
setSurfaceVisible: options.setSurfaceVisible,
}).window;
}