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
@@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.8.2 - Future
|
||||||
|
|
||||||
|
* Add an option to move the app switcher to the right or bottom, and adjust screen depth if bottom
|
||||||
|
|
||||||
## 0.8.1 - 2026-09-30
|
## 0.8.1 - 2026-09-30
|
||||||
|
|
||||||
### Assorted Features and Bug Fixes
|
### Assorted Features and Bug Fixes
|
||||||
|
|||||||
@@ -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.",
|
"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];
|
export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stereo depth of the whole display, in the firmware's depth units: the
|
* Stereo depth of the whole display, in the firmware's depth units: the
|
||||||
* lenses shift everything by half this many pixels each, in opposite
|
* lenses shift everything by half this many pixels each, in opposite
|
||||||
* directions. Only applies with the app switcher at the bottom, where the
|
* directions. Only applies with the app switcher at the bottom, where the
|
||||||
* windows' 576px width leaves 32px at each side to shift into (see
|
* windows' 576px width leaves 32px at each side: one for the side of the
|
||||||
* geometry.ts uiDepth); values stay even so the per-lens halves of nested
|
* 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.
|
* depths add exactly.
|
||||||
*/
|
*/
|
||||||
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import {
|
|||||||
switcherPosition,
|
switcherPosition,
|
||||||
switcherRect,
|
switcherRect,
|
||||||
TOP_BAR_HEIGHT,
|
TOP_BAR_HEIGHT,
|
||||||
|
windowFramed,
|
||||||
windowTop,
|
windowTop,
|
||||||
type WindowHeightMode,
|
type WindowHeightMode,
|
||||||
} from "./geometry";
|
} from "./geometry";
|
||||||
@@ -291,6 +292,8 @@ export class ShellChromeLayer implements Layer {
|
|||||||
this.drawSidebar(image, state);
|
this.drawSidebar(image, state);
|
||||||
}
|
}
|
||||||
this.drawTopBar(image, state);
|
this.drawTopBar(image, state);
|
||||||
|
const frame = windowFrameRect(state);
|
||||||
|
if (frame) drawWindowFrame(image, frame);
|
||||||
drawAmbientCards(image, topBarSpan(state).right);
|
drawAmbientCards(image, topBarSpan(state).right);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@@ -307,6 +310,20 @@ export class ShellChromeLayer implements Layer {
|
|||||||
this.drawTopBar(canvas, state);
|
this.drawTopBar(canvas, state);
|
||||||
const bar = topBarSpan(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 });
|
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);
|
drawAmbientCards(canvas, bar.right, parts);
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
@@ -425,7 +442,10 @@ export class ShellChromeLayer implements Layer {
|
|||||||
// mode, sidebar focused) it still stops at the strip.
|
// mode, sidebar focused) it still stops at the strip.
|
||||||
const { left: barLeft, right: barRight } = topBarSpan(state);
|
const { left: barLeft, right: barRight } = topBarSpan(state);
|
||||||
image.fillRect(barLeft, barTop, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
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 now = new Date();
|
||||||
const clock = `${formatClockDate(now)} ${formatClockTime(now)}`;
|
const clock = `${formatClockDate(now)} ${formatClockTime(now)}`;
|
||||||
@@ -665,6 +685,55 @@ function attentionDot(value: number): GrayImage {
|
|||||||
return dot;
|
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;
|
const TAB_RADIUS = 6;
|
||||||
// How far the diversion pokes past the separator into the main area.
|
// How far the diversion pokes past the separator into the main area.
|
||||||
const TAB_EXTEND = 0;
|
const TAB_EXTEND = 0;
|
||||||
@@ -681,13 +750,18 @@ function drawSeparator(
|
|||||||
gap: SwitcherCell | null,
|
gap: SwitcherCell | null,
|
||||||
): void {
|
): void {
|
||||||
if (switcherPosition() === "bottom") {
|
if (switcherPosition() === "bottom") {
|
||||||
// Along the row's top edge, the full width of the row.
|
// Along the row's top edge: the full width of the row, or between the
|
||||||
const y = strip.y, right = strip.x + strip.width - 1;
|
// 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) {
|
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);
|
image.drawLine(gap.x + gap.width, y, right, y, BORDER_VALUE);
|
||||||
} else {
|
} else {
|
||||||
image.drawLine(strip.x, y, right, y, BORDER_VALUE);
|
image.drawLine(left, y, right, y, BORDER_VALUE);
|
||||||
}
|
}
|
||||||
return;
|
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.
|
* 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
|
* 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
|
* 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).
|
* whole display's stereo shift (uiDepth).
|
||||||
*/
|
*/
|
||||||
export const SWITCHER_ROW_HEIGHT = 36;
|
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
|
* 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
|
* 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
|
* Stereo depth of the whole display (Settings > Customization > Depth), in
|
||||||
* the firmware's depth units; the shell scene carries it to the compositor,
|
* 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
|
* 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 switcher at the bottom, where the windows' side margins, less the
|
||||||
* the shift.
|
* window frame's pixel, leave room for the shift.
|
||||||
*/
|
*/
|
||||||
export function uiDepth(): number {
|
export function uiDepth(): number {
|
||||||
return switcherPosition() === "bottom" ? Number(uiDepthSetting.get()) : 0;
|
return switcherPosition() === "bottom" ? Number(uiDepthSetting.get()) : 0;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import {
|
|||||||
switcherRowHeight,
|
switcherRowHeight,
|
||||||
uiDepth,
|
uiDepth,
|
||||||
windowBandHeight,
|
windowBandHeight,
|
||||||
|
windowFramed,
|
||||||
windowTop,
|
windowTop,
|
||||||
type WindowHeightMode,
|
type WindowHeightMode,
|
||||||
} from "./geometry";
|
} from "./geometry";
|
||||||
@@ -938,7 +939,7 @@ class Shell {
|
|||||||
* foreground window's band (full height for a max-height window, the
|
* foreground window's band (full height for a max-height window, the
|
||||||
* vertical-position-dependent 288px band otherwise) plus the switcher: a
|
* vertical-position-dependent 288px band otherwise) plus the switcher: a
|
||||||
* side strip's icon columns (minus the outer dead strip the one-column
|
* 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 } {
|
screenshotCropRect(): { x: number; y: number; width: number; height: number } {
|
||||||
const appId = this.foregroundWindow()?.appId;
|
const appId = this.foregroundWindow()?.appId;
|
||||||
@@ -950,6 +951,10 @@ class Shell {
|
|||||||
left = Math.min(left, strip.left);
|
left = Math.min(left, strip.left);
|
||||||
right = Math.max(right, strip.right);
|
right = Math.max(right, strip.right);
|
||||||
}
|
}
|
||||||
|
if (windowFramed(appId)) {
|
||||||
|
left -= 1;
|
||||||
|
right += 1;
|
||||||
|
}
|
||||||
const y = windowTop(heightMode, appId);
|
const y = windowTop(heightMode, appId);
|
||||||
const bottom = y + windowBandHeight(heightMode, appId) + switcherRowHeight(appId);
|
const bottom = y + windowBandHeight(heightMode, appId) + switcherRowHeight(appId);
|
||||||
return { x: left, y, width: right - left, height: bottom - y };
|
return { x: left, y, width: right - left, height: bottom - y };
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ test('all explicit size/position combinations stay within the display and align
|
|||||||
assert.ok(row.y + row.height <= 480);
|
assert.ok(row.y + row.height <= 480);
|
||||||
// A reserved bottom row hangs right under the window, as wide as it.
|
// A reserved bottom row hangs right under the window, as wide as it.
|
||||||
if (g.switcherRowHeight(appId)) assert.deepEqual([row.x, row.y, row.width], [rect.x, rect.y + rect.height, rect.width]);
|
if (g.switcherRowHeight(appId)) assert.deepEqual([row.x, row.y, row.width], [rect.x, rect.y + rect.height, rect.width]);
|
||||||
|
// The frame's sides, just outside the window, survive the
|
||||||
|
// deepest shift (±62 moves each lens 31px).
|
||||||
|
if (g.windowFramed(appId)) assert.ok(rect.x - 1 - 31 >= 0 && rect.x + rect.width + 31 < 640);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +104,7 @@ test('the app switcher can sit on the right edge', () => {
|
|||||||
assert.equal(g.screenCenterInViewportX(), 320);
|
assert.equal(g.screenCenterInViewportX(), 320);
|
||||||
assert.equal(g.isOnSwitcherEdge(600, 10, 'min'), true);
|
assert.equal(g.isOnSwitcherEdge(600, 10, 'min'), true);
|
||||||
assert.equal(g.isOnSwitcherEdge(10, 200, 'min'), false);
|
assert.equal(g.isOnSwitcherEdge(10, 200, 'min'), false);
|
||||||
|
assert.equal(g.windowFramed(), false);
|
||||||
// Depth needs the bottom row's side margins.
|
// Depth needs the bottom row's side margins.
|
||||||
g.settings.uiDepthSetting.value = '32';
|
g.settings.uiDepthSetting.value = '32';
|
||||||
assert.equal(g.uiDepth(), 0);
|
assert.equal(g.uiDepth(), 0);
|
||||||
@@ -123,15 +127,88 @@ test('a bottom app switcher centres 576-wide windows and hangs one tall tab unde
|
|||||||
assert.equal(g.switcherRect('min').y, 444);
|
assert.equal(g.switcherRect('min').y, 444);
|
||||||
// The true centre is the viewport's own with the window centred.
|
// The true centre is the viewport's own with the window centred.
|
||||||
assert.equal(g.screenCenterInViewportX(), 288);
|
assert.equal(g.screenCenterInViewportX(), 288);
|
||||||
// Depth applies only here.
|
// Depth applies only here, as does the window frame.
|
||||||
g.settings.uiDepthSetting.value = '-48';
|
g.settings.uiDepthSetting.value = '-48';
|
||||||
assert.equal(g.uiDepth(), -48);
|
assert.equal(g.uiDepth(), -48);
|
||||||
|
assert.equal(g.windowFramed(), true);
|
||||||
// Full panel: windows fill the panel and the row overlays the bottom edge while focused.
|
// Full panel: windows fill the panel and the row overlays the bottom edge while focused.
|
||||||
g.settings.displayModeSetting.value = '640x480';
|
g.settings.displayModeSetting.value = '640x480';
|
||||||
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
|
assert.deepEqual(g.rect('max'), { x: 0, y: 28, width: 640, height: 452 });
|
||||||
assert.deepEqual({ ...g.switcherRect('max') }, { x: 0, y: 444, width: 640, height: 36 });
|
assert.deepEqual({ ...g.switcherRect('max') }, { x: 0, y: 444, width: 640, height: 36 });
|
||||||
assert.equal(g.sidebarStripVisible('window'), false);
|
assert.equal(g.sidebarStripVisible('window'), false);
|
||||||
assert.equal(g.sidebarStripVisible('sidebar'), true);
|
assert.equal(g.sidebarStripVisible('sidebar'), true);
|
||||||
|
assert.equal(g.windowFramed(), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a bottom app switcher frames the foreground window\'s content in a rounded border', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
|
g.settings.uiDepthSetting.value = '62';
|
||||||
|
const graphics = require('../.test-build/app/graphics/image.js');
|
||||||
|
const shellScene = require('../.test-build/app/graphics/shell-scene.js');
|
||||||
|
const font = { lineHeight: 12, ascent: 10, measureText: (text) => text.length * 4, drawText() {} };
|
||||||
|
let nextKey = 100;
|
||||||
|
const modules = {
|
||||||
|
'../../graphics/shell-scene': shellScene, '../../graphics/image': graphics,
|
||||||
|
'../../graphics/ui-fonts': { getDefaultSmallFont: () => font, getDefaultMediumFont: () => font },
|
||||||
|
'./ambient-cards': { activeAmbientCards: () => [] },
|
||||||
|
'../../native/notification-icons': { readActiveNotificationIcons: () => ({ icons: [], stale: false }) },
|
||||||
|
'../../native/phone-battery': { readPhoneBatteryState: () => ({ battery: null }) },
|
||||||
|
'../../util/render-freshness': { renderPassAllowsStaleData: () => false },
|
||||||
|
'../dashboard-settings': { batteryDisplayModeSetting: { get: () => 'icon' } },
|
||||||
|
'../clock-format': { formatClockDate: () => '', formatClockTime: () => '' },
|
||||||
|
'../layers': { LayerStack: { allocateShellKey: () => nextKey++ } },
|
||||||
|
'../menu': { scrollToKeepSelectionVisible: () => 0 },
|
||||||
|
'./geometry': g,
|
||||||
|
};
|
||||||
|
const context = { exports: {}, require: (name) => modules[name] ?? {} };
|
||||||
|
vm.runInNewContext(js(read('app/ui/shell/chrome-layer.ts')), context);
|
||||||
|
const state = {
|
||||||
|
windows: [{ attention: false, drawIcon() {} }], selectedIndex: 0, focus: 'window', foregroundHeightMode: 'min',
|
||||||
|
battery: { headset: null, ring: null, watch: null }, trayIcons: [],
|
||||||
|
};
|
||||||
|
const chrome = new context.exports.ShellChromeLayer(() => state);
|
||||||
|
const parts = chrome.paintParts();
|
||||||
|
// The min band's content spans y=106..365, between the bar's bottom row
|
||||||
|
// (the frame's top) at 105 and the row's top edge (its bottom) at 366.
|
||||||
|
const part = (key) => parts.find((p) => p.shellKey === key);
|
||||||
|
const [left, right, top, strip] = [part(100), part(101), part(102), part(1)];
|
||||||
|
assert.deepEqual([left.x, left.y, left.image.width, left.image.height], [31, 105, 8, 261]);
|
||||||
|
assert.deepEqual([right.x, right.image.width], [601, 8]);
|
||||||
|
assert.deepEqual([top.x, top.y, top.image.width, top.image.height], [39, 105, 562, 1]);
|
||||||
|
assert.ok(!left.depth && !right.depth && !top.depth);
|
||||||
|
const at = (p, x, y) => p.image.pixels[(y - p.y) * p.image.width + x - p.x];
|
||||||
|
// Straight sides just outside the window; the top along the bar's bottom row.
|
||||||
|
assert.equal(at(left, 31, 200), 40);
|
||||||
|
assert.equal(at(right, 608, 200), 40);
|
||||||
|
assert.equal(at(top, 300, 105), 40);
|
||||||
|
// Rounded corners: black outside the curve, the window's own corner masked.
|
||||||
|
assert.equal(at(left, 31, 105), 1);
|
||||||
|
assert.equal(at(left, 36, 105), 40);
|
||||||
|
assert.equal(at(left, 32, 106), 1);
|
||||||
|
assert.equal(at(left, 32, 365), 1);
|
||||||
|
assert.equal(at(right, 607, 365), 1);
|
||||||
|
// The separator is the bottom side, starting where the corner's curve ends.
|
||||||
|
assert.equal(at(strip, 35, 366), 1);
|
||||||
|
assert.equal(at(strip, 36, 366), 40);
|
||||||
|
assert.equal(at(strip, 603, 366), 40);
|
||||||
|
assert.equal(at(strip, 604, 366), 1);
|
||||||
|
// Parts after the -2 top bar, so the frame draws over it.
|
||||||
|
assert.ok(parts.indexOf(part(2)) < parts.indexOf(left));
|
||||||
|
shellScene.encodeShellScene(parts, g.uiDepth());
|
||||||
|
// The flat paint matches. The bar's own divider gives way to the frame's
|
||||||
|
// top, and the frame stops short of the bar.
|
||||||
|
const image = chrome.paint();
|
||||||
|
assert.equal(image.pixels[200 * 640 + 31], 40);
|
||||||
|
assert.equal(image.pixels[200 * 640 + 608], 40);
|
||||||
|
assert.equal(image.pixels[105 * 640 + 33], 1);
|
||||||
|
assert.equal(image.pixels[105 * 640 + 300], 40);
|
||||||
|
assert.equal(image.pixels[90 * 640 + 31], 0);
|
||||||
|
const bar = part(2);
|
||||||
|
assert.equal(bar.image.pixels[(105 - bar.y) * bar.image.width + 300 - bar.x], 1);
|
||||||
|
// No frame in the full-panel mode.
|
||||||
|
g.settings.displayModeSetting.value = '640x480';
|
||||||
|
assert.equal(chrome.paintParts().filter((p) => p.shellKey >= 100).length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Exercise the real worker message handler with platform work stubbed out.
|
// Exercise the real worker message handler with platform work stubbed out.
|
||||||
|
|||||||
Reference in new issue
Block a user