mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Add Border option to Settings>Customization
This commit is contained in:
1 parent
8b70585da8
commit
c6ce79ab70
7 files changed
+210
-50
No files matched your search
@@ -202,14 +202,16 @@ const launchableApps = () => ALL_APPS.filter((app) => app.showInLauncher !== fal
|
|||||||
* screen, the display mode's size (a band's position only moves windows), whether the app switcher
|
* screen, the display mode's size (a band's position only moves windows), whether the app switcher
|
||||||
* takes width beside windows, height below them or neither (a popup), and
|
* takes width beside windows, height below them or neither (a popup), and
|
||||||
* the chrome rows each window loses to it: below them, whether the status
|
* the chrome rows each window loses to it: below them, whether the status
|
||||||
* bar joins the row (dropping the top bar); with a popup, whether the
|
* bar joins the row (dropping the top bar, for the window frame's top row
|
||||||
* status bar keeps rows of its own and the window frame (where the status
|
* if it has a frame); with a popup, whether the status bar keeps rows of its
|
||||||
* bar goes only moves windows).
|
* own and the window frame (where the status bar goes only moves windows).
|
||||||
*/
|
*/
|
||||||
function viewportSizesKey(): string {
|
function viewportSizesKey(): string {
|
||||||
const position = appSwitcherPositionSetting.get();
|
const position = appSwitcherPositionSetting.get();
|
||||||
const switcher = position === "bottom" ? `row|${statusBarPositionSetting.get()}`
|
const statusBar = statusBarPositionSetting.get();
|
||||||
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`
|
const framed = windowBorderSetting.get() === "all";
|
||||||
|
const switcher = position === "bottom" ? `row|${statusBar}|${statusBar === "bottom" && framed}`
|
||||||
|
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${framed}`
|
||||||
: "strip";
|
: "strip";
|
||||||
const layout = displayLayoutSetting.get();
|
const layout = displayLayoutSetting.get();
|
||||||
return `${screenWidth()}x${screenHeight()}|${layout.startsWith("band-") ? "band" : layout}|${switcher}`;
|
return `${screenWidth()}x${screenHeight()}|${layout.startsWith("band-") ? "band" : layout}|${switcher}`;
|
||||||
|
|||||||
@@ -581,18 +581,36 @@ export const statusBarVisibilitySetting = new ConfigSettingEnum<StatusBarVisibil
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the foreground window gets a rounded border with a popup app
|
* Which lines the shell draws round the foreground window with a bottom or
|
||||||
* switcher (geometry.ts windowFramed); without one, a line divides the
|
* popup app switcher: a rounded border all round it (geometry.ts
|
||||||
* window from the status bar.
|
* windowFramed), only a straight line between it and the status bar, or
|
||||||
|
* none at all.
|
||||||
*/
|
*/
|
||||||
export const windowBorderSetting = new ConfigSettingBoolean({
|
export type WindowBorder = "all" | "status" | "none";
|
||||||
|
|
||||||
|
const WINDOW_BORDER_LABELS: Record<WindowBorder, string> = {
|
||||||
|
all: "All around",
|
||||||
|
status: "Status line",
|
||||||
|
none: "None",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Until 2026-11-09 this was a toggle that only a popup app switcher had,
|
||||||
|
// between the rounded border and the status line; a bottom row's windows
|
||||||
|
// always had the border.
|
||||||
|
function legacyWindowBorder(): WindowBorder {
|
||||||
|
return appSwitcherPositionSetting.get() === "popup" && !getBooleanSetting("display.windowBorder", true) ? "status" : "all";
|
||||||
|
}
|
||||||
|
|
||||||
|
export const windowBorderSetting = new ConfigSettingEnumWithLegacy<WindowBorder>({
|
||||||
id: "window-border",
|
id: "window-border",
|
||||||
label: "Window border",
|
label: "Border",
|
||||||
storageKey: "display.windowBorder",
|
storageKey: "display.border",
|
||||||
defaultValue: true,
|
defaultValue: "all",
|
||||||
|
values: ["all", "status", "none"],
|
||||||
|
formatValue: (value) => WINDOW_BORDER_LABELS[value] ?? value,
|
||||||
description:
|
description:
|
||||||
"Draw a rounded border around the window. Without it, a line separates the window from the status bar. Available with a popup app switcher. Changing it reopens open apps in the new size.",
|
"All around draws a rounded border around the window. Status line draws only a straight line between the window and the status bar. None draws no lines. Available with the app switcher at the bottom or as a popup. Open apps reopen at their new size when a change resizes windows.",
|
||||||
});
|
}, legacyWindowBorder);
|
||||||
|
|
||||||
export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
|
export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
|
||||||
id: "brightness",
|
id: "brightness",
|
||||||
|
|||||||
@@ -138,8 +138,9 @@ function settingsSections(): SettingsSection[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Customization",
|
label: "Customization",
|
||||||
// Depth only applies (and only shows) with the app switcher at the
|
// Depth, the status bar's place and the border only apply (and only
|
||||||
// bottom; the panel re-reads the rows each paint.
|
// show) with the app switcher at the bottom or a popup; the panel
|
||||||
|
// re-reads the rows each paint.
|
||||||
get items() {
|
get items() {
|
||||||
return customizationItems();
|
return customizationItems();
|
||||||
},
|
},
|
||||||
@@ -318,9 +319,12 @@ function customizationRows(): () => MenuItem[] {
|
|||||||
// resizes or moves windows on change.
|
// resizes or moves windows on change.
|
||||||
const statusBar = enumSettingMenuItem(statusBarPositionSetting);
|
const statusBar = enumSettingMenuItem(statusBarPositionSetting);
|
||||||
// Popup switcher only: whether the status bar shows only in the switcher
|
// Popup switcher only: whether the status bar shows only in the switcher
|
||||||
// (windows then grow into its rows), and the foreground window's border.
|
// (windows then grow into its rows).
|
||||||
const statusBarVisibility = enumSettingMenuItem(statusBarVisibilitySetting);
|
const statusBarVisibility = enumSettingMenuItem(statusBarVisibilitySetting);
|
||||||
const windowBorder = toggleSettingMenuItem(windowBorderSetting);
|
// The lines round the foreground window: a rounded border all around, only
|
||||||
|
// the line between it and the status bar, or none; the dashboard
|
||||||
|
// controller resizes windows when the border's rows come or go.
|
||||||
|
const windowBorder = enumSettingMenuItem(windowBorderSetting);
|
||||||
const rest = [
|
const rest = [
|
||||||
// Submenu: top-bar battery indicator style plus per-device visibility.
|
// Submenu: top-bar battery indicator style plus per-device visibility.
|
||||||
batteryIndicatorsMenuItem(),
|
batteryIndicatorsMenuItem(),
|
||||||
@@ -333,7 +337,7 @@ function customizationRows(): () => MenuItem[] {
|
|||||||
// Miles or kilometers: Weather's wind speed and Navigate's distances.
|
// Miles or kilometers: Weather's wind speed and Navigate's distances.
|
||||||
enumSettingMenuItem(distanceUnitSetting),
|
enumSettingMenuItem(distanceUnitSetting),
|
||||||
];
|
];
|
||||||
const bottomRows = [font, position, depth, statusBar, ...rest];
|
const bottomRows = [font, position, depth, statusBar, windowBorder, ...rest];
|
||||||
const popupRows = [font, position, depth, statusBar, statusBarVisibility, windowBorder, ...rest];
|
const popupRows = [font, position, depth, statusBar, statusBarVisibility, windowBorder, ...rest];
|
||||||
const sideRows = [font, position, ...rest];
|
const sideRows = [font, position, ...rest];
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import {
|
|||||||
SHELL_OPAQUE_BLACK,
|
SHELL_OPAQUE_BLACK,
|
||||||
SIDEBAR_WIDTH,
|
SIDEBAR_WIDTH,
|
||||||
sidebarStripVisible,
|
sidebarStripVisible,
|
||||||
|
statusBarDivider,
|
||||||
statusBarEdge,
|
statusBarEdge,
|
||||||
statusBarOverlays,
|
statusBarOverlays,
|
||||||
statusBarTop,
|
statusBarTop,
|
||||||
@@ -45,6 +46,7 @@ import {
|
|||||||
SWITCHER_ROW_HEIGHT,
|
SWITCHER_ROW_HEIGHT,
|
||||||
switcherPosition,
|
switcherPosition,
|
||||||
switcherRect,
|
switcherRect,
|
||||||
|
switcherRowDivider,
|
||||||
TOP_BAR_HEIGHT,
|
TOP_BAR_HEIGHT,
|
||||||
windowFooterHeight,
|
windowFooterHeight,
|
||||||
windowFramed,
|
windowFramed,
|
||||||
@@ -188,8 +190,11 @@ function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId
|
|||||||
// tab there carries the side straight down (drawWindowFrame squares that
|
// tab there carries the side straight down (drawWindowFrame squares that
|
||||||
// corner for it). Scrolled past it, the cells keep the margin the left
|
// corner for it). Scrolled past it, the cells keep the margin the left
|
||||||
// chevron needs. The count of slots stays the same either way. Only the
|
// chevron needs. The count of slots stays the same either way. Only the
|
||||||
// first row's cells touch the separator; a second row's lines up under it.
|
// first row's cells touch the separator; a second row's lines up under
|
||||||
|
// it. Where the row has no separator line (geometry.ts
|
||||||
|
// switcherRowDivider) none do, and every selection is a box.
|
||||||
const first = windowFramed(appId) && scrollRow === 0 ? row.x - 1 : row.x + LIST_MARGIN - 2;
|
const first = windowFramed(appId) && scrollRow === 0 ? row.x - 1 : row.x + LIST_MARGIN - 2;
|
||||||
|
const divided = switcherRowDivider(appId);
|
||||||
return {
|
return {
|
||||||
position,
|
position,
|
||||||
iconSize: ROW_ICON_SIZE,
|
iconSize: ROW_ICON_SIZE,
|
||||||
@@ -198,7 +203,7 @@ function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId
|
|||||||
const line = (slot / columns) | 0;
|
const line = (slot / columns) | 0;
|
||||||
return {
|
return {
|
||||||
x: first + (slot % columns) * ROW_STEP, y: row.y + line * SWITCHER_ROW_HEIGHT,
|
x: first + (slot % columns) * ROW_STEP, y: row.y + line * SWITCHER_ROW_HEIGHT,
|
||||||
width: ROW_ICON_SIZE + 4, height: SWITCHER_ROW_HEIGHT, atSeparator: line === 0,
|
width: ROW_ICON_SIZE + 4, height: SWITCHER_ROW_HEIGHT, atSeparator: divided && line === 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -413,7 +418,8 @@ function topBarSpan(state: ShellChromeState): { left: number; right: number } {
|
|||||||
* bar's layout starts in them: a row lower at the window's bottom, where
|
* 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
|
* 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
|
* of the line between bar and window, or null where the window frame's side
|
||||||
* runs along it instead.
|
* runs along it instead, or the Border setting leaves the line out
|
||||||
|
* (geometry.ts statusBarDivider).
|
||||||
*/
|
*/
|
||||||
type StatusBarPlacement = { left: number; right: number; top: number; contentTop: number; divider: number | null };
|
type StatusBarPlacement = { left: number; right: number; top: number; contentTop: number; divider: number | null };
|
||||||
|
|
||||||
@@ -433,7 +439,8 @@ function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null
|
|||||||
const { left, right } = topBarSpan(state);
|
const { left, right } = topBarSpan(state);
|
||||||
const top = statusBarTop(state.foregroundHeightMode, appId);
|
const top = statusBarTop(state.foregroundHeightMode, appId);
|
||||||
const atBottom = statusBarEdge() === "bottom";
|
const atBottom = statusBarEdge() === "bottom";
|
||||||
const divider = windowFramed(appId) && !overlays ? null : atBottom ? top : top + TOP_BAR_HEIGHT - 1;
|
const framedSide = windowFramed(appId) && !overlays;
|
||||||
|
const divider = framedSide || !statusBarDivider() ? null : atBottom ? top : top + TOP_BAR_HEIGHT - 1;
|
||||||
return { left, right, top, contentTop: atBottom ? top + 1 : top, divider };
|
return { left, right, top, contentTop: atBottom ? top + 1 : top, divider };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1001,7 +1008,8 @@ export class ShellChromeLayer implements Layer {
|
|||||||
// stops at the strip.
|
// stops at the strip.
|
||||||
const { left: barLeft, right: barRight } = bar;
|
const { left: barLeft, right: barRight } = bar;
|
||||||
image.fillRect(barLeft, bar.top, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
|
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).
|
// A framed window's frame draws this line as its side (drawWindowFrame);
|
||||||
|
// without any border there is none.
|
||||||
if (bar.divider !== null) {
|
if (bar.divider !== null) {
|
||||||
image.drawLine(barLeft, bar.divider, barRight - 1, bar.divider, BORDER_VALUE);
|
image.drawLine(barLeft, bar.divider, barRight - 1, bar.divider, BORDER_VALUE);
|
||||||
}
|
}
|
||||||
@@ -1369,7 +1377,9 @@ const TAB_STROKE = 150;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the switcher/main separator line along the strip's inner edge, with
|
* Draw the switcher/main separator line along the strip's inner edge, with
|
||||||
* a gap where the selection tab `gap` diverts it.
|
* a gap where the selection tab `gap` diverts it. A bottom row has the line
|
||||||
|
* only where the Border setting gives it one (geometry.ts
|
||||||
|
* switcherRowDivider).
|
||||||
*/
|
*/
|
||||||
function drawSeparator(
|
function drawSeparator(
|
||||||
image: GrayImage,
|
image: GrayImage,
|
||||||
@@ -1378,6 +1388,7 @@ function drawSeparator(
|
|||||||
gap: SwitcherCell | null,
|
gap: SwitcherCell | null,
|
||||||
): void {
|
): void {
|
||||||
if (switcherPosition() === "bottom") {
|
if (switcherPosition() === "bottom") {
|
||||||
|
if (!switcherRowDivider(state.foregroundAppId)) return;
|
||||||
// Along the row's top edge: the full width of the row, or between the
|
// 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.
|
// corners of the window frame, whose bottom side this is.
|
||||||
// A selection tab at the frame's left side squares that corner (see
|
// A selection tab at the frame's left side squares that corner (see
|
||||||
|
|||||||
+42
-10
@@ -9,6 +9,7 @@ import {
|
|||||||
statusBarPositionSetting,
|
statusBarPositionSetting,
|
||||||
statusBarVisibilitySetting,
|
statusBarVisibilitySetting,
|
||||||
uiDepthSetting,
|
uiDepthSetting,
|
||||||
|
type WindowBorder,
|
||||||
windowBorderSetting,
|
windowBorderSetting,
|
||||||
} from "../dashboard-settings";
|
} from "../dashboard-settings";
|
||||||
|
|
||||||
@@ -189,28 +190,59 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which lines the chrome draws round the foreground window (Settings >
|
||||||
|
* Customization > Border): all of them, only the one between the window and
|
||||||
|
* the status bar, or none. The choice is a bottom or popup switcher's; a
|
||||||
|
* side strip always has its lines.
|
||||||
|
*/
|
||||||
|
function windowBorder(): WindowBorder {
|
||||||
|
return sideStrip() ? "all" : windowBorderSetting.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the foreground window's content gets a rounded frame (drawn by
|
* Whether the foreground window's content gets a rounded frame (drawn by
|
||||||
* the chrome layer). Its left and right sides take the pixel just outside
|
* the chrome layer): with every border line on (windowBorder), where
|
||||||
* the 576-wide window; there's no room around a Full Screen or immersive
|
* there's room. Its left and right sides take the pixel just outside the
|
||||||
* window, nor need beside a side strip. With a reserved bottom switcher row
|
* 576-wide window; there's no room around a Full Screen or immersive
|
||||||
* it otherwise always has one: the row's top edge is the frame's bottom side, as the window
|
* window, nor need beside a side strip. With a reserved bottom switcher
|
||||||
* header's last row is its top. With a popup switcher it's the Window
|
* row, the row's top edge is the frame's bottom side, as the window
|
||||||
* border setting's choice, and its top and bottom take a header or footer
|
* header's last row is its top. With a popup switcher, its top and bottom
|
||||||
* row of their own, except where the status bar's row next to the window
|
* take a header or footer row of their own, except where the status bar's
|
||||||
* serves.
|
* row next to the window serves.
|
||||||
*/
|
*/
|
||||||
export function windowFramed(appId?: string): boolean {
|
export function windowFramed(appId?: string): boolean {
|
||||||
|
if (fullWidth(appId) || windowBorder() !== "all") return false;
|
||||||
switch (switcherPosition()) {
|
switch (switcherPosition()) {
|
||||||
case "bottom":
|
case "bottom":
|
||||||
return switcherRowHeight(appId) > 0 && !fullWidth(appId);
|
return switcherRowHeight(appId) > 0;
|
||||||
case "popup":
|
case "popup":
|
||||||
return !fullWidth(appId) && windowBorderSetting.get();
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a line divides a status bar with rows of its own (the top bar, or
|
||||||
|
* a popup switcher's at the bottom) from the window. A window frame's side
|
||||||
|
* is that line where there is one (chrome-layer.ts statusBarPlacement).
|
||||||
|
*/
|
||||||
|
export function statusBarDivider(): boolean {
|
||||||
|
return windowBorder() !== "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a line runs along a bottom switcher's top edge, between it and
|
||||||
|
* the window: a window frame's bottom side, or straight across where the
|
||||||
|
* window has no room for a frame. As the status line alone, only where the
|
||||||
|
* status bar shares the row.
|
||||||
|
*/
|
||||||
|
export function switcherRowDivider(appId?: string): boolean {
|
||||||
|
const border = windowBorder();
|
||||||
|
return border === "all" || (border === "status" && statusInSwitcherRow(appId));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the status bar shares the bottom switcher row instead of topping
|
* Whether the status bar shares the bottom switcher row instead of topping
|
||||||
* each window (Settings > Customization > Status bar position): only beside
|
* each window (Settings > Customization > Status bar position): only beside
|
||||||
|
|||||||
+89
-15
@@ -14,7 +14,7 @@ function geometry(screen = { width: 640, height: 480 }) {
|
|||||||
const settings = Object.fromEntries(Object.entries({
|
const settings = Object.fromEntries(Object.entries({
|
||||||
displayLayoutSetting: 'band-middle', navigateDisplayLayoutSetting: 'global', terminalDisplayLayoutSetting: 'default',
|
displayLayoutSetting: 'band-middle', navigateDisplayLayoutSetting: 'global', terminalDisplayLayoutSetting: 'default',
|
||||||
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
|
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
|
||||||
statusBarVisibilitySetting: 'always', windowBorderSetting: true,
|
statusBarVisibilitySetting: 'always', windowBorderSetting: 'all',
|
||||||
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
|
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
|
||||||
const context = { exports: {}, require: (name) => {
|
const context = { exports: {}, require: (name) => {
|
||||||
if (name === '../../graphics/screen-size') return { screenWidth: () => screen.width, screenHeight: () => screen.height };
|
if (name === '../../graphics/screen-size') return { screenWidth: () => screen.width, screenHeight: () => screen.height };
|
||||||
@@ -99,18 +99,22 @@ test('Full Screen widens Tall windows to the panel and drops depth, beside a bot
|
|||||||
test('all display modes and layouts stay within the display and align content below the bar', () => {
|
test('all display modes and layouts stay within the display and align content below the bar', () => {
|
||||||
const g = geometry();
|
const g = geometry();
|
||||||
g.settings.uiDepthSetting.value = '48';
|
g.settings.uiDepthSetting.value = '48';
|
||||||
const combos = [['left', 'top'], ['right', 'top'], ['bottom', 'top'], ['bottom', 'bottom'], ['left', 'bottom']];
|
// A side strip has no choice of border: the setting doesn't reach it.
|
||||||
|
const combos = [['left', 'top'], ['right', 'top'], ['left', 'bottom'], ['right', 'top', 'always', 'none']];
|
||||||
for (const statusBar of ['top', 'bottom']) {
|
for (const statusBar of ['top', 'bottom']) {
|
||||||
for (const visibility of ['always', 'switcher']) {
|
for (const border of ['all', 'status', 'none']) {
|
||||||
for (const border of [true, false]) combos.push(['popup', statusBar, visibility, border]);
|
combos.push(['bottom', statusBar, 'always', border]);
|
||||||
|
for (const visibility of ['always', 'switcher']) combos.push(['popup', statusBar, visibility, border]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const [switcher, statusBar, visibility = 'always', border = true] of combos) {
|
for (const [switcher, statusBar, visibility = 'always', border = 'all'] of combos) {
|
||||||
g.settings.appSwitcherPositionSetting.value = switcher;
|
g.settings.appSwitcherPositionSetting.value = switcher;
|
||||||
g.settings.statusBarPositionSetting.value = statusBar;
|
g.settings.statusBarPositionSetting.value = statusBar;
|
||||||
g.settings.statusBarVisibilitySetting.value = visibility;
|
g.settings.statusBarVisibilitySetting.value = visibility;
|
||||||
g.settings.windowBorderSetting.value = border;
|
g.settings.windowBorderSetting.value = border;
|
||||||
const side = switcher === 'left' || switcher === 'right';
|
const side = switcher === 'left' || switcher === 'right';
|
||||||
|
// Only no border at all drops the line between a status bar and the window.
|
||||||
|
assert.equal(g.statusBarDivider(), side || border !== 'none');
|
||||||
for (const globalMode of LAYOUTS) {
|
for (const globalMode of LAYOUTS) {
|
||||||
g.settings.displayLayoutSetting.value = globalMode;
|
g.settings.displayLayoutSetting.value = globalMode;
|
||||||
for (const appId of ['navigate', 'terminal']) {
|
for (const appId of ['navigate', 'terminal']) {
|
||||||
@@ -127,15 +131,18 @@ test('all display modes and layouts stay within the display and align content be
|
|||||||
if (switcher === 'popup') {
|
if (switcher === 'popup') {
|
||||||
// Each edge has the status bar's rows (unless it only
|
// Each edge has the status bar's rows (unless it only
|
||||||
// overlays), else the frame's side, else nothing.
|
// overlays), else the frame's side, else nothing.
|
||||||
assert.equal(g.windowFramed(appId), border && !wide);
|
assert.equal(g.windowFramed(appId), border === 'all' && !wide);
|
||||||
const edge = (side) => visibility === 'always' && statusBar === side ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0;
|
const edge = (side) => visibility === 'always' && statusBar === side ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0;
|
||||||
assert.deepEqual([header, footer], [edge('top'), edge('bottom')]);
|
assert.deepEqual([header, footer], [edge('top'), edge('bottom')]);
|
||||||
// The status bar's rows lie within the band, at its edge.
|
// The status bar's rows lie within the band, at its edge.
|
||||||
const top = g.windowTop(heightMode, appId), band = g.windowBandHeight(heightMode, appId);
|
const top = g.windowTop(heightMode, appId), band = g.windowBandHeight(heightMode, appId);
|
||||||
assert.equal(g.statusBarTop(heightMode, appId), statusBar === 'top' ? top : top + band - g.TOP_BAR_HEIGHT);
|
assert.equal(g.statusBarTop(heightMode, appId), statusBar === 'top' ? top : top + band - g.TOP_BAR_HEIGHT);
|
||||||
} else {
|
} else {
|
||||||
assert.equal(g.windowFramed(appId), switcher === 'bottom' && !wide);
|
assert.equal(g.windowFramed(appId), switcher === 'bottom' && border === 'all' && !wide);
|
||||||
assert.deepEqual([header, footer], [!g.statusInSwitcherRow(appId) ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0, 0]);
|
assert.deepEqual([header, footer], [!g.statusInSwitcherRow(appId) ? g.TOP_BAR_HEIGHT : g.windowFramed(appId) ? 1 : 0, 0]);
|
||||||
|
// A bottom row's top edge is a line with every border, or as
|
||||||
|
// the status line where the status bar is in the row.
|
||||||
|
if (switcher === 'bottom') assert.equal(g.switcherRowDivider(appId), border === 'all' || (border === 'status' && statusBar === 'bottom'));
|
||||||
}
|
}
|
||||||
assert.equal(rect.y, g.windowTop(heightMode, appId) + header);
|
assert.equal(rect.y, g.windowTop(heightMode, appId) + header);
|
||||||
assert.equal(rect.height + header + footer, g.windowBandHeight(heightMode, appId));
|
assert.equal(rect.height + header + footer, g.windowBandHeight(heightMode, appId));
|
||||||
@@ -196,13 +203,16 @@ test('a popup app switcher centres 576-wide windows, whose edges the status bar
|
|||||||
assert.deepEqual(g.rect('min'), { x: 32, y: 97, width: 576, height: 286 });
|
assert.deepEqual(g.rect('min'), { x: 32, y: 97, width: 576, height: 286 });
|
||||||
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 1, width: 576, height: 478 });
|
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 1, width: 576, height: 478 });
|
||||||
assert.equal(g.statusBarTop('min'), 356);
|
assert.equal(g.statusBarTop('min'), 356);
|
||||||
// Without the frame too, windows have no chrome rows at all.
|
// Without the frame too (just the status line, or no border), windows
|
||||||
g.settings.windowBorderSetting.value = false;
|
// have no chrome rows at all.
|
||||||
assert.equal(g.windowFramed(), false);
|
for (const border of ['status', 'none']) {
|
||||||
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 0, width: 576, height: 480 });
|
g.settings.windowBorderSetting.value = border;
|
||||||
assert.deepEqual(g.rect('medium'), { x: 32, y: 96, width: 576, height: 288 });
|
assert.equal(g.windowFramed(), false);
|
||||||
|
assert.deepEqual(g.rect('max', 'terminal'), { x: 32, y: 0, width: 576, height: 480 });
|
||||||
|
assert.deepEqual(g.rect('medium'), { x: 32, y: 96, width: 576, height: 288 });
|
||||||
|
}
|
||||||
// Full Screen: the status bar keeps its edge, but there's no room for a frame.
|
// Full Screen: the status bar keeps its edge, but there's no room for a frame.
|
||||||
g.settings.windowBorderSetting.value = true;
|
g.settings.windowBorderSetting.value = 'all';
|
||||||
g.settings.statusBarVisibilitySetting.value = 'always';
|
g.settings.statusBarVisibilitySetting.value = 'always';
|
||||||
g.settings.displayLayoutSetting.value = 'fullscreen';
|
g.settings.displayLayoutSetting.value = 'fullscreen';
|
||||||
assert.equal(g.windowFramed(), false);
|
assert.equal(g.windowFramed(), false);
|
||||||
@@ -844,9 +854,9 @@ test('a popup switcher\'s status bar can sit at the bottom, show only in the swi
|
|||||||
g.settings.statusBarPositionSetting.value = 'bottom';
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
[bar] = chrome.paintParts();
|
[bar] = chrome.paintParts();
|
||||||
assert.deepEqual([bar.y, at(bar, 300, 356), at(bar, 300, 383)], [356, 40, 1]);
|
assert.deepEqual([bar.y, at(bar, 300, 356), at(bar, 300, 383)], [356, 40, 1]);
|
||||||
// Always shown without a frame, a divider still separates bar and window.
|
// Always shown with only the status line, a divider still separates bar and window.
|
||||||
g.settings.statusBarVisibilitySetting.value = 'always';
|
g.settings.statusBarVisibilitySetting.value = 'always';
|
||||||
g.settings.windowBorderSetting.value = false;
|
g.settings.windowBorderSetting.value = 'status';
|
||||||
state.focus = 'window';
|
state.focus = 'window';
|
||||||
const parts = chrome.paintParts();
|
const parts = chrome.paintParts();
|
||||||
assert.deepEqual(Array.from(parts, (p) => p.shellKey), [2]);
|
assert.deepEqual(Array.from(parts, (p) => p.shellKey), [2]);
|
||||||
@@ -854,6 +864,70 @@ test('a popup switcher\'s status bar can sit at the bottom, show only in the swi
|
|||||||
g.settings.statusBarPositionSetting.value = 'top';
|
g.settings.statusBarPositionSetting.value = 'top';
|
||||||
[bar] = chrome.paintParts();
|
[bar] = chrome.paintParts();
|
||||||
assert.deepEqual([bar.y, at(bar, 300, 123)], [96, 40]);
|
assert.deepEqual([bar.y, at(bar, 300, 123)], [96, 40]);
|
||||||
|
// With no border the bar is all there is, at either edge.
|
||||||
|
g.settings.windowBorderSetting.value = 'none';
|
||||||
|
[bar] = chrome.paintParts();
|
||||||
|
assert.deepEqual([bar.y, at(bar, 300, 123)], [96, 1]);
|
||||||
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
|
assert.deepEqual(Array.from(chrome.paintParts(), (p) => [p.shellKey, p.y, at(p, 300, 356)]), [[2, 356, 1]]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a bottom app switcher\'s border can be just the line by the status bar, or nothing', () => {
|
||||||
|
const g = geometry();
|
||||||
|
g.settings.appSwitcherPositionSetting.value = 'bottom';
|
||||||
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
|
g.settings.windowBorderSetting.value = 'status';
|
||||||
|
const { chrome, state } = chromeLayer(g, { windows: 2 });
|
||||||
|
state.selectedIndex = 1;
|
||||||
|
const frames = (parts) => parts.flatMap((p) => p.image.draws.filter((d) => d.presentation?.displayList));
|
||||||
|
const at = (p, x, y) => p.image.pixels[(y - p.y) * p.image.width + x - p.x];
|
||||||
|
// With the status bar in the row, the line is the row's top edge, straight
|
||||||
|
// across the window's width; no frame, so the content takes the header's
|
||||||
|
// row and the row's surface is no wider than the window.
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 78, width: 576, height: 288 });
|
||||||
|
let parts = chrome.paintParts();
|
||||||
|
let [row] = parts;
|
||||||
|
assert.equal(frames(parts).length, 0);
|
||||||
|
assert.deepEqual([row.x, row.y, row.image.width], [32, 366, 576]);
|
||||||
|
assert.deepEqual([at(row, 32, 366), at(row, 300, 366), at(row, 607, 366)], [40, 40, 40]);
|
||||||
|
// The cells keep their margin from the row's end, and the selection is
|
||||||
|
// still a tab diverting the line.
|
||||||
|
assert.deepEqual([chrome.windowIndexAt(39, 380, 2), chrome.windowIndexAt(40, 380, 2), chrome.windowIndexAt(80, 380, 2)], [null, 0, 1]);
|
||||||
|
assert.deepEqual([at(row, 79, 366), at(row, 80, 366), at(row, 98, 366), at(row, 80, 380)], [40, 150, 1, 150]);
|
||||||
|
// The flat paint has no frame either.
|
||||||
|
assert.equal(chrome.paint().draws.filter((d) => d.presentation?.displayList).length, 0);
|
||||||
|
// With the status bar on top, the line is the top bar's divider, and the
|
||||||
|
// row has none: its selection is a box, as in a second row.
|
||||||
|
g.settings.statusBarPositionSetting.value = 'top';
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 106, width: 576, height: 260 });
|
||||||
|
parts = chrome.paintParts();
|
||||||
|
let bar;
|
||||||
|
[bar, row] = parts;
|
||||||
|
assert.deepEqual([Array.from(parts, (p) => p.shellKey), frames(parts).length], [[2, 1], 0]);
|
||||||
|
assert.deepEqual([at(bar, 32, 105), at(bar, 607, 105)], [40, 40]);
|
||||||
|
assert.deepEqual([at(row, 32, 366), at(row, 300, 366)], [1, 1]);
|
||||||
|
assert.deepEqual([at(row, 98, 366), at(row, 80, 380), at(row, 98, 401)], [150, 150, 150]);
|
||||||
|
// Focused, the box fills round the icon.
|
||||||
|
state.focus = 'sidebar';
|
||||||
|
[, row] = chrome.paintParts();
|
||||||
|
assert.deepEqual([at(row, 81, 380), at(row, 98, 380)], [255, 120]);
|
||||||
|
state.focus = 'window';
|
||||||
|
// No border: neither line, wherever the status bar is.
|
||||||
|
g.settings.windowBorderSetting.value = 'none';
|
||||||
|
[bar, row] = chrome.paintParts();
|
||||||
|
assert.deepEqual([at(bar, 300, 105), at(row, 300, 366), at(row, 98, 366)], [1, 1, 150]);
|
||||||
|
g.settings.statusBarPositionSetting.value = 'bottom';
|
||||||
|
parts = chrome.paintParts();
|
||||||
|
[row] = parts;
|
||||||
|
assert.deepEqual([frames(parts).length, at(row, 32, 366), at(row, 300, 366), at(row, 98, 366)], [0, 1, 1, 150]);
|
||||||
|
assert.deepEqual(g.rect('min'), { x: 32, y: 78, width: 576, height: 288 });
|
||||||
|
// All around, a Full Screen window has no room for a frame and keeps its
|
||||||
|
// straight lines, as beside a side strip.
|
||||||
|
g.settings.windowBorderSetting.value = 'all';
|
||||||
|
g.settings.statusBarPositionSetting.value = 'top';
|
||||||
|
g.settings.displayLayoutSetting.value = 'fullscreen';
|
||||||
|
[bar, row] = chrome.paintParts();
|
||||||
|
assert.deepEqual([at(bar, 300, 27), at(row, 0, 444), at(row, 639, 444)], [40, 40, 40]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a notification the switcher selects sits in a box, filled with its icon inverted while the switcher has focus', () => {
|
test('a notification the switcher selects sits in a box, filled with its icon inverted while the switcher has focus', () => {
|
||||||
|
|||||||
@@ -35,6 +35,25 @@ test('the display mode starts as the middle band, or carries over the old mode a
|
|||||||
assert.equal(api.displayLayoutSetting.get(), 'band-bottom');
|
assert.equal(api.displayLayoutSetting.get(), 'band-bottom');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('the border starts all around, or as the status line a popup switcher\'s old Window border toggle left', () => {
|
||||||
|
const border = (entries) => settingsFixture(new Map(entries)).windowBorderSetting.get();
|
||||||
|
assert.equal(border([]), 'all');
|
||||||
|
assert.equal(border([['display.appSwitcherPosition', 'popup']]), 'all');
|
||||||
|
assert.equal(border([['display.appSwitcherPosition', 'popup'], ['display.windowBorder', true]]), 'all');
|
||||||
|
assert.equal(border([['display.appSwitcherPosition', 'popup'], ['display.windowBorder', false]]), 'status');
|
||||||
|
// A bottom row's windows had the border whatever the toggle said.
|
||||||
|
assert.equal(border([['display.windowBorder', false]]), 'all');
|
||||||
|
// Once set, the setting is its own, for either switcher.
|
||||||
|
const store = new Map([['display.appSwitcherPosition', 'popup'], ['display.windowBorder', false]]);
|
||||||
|
const api = settingsFixture(store);
|
||||||
|
assert.equal(api.windowBorderSetting.displayValue(), 'Status line');
|
||||||
|
api.windowBorderSetting.set('none');
|
||||||
|
assert.equal(store.get('display.border'), 'none');
|
||||||
|
api.appSwitcherPositionSetting.set('bottom');
|
||||||
|
assert.equal(api.windowBorderSetting.get(), 'none');
|
||||||
|
assert.deepEqual(Array.from(api.windowBorderSetting.values, (value) => api.windowBorderSetting.displayValue(value)), ['All around', 'Status line', 'None']);
|
||||||
|
});
|
||||||
|
|
||||||
test('the glasses model name follows the paired glasses type', () => {
|
test('the glasses model name follows the paired glasses type', () => {
|
||||||
const model = (entries) => settingsFixture(new Map(entries)).glassesModelName();
|
const model = (entries) => settingsFixture(new Map(entries)).glassesModelName();
|
||||||
assert.equal(model([]), 'G2');
|
assert.equal(model([]), 'G2');
|
||||||
|
|||||||
Reference in new issue
Block a user