Even store integration

This commit is contained in:
James Babcock committed 2026-08-16 21:01:20 -07:00
1 parent 5cd61da362
commit add8763028
16 files changed
+737 -56

No files matched your search

+28
View File
@@ -125,6 +125,34 @@ export function windowIcon(icon: IconName | undefined, letter: string, glyph?: s
return icon ? makeSvgWindowIcon(icon, glyph) : makeLetterWindowIcon(letter);
}
/** Window icon backed by an arbitrary cached grayscale image renderer. */
export function makeImageWindowIcon(
render: (size: number) => GrayImage | null,
fallback: ShellChromeWindow["drawIcon"],
): ShellChromeWindow["drawIcon"] {
return (image, x, y, size, inverted) => {
const icon = render(size);
if (!icon) {
fallback(image, x, y, size, inverted);
return;
}
const dx = x + Math.max(0, ((size - icon.width) / 2) | 0);
const dy = y + Math.max(0, ((size - icon.height) / 2) | 0);
if (!inverted) {
image.bitBlt(icon, dx, dy, { transparentZero: true });
return;
}
for (let row = 0; row < icon.height; row++) {
for (let col = 0; col < icon.width; col++) {
const coverage = icon.pixels[row * icon.width + col] ?? 0;
if (coverage > 0) {
image.setPixel(dx + col, dy + row, Math.max(SHELL_OPAQUE_BLACK, 255 - coverage));
}
}
}
};
}
/**
* Base layer of the shell surface: the window sidebar on the left and the
* status top bar. Everything not explicitly painted stays 0 (transparent on
+3 -1
View File
@@ -23,6 +23,8 @@ export type InProcessWindowOptions = {
iconLetter: string;
/** Lucide icon name for the sidebar indicator; falls back to iconLetter. */
icon?: IconName;
/** App-supplied sidebar icon renderer; takes precedence over icon/iconLetter. */
drawIcon?: ShellWindow["drawIcon"];
closeable: boolean;
/** Window height: the standard 288px band ("min", default) or full screen ("max"). */
heightMode?: WindowHeightMode;
@@ -148,7 +150,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
options.onClosed?.();
options.removeSurface?.();
},
drawIcon: windowIcon(options.icon, options.iconLetter),
drawIcon: options.drawIcon ?? windowIcon(options.icon, options.iconLetter),
handleInput: async (event, frameId) => {
// The default long-press response: the window menu. Handled here (not
// per-layer) so it works over submenus and app content alike.