forked from Blendman974/faceclaw
UI refinement pass
Remove gesture-help bottom-bars from many places in the UI, adjust layouts to be able to handle larger fonts, and other small UI fixes.
This commit is contained in:
1 parent
dc18737dfc
commit
35e6977c6c
17 files changed
+394
-321
No files matched your search
@@ -3,9 +3,8 @@ import { truncateText, truncateLeft } from "../../graphics/textwrap";
|
||||
import { GrayImage, type UiFont } from "../../graphics/image";
|
||||
import { renderIcon, type IconName } from "../../graphics/icons";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL } from "../../ui/gestures";
|
||||
import { drawListScrollbar, drawSelectionHighlight, scrollToKeepSelectionVisible, type MenuItem } from "../../ui/menu";
|
||||
import { lineStep, tightRowHeight } from "../../ui/metrics";
|
||||
import { iconGridMinRowHeight, tightRowHeight } from "../../ui/metrics";
|
||||
import { ConfigSettingEnum } from "../../ui/dashboard-settings";
|
||||
import { getStringSetting, setStringSetting } from "../../native/settings-store";
|
||||
import {
|
||||
@@ -20,14 +19,12 @@ import { Layer, type DashboardInputEvent, type LayerContext } from "../../ui/lay
|
||||
|
||||
const LIST_X = 20;
|
||||
|
||||
/** Header: title line + path line (34px at the 12px bitmap default). */
|
||||
/** Header: one line holding both the title and the current path. */
|
||||
function headerHeight(font: UiFont): number {
|
||||
return 8 + lineStep(font) + font.lineHeight;
|
||||
return 10 + font.lineHeight;
|
||||
}
|
||||
|
||||
const GRID_COLS = 5;
|
||||
const GRID_VISIBLE_ROWS = 3;
|
||||
const GRID_BOTTOM_MARGIN = 20;
|
||||
const ICON_SIZE = 44;
|
||||
const LABEL_GAP = 2;
|
||||
|
||||
@@ -142,7 +139,8 @@ export class FileBrowserLayer implements Layer {
|
||||
|
||||
image.drawText(font, 20, 8, "Files", 220);
|
||||
const pathLabel = this.location === null ? "Places" : this.location;
|
||||
image.drawText(font, 20, 8 + lineStep(font), truncateLeft(font, pathLabel, width - 40), 130);
|
||||
const pathX = 20 + font.measureText("Files") + 14;
|
||||
image.drawText(font, pathX, 8, truncateLeft(font, pathLabel, width - pathX - 20), 130);
|
||||
|
||||
if (filesViewModeSetting.get() === "list") {
|
||||
this.paintList(image, font, rows, ctx);
|
||||
@@ -158,7 +156,7 @@ export class FileBrowserLayer implements Layer {
|
||||
|
||||
const rowH = tightRowHeight(font);
|
||||
const headerH = headerHeight(font);
|
||||
const listHeight = height - headerH - font.lineHeight - 10;
|
||||
const listHeight = height - headerH - 4;
|
||||
const visibleRows = Math.max(1, (listHeight / rowH) | 0);
|
||||
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, this.listIndex, visibleRows, rows.length);
|
||||
|
||||
@@ -173,8 +171,6 @@ export class FileBrowserLayer implements Layer {
|
||||
const value = itemValue(row, selected);
|
||||
image.drawText(font, LIST_X, y + 1, truncateText(font, row.label, width - 2 * LIST_X), value);
|
||||
}
|
||||
|
||||
image.drawText(font, 20, height - font.lineHeight - 4, `${GESTURE_CLICK} open ${GESTURE_DOUBLE_CLICK} up / back`, 110);
|
||||
}
|
||||
|
||||
private paintIcons(image: GrayImage, font: UiFont, rows: BrowserItem[], ctx: LayerContext): void {
|
||||
@@ -184,12 +180,13 @@ export class FileBrowserLayer implements Layer {
|
||||
this.selectedRow = clamp(this.selectedRow, 0, Math.max(0, iconRows.length - 1));
|
||||
|
||||
const gridTop = headerHeight(font);
|
||||
const gridBottom = height - GRID_BOTTOM_MARGIN;
|
||||
const rowH = Math.floor((gridBottom - gridTop) / GRID_VISIBLE_ROWS);
|
||||
const gridBottom = height - 6;
|
||||
const visibleRows = Math.max(1, Math.floor((gridBottom - gridTop) / iconGridMinRowHeight(font, ICON_SIZE, LABEL_GAP)));
|
||||
const rowH = Math.floor((gridBottom - gridTop) / visibleRows);
|
||||
const colW = width / GRID_COLS;
|
||||
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, this.selectedRow, GRID_VISIBLE_ROWS, iconRows.length);
|
||||
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, this.selectedRow, visibleRows, iconRows.length);
|
||||
|
||||
const lastVisible = Math.min(iconRows.length, this.scrollRow + GRID_VISIBLE_ROWS);
|
||||
const lastVisible = Math.min(iconRows.length, this.scrollRow + visibleRows);
|
||||
for (let rowIndex = this.scrollRow; rowIndex < lastVisible; rowIndex++) {
|
||||
const row = iconRows[rowIndex]!;
|
||||
const y = gridTop + (rowIndex - this.scrollRow) * rowH;
|
||||
@@ -229,15 +226,9 @@ export class FileBrowserLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
if (iconRows.length > GRID_VISIBLE_ROWS) {
|
||||
drawListScrollbar(image, width - 5, gridTop, GRID_VISIBLE_ROWS * rowH - 4, this.scrollRow, GRID_VISIBLE_ROWS, iconRows.length);
|
||||
if (iconRows.length > visibleRows) {
|
||||
drawListScrollbar(image, width - 5, gridTop, visibleRows * rowH - 4, this.scrollRow, visibleRows, iconRows.length);
|
||||
}
|
||||
|
||||
const hint =
|
||||
this.iconMode === "row"
|
||||
? `${GESTURE_SCROLL} row ${GESTURE_CLICK} pick ${GESTURE_DOUBLE_CLICK} up / back`
|
||||
: `${GESTURE_SCROLL} item ${GESTURE_CLICK} open ${GESTURE_DOUBLE_CLICK} row`;
|
||||
image.drawText(font, 20, height - font.lineHeight - 4, hint, 110);
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user