forked from Blendman974/faceclaw
Borderless modes have different padding inside the builtin apps
Most of the builtin apps had some padding between the window edge and their content, because they expect to be displayed with a line border on their edge. We added a customization option to remove the border, so, that padding is not always necessary. Make the layouts dynamically adjust, to omit the padding when it isn't needed.
This commit is contained in:
1 parent
e158452ba4
commit
a02b849200
115 files changed
+3600
-1583
No files matched your search
@@ -4,7 +4,7 @@ import { GrayImage } from "../../graphics/image";
|
||||
import { type Plane } from "../../graphics/plane";
|
||||
import { renderIcon, type IconName } from "../../graphics/icons";
|
||||
import { InputEvent } from "../../ui/gestures";
|
||||
import { IconGrid, ICON_GRID_BAND_INSET_X, ICON_GRID_HIGHLIGHT_INSET_Y, ICON_GRID_ICON_SIZE } from "../../ui/icon-grid";
|
||||
import { IconGrid, ICON_GRID_ICON_SIZE } from "../../ui/icon-grid";
|
||||
import { Layer, LayerActions, LayerContext } from "../../ui/layers";
|
||||
import { MenuLayer, type MenuItem } from "../../ui/menu";
|
||||
import { WINDOW_MENU_LAYOUT } from "../../ui/window-menu";
|
||||
@@ -43,12 +43,9 @@ export type LauncherOptions = {
|
||||
export const LAUNCHER_WINDOW_ID = "launcher";
|
||||
export const LAUNCHER_SURFACE_ID = "window:launcher";
|
||||
|
||||
const GRID_TOP = 6;
|
||||
/**
|
||||
* The root grid's top: its first row's highlight band then sits as far
|
||||
* below the window's top edge as it is from the side edges.
|
||||
*/
|
||||
const ROOT_GRID_TOP = ICON_GRID_BAND_INSET_X - ICON_GRID_HIGHLIGHT_INSET_Y;
|
||||
/** A folder's name, above its grid: how far in from the grid's side, and the gap under it. */
|
||||
const FOLDER_NAME_INSET_X = 4;
|
||||
const FOLDER_NAME_GAP = 6;
|
||||
|
||||
/** One cell of the grid: an app, or a folder holding some of the apps. */
|
||||
type LauncherGridEntry =
|
||||
@@ -260,16 +257,25 @@ class LauncherGridLayer implements Layer {
|
||||
|
||||
paint(ctx: LayerContext): GrayImage {
|
||||
const font = getDefaultSmallFont();
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const { width, height, padding } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
// The folder-name header band scales with the font.
|
||||
const gridTop = this.currentFolder !== null ? GRID_TOP + font.lineHeight + 4 : ROOT_GRID_TOP;
|
||||
const gridX = padding.left;
|
||||
const gridWidth = width - padding.left - padding.right;
|
||||
// The grid scrolls, so it runs to the window's top and bottom edges, the
|
||||
// padding suggested for them inside it: its end rows keep clear of a
|
||||
// border there, and a row cut off for scrolling meets the border rather
|
||||
// than a blank strip. A folder's name stays put above its grid instead,
|
||||
// in a band that scales with the font.
|
||||
let gridTop = 0;
|
||||
let padTop = padding.top;
|
||||
if (this.currentFolder !== null) {
|
||||
image.drawText(font, 8, GRID_TOP - 2, truncateText(font, this.currentFolder, width - 16), 160);
|
||||
const nameX = gridX + FOLDER_NAME_INSET_X;
|
||||
image.drawText(font, nameX, padding.top, truncateText(font, this.currentFolder, gridWidth - 2 * FOLDER_NAME_INSET_X), 160);
|
||||
gridTop = padding.top + font.lineHeight + FOLDER_NAME_GAP;
|
||||
padTop = 0;
|
||||
}
|
||||
// The grid runs to the window's bottom edge, so a row cut off there for
|
||||
// scrolling meets the window's border rather than a blank strip.
|
||||
this.grid.paint(image, { x: 0, y: gridTop, width, height: height - gridTop }, ctx.stack.isFocused());
|
||||
this.grid.paint(image, { x: gridX, y: gridTop, width: gridWidth, height: height - gridTop, padTop, padBottom: padding.bottom },
|
||||
ctx.stack.isFocused());
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user