forked from Blendman974/faceclaw
Refine the UI of app-switcher-on-bottom UI
This commit is contained in:
1 parent
8f99779f98
commit
ee8b98d1b0
6 files changed
+186
-13
No files matched your search
@@ -367,15 +367,16 @@ export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosit
|
||||
"Which edge of the display the strip of open-app icons sits on. Left and right take a column beside windows; bottom puts a row beneath the window, which leaves room at the sides to set the display's depth, and makes full-height windows a little shorter. Moving it to or from the bottom reopens open apps in the new size.",
|
||||
});
|
||||
|
||||
const UI_DEPTH_VALUES = ["-64", "-48", "-32", "-16", "0", "16", "32", "48", "64"] as const;
|
||||
const UI_DEPTH_VALUES = ["-62", "-48", "-32", "-16", "0", "16", "32", "48", "62"] as const;
|
||||
export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
|
||||
|
||||
/**
|
||||
* Stereo depth of the whole display, in the firmware's depth units: the
|
||||
* lenses shift everything by half this many pixels each, in opposite
|
||||
* directions. Only applies with the app switcher at the bottom, where the
|
||||
* windows' 576px width leaves 32px at each side to shift into (see
|
||||
* geometry.ts uiDepth); values stay even so the per-lens halves of nested
|
||||
* windows' 576px width leaves 32px at each side: one for the side of the
|
||||
* window's frame and 31 to shift into, hence ±62 (see geometry.ts uiDepth
|
||||
* and windowFramed); values stay even so the per-lens halves of nested
|
||||
* depths add exactly.
|
||||
*/
|
||||
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
switcherPosition,
|
||||
switcherRect,
|
||||
TOP_BAR_HEIGHT,
|
||||
windowFramed,
|
||||
windowTop,
|
||||
type WindowHeightMode,
|
||||
} from "./geometry";
|
||||
@@ -291,6 +292,8 @@ export class ShellChromeLayer implements Layer {
|
||||
this.drawSidebar(image, state);
|
||||
}
|
||||
this.drawTopBar(image, state);
|
||||
const frame = windowFrameRect(state);
|
||||
if (frame) drawWindowFrame(image, frame);
|
||||
drawAmbientCards(image, topBarSpan(state).right);
|
||||
return image;
|
||||
}
|
||||
@@ -307,6 +310,20 @@ export class ShellChromeLayer implements Layer {
|
||||
this.drawTopBar(canvas, state);
|
||||
const bar = topBarSpan(state);
|
||||
parts.push({ ...shellCrop(canvas, bar.left, windowTop(state.foregroundHeightMode, state.foregroundAppId), bar.right - bar.left, TOP_BAR_HEIGHT, 2), depth: -2 });
|
||||
const frame = windowFrameRect(state);
|
||||
if (frame) {
|
||||
// Over the top bar, whose bottom row it shares, but at the screen's
|
||||
// own depth rather than the bar's -2, which on top of a -62 screen
|
||||
// depth would shift a side off the screen. Split into its two sides
|
||||
// (corners included) and the top between them, as one surface would
|
||||
// be almost all transparent.
|
||||
const frameCanvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
drawWindowFrame(frameCanvas, frame);
|
||||
const [leftKey, rightKey, topKey] = windowFrameKeys(), sideHeight = frame.height - 1;
|
||||
parts.push(shellCrop(frameCanvas, frame.x, frame.y, FRAME_RADIUS, sideHeight, leftKey));
|
||||
parts.push(shellCrop(frameCanvas, frame.x + frame.width - FRAME_RADIUS, frame.y, FRAME_RADIUS, sideHeight, rightKey));
|
||||
parts.push(shellCrop(frameCanvas, frame.x + FRAME_RADIUS, frame.y, frame.width - 2 * FRAME_RADIUS, 1, topKey));
|
||||
}
|
||||
drawAmbientCards(canvas, bar.right, parts);
|
||||
return parts;
|
||||
}
|
||||
@@ -425,7 +442,10 @@ export class ShellChromeLayer implements Layer {
|
||||
// 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);
|
||||
image.drawLine(barLeft, barTop + TOP_BAR_HEIGHT - 1, barRight - 1, barTop + TOP_BAR_HEIGHT - 1, BORDER_VALUE);
|
||||
// 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);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const clock = `${formatClockDate(now)} ${formatClockTime(now)}`;
|
||||
@@ -665,6 +685,55 @@ function attentionDot(value: number): GrayImage {
|
||||
return dot;
|
||||
}
|
||||
|
||||
type Rect = { x: number; y: number; width: number; height: number };
|
||||
|
||||
/** Corner radius of the foreground window's frame. */
|
||||
const FRAME_RADIUS = 8;
|
||||
|
||||
/**
|
||||
* The rounded frame around the foreground window's content (below its top
|
||||
* bar), 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 top bar's bottom row, in place of the bar's divider. Its
|
||||
* bottom is the switcher row's top edge, where drawSeparator draws it so
|
||||
* the selection tab can divert it.
|
||||
*/
|
||||
function windowFrameRect(state: ShellChromeState): Rect | null {
|
||||
if (!windowFramed(state.foregroundAppId)) return null;
|
||||
const viewport = appViewportRect(state.foregroundHeightMode, state.foregroundAppId);
|
||||
return { x: viewport.x - 1, y: viewport.y - 1, width: viewport.width + 2, height: viewport.height + 2 };
|
||||
}
|
||||
|
||||
/** Shell surface keys of the window frame's left side, right side and top. */
|
||||
let frameKeys: [number, number, number] | undefined;
|
||||
function windowFrameKeys(): [number, number, number] {
|
||||
if (!frameKeys) frameKeys = [LayerStack.allocateShellKey(), LayerStack.allocateShellKey(), LayerStack.allocateShellKey()];
|
||||
return frameKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the window frame (see windowFrameRect) but for its bottom row,
|
||||
* stroked line by line like the selection tab's outline. Outside each
|
||||
* rounded corner it paints opaque black, so the window's square corners
|
||||
* don't show past the curve. Everything but the top's straight run lies
|
||||
* within FRAME_RADIUS of the sides.
|
||||
*/
|
||||
function drawWindowFrame(image: GrayImage, frame: Rect): void {
|
||||
const { x, y, width, height } = frame;
|
||||
for (let i = 0; i < height - 1; i++) {
|
||||
const outer = tabInset(i, 0, height, FRAME_RADIUS);
|
||||
image.fillRect(x, y + i, outer, 1, SHELL_OPAQUE_BLACK);
|
||||
image.fillRect(x + width - outer, y + i, outer, 1, SHELL_OPAQUE_BLACK);
|
||||
if (i === 0) {
|
||||
image.fillRect(x + outer, y, width - 2 * outer, 1, BORDER_VALUE);
|
||||
continue;
|
||||
}
|
||||
const stroke = Math.max(1, 1 + tabInset(i, 1, height - 1, FRAME_RADIUS - 1) - outer);
|
||||
image.fillRect(x + outer, y + i, stroke, 1, BORDER_VALUE);
|
||||
image.fillRect(x + width - outer - stroke, y + i, stroke, 1, BORDER_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
const TAB_RADIUS = 6;
|
||||
// How far the diversion pokes past the separator into the main area.
|
||||
const TAB_EXTEND = 0;
|
||||
@@ -681,13 +750,18 @@ function drawSeparator(
|
||||
gap: SwitcherCell | null,
|
||||
): void {
|
||||
if (switcherPosition() === "bottom") {
|
||||
// Along the row's top edge, the full width of the row.
|
||||
const y = strip.y, right = strip.x + strip.width - 1;
|
||||
// Along the row's top edge: the full width of the row, or between the
|
||||
// corners of the window frame, whose bottom side this is.
|
||||
const frame = windowFrameRect(state);
|
||||
const inset = frame ? tabInset(frame.height - 1, 0, frame.height, FRAME_RADIUS) : 0;
|
||||
const left = frame ? frame.x + inset : strip.x;
|
||||
const right = frame ? frame.x + frame.width - 1 - inset : strip.x + strip.width - 1;
|
||||
const y = strip.y;
|
||||
if (gap) {
|
||||
image.drawLine(strip.x, y, gap.x, y, BORDER_VALUE);
|
||||
image.drawLine(left, y, gap.x, y, BORDER_VALUE);
|
||||
image.drawLine(gap.x + gap.width, y, right, y, BORDER_VALUE);
|
||||
} else {
|
||||
image.drawLine(strip.x, y, right, y, BORDER_VALUE);
|
||||
image.drawLine(left, y, right, y, BORDER_VALUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ export const SIDEBAR_WIDTH = 64;
|
||||
* 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 for the
|
||||
* 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).
|
||||
*/
|
||||
export const SWITCHER_ROW_HEIGHT = 36;
|
||||
@@ -108,6 +109,17 @@ 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 top bar's divider 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.
|
||||
*/
|
||||
export function windowFramed(appId?: string): boolean {
|
||||
return switcherRowHeight(appId) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -149,8 +161,8 @@ 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 leave room for
|
||||
* the shift.
|
||||
* the switcher at the bottom, 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;
|
||||
|
||||
@@ -58,6 +58,7 @@ import {
|
||||
switcherRowHeight,
|
||||
uiDepth,
|
||||
windowBandHeight,
|
||||
windowFramed,
|
||||
windowTop,
|
||||
type WindowHeightMode,
|
||||
} from "./geometry";
|
||||
@@ -938,7 +939,7 @@ 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.
|
||||
* variant leaves), or the row under it and the window frame's sides.
|
||||
*/
|
||||
screenshotCropRect(): { x: number; y: number; width: number; height: number } {
|
||||
const appId = this.foregroundWindow()?.appId;
|
||||
@@ -950,6 +951,10 @@ class Shell {
|
||||
left = Math.min(left, strip.left);
|
||||
right = Math.max(right, strip.right);
|
||||
}
|
||||
if (windowFramed(appId)) {
|
||||
left -= 1;
|
||||
right += 1;
|
||||
}
|
||||
const y = windowTop(heightMode, appId);
|
||||
const bottom = y + windowBandHeight(heightMode, appId) + switcherRowHeight(appId);
|
||||
return { x: left, y, width: right - left, height: bottom - y };
|
||||
|
||||
Reference in new issue
Block a user