Multi-row status/app-switcher bar layouts

This commit is contained in:
James Babcock committed 2026-10-13 00:21:01 -07:00
1 parent f6201d8e41
commit 26e4396972
14 files changed
+706 -229

No files matched your search

+49 -20
View File
@@ -26,17 +26,38 @@ export const TOP_BAR_HEIGHT = 28;
export const SIDEBAR_WIDTH = 64;
/**
* Height of the app switcher as a row under the window: one tall tab, the
* Height of one row of the app switcher under the window: one tall tab, the
* same 36px (a 32px icon plus 2px either side) as a one-column sidebar slot.
* The row is wide enough that it never needs the sidebar's smaller
* two-column icons. It comes out of the height available to windows; their
* width stays 576, centred, leaving SIDEBAR_WIDTH / 2 at each side: one
* pixel for the side of the window's frame (windowFramed), the rest for the
* whole display's stereo shift (uiDepth). Full Screen windows take those
* margins too, giving up both.
* margins too, giving up both. When the row's contents don't fit, the
* switcher grows a second row (see setSwitcherBarHeight).
*/
export const SWITCHER_ROW_HEIGHT = 36;
/**
* Height of the bottom switcher as its contents last laid out (chrome-layer.ts
* planBottomBar): SWITCHER_ROW_HEIGHT, or more once the status bar's items
* or the window icons take a second row. One for the switcher reserved
* under windows, one for the switcher overlaying an immersive window.
*/
const switcherBarHeights = { reserved: SWITCHER_ROW_HEIGHT, overlay: SWITCHER_ROW_HEIGHT };
/**
* Set the bottom switcher's height for its current layout under the given
* (foreground) app's window: the overlay's over an immersive window, else
* the row reserved under windows. True if that moves or resizes windows.
*/
export function setSwitcherBarHeight(height: number, appId?: string): boolean {
const which = isImmersive(appId) ? "overlay" : "reserved";
if (switcherBarHeights[which] === height) return false;
switcherBarHeights[which] = height;
return which === "reserved";
}
/** Which edge the app switcher is on, or a popup (Settings > Customization). */
export function switcherPosition(): AppSwitcherPosition {
return appSwitcherPositionSetting.get();
@@ -116,13 +137,13 @@ export function sidebarWidth(appId?: string): number {
}
/**
* How much of the screen's height a bottom switcher row takes away from app
* windows: the row, or nothing beside a side strip or under an immersive
* window (where the row overlays the window's bottom edge while it has
* focus).
* How much of the screen's height a bottom switcher takes away from app
* windows: its rows (one, or two when the layout needs them), or nothing
* beside a side strip or under an immersive window (where the switcher
* overlays the window's bottom edge while it has focus).
*/
export function switcherRowHeight(appId?: string): number {
return !isImmersive(appId) && switcherPosition() === "bottom" ? SWITCHER_ROW_HEIGHT : 0;
return !isImmersive(appId) && switcherPosition() === "bottom" ? switcherBarHeights.reserved : 0;
}
/**
@@ -139,23 +160,25 @@ 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. Over an immersive window
* the 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).
* the row overlays the bottom edge of the screen. Either way it is as tall
* as its layout (setSwitcherBarHeight). 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":
case "bottom": {
const reserved = switcherRowHeight(appId);
const height = reserved || switcherBarHeights.overlay;
return {
x: appViewportLeft(appId),
y: switcherRowHeight(appId) > 0
? windowTop(heightMode, appId) + windowBandHeight(heightMode, appId)
: G2_LENS_HEIGHT - SWITCHER_ROW_HEIGHT,
y: reserved > 0 ? windowTop(heightMode, appId) + windowBandHeight(heightMode, appId) : G2_LENS_HEIGHT - height,
width: appViewportWidth(appId),
height: SWITCHER_ROW_HEIGHT,
height,
};
}
case "right":
return { x: G2_LENS_WIDTH - SIDEBAR_WIDTH, y: minWindowTop(appId), width: SIDEBAR_WIDTH, height: MIN_WINDOW_HEIGHT };
default:
@@ -345,7 +368,7 @@ export const SHELL_OPAQUE_BLACK = 1;
* firmware uses, leaving most of the field of view clear; "medium" is one
* 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
* (terminal views), less a bottom switcher's rows. All include the header the
* shell draws at the window's top edge (windowHeaderHeight) and any footer
* at its bottom (windowFooterHeight).
*/
@@ -356,7 +379,7 @@ export const MIN_WINDOW_HEIGHT = 288;
/**
* Height of the screen area windows are placed in: the whole screen, less
* a bottom switcher row's height.
* a bottom switcher's height.
*/
function windowAreaHeight(appId?: string): number {
return G2_LENS_HEIGHT - switcherRowHeight(appId);
@@ -394,11 +417,17 @@ export function minWindowTop(appId?: string): number {
/**
* Top edge (y) of a window's header; max-height windows pin to the screen
* top. A bottom switcher row hangs under the band, so the band and row
* together distribute the screen's slack.
* top. A bottom switcher row hangs under the band, so the band and a
* one-row switcher together distribute the screen's slack. A switcher of
* more rows takes its extra height out of the slack under it, pushing the
* band up only as far as there is too little, so the band doesn't move as
* the switcher's layout changes unless it has to.
*/
export function windowTop(mode: WindowHeightMode, appId?: string): number {
return Math.round((windowAreaHeight(appId) - windowBandHeight(mode, appId)) * verticalPositionFraction(appId));
const band = windowBandHeight(mode, appId);
const oneRowArea = G2_LENS_HEIGHT - (switcherRowHeight(appId) > 0 ? SWITCHER_ROW_HEIGHT : 0);
const top = Math.round((oneRowArea - band) * verticalPositionFraction(appId));
return Math.min(top, windowAreaHeight(appId) - band);
}
/** App-content viewport size for a height mode (independent of vertical position). */