Add centered/popup version of app switcher; plus various UI tweaks

This commit is contained in:
James Babcock committed 2026-10-02 23:36:51 -07:00
1 parent 295922effd
commit 96e155ebb0
12 files changed
+810 -190

No files matched your search

+233 -46
View File
@@ -32,11 +32,15 @@ import {
SHELL_OPAQUE_BLACK,
SIDEBAR_WIDTH,
sidebarStripVisible,
statusBarEdge,
statusBarOverlays,
statusBarTop,
statusInSwitcherRow,
SWITCHER_ROW_HEIGHT,
switcherPosition,
switcherRect,
TOP_BAR_HEIGHT,
windowFooterHeight,
windowFramed,
windowHeaderHeight,
windowTop,
@@ -80,6 +84,30 @@ const ROW_STATUS_GAP = 8;
// all of them, when there are fewer); the windows take whatever is left.
const ROW_MIN_WINDOW_SLOTS = 3;
// The popup switcher (geometry.ts "popup"): a box centred over the
// foreground window's content, holding a row of window icons above the
// selected window's title. Each icon sits in a square cell, which the
// selection fills white (the popup only shows while it has focus).
const POPUP_ICON_SIZE = ROW_ICON_SIZE;
const POPUP_CELL = POPUP_ICON_SIZE + 12;
const POPUP_STEP = POPUP_CELL + 4;
const POPUP_PADDING = 12;
// Room at each end of the icons for a scroll chevron, once they scroll.
const POPUP_CHEVRON_ROOM = 12;
const POPUP_TITLE_GAP = 6;
// The box keeps this far from the window's sides, and is at least this
// wide, leaving a few windows' titles room.
const POPUP_MARGIN = 16;
const POPUP_MIN_WIDTH = 272;
// The system menu's border.
const POPUP_BORDER_VALUE = 72;
// Nearer than the window, as the system menu is.
const POPUP_DEPTH = 4;
// Brightness of everything under the chrome (the windows) while the popup
// shows: lighter than a context menu's dim, since the dimmed window is the
// selected one, which the wearer may be looking for.
const POPUP_DIM = 0.5;
/** Icon rows that fit in one sidebar column. */
function rowsPerColumn(variant: SidebarVariant): number {
return Math.max(1, ((LIST_HEIGHT + ICON_SPACING) / (variant.iconSize + ICON_SPACING)) | 0);
@@ -173,6 +201,40 @@ function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId
};
}
/**
* Popup switcher geometry for the foreground window: its box, centred over
* the window's content (geometry.ts switcherRect), as wide as the icons
* need up to the window's width less margins (at least POPUP_MIN_WIDTH),
* the cells of the visible icons by slot (as switcherLayout's), and the
* title's top. Past what fits, the icons scroll, with room for a chevron at
* either end.
*/
function popupLayout(windowCount: number, state: ShellChromeState): SwitcherLayout & { box: Rect; titleTop: number } {
const area = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
const room = area.width - 2 * (POPUP_MARGIN + POPUP_PADDING);
const fits = (width: number) => Math.max(1, ((width + POPUP_STEP - POPUP_CELL) / POPUP_STEP) | 0);
const scrolls = windowCount > fits(room);
const visibleCount = scrolls ? fits(room - 2 * POPUP_CHEVRON_ROOM) : Math.max(1, windowCount);
const iconsWidth = visibleCount * POPUP_STEP - (POPUP_STEP - POPUP_CELL);
const width = 2 * POPUP_PADDING + Math.max(iconsWidth + (scrolls ? 2 * POPUP_CHEVRON_ROOM : 0), POPUP_MIN_WIDTH - 2 * POPUP_PADDING);
const height = 2 * POPUP_PADDING + POPUP_CELL + POPUP_TITLE_GAP + getDefaultMediumFont().lineHeight;
const box = {
x: area.x + ((area.width - width) >> 1),
y: area.y + Math.max(0, (area.height - height) >> 1),
width,
height,
};
const iconsLeft = box.x + ((width - iconsWidth) >> 1), cellTop = box.y + POPUP_PADDING;
return {
position: "popup",
iconSize: POPUP_ICON_SIZE,
visibleCount,
cell: (slot) => ({ x: iconsLeft + slot * POPUP_STEP, y: cellTop, width: POPUP_CELL, height: POPUP_CELL, atSeparator: false }),
box,
titleTop: cellTop + POPUP_CELL + POPUP_TITLE_GAP,
};
}
/**
* 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
@@ -200,6 +262,36 @@ function topBarSpan(state: ShellChromeState): { left: number; right: number } {
}
return { left, right };
}
/**
* Where the status bar is drawn for the foreground window: TOP_BAR_HEIGHT
* rows from `top`, across `left`..`right`. `contentTop` is where the top
* bar's layout starts in them: a row lower at the window's bottom, where
* the bar's first row is the one next to the window. `divider` is the row
* of the line between bar and window, or null where the window frame's side
* runs along it instead.
*/
type StatusBarPlacement = { left: number; right: number; top: number; contentTop: number; divider: number | null };
/**
* 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.
*/
function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null {
const appId = state.foregroundAppId;
if (statusInSwitcherRow(appId)) return null;
const overlays = statusBarOverlays();
if (overlays && !sidebarStripVisible(state.focus, appId)) return null;
const { left, right } = topBarSpan(state);
const top = statusBarTop(state.foregroundHeightMode, appId);
const atBottom = statusBarEdge() === "bottom";
const divider = windowFramed(appId) && !overlays ? null : atBottom ? top : top + TOP_BAR_HEIGHT - 1;
return { left, right, top, contentTop: atBottom ? top + 1 : top, divider };
}
const NOTIFICATION_ICON_SIZE = 24;
const BORDER_VALUE = 40;
@@ -309,6 +401,8 @@ export function makeImageWindowIcon(
export class ShellChromeLayer implements Layer {
// First switcher icon shown; adjusted each paint to keep the selection visible.
private scrollRow = 0;
// The popup switcher's shell surface.
private popupKey: number | undefined;
// Where the last paint ended a bottom row's window icons, for hit testing.
private rowWindowsRight: number | undefined;
// Whether the last paint's selection tab carries the window frame's left
@@ -321,15 +415,20 @@ export class ShellChromeLayer implements Layer {
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
const state = this.getState();
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
const popup = switcherPosition() === "popup";
// Full-panel mode: the strip is an overlay, present only while the user
// is in it (the window underneath keeps its full width the rest of the time).
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
// is in it (the window underneath keeps its full width the rest of the
// time); a popup only ever shows then.
const switcherShown = sidebarStripVisible(state.focus, state.foregroundAppId);
if (switcherShown && !popup) {
this.drawSidebar(image, state, statusInRow ? image : undefined);
}
if (!statusInRow) this.drawTopBar(image, state);
const bar = statusBarPlacement(state);
if (bar) this.drawTopBar(image, state, bar);
const frame = windowFrameRect(state);
if (frame) drawWindowFrame(image, frame, this.frameCornerSquare);
if (frame) drawWindowFrame(image, frame, this.frameCornerSquare, popup);
drawAmbientCards(image, topBarSpan(state).right);
if (switcherShown && popup) this.drawPopup(image, state);
return image;
}
@@ -337,12 +436,18 @@ export class ShellChromeLayer implements Layer {
const state = this.getState(), parts: Plane[] = [];
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
const bar = topBarSpan(state);
if (!statusInRow) {
this.drawTopBar(canvas, state);
parts.push({ ...shellCrop(canvas, bar.left, windowTop(state.foregroundHeightMode, state.foregroundAppId), bar.right - bar.left, TOP_BAR_HEIGHT, 2), depth: -2 });
const span = topBarSpan(state);
const bar = statusBarPlacement(state);
if (bar) {
this.drawTopBar(canvas, state, bar);
parts.push({ ...shellCrop(canvas, bar.left, bar.top, bar.right - bar.left, TOP_BAR_HEIGHT, 2), depth: -2 });
}
if (sidebarStripVisible(state.focus, state.foregroundAppId)) {
const switcherShown = sidebarStripVisible(state.focus, state.foregroundAppId);
if (switcherPosition() === "popup") {
this.paintPopupParts(state, parts, canvas, switcherShown);
return parts;
}
if (switcherShown) {
const stripCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
const statusLeft = this.drawSidebar(stripCanvas, state, statusInRow ? canvas : undefined);
// The window frame rides on the switcher row, whose top edge is its
@@ -355,8 +460,8 @@ export class ShellChromeLayer implements Layer {
// Under a framed window the row's surface spans the frame, whose left
// side the first selection tab continues.
const strip = switcherRect(state.foregroundHeightMode, state.foregroundAppId);
const span = frame ?? strip;
parts.push(shellCrop(stripCanvas, span.x, strip.y, span.width, strip.height, 1));
const rowSpan = frame ?? strip;
parts.push(shellCrop(stripCanvas, rowSpan.x, strip.y, rowSpan.width, strip.height, 1));
if (statusLeft !== null) {
// The status bar keeps the top bar's surface and its depth, -2, over
// the row's right end below its separator line, so the clock ticking
@@ -365,10 +470,37 @@ export class ShellChromeLayer implements Layer {
parts.push({ ...shellCrop(canvas, statusLeft, strip.y + 1, right - statusLeft, strip.height - 1, 2), depth: -2 });
}
}
drawAmbientCards(canvas, bar.right, parts);
drawAmbientCards(canvas, span.right, parts);
return parts;
}
/**
* The popup switcher mode's parts after the status bar's: the window
* frame, ambient cards, then, while the switcher has focus, the popup. Its
* dim rides on the first part, so it dims the windows beneath the chrome
* and none of the chrome.
*/
private paintPopupParts(state: ShellChromeState, parts: Plane[], canvas: GrayImage, switcherShown: boolean): void {
const frame = windowFrameRect(state);
if (frame) {
// A shell surface is an opaque rectangle and needs a pixel of its own
// to be sent at all, so the frame rides on one at its top-left corner,
// outside its curve, which it paints black anyway. As in the bottom
// row's case, it plays at the screen's own depth.
const frameCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
frameCanvas.fillRect(frame.x, frame.y, 1, 1, SHELL_OPAQUE_BLACK);
drawWindowFrame(frameCanvas, frame, false, true);
parts.push(shellCrop(frameCanvas, frame.x, frame.y, 1, 1, 1));
}
drawAmbientCards(canvas, topBarSpan(state).right, parts);
if (!switcherShown) return;
const popupCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
const box = this.drawPopup(popupCanvas, state);
this.popupKey ??= LayerStack.allocateShellKey();
parts.push({ ...shellCrop(popupCanvas, box.x, box.y, box.width, box.height, this.popupKey), depth: POPUP_DEPTH });
parts[0] = { ...parts[0]!, dimUnderneath: POPUP_DIM };
}
handleInput(): void {
// Shell input is handled by the shell state machine before it reaches the
// layer stack; the chrome itself never consumes events.
@@ -382,7 +514,8 @@ export class ShellChromeLayer implements Layer {
windowIndexAt(x: number, y: number, windowCount: number): number | null {
if (windowCount === 0) return null;
const state = this.getState();
const layout = switcherLayout(windowCount, state.foregroundHeightMode, state.foregroundAppId, this.rowWindowsRight, this.scrollRow);
const layout = switcherPosition() === "popup" ? popupLayout(windowCount, state)
: switcherLayout(windowCount, state.foregroundHeightMode, state.foregroundAppId, this.rowWindowsRight, this.scrollRow);
const lastVisible = Math.min(windowCount, this.scrollRow + layout.visibleCount);
for (let index = this.scrollRow; index < lastVisible; index++) {
const cell = layout.cell(index - this.scrollRow);
@@ -525,20 +658,70 @@ export class ShellChromeLayer implements Layer {
return iconsLeft;
}
private drawTopBar(image: GrayImage, state: ShellChromeState): void {
const font = getDefaultMediumFont();
// The bar sits at the top edge of the foreground window's band, wherever
// its height mode puts that (screen top for max height). It moves when
// the foreground switches to a window of a different height.
const barTop = windowTop(state.foregroundHeightMode, state.foregroundAppId);
// The bar spans the app viewport; with a side strip overlaid (full-panel
// mode, sidebar focused) it still stops at the strip.
const { left: barLeft, right: barRight } = topBarSpan(state);
image.fillRect(barLeft, barTop, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
// A framed window's frame draws this line as its top (drawWindowFrame).
if (!windowFramed(state.foregroundAppId)) {
image.drawLine(barLeft, barTop + TOP_BAR_HEIGHT - 1, barRight - 1, barTop + TOP_BAR_HEIGHT - 1, BORDER_VALUE);
/**
* The popup switcher: its box centred over the foreground window's
* content, the visible window icons in a row with the selected one's cell
* filled white (and its icon inverted), chevrons where more scroll, and
* the selected window's title underneath. Returns the box.
*/
private drawPopup(image: GrayImage, state: ShellChromeState): Rect {
const count = state.windows.length;
const layout = popupLayout(count, state);
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, state.selectedIndex, layout.visibleCount, count);
const { box } = layout;
image.fillRect(box.x, box.y, box.width, box.height, SHELL_OPAQUE_BLACK);
image.drawRect(box.x, box.y, box.width, box.height, POPUP_BORDER_VALUE);
const lastVisible = Math.min(count, this.scrollRow + layout.visibleCount);
for (let index = this.scrollRow; index < lastVisible; index++) {
const window = state.windows[index]!;
const cell = layout.cell(index - this.scrollRow);
const x = cell.x + ((cell.width - POPUP_ICON_SIZE) >> 1);
const y = cell.y + ((cell.height - POPUP_ICON_SIZE) >> 1);
const selected = index === state.selectedIndex;
if (selected) image.fillRoundedRect(cell.x, cell.y, cell.width, cell.height, 255, TAB_RADIUS);
// As in the sidebar: unselected icons are resources of their own, so
// moving the selection resends only the box.
const icon = selected ? image : new GrayImage(POPUP_ICON_SIZE, POPUP_ICON_SIZE + 1);
const iconX = selected ? x : 0, iconY = selected ? y : 1;
window.drawIcon(icon, iconX, iconY, POPUP_ICON_SIZE, selected);
if (window.attention) {
icon.drawImage(attentionDot(selected ? SHELL_OPAQUE_BLACK : 255), iconX + POPUP_ICON_SIZE - 7, iconY - 1);
}
if (!selected) image.drawDepthImage(icon, x, y - 1, -2);
}
// Chevrons sit in the room either side of the icons, pointing off them.
const first = layout.cell(0), chevronY = first.y + (first.height >> 1);
if (this.scrollRow > 0) {
drawChevron(image, first.x - 5, chevronY, "left");
}
if (lastVisible < count) {
const last = layout.cell(lastVisible - 1 - this.scrollRow);
drawChevron(image, last.x + last.width + 4, chevronY, "right");
}
const selectedWindow = state.windows[state.selectedIndex];
if (selectedWindow) {
const font = getDefaultMediumFont();
const title = truncateText(font, selectedWindow.title, box.width - 2 * POPUP_PADDING);
image.drawText(font, box.x + ((box.width - font.measureText(title)) >> 1), layout.titleTop, title, 210);
}
return box;
}
private drawTopBar(image: GrayImage, state: ShellChromeState, bar: StatusBarPlacement): void {
const font = getDefaultMediumFont();
// The bar sits at the top (or, with a popup switcher, maybe the bottom)
// edge of the foreground window's band, wherever its height mode puts
// that (screen top for max height). It moves when the foreground
// switches to a window of a different height. It spans the app viewport;
// with a side strip overlaid (full-panel mode, sidebar focused) it still
// stops at the strip.
const { left: barLeft, right: barRight } = bar;
image.fillRect(barLeft, bar.top, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
// A framed window's frame draws this line as its side (drawWindowFrame).
if (bar.divider !== null) {
image.drawLine(barLeft, bar.divider, barRight - 1, bar.divider, BORDER_VALUE);
}
const barTop = bar.contentTop;
const clock = clockText();
const clockX = barLeft + 10;
@@ -726,9 +909,9 @@ const AMBIENT_MAX_LINES_PER_CARD = 3;
/**
* 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
* cross into the window header are dropped rather than clipped. `right` is the
* top bar's right edge, which the cards align to.
* bottom of the window band (above any footer) and newer ones stack above
* it. Cards that would cross into the window header are dropped rather than
* clipped. `right` is the top bar's right edge, which the cards align to.
*/
const ambientKeys = new Map<string, number>();
function drawAmbientCards(image: GrayImage, right: number, parts?: Plane[]): void {
@@ -736,7 +919,7 @@ function drawAmbientCards(image: GrayImage, right: number, parts?: Plane[]): voi
if (!cards.length) return;
const font = getDefaultSmallFont();
const bandTop = minWindowTop();
const bandBottom = bandTop + MIN_WINDOW_HEIGHT;
const bandBottom = bandTop + MIN_WINDOW_HEIGHT - windowFooterHeight();
// 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;
@@ -799,13 +982,15 @@ type Rect = { x: number; y: number; width: number; height: number };
const FRAME_RADIUS = 8;
/**
* The rounded frame around the foreground window's content (below its
* header), when it has one (geometry.ts windowFramed): one pixel all round.
* Its sides run down the pixel just outside each side of the window, and
* its top is the header's last row: the top bar's, in place of the bar's
* divider, or the whole one-row header with the status bar in the switcher
* row. Its bottom is the switcher row's top edge, where drawSeparator draws
* it so the selection tab can divert it.
* The rounded frame around the foreground window's content (between its
* header and footer), when it has one (geometry.ts windowFramed): one pixel
* all round. Its sides run down the pixel just outside each side of the
* window, and its top is the header's last row: the top bar's, in place of
* the bar's divider, or the whole one-row header with the status bar
* elsewhere. Its bottom is a bottom switcher row's top edge, where
* drawSeparator draws it so the selection tab can divert it; with a popup
* switcher, the footer's first row, likewise a bottom status bar's or the
* whole one-row footer.
*/
function windowFrameRect(state: ShellChromeState): Rect | null {
if (!windowFramed(state.foregroundAppId)) return null;
@@ -817,19 +1002,21 @@ function windowFrameRect(state: ShellChromeState): Rect | null {
* Draw the window frame (see windowFrameRect) as a retained firmware rounded
* rect over whatever lies beneath it: no fill, so the window's content shows
* through, and black outside the curve, cutting the content's square
* corners to it. It is clipped short of its bottom row, which drawSeparator
* draws with the selection tab's gap. With `squareBottomLeft` (a selection
* tab continuing its left side down), the rect is clipped away from that
* corner's box too, and the side runs straight through it as a one-pixel
* clipped clear, leaving the content's corner whole.
* corners to it. Over a bottom switcher row it is clipped short of its
* bottom row, which drawSeparator draws with the selection tab's gap; with
* `withBottom` (a popup switcher's frame) it is drawn whole. With
* `squareBottomLeft` (a selection tab continuing its left side down), the
* rect is clipped away from that corner's box too, and the side runs
* straight through it as a one-pixel clipped clear, leaving the content's
* corner whole.
*/
function drawWindowFrame(image: GrayImage, frame: Rect, squareBottomLeft: boolean): void {
function drawWindowFrame(image: GrayImage, frame: Rect, squareBottomLeft: boolean, withBottom = false): void {
const border = grayToNibble(BORDER_VALUE), above = frame.height - 1;
const rounded = (clip: ListClip): ListCall => ({
const rounded = (clip?: ListClip): ListCall => ({
op: DrawOp.ROUNDED_RECT, x: 0, y: 0, width: frame.width, height: frame.height, radius: FRAME_RADIUS,
background: 0, border, outside: 0, clip,
background: 0, border, outside: 0, ...(clip ? { clip } : {}),
});
const calls = squareBottomLeft ? [
const calls = withBottom ? [rounded()] : squareBottomLeft ? [
rounded({ x: FRAME_RADIUS, y: 0, width: frame.width - FRAME_RADIUS, height: above }),
rounded({ x: 0, y: 0, width: FRAME_RADIUS, height: above - FRAME_RADIUS }),
{ op: DrawOp.CLEAR, color: border, clip: { x: 0, y: above - FRAME_RADIUS, width: 1, height: FRAME_RADIUS } },
+118 -37
View File
@@ -10,7 +10,9 @@ import {
terminalDisplayModeSetting,
terminalVerticalPositionSetting,
statusBarPositionSetting,
statusBarVisibilitySetting,
uiDepthSetting,
windowBorderSetting,
} from "../dashboard-settings";
/** Top bar: 24px notification icons plus a little padding. */
@@ -18,10 +20,10 @@ export const TOP_BAR_HEIGHT = 28;
/**
* Width of the sidebar strip as painted (the app switcher on the left or
* right edge). App windows get the other 576px — the surface width EvenHub
* apps expect — and keep that width with the switcher at the bottom too,
* except in the full-panel display mode, where the switcher overlays the
* app (see sidebarWidth). Icon column layout within the strip (one wide
* column vs. two narrow ones) is the chrome layer's business.
* apps expect — and keep that width with the switcher at the bottom or a
* popup too, except in the full-panel display mode, where the switcher
* overlays the 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;
@@ -36,11 +38,17 @@ export const SIDEBAR_WIDTH = 64;
*/
export const SWITCHER_ROW_HEIGHT = 36;
/** Which edge the app switcher is on (Settings > Customization). */
/** Which edge the app switcher is on, or a popup (Settings > Customization). */
export function switcherPosition(): AppSwitcherPosition {
return appSwitcherPositionSetting.get();
}
/** Whether the app switcher is a strip down the left or right edge. */
function sideStrip(): boolean {
const position = switcherPosition();
return position === "left" || position === "right";
}
/** The Display > Display mode setting (see dashboard-settings.ts). */
function appDisplayMode(appId?: string) {
return appId === "navigate" ? navigateDisplayModeSetting.get()
@@ -59,12 +67,12 @@ function fullPanel(appId?: string): boolean {
/**
* 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).
* the strip, or nothing when the switcher is a bottom row or a popup 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;
return !fullPanel(appId) && sideStrip() ? SIDEBAR_WIDTH : 0;
}
/**
@@ -77,11 +85,12 @@ export function switcherRowHeight(appId?: string): number {
}
/**
* 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.
* Whether the switcher is on screen: always when it reserves room; as a
* popup, or in the full-panel mode (where it overlays the window), only
* while it has focus.
*/
export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string): boolean {
return !fullPanel(appId) || focus === "sidebar";
return (!fullPanel(appId) && switcherPosition() !== "popup") || focus === "sidebar";
}
/**
@@ -90,10 +99,14 @@ export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string)
* (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.
* row overlays the bottom edge of the screen. A popup's is the area it
* centres in, the foreground window's content (the chrome layer sizes the
* box itself).
*/
export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x: number; y: number; width: number; height: number } {
switch (switcherPosition()) {
case "popup":
return appViewportRect(heightMode, appId);
case "bottom":
return {
x: appViewportLeft(appId),
@@ -112,40 +125,105 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
/**
* Whether the foreground window's content gets a rounded frame (drawn by
* the chrome layer): with a reserved bottom switcher row, whose top edge is
* the frame's bottom side, as the window header's last row is its top. Its
* left and right sides take the pixel just outside the 576-wide window;
* there's no room in the full-panel mode, nor need beside a side strip.
* the chrome layer). Its left and right sides take the pixel just outside
* the 576-wide window; there's no room in the full-panel mode, nor need
* beside a side strip. With a reserved bottom switcher row it always has
* one: the row's top edge is the frame's bottom side, as the window
* header's last row is its top. With a popup switcher it's the Window
* border setting's choice, and its top and bottom take a header or footer
* row of their own, except where the status bar's row next to the window
* serves.
*/
export function windowFramed(appId?: string): boolean {
return switcherRowHeight(appId) > 0;
switch (switcherPosition()) {
case "bottom":
return switcherRowHeight(appId) > 0;
case "popup":
return !fullPanel(appId) && windowBorderSetting.get();
default:
return false;
}
}
/**
* Whether the status bar shares the bottom switcher row instead of topping
* each window (Settings > Customization > Status bar): only beside a
* reserved row, as the full-panel mode's row shows just while it has focus.
* each window (Settings > Customization > Status bar position): only beside
* a reserved row, as the full-panel mode's row shows just while it has focus.
*/
export function statusInSwitcherRow(appId?: string): boolean {
return windowFramed(appId) && statusBarPositionSetting.get() === "switcher";
return switcherRowHeight(appId) > 0 && statusBarPositionSetting.get() === "bottom";
}
/**
* Which edge of the foreground window's band the status bar runs along
* (outside the switcher row): the top, or, with a popup switcher, the
* bottom too (Settings > Customization > Status bar position).
*/
export function statusBarEdge(): "top" | "bottom" {
return switcherPosition() === "popup" && statusBarPositionSetting.get() === "bottom" ? "bottom" : "top";
}
/**
* Whether the status bar shows only while a popup switcher is up, over the
* edge of the window's content, rather than always in rows of the band's
* own (Settings > Customization > Status bar visibility).
*/
export function statusBarOverlays(): boolean {
return switcherPosition() === "popup" && statusBarVisibilitySetting.get() === "switcher";
}
/**
* 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.
*/
function windowEdgeHeight(edge: "top" | "bottom", appId?: string): number {
if (switcherPosition() !== "popup") {
return edge === "bottom" ? 0 : statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
}
if (!statusBarOverlays() && statusBarEdge() === edge) return TOP_BAR_HEIGHT;
return windowFramed(appId) ? 1 : 0;
}
/**
* Height of the header the shell draws over each window's content: the top
* bar, or, with the status bar in the switcher row, just the row the
* window frame's top runs along.
* bar; with the status bar elsewhere, just the row the window frame's top
* runs along, or nothing without a frame.
*/
export function windowHeaderHeight(appId?: string): number {
return statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
return windowEdgeHeight("top", appId);
}
/**
* Height of the footer the shell draws under each window's content, within
* its band: with a popup switcher, the status bar at the bottom, or the row
* the window frame's bottom runs along; else nothing.
*/
export function windowFooterHeight(appId?: string): number {
return windowEdgeHeight("bottom", appId);
}
/**
* Top edge (y) of the status bar's TOP_BAR_HEIGHT rows for a window: the
* band's first rows, or its last with the status bar at the bottom. Over
* the content when the status bar overlays (statusBarOverlays).
*/
export function statusBarTop(heightMode: WindowHeightMode, appId?: string): number {
const top = windowTop(heightMode, appId);
return statusBarEdge() === "bottom" ? top + windowBandHeight(heightMode, appId) - TOP_BAR_HEIGHT : top;
}
/**
* 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.
* the top of a bottom row (under the given foreground window) down. A popup
* is modal: while it shows, the whole screen is the switcher's.
*/
export function isOnSwitcherEdge(x: number, y: number, heightMode: WindowHeightMode, appId?: string): boolean {
switch (switcherPosition()) {
case "popup":
return true;
case "bottom":
return y >= switcherRect(heightMode, appId).y;
case "right":
@@ -162,7 +240,8 @@ function appViewportWidth(appId?: string): number {
/**
* Left edge (x) of app windows: past a left strip, centred above a bottom
* row (see SWITCHER_ROW_HEIGHT), else the screen edge.
* row (see SWITCHER_ROW_HEIGHT) or under a popup switcher, else the screen
* edge.
*/
export function appViewportLeft(appId?: string): number {
if (fullPanel(appId)) return 0;
@@ -170,6 +249,7 @@ export function appViewportLeft(appId?: string): number {
case "left":
return SIDEBAR_WIDTH;
case "bottom":
case "popup":
return SIDEBAR_WIDTH / 2;
default:
return 0;
@@ -180,11 +260,11 @@ export function appViewportLeft(appId?: string): number {
* 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, less the
* window frame's pixel, leave room for the shift.
* the switcher at the bottom or a popup, where the windows' side margins,
* less the window frame's pixel, leave room for the shift.
*/
export function uiDepth(): number {
return switcherPosition() === "bottom" ? Number(uiDepthSetting.get()) : 0;
return sideStrip() ? 0 : Number(uiDepthSetting.get());
}
/**
@@ -215,10 +295,11 @@ export const SHELL_OPAQUE_BLACK = 1;
/**
* Windows come in three heights. "min" covers the same 288px band the stock
* firmware uses, leaving most of the field of view clear; "medium" is one
* header taller, so the content area below the header is a full 288px (the
* EvenHub app surface height); "max" uses the whole 480px screen (terminal
* views), less a bottom switcher row. All include a header drawn by the
* shell at the window's top edge (windowHeaderHeight).
* header (and footer) taller, so the content area between them is a full
* 288px (the EvenHub app surface height); "max" uses the whole 480px screen
* (terminal views), less a bottom switcher row. All include the header the
* shell draws at the window's top edge (windowHeaderHeight) and any footer
* at its bottom (windowFooterHeight).
*/
export type WindowHeightMode = "min" | "medium" | "max";
@@ -233,13 +314,13 @@ function windowAreaHeight(appId?: string): number {
return G2_LENS_HEIGHT - switcherRowHeight(appId);
}
/** Total height (header + content) of a window's band in the given mode. */
/** Total height (header + content + footer) of a window's band in the given mode. */
export function windowBandHeight(mode: WindowHeightMode, appId?: string): number {
switch (effectiveHeightMode(mode, appId)) {
case "max":
return windowAreaHeight(appId);
case "medium":
return MIN_WINDOW_HEIGHT + windowHeaderHeight(appId);
return MIN_WINDOW_HEIGHT + windowHeaderHeight(appId) + windowFooterHeight(appId);
default:
return MIN_WINDOW_HEIGHT;
}
@@ -288,11 +369,11 @@ export function windowTop(mode: WindowHeightMode, appId?: string): number {
export function appViewportSize(mode: WindowHeightMode, appId?: string): { width: number; height: number } {
return {
width: appViewportWidth(appId),
height: windowBandHeight(mode, appId) - windowHeaderHeight(appId),
height: windowBandHeight(mode, appId) - windowHeaderHeight(appId) - windowFooterHeight(appId),
};
}
/** Screen rect of a window's app-content viewport (below its header). */
/** Screen rect of a window's app-content viewport (between its header and footer). */
export function appViewportRect(mode: WindowHeightMode, appId?: string): {
x: number;
y: number;
+11 -5
View File
@@ -42,8 +42,10 @@ import {
onAnySettingChanged,
openAiApiKeySetting,
statusBarPositionSetting,
statusBarVisibilitySetting,
timeFormatSetting,
wakeWordActionSetting,
windowBorderSetting,
} from "../dashboard-settings";
import { onAmbientCardsChanged } from "./ambient-cards";
import { ShellChromeLayer, sidebarContentSpan, type ShellChromeState, type ShellChromeWindow } from "./chrome-layer";
@@ -321,7 +323,8 @@ class ShellAlertLayer implements Layer {
* What a watch swipe means while the app switcher has focus, as the ring
* 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).
* from it there is nowhere further to go (ignored). A popup's row of icons
* lies over the window, so either way across it enters the window.
*/
const SWITCHER_SWIPES: Record<
AppSwitcherPosition,
@@ -330,15 +333,17 @@ const SWITCHER_SWIPES: Record<
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" },
popup: { "swipe-left": "scroll-up", "swipe-right": "scroll-down", "swipe-up": "click", "swipe-down": "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.
* for (the top bar's contents and placement, the window frame, the scene's
* stereo depth), as one comparable string.
*/
function chromeSettingsKey(): string {
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}|${uiDepth()}|${statusBarPositionSetting.get()}`;
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}|${uiDepth()}|${statusBarPositionSetting.get()}`
+ `|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`;
}
class Shell {
@@ -940,7 +945,8 @@ class Shell {
* foreground window's band (full height for a max-height window, the
* vertical-position-dependent 288px band otherwise) plus the switcher: a
* side strip's icon columns (minus the outer dead strip the one-column
* variant leaves), or the row under it and the window frame's sides.
* variant leaves), or the row under it, and the window frame's sides. A
* popup switcher lies within the band.
*/
screenshotCropRect(): { x: number; y: number; width: number; height: number } {
const appId = this.foregroundWindow()?.appId;