forked from Blendman974/faceclaw
Use TTF fonts throughout the UI; also add some more functions to app extension API
This commit is contained in:
1 parent
5abbe2a405
commit
96842ceb23
82 files changed
+2666
-288
No files matched your search
@@ -6,12 +6,7 @@ import {
|
||||
setBooleanSetting,
|
||||
setStringSetting,
|
||||
} from "~/native/settings-store";
|
||||
import {
|
||||
getDefaultSmallFont,
|
||||
UI_FONT_SETTING_KEY,
|
||||
UI_FONT_VALUES,
|
||||
type UiFontChoice,
|
||||
} from "~/graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "~/graphics/ui-fonts";
|
||||
import { wrapText } from "~/graphics/textwrap";
|
||||
import {
|
||||
ASSISTANT_MODEL_VALUES,
|
||||
@@ -217,16 +212,6 @@ export const batteryDisplayModeSetting = new ConfigSettingEnum<BatteryDisplayMod
|
||||
description: "How the top bar shows the phone and glasses battery levels: a small gauge icon or an exact percentage.",
|
||||
});
|
||||
|
||||
export const uiFontSetting = new ConfigSettingEnum<UiFontChoice>({
|
||||
id: "uiFont",
|
||||
label: "Font",
|
||||
storageKey: UI_FONT_SETTING_KEY,
|
||||
defaultValue: "terminus",
|
||||
values: UI_FONT_VALUES,
|
||||
formatValue: uiFontLabel,
|
||||
description: "Typeface for UI text on the glasses. Terminus is fixed-width; TerminusV is a proportional variant that fits more text per line.",
|
||||
});
|
||||
|
||||
export const timeFormatSetting = new ConfigSettingEnum<TimeFormat>({
|
||||
id: "timeFormat",
|
||||
label: "Time format",
|
||||
@@ -631,10 +616,6 @@ export function timeFormatLabel(value: TimeFormat): string {
|
||||
return value === "12h" ? "12-hour" : "24-hour";
|
||||
}
|
||||
|
||||
export function uiFontLabel(value: UiFontChoice): string {
|
||||
return value === "terminusv" ? "TerminusV" : "Terminus";
|
||||
}
|
||||
|
||||
export function loadNightscoutSettings(): NightscoutSettings {
|
||||
return {
|
||||
siteUrl: nightscoutSiteUrlSetting.get(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { knownFolders } from "@nativescript/core";
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import type { GrayImage } from "../../graphics/image";
|
||||
import { getDashboardLogo } from "../../graphics/logo";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
@@ -44,13 +44,13 @@ import {
|
||||
textSettingMenuItem,
|
||||
timeFormatSetting,
|
||||
toggleSettingMenuItem,
|
||||
uiFontSetting,
|
||||
verticalPositionSetting,
|
||||
voiceProviderSetting,
|
||||
screenTimeoutSetting,
|
||||
wakeWordActionSetting,
|
||||
} from "../dashboard-settings";
|
||||
import { SettingsPanelLayer, type SettingsSection } from "./settings-panel";
|
||||
import { terminalFontPickerMenuItem, uiFontPickerMenuItem } from "../font-picker";
|
||||
|
||||
/** The Settings app's master-detail panel (sections on the left, contents on the right). */
|
||||
export function createSettingsPanelLayer(): SettingsPanelLayer {
|
||||
@@ -78,8 +78,8 @@ function settingsSections(): SettingsSection[] {
|
||||
enumSettingMenuItem(batteryDisplayModeSetting),
|
||||
// Controls the top-bar clock (24-hour vs 12-hour).
|
||||
enumSettingMenuItem(timeFormatSetting),
|
||||
// Selects the UI body typeface (Terminus vs proportional TerminusV).
|
||||
enumSettingMenuItem(uiFontSetting),
|
||||
// Opens the modal font picker (face, weight, size) for UI text.
|
||||
uiFontPickerMenuItem(),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -120,6 +120,7 @@ function settingsSections(): SettingsSection[] {
|
||||
// Connections (g2mirror:// strings) are managed inside the Terminal
|
||||
// app's Manage Connections section, not here.
|
||||
items: [
|
||||
terminalFontPickerMenuItem(),
|
||||
textSettingMenuItem(terminalLaunchPresetsSetting),
|
||||
toggleSettingMenuItem(terminalAutoReconnectSetting),
|
||||
toggleSettingMenuItem(terminalWakeOnBellSetting),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* lines highlight as one unit) and the scroll position follows it, matching
|
||||
* the house list style in ui/menu.ts.
|
||||
*/
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont";
|
||||
import { GrayImage, type UiFont } from "../../graphics/image";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { drawListScrollbar, drawSelectionHighlight } from "../menu";
|
||||
@@ -35,7 +35,7 @@ type LayoutLine = {
|
||||
indentX: number;
|
||||
textX: number;
|
||||
height: number;
|
||||
font: BdfFont;
|
||||
font: UiFont;
|
||||
/** Line belongs to a code block (shaded background). */
|
||||
codeBlock: boolean;
|
||||
segments: Segment[];
|
||||
@@ -305,7 +305,7 @@ function inlineSpans(inlines: readonly DocInline[]): InlineSpan[] {
|
||||
|
||||
/** Split one wrapped line (plainText[start..start+text.length)) at span boundaries. */
|
||||
function segmentLine(
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
text: string,
|
||||
start: number,
|
||||
spans: readonly InlineSpan[],
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
/**
|
||||
* Modal font picker for the Settings app: choose a face (bitmap Terminus
|
||||
* variants or any installed TTF family), a weight (the family's installed
|
||||
* styles), and a pixel size, with a live preview line rendered in the draft
|
||||
* font. Selections only persist on Save; double-click cancels.
|
||||
*
|
||||
* Used for both the UI font (Display section) and the terminal font
|
||||
* (Terminal section, filtered to monospace faces).
|
||||
*/
|
||||
import { getFont } from "../graphics/bdffont";
|
||||
import { GrayImage, type UiFont } from "../graphics/image";
|
||||
import { TtfFont } from "../graphics/ttf-font";
|
||||
import { listInstalledFonts, type InstalledFont } from "../graphics/installed-fonts";
|
||||
import {
|
||||
fontSelectionLabel,
|
||||
getDefaultSmallFont,
|
||||
getTerminalFontSelection,
|
||||
getUiFontSelection,
|
||||
setTerminalFontSelection,
|
||||
setUiFontSelection,
|
||||
type BitmapFace,
|
||||
type UiFontSelection,
|
||||
} from "../graphics/ui-fonts";
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import { drawRightValueMenuItem, drawSelectionHighlight, openModalMenu, type MenuItem } from "./menu";
|
||||
import type { DashboardInputEvent, Layer, LayerContext } from "./layers";
|
||||
|
||||
const SIZE_CHOICES = [12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28] as const;
|
||||
const DEFAULT_TTF_SIZE = 16;
|
||||
const PREVIEW_TEXT = "The quick brown fox jumps over 0123456789";
|
||||
|
||||
type FontPickerOptions = {
|
||||
title: string;
|
||||
/** Only offer faces where every style is monospace (terminal picker). */
|
||||
monospaceOnly: boolean;
|
||||
/** Bitmap faces offered ahead of the installed TTF families. */
|
||||
bitmapFaces: readonly { face: BitmapFace; label: string }[];
|
||||
get(): UiFontSelection;
|
||||
set(selection: UiFontSelection): void;
|
||||
};
|
||||
|
||||
type FontFamily = {
|
||||
label: string;
|
||||
fonts: InstalledFont[];
|
||||
};
|
||||
|
||||
/** The draft being edited: a bitmap face, or a TTF family + style + size. */
|
||||
type Draft =
|
||||
| { kind: "bitmap"; face: BitmapFace }
|
||||
| { kind: "ttf"; family: FontFamily; font: InstalledFont; size: number };
|
||||
|
||||
const ROWS = ["face", "weight", "size", "save"] as const;
|
||||
type RowId = (typeof ROWS)[number];
|
||||
|
||||
export class FontPickerLayer implements Layer {
|
||||
private readonly families: FontFamily[];
|
||||
private draft: Draft;
|
||||
private selectedRow = 0;
|
||||
|
||||
constructor(private readonly options: FontPickerOptions) {
|
||||
this.families = collectFamilies(options.monospaceOnly);
|
||||
this.draft = this.draftFromSelection(options.get());
|
||||
}
|
||||
|
||||
private draftFromSelection(selection: UiFontSelection): Draft {
|
||||
if (selection.kind === "ttf") {
|
||||
for (const family of this.families) {
|
||||
const font = family.fonts.find((f) => f.fileName === selection.file);
|
||||
if (font) return { kind: "ttf", family, font, size: selection.size };
|
||||
}
|
||||
}
|
||||
const face =
|
||||
selection.kind === "bitmap" && this.options.bitmapFaces.some((b) => b.face === selection.face)
|
||||
? selection.face
|
||||
: this.options.bitmapFaces[0]?.face ?? "terminus";
|
||||
return { kind: "bitmap", face };
|
||||
}
|
||||
|
||||
private draftSelection(): UiFontSelection {
|
||||
return this.draft.kind === "bitmap"
|
||||
? { kind: "bitmap", face: this.draft.face }
|
||||
: { kind: "ttf", file: this.draft.font.fileName, size: this.draft.size };
|
||||
}
|
||||
|
||||
/** The draft's concrete font for the preview (bitmap fallback if unloadable). */
|
||||
private previewFont(): UiFont {
|
||||
if (this.draft.kind === "ttf") {
|
||||
const font = TtfFont.load(this.draft.font.path, this.draft.size);
|
||||
if (font) return font;
|
||||
}
|
||||
return this.draft.kind === "bitmap" && this.draft.face === "terminusv"
|
||||
? getFont("terminusv12")
|
||||
: getFont("terminus12");
|
||||
}
|
||||
|
||||
paint(ctx: LayerContext): GrayImage {
|
||||
const font = getDefaultSmallFont();
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const focused = ctx.stack.isFocused();
|
||||
image.drawText(font, 22, 14, this.options.title, 220);
|
||||
|
||||
const rowX = 22;
|
||||
const rowWidth = width - 2 * rowX;
|
||||
const rowHeight = 22;
|
||||
const rowsTop = 40;
|
||||
for (let index = 0; index < ROWS.length; index++) {
|
||||
const row = ROWS[index]!;
|
||||
const y = rowsTop + index * rowHeight;
|
||||
const disabled = this.rowDisabled(row);
|
||||
if (index === this.selectedRow) {
|
||||
drawSelectionHighlight(image, rowX - 10, y - 2, rowWidth + 20, rowHeight - 2, focused, 8);
|
||||
}
|
||||
if (row === "save") {
|
||||
image.drawText(font, rowX, y + 3, "Save", index === this.selectedRow ? 255 : 200);
|
||||
continue;
|
||||
}
|
||||
const label = row === "face" ? "Font" : row === "weight" ? "Weight" : "Size";
|
||||
const value = this.rowValue(row);
|
||||
if (disabled) {
|
||||
image.drawText(font, rowX, y + 3, label, 70);
|
||||
image.drawText(font, rowX + rowWidth - font.measureText(value) - 2, y + 3, value, 70);
|
||||
} else {
|
||||
drawRightValueMenuItem(image, font, rowX, y, rowWidth, label, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Preview: a separator, then the sample line in the draft font.
|
||||
const previewTop = rowsTop + ROWS.length * rowHeight + 10;
|
||||
image.drawLine(rowX - 10, previewTop, rowX + rowWidth + 10, previewTop, 60);
|
||||
const preview = this.previewFont();
|
||||
const sample =
|
||||
preview.measureText(PREVIEW_TEXT) <= rowWidth + 20 ? PREVIEW_TEXT : "The quick brown fox 0123";
|
||||
preview.drawText(image, rowX - 4, previewTop + 8, sample, 230);
|
||||
const info = `Line height: ${preview.lineHeight}px`;
|
||||
image.drawText(font, rowX - 4, previewTop + 8 + preview.lineHeight + 6, info, 110);
|
||||
|
||||
image.drawText(font, rowX - 4, height - 30, `scroll select click change ${GESTURE_DOUBLE_CLICK} cancel`, 90);
|
||||
return image;
|
||||
}
|
||||
|
||||
private rowDisabled(row: RowId): boolean {
|
||||
return (row === "weight" || row === "size") && this.draft.kind === "bitmap";
|
||||
}
|
||||
|
||||
private rowValue(row: RowId): string {
|
||||
if (row === "face") {
|
||||
if (this.draft.kind === "bitmap") {
|
||||
return this.options.bitmapFaces.find((b) => b.face === (this.draft as { face: BitmapFace }).face)?.label
|
||||
?? "Terminus";
|
||||
}
|
||||
return this.draft.family.label;
|
||||
}
|
||||
if (this.draft.kind === "bitmap") return "-";
|
||||
if (row === "weight") return this.draft.font.style || "Regular";
|
||||
return String(this.draft.size);
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
switch (event.type) {
|
||||
case "scroll-up":
|
||||
this.selectedRow = (this.selectedRow + ROWS.length - 1) % ROWS.length;
|
||||
return;
|
||||
case "scroll-down":
|
||||
this.selectedRow = (this.selectedRow + 1) % ROWS.length;
|
||||
return;
|
||||
case "click": {
|
||||
const row = ROWS[this.selectedRow]!;
|
||||
if (this.rowDisabled(row)) return;
|
||||
if (row === "face") this.openFaceMenu(ctx);
|
||||
else if (row === "weight") this.openWeightMenu(ctx);
|
||||
else if (row === "size") this.openSizeMenu(ctx);
|
||||
else {
|
||||
this.options.set(this.draftSelection());
|
||||
ctx.stack.pop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private openFaceMenu(ctx: LayerContext): void {
|
||||
const items: MenuItem[] = [];
|
||||
for (const bitmap of this.options.bitmapFaces) {
|
||||
items.push({
|
||||
label: `${bitmap.label} (bitmap)`,
|
||||
onSelect: (innerCtx) => {
|
||||
this.draft = { kind: "bitmap", face: bitmap.face };
|
||||
innerCtx.stack.pop();
|
||||
},
|
||||
});
|
||||
}
|
||||
for (const family of this.families) {
|
||||
items.push({
|
||||
label: family.label,
|
||||
onSelect: (innerCtx) => {
|
||||
this.setFamily(family);
|
||||
innerCtx.stack.pop();
|
||||
},
|
||||
});
|
||||
}
|
||||
const currentIndex =
|
||||
this.draft.kind === "bitmap"
|
||||
? Math.max(0, this.options.bitmapFaces.findIndex((b) => b.face === (this.draft as { face: BitmapFace }).face))
|
||||
: this.options.bitmapFaces.length + this.families.indexOf(this.draft.family);
|
||||
openModalMenu(ctx, "Font", items, Math.max(0, currentIndex));
|
||||
}
|
||||
|
||||
/** Switch families, carrying the weight (nearest available) and size over. */
|
||||
private setFamily(family: FontFamily): void {
|
||||
const previous = this.draft;
|
||||
const targetOrder = previous.kind === "ttf" ? previous.font.weightOrder : 400;
|
||||
const size = previous.kind === "ttf" ? previous.size : DEFAULT_TTF_SIZE;
|
||||
let font = family.fonts[0]!;
|
||||
for (const candidate of family.fonts) {
|
||||
if (Math.abs(candidate.weightOrder - targetOrder) < Math.abs(font.weightOrder - targetOrder)) {
|
||||
font = candidate;
|
||||
}
|
||||
}
|
||||
this.draft = { kind: "ttf", family, font, size };
|
||||
}
|
||||
|
||||
private openWeightMenu(ctx: LayerContext): void {
|
||||
if (this.draft.kind !== "ttf") return;
|
||||
const draft = this.draft;
|
||||
const items = draft.family.fonts.map((font): MenuItem => ({
|
||||
label: font.style || "Regular",
|
||||
onSelect: (innerCtx) => {
|
||||
this.draft = { ...draft, font };
|
||||
innerCtx.stack.pop();
|
||||
},
|
||||
}));
|
||||
openModalMenu(ctx, "Weight", items, Math.max(0, draft.family.fonts.indexOf(draft.font)));
|
||||
}
|
||||
|
||||
private openSizeMenu(ctx: LayerContext): void {
|
||||
if (this.draft.kind !== "ttf") return;
|
||||
const draft = this.draft;
|
||||
const items = SIZE_CHOICES.map((size): MenuItem => ({
|
||||
label: String(size),
|
||||
onSelect: (innerCtx) => {
|
||||
this.draft = { ...draft, size };
|
||||
innerCtx.stack.pop();
|
||||
},
|
||||
}));
|
||||
openModalMenu(ctx, "Size", items, Math.max(0, SIZE_CHOICES.indexOf(draft.size as (typeof SIZE_CHOICES)[number])));
|
||||
}
|
||||
}
|
||||
|
||||
/** Installed fonts grouped into families (styles sorted by weight). */
|
||||
function collectFamilies(monospaceOnly: boolean): FontFamily[] {
|
||||
const byLabel = new Map<string, FontFamily>();
|
||||
for (const font of listInstalledFonts()) {
|
||||
if (monospaceOnly && !font.monospace) continue;
|
||||
let family = byLabel.get(font.family);
|
||||
if (!family) {
|
||||
family = { label: font.family, fonts: [] };
|
||||
byLabel.set(font.family, family);
|
||||
}
|
||||
family.fonts.push(font);
|
||||
}
|
||||
return [...byLabel.values()];
|
||||
}
|
||||
|
||||
/** Settings row for the UI font: label + current value, opens the picker. */
|
||||
export function uiFontPickerMenuItem(): MenuItem {
|
||||
return fontPickerMenuItem({
|
||||
rowLabel: "Font",
|
||||
description:
|
||||
"Typeface for UI text on the glasses: a bitmap Terminus variant or any installed TTF face at a chosen weight and size. Install more fonts from the Files app.",
|
||||
title: "UI font",
|
||||
monospaceOnly: false,
|
||||
bitmapFaces: [
|
||||
{ face: "terminus", label: "Terminus" },
|
||||
{ face: "terminusv", label: "TerminusV" },
|
||||
],
|
||||
get: getUiFontSelection,
|
||||
set: setUiFontSelection,
|
||||
});
|
||||
}
|
||||
|
||||
/** Settings row for the terminal font (monospace faces only). */
|
||||
export function terminalFontPickerMenuItem(): MenuItem {
|
||||
return fontPickerMenuItem({
|
||||
rowLabel: "Font",
|
||||
description:
|
||||
"Typeface for terminal windows, limited to fixed-width faces. Takes effect for newly opened terminal windows.",
|
||||
title: "Terminal font",
|
||||
monospaceOnly: true,
|
||||
bitmapFaces: [{ face: "terminus", label: "Terminus" }],
|
||||
get: getTerminalFontSelection,
|
||||
set: setTerminalFontSelection,
|
||||
});
|
||||
}
|
||||
|
||||
function fontPickerMenuItem(options: FontPickerOptions & { rowLabel: string; description: string }): MenuItem {
|
||||
return {
|
||||
label: options.rowLabel,
|
||||
description: options.description,
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.push(new FontPickerLayer(options));
|
||||
},
|
||||
render: ({ image, x, y, width }) => {
|
||||
drawRightValueMenuItem(
|
||||
image,
|
||||
getDefaultSmallFont(),
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
options.rowLabel,
|
||||
fontSelectionLabel(options.get()),
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
+8
-2
@@ -103,8 +103,8 @@ export interface Layer {
|
||||
export class LayerStack {
|
||||
private readonly layers: Layer[];
|
||||
private readonly ctx: LayerContext;
|
||||
private readonly baseWidth: number;
|
||||
private readonly baseHeight: number;
|
||||
private baseWidth: number;
|
||||
private baseHeight: number;
|
||||
private readonly focusedFn: () => boolean;
|
||||
|
||||
constructor(
|
||||
@@ -168,6 +168,12 @@ export class LayerStack {
|
||||
return { width: this.baseWidth, height: this.baseHeight };
|
||||
}
|
||||
|
||||
/** Resize the base viewport (e.g. an EvenHub window switching to the tall canvas). */
|
||||
setBaseSize(size: { width: number; height: number }): void {
|
||||
this.baseWidth = size.width;
|
||||
this.baseHeight = size.height;
|
||||
}
|
||||
|
||||
setActions(actions: Partial<LayerActions>): void {
|
||||
Object.assign(this.ctx.actions, actions);
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage, type UiFont } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { getDefaultSmallFont, type BdfFont } from "../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { clamp } from "../util/numeric-util";
|
||||
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "./layers";
|
||||
|
||||
@@ -121,7 +121,7 @@ export function drawListScrollbar(
|
||||
*/
|
||||
export function drawSubmenuIndicator(
|
||||
image: GrayImage,
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
highlightX: number,
|
||||
highlightY: number,
|
||||
highlightWidth: number,
|
||||
@@ -136,7 +136,7 @@ export function drawSubmenuIndicator(
|
||||
|
||||
export function drawToggleMenuItem(
|
||||
image: GrayImage,
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
@@ -159,7 +159,7 @@ export function drawToggleMenuItem(
|
||||
|
||||
export function drawRightValueMenuItem(
|
||||
image: GrayImage,
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { clamp } from "~/util/numeric-util";
|
||||
import { formatRelativeTime } from "~/util/date-util";
|
||||
import { BdfFont, getDefaultSmallFont } from "../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { truncateText } from "../graphics/textwrap";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { GrayImage, type UiFont } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import {
|
||||
@@ -237,7 +237,7 @@ export class SingleNotificationLayer implements Layer {
|
||||
|
||||
|
||||
function buildNotificationCardLayout(
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
notification: AndroidNotification,
|
||||
selected: boolean,
|
||||
cardTextWidth: number,
|
||||
@@ -273,7 +273,7 @@ function buildNotificationCardLayout(
|
||||
|
||||
function drawNotificationCard(
|
||||
image: GrayImage,
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
layout: CardLayout,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -313,7 +313,7 @@ function scrollForSelected(layouts: CardLayout[], selectedIndex: number, viewpor
|
||||
|
||||
function drawDetailContent(
|
||||
image: GrayImage,
|
||||
font: BdfFont,
|
||||
font: UiFont,
|
||||
notification: AndroidNotification,
|
||||
icon: GrayImage | null,
|
||||
width: number,
|
||||
@@ -353,7 +353,7 @@ function drawDetailContent(
|
||||
}
|
||||
}
|
||||
|
||||
function drawDetailMenu(image: GrayImage, font: BdfFont, menu: DetailMenuItem[], selectedIndex: number, width: number): void {
|
||||
function drawDetailMenu(image: GrayImage, font: UiFont, menu: DetailMenuItem[], selectedIndex: number, width: number): void {
|
||||
const menuX = width - DETAIL_MENU_WIDTH - 24;
|
||||
const menuY = 24;
|
||||
for (let index = 0; index < menu.length; index++) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont";
|
||||
import { type BdfFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { GESTURE_DOUBLE_CLICK } from "../gestures";
|
||||
import { drawSelectionHighlight } from "../menu";
|
||||
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { BATTERY_ICON_WIDTH, drawBattery } from "../../graphics/battery";
|
||||
import { readActiveNotificationIcons } from "../../native/notification-icons";
|
||||
import { readPhoneBatteryState } from "../../native/phone-battery";
|
||||
|
||||
@@ -41,6 +41,8 @@ export type InProcessWindowOptions = {
|
||||
submitFrame: (planes: Plane[], paintMs: number, frameId: number) => Promise<void>;
|
||||
setSurfaceVisible: (visible: boolean) => void;
|
||||
removeSurface?: () => void;
|
||||
/** Resize this window's compositor surface after a height-mode change. */
|
||||
reconfigureSurface?: (heightMode: WindowHeightMode) => void;
|
||||
onClosed?: () => void;
|
||||
};
|
||||
|
||||
@@ -48,6 +50,8 @@ export type InProcessWindow = {
|
||||
window: ShellWindow;
|
||||
stack: LayerStack;
|
||||
requestRender: () => void;
|
||||
/** Change the window's height band at runtime (resizes the viewport + surface). */
|
||||
setHeightMode: (mode: WindowHeightMode) => void;
|
||||
};
|
||||
|
||||
/** The controller-provided plumbing common to every in-process app window. */
|
||||
@@ -56,6 +60,7 @@ export type InProcessAppOptions = {
|
||||
submitFrame: (planes: Plane[], paintMs: number, frameId: number) => Promise<void>;
|
||||
setSurfaceVisible: (visible: boolean) => void;
|
||||
removeSurface: () => void;
|
||||
reconfigureSurface?: (heightMode: WindowHeightMode) => void;
|
||||
onClosed: () => void;
|
||||
};
|
||||
|
||||
@@ -65,7 +70,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
console.error(`${options.windowId} render failed: ${error}`);
|
||||
});
|
||||
};
|
||||
const heightMode = options.heightMode ?? "min";
|
||||
let heightMode = options.heightMode ?? "min";
|
||||
const stack = new LayerStack(
|
||||
options.baseLayer,
|
||||
{ ...options.actions, requestRender },
|
||||
@@ -168,7 +173,15 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
options.setSurfaceVisible(foreground);
|
||||
},
|
||||
};
|
||||
return { window, stack, requestRender };
|
||||
const setHeightMode = (mode: WindowHeightMode) => {
|
||||
if (heightMode === mode) return;
|
||||
heightMode = mode;
|
||||
window.heightMode = mode;
|
||||
stack.setBaseSize(appViewportSize(mode));
|
||||
options.reconfigureSurface?.(mode);
|
||||
requestRender();
|
||||
};
|
||||
return { window, stack, requestRender, setHeightMode };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { EvenAIStatus, EventSourceType, OsEventTypeList } from "../../g2/events";
|
||||
import type { RawInputEvent } from "../../native/faceclaw-communicator";
|
||||
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import type { ToolDebugEntry } from "../../assistant/tool-registry";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { wrapText, truncateText } from "../../graphics/textwrap";
|
||||
import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont";
|
||||
import { type BdfFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { voiceControlBridge, type VoiceTranscriptEvent } from "../../native/voice-control";
|
||||
import { refineDictation, type AnthropicStreamHandle } from "../../native/anthropic";
|
||||
import { anthropicApiKeySetting } from "../dashboard-settings";
|
||||
|
||||
Reference in new issue
Block a user