forked from Blendman974/faceclaw
Sidebar uses icons for apps
This commit is contained in:
1 parent
d0c30f9ca9
commit
22c779553c
27 files changed
+379
-37
No files matched your search
@@ -2,6 +2,8 @@ import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL } from "../gestures";
|
||||
import { drawSelectionHighlight } from "../menu";
|
||||
import {
|
||||
buildSoundSequencePayload,
|
||||
CFW_SEQ_MAX,
|
||||
@@ -36,7 +38,7 @@ export class BuzzerDemoLayer implements Layer {
|
||||
const image = new GrayImage(width, height, 0);
|
||||
|
||||
image.drawText(font, 20, 8, "Buzzer demo", 220);
|
||||
const status = this.playing ? `Playing: ${this.playing}` : "Click to play";
|
||||
const status = this.playing ? `Playing: ${this.playing}` : `${GESTURE_CLICK} play`;
|
||||
image.drawText(font, width - 24 - font.measureText(status), 8, status, 140);
|
||||
|
||||
const listHeight = height - HEADER_HEIGHT - FOOTER_HEIGHT;
|
||||
@@ -54,14 +56,13 @@ export class BuzzerDemoLayer implements Layer {
|
||||
const y = HEADER_HEIGHT + (index - this.scrollRow) * ROW_HEIGHT;
|
||||
const selected = index === this.selectedIndex;
|
||||
if (selected) {
|
||||
image.fillRoundedRect(LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, 15, 4);
|
||||
image.drawRoundedRect(LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, 45, 4);
|
||||
drawSelectionHighlight(image, LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, ctx.stack.isFocused(), 4);
|
||||
}
|
||||
image.drawText(font, LIST_X, y + 1, effect.name, selected ? 255 : 200);
|
||||
image.drawText(font, LIST_X + 110, y + 1, effect.desc, selected ? 180 : 120);
|
||||
}
|
||||
|
||||
image.drawText(font, 20, height - 16, "Scroll: select Click: play Double-click: back", 110);
|
||||
image.drawText(font, 20, height - 16, `${GESTURE_SCROLL} select ${GESTURE_CLICK} play ${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK } from "../gestures";
|
||||
import { drawSelectionHighlight } from "../menu";
|
||||
import {
|
||||
hasAllFilesAccess,
|
||||
listDirectory,
|
||||
@@ -70,14 +72,13 @@ export class FileBrowserLayer implements Layer {
|
||||
const y = HEADER_HEIGHT + (index - this.scrollRow) * ROW_HEIGHT;
|
||||
const selected = index === this.selectedIndex;
|
||||
if (selected) {
|
||||
image.fillRoundedRect(LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, 15, 4);
|
||||
image.drawRoundedRect(LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, 45, 4);
|
||||
drawSelectionHighlight(image, LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, ctx.stack.isFocused(), 4);
|
||||
}
|
||||
const value = rowValue(row, selected);
|
||||
image.drawText(font, LIST_X, y + 1, truncateRight(font, row.label, width - 2 * LIST_X), value);
|
||||
}
|
||||
|
||||
image.drawText(font, 20, height - 16, "Click: open Double-click: up / back", 110);
|
||||
image.drawText(font, 20, height - 16, `${GESTURE_CLICK} open ${GESTURE_DOUBLE_CLICK} up / back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { nightscoutBridge, type NightscoutState } from "../../native/nightscout-
|
||||
import { isNightscoutSettingsConfigured } from "../dashboard-settings";
|
||||
import { formatAgeShortFromTimestamp, formatTimestamp } from "~/util/date-util";
|
||||
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK } from "../gestures";
|
||||
const nightscoutLargeFont = getDefaultLargeFont();
|
||||
const NIGHTSCOUT_STALE_MS = 15 * 60 * 1000;
|
||||
const NIGHTSCOUT_GRAPH_WINDOW_MS = 2 * 60 * 60 * 1000;
|
||||
@@ -294,7 +295,6 @@ export class NightscoutLayer implements Layer {
|
||||
const nightscout = nightscoutBridge.snapshot();
|
||||
const nowMs = Date.now();
|
||||
const footerY = height - 26;
|
||||
image.drawRect(12, 12, width - 24, height - 24, 52);
|
||||
image.drawText(font, 22, 16, "Nightscout", 220);
|
||||
|
||||
if (!isNightscoutSettingsConfigured() || nightscout.configurationMissing) {
|
||||
@@ -306,7 +306,7 @@ export class NightscoutLayer implements Layer {
|
||||
if (!nightscout.available || !nightscout.latest) {
|
||||
image.drawText(font, 22, 44, "No Nightscout data available.", 180);
|
||||
image.drawText(font, 22, 58, truncateLine(nightscout.status, 60), 140);
|
||||
image.drawText(font, 22, footerY, "Click: refresh Double-click: back", 110);
|
||||
image.drawText(font, 22, footerY, `${GESTURE_CLICK} refresh ${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ export class NightscoutLayer implements Layer {
|
||||
const graphHeight = Math.max(40, height - 128 - 48);
|
||||
drawNightscoutGraph(image, { x: 22, y: 128, width: width - 44, height: graphHeight }, nightscout, nowMs, font);
|
||||
image.drawText(font, 22, height - 42, "2-hour glucose history with basal / carbs / boluses", 130);
|
||||
image.drawText(font, 22, footerY, "Click: refresh Double-click: back", 110);
|
||||
image.drawText(font, 22, footerY, `${GESTURE_CLICK} refresh ${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ export class TelepromptLayer implements Layer {
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const footerY = height - FOOTER_MARGIN;
|
||||
this.bodyLineCount = Math.max(1, Math.floor((footerY - BODY_Y) / LINE_STEP));
|
||||
image.drawRect(12, 12, width - 24, height - 24, 52);
|
||||
image.drawText(font, MARGIN_X + 4, TITLE_Y, truncateToWidth(font, this.title, width - 2 * MARGIN_X - 8), 220);
|
||||
|
||||
const lines = this.getLines(font, width);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Layer, type DashboardInputEvent, type LayerContext } from "../layers";
|
||||
* (createTranscribeAppWindow); this layer accumulates the transcript, shows
|
||||
* it, and saves it to Downloads on click.
|
||||
*/
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK } from "../gestures";
|
||||
export class TranscribeLayer implements Layer {
|
||||
private status = "Listening...";
|
||||
// Finalized utterances, plus the live (replace-semantics) partial appended
|
||||
@@ -37,7 +38,6 @@ export class TranscribeLayer implements Layer {
|
||||
const text = this.displayText() || "Listening...";
|
||||
const wrapped = wrapTranscribeText(font, text, width - 64);
|
||||
|
||||
image.drawRect(12, 12, width - 24, height - 24, 52);
|
||||
image.drawText(font, 24, 20, "Transcribe", 200);
|
||||
image.drawText(font, 24, 40, this.saveNotice || this.status, 110);
|
||||
|
||||
@@ -50,7 +50,7 @@ export class TranscribeLayer implements Layer {
|
||||
image.drawText(font, 32, y, wrapped[index]!, 230);
|
||||
}
|
||||
|
||||
image.drawText(font, 24, footerY, "Click: save Double-click: back", 110);
|
||||
image.drawText(font, 24, footerY, `${GESTURE_CLICK} save ${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import {
|
||||
getBooleanSetting,
|
||||
getStringSetting,
|
||||
@@ -430,14 +431,13 @@ export class EditTextSettingLayer implements Layer {
|
||||
// viewport in the settings app).
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
image.drawRect(12, 12, width - 24, height - 24, 52);
|
||||
image.drawText(font, 22, 16, this.setting.glassesEditTitle, 220);
|
||||
const message = wrapText(font, "Look at the phone app to type a value.", width - 48);
|
||||
for (let index = 0; index < message.length; index++) {
|
||||
image.drawText(font, 22, 52 + index * 14, message[index]!, 200);
|
||||
}
|
||||
image.drawText(font, 22, 110, truncateSetting(this.setting.get(), 52), 220);
|
||||
image.drawText(font, 22, height - 36, "Double-click to go back", 110);
|
||||
image.drawText(font, 22, height - 36, `${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Compact glyphs for the ring gestures, used in on-glasses hint text instead
|
||||
* of spelling the gesture out. All codepoints exist in terminus12/16.
|
||||
*
|
||||
* click · (U+00B7 middle dot)
|
||||
* double-click ·· (twice)
|
||||
* scroll ▲▼ (U+25B2 / U+25BC)
|
||||
* long-press - (hyphen-minus)
|
||||
*/
|
||||
export const GESTURE_CLICK = "·";
|
||||
export const GESTURE_DOUBLE_CLICK = "··";
|
||||
export const GESTURE_SCROLL_UP = "▲";
|
||||
export const GESTURE_SCROLL_DOWN = "▼";
|
||||
export const GESTURE_SCROLL = "▲▼";
|
||||
export const GESTURE_LONG_PRESS = "-";
|
||||
|
||||
/**
|
||||
* Join "glyph action" hint pairs into a single line, e.g.
|
||||
* gestureHints([[GESTURE_CLICK, "save"], [GESTURE_DOUBLE_CLICK, "back"]])
|
||||
* => "· save ·· back"
|
||||
*/
|
||||
export function gestureHints(pairs: Array<[string, string]>): string {
|
||||
return pairs.map(([glyph, action]) => `${glyph} ${action}`).join(" ");
|
||||
}
|
||||
+15
-1
@@ -57,8 +57,17 @@ export class LayerStack {
|
||||
private readonly ctx: LayerContext;
|
||||
private readonly baseWidth: number;
|
||||
private readonly baseHeight: number;
|
||||
private readonly focusedFn: () => boolean;
|
||||
|
||||
constructor(baseLayer: Layer, actions: LayerActions, baseSize?: { width: number; height: number }) {
|
||||
constructor(
|
||||
baseLayer: Layer,
|
||||
actions: LayerActions,
|
||||
baseSize?: { width: number; height: number },
|
||||
// Whether this stack is the current input target; drives the strength of
|
||||
// selection highlights (a visible-but-unfocused window dims its selection).
|
||||
// Defaults to always-focused for shell overlays and standalone stacks.
|
||||
isFocused: () => boolean = () => true,
|
||||
) {
|
||||
this.layers = [baseLayer];
|
||||
this.ctx = {
|
||||
stack: this,
|
||||
@@ -66,6 +75,11 @@ export class LayerStack {
|
||||
};
|
||||
this.baseWidth = baseSize?.width ?? G2_LENS_WIDTH;
|
||||
this.baseHeight = baseSize?.height ?? G2_LENS_HEIGHT;
|
||||
this.focusedFn = isFocused;
|
||||
}
|
||||
|
||||
isFocused(): boolean {
|
||||
return this.focusedFn();
|
||||
}
|
||||
|
||||
push(layer: Layer): void {
|
||||
|
||||
+32
-3
@@ -4,6 +4,7 @@ import { getDefaultSmallFont, type BdfFont } from "../graphics/bdffont";
|
||||
import { clamp } from "../util/numeric-util";
|
||||
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "./layers";
|
||||
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
const DEFAULT_MENU_X = 8;
|
||||
const DEFAULT_MENU_Y = 8;
|
||||
const DEFAULT_MENU_WIDTH = 272;
|
||||
@@ -46,6 +47,26 @@ export type MenuItem = {
|
||||
render?: (args: MenuItemRenderArgs) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Draw a selection highlight for a list row. A focused list fills the row and
|
||||
* outlines it; a visible-but-unfocused list draws only the outline, so the
|
||||
* selection stays legible without implying it will receive input.
|
||||
*/
|
||||
export function drawSelectionHighlight(
|
||||
image: GrayImage,
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
focused: boolean,
|
||||
radius = 6,
|
||||
): void {
|
||||
if (focused) {
|
||||
image.fillRoundedRect(x, y, width, height, MENU_HIGHLIGHT_SELECTED_BACKGROUND_FILL, radius);
|
||||
}
|
||||
image.drawRoundedRect(x, y, width, height, MENU_HIGHLIGHT_SELECTED_BORDER_STROKE, radius);
|
||||
}
|
||||
|
||||
export function drawToggleMenuItem(
|
||||
image: GrayImage,
|
||||
font: BdfFont,
|
||||
@@ -122,14 +143,22 @@ export class MenuLayer implements Layer {
|
||||
}
|
||||
|
||||
const bodyY = y + chromeTop;
|
||||
const focused = ctx.stack.isFocused();
|
||||
const lastVisibleRow = Math.min(this.items.length, this.scrollRow + visibleRowCount);
|
||||
for (let index = this.scrollRow; index < lastVisibleRow; index++) {
|
||||
const item = this.items[index]!;
|
||||
const rowY = bodyY + (index - this.scrollRow) * MENU_ROW_HEIGHT;
|
||||
const selected = index === this.selectedIndex;
|
||||
if (selected) {
|
||||
image.fillRoundedRect(x + 12, rowY + MENU_HIGHLIGHT_Y_OFFSET, width - 24, MENU_HIGHLIGHT_HEIGHT, MENU_HIGHLIGHT_SELECTED_BACKGROUND_FILL);
|
||||
image.drawRoundedRect(x + 12, rowY + MENU_HIGHLIGHT_Y_OFFSET, width - 24, MENU_HIGHLIGHT_HEIGHT, MENU_HIGHLIGHT_SELECTED_BORDER_STROKE);
|
||||
drawSelectionHighlight(
|
||||
image,
|
||||
x + 12,
|
||||
rowY + MENU_HIGHLIGHT_Y_OFFSET,
|
||||
width - 24,
|
||||
MENU_HIGHLIGHT_HEIGHT,
|
||||
focused,
|
||||
8,
|
||||
);
|
||||
}
|
||||
if (item.render) {
|
||||
item.render({
|
||||
@@ -214,7 +243,7 @@ export class TextPageLayer implements Layer {
|
||||
for (let index = 0; index < wrapped.length; index++) {
|
||||
image.drawText(font, 24, 42 + index * 14, wrapped[index]!, 190);
|
||||
}
|
||||
image.drawText(font, 24, 252, "Double-click to go back", 110);
|
||||
image.drawText(font, 24, 252, `${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { formatRelativeTime } from "~/util/date-util";
|
||||
import { BdfFont, getDefaultSmallFont } from "../graphics/bdffont";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import {
|
||||
dismissNotification,
|
||||
invokeNotificationAction,
|
||||
@@ -81,7 +82,7 @@ export class NotificationsListLayer implements Layer {
|
||||
|
||||
if (!notifications.length) {
|
||||
image.drawText(font, 24, 72, "No current Android notifications.", 190);
|
||||
image.drawText(font, 24, height - 36, "Double-click: back to sidebar", 110);
|
||||
image.drawText(font, 24, height - 36, `${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { readActiveNotificationIcons } from "../../native/notification-icons";
|
||||
import { readPhoneBatteryState } from "../../native/phone-battery";
|
||||
import { noteStaleDataUsed, renderPassAllowsStaleData } from "../../util/render-freshness";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { renderIcon, type IconName } from "../../graphics/icons";
|
||||
import { batteryDisplayModeSetting } from "../dashboard-settings";
|
||||
import { Layer } from "../layers";
|
||||
import { SHELL_OPAQUE_BLACK, SIDEBAR_WIDTH, TOP_BAR_HEIGHT } from "./geometry";
|
||||
@@ -33,7 +34,7 @@ export type ShellChromeState = {
|
||||
trayIcons: GrayImage[];
|
||||
};
|
||||
|
||||
/** Reusable placeholder window icon: rounded outline with a single letter. */
|
||||
/** Placeholder window icon: rounded outline with a single letter. */
|
||||
export function makeLetterWindowIcon(letter: string): ShellChromeWindow["drawIcon"] {
|
||||
return (image, x, y, size) => {
|
||||
const font = getDefaultMediumFont();
|
||||
@@ -44,6 +45,22 @@ export function makeLetterWindowIcon(letter: string): ShellChromeWindow["drawIco
|
||||
};
|
||||
}
|
||||
|
||||
/** Window icon rendered from an SVG (Lucide), rendered once per size and cached. */
|
||||
export function makeSvgWindowIcon(name: IconName): ShellChromeWindow["drawIcon"] {
|
||||
return (image, x, y, size) => {
|
||||
const icon = renderIcon(name, size);
|
||||
if (!icon) return;
|
||||
const dx = x + Math.max(0, ((size - icon.width) / 2) | 0);
|
||||
const dy = y + Math.max(0, ((size - icon.height) / 2) | 0);
|
||||
image.bitBlt(icon, dx, dy, { transparentZero: true });
|
||||
};
|
||||
}
|
||||
|
||||
/** SVG icon when a name is given, else the letter placeholder. */
|
||||
export function windowIcon(icon: IconName | undefined, letter: string): ShellChromeWindow["drawIcon"] {
|
||||
return icon ? makeSvgWindowIcon(icon) : makeLetterWindowIcon(letter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base layer of the shell surface: the window sidebar on the left and the
|
||||
* status top bar. Everything not explicitly painted stays 0 (transparent on
|
||||
|
||||
@@ -43,6 +43,7 @@ export function createDebugTestsAppWindow(options: InProcessAppOptions): InProce
|
||||
windowId: DEBUG_TESTS_WINDOW_ID,
|
||||
title: "Debug tests",
|
||||
iconLetter: "Db",
|
||||
icon: "flask-conical",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(menu),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { beginRenderPass, endRenderPass } from "../../util/render-freshness";
|
||||
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { makeLetterWindowIcon } from "./chrome-layer";
|
||||
import { windowIcon } from "./chrome-layer";
|
||||
import { type IconName } from "../../graphics/icons";
|
||||
import { APP_VIEWPORT } from "./geometry";
|
||||
import { shell, type ShellWindow } from "./shell";
|
||||
|
||||
@@ -17,6 +18,8 @@ export type InProcessWindowOptions = {
|
||||
windowId: string;
|
||||
title: string;
|
||||
iconLetter: string;
|
||||
/** Lucide icon name for the sidebar indicator; falls back to iconLetter. */
|
||||
icon?: IconName;
|
||||
closeable: boolean;
|
||||
/** Shared actions; requestRender is rebound to this window's render. */
|
||||
actions: LayerActions;
|
||||
@@ -52,6 +55,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
options.baseLayer,
|
||||
{ ...options.actions, requestRender },
|
||||
{ width: APP_VIEWPORT.width, height: APP_VIEWPORT.height },
|
||||
() => shell.isWindowFocused(options.windowId),
|
||||
);
|
||||
|
||||
// Data sources with caches (e.g. notification icons) may serve stale data
|
||||
@@ -83,7 +87,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
options.onClosed?.();
|
||||
options.removeSurface?.();
|
||||
},
|
||||
drawIcon: makeLetterWindowIcon(options.iconLetter),
|
||||
drawIcon: windowIcon(options.icon, options.iconLetter),
|
||||
handleInput: async (event, frameId) => {
|
||||
await stack.handleInput(event);
|
||||
await render(frameId);
|
||||
|
||||
@@ -50,6 +50,7 @@ export function createLauncherWindow(options: LauncherOptions): ShellWindow {
|
||||
windowId: LAUNCHER_WINDOW_ID,
|
||||
title: "Apps",
|
||||
iconLetter: "A",
|
||||
icon: "layout-grid",
|
||||
closeable: false,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(menu),
|
||||
|
||||
@@ -2,6 +2,8 @@ import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL } from "../gestures";
|
||||
import { drawSelectionHighlight } from "../menu";
|
||||
import {
|
||||
mediaControllerBridge,
|
||||
type MediaControllerState,
|
||||
@@ -63,14 +65,14 @@ class MusicAppLayer implements Layer {
|
||||
for (let index = 0; index < lines.length; index++) {
|
||||
image.drawText(font, 24, 44 + index * 14, lines[index]!, 180);
|
||||
}
|
||||
image.drawText(font, 20, height - 16, "Click: open settings Double-click: back", 110);
|
||||
image.drawText(font, 20, height - 16, `${GESTURE_CLICK} open settings ${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
if (!media.available) {
|
||||
image.drawText(font, 24, 44, "No active media session.", 180);
|
||||
image.drawText(font, 24, 62, "Start playback in another app on the phone.", 150);
|
||||
image.drawText(font, 20, height - 16, "Double-click: back to sidebar", 110);
|
||||
image.drawText(font, 20, height - 16, `${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -104,14 +106,13 @@ class MusicAppLayer implements Layer {
|
||||
const y = LIST_TOP + (index - this.scrollRow) * ROW_HEIGHT;
|
||||
const selected = index === this.selectedIndex;
|
||||
if (selected) {
|
||||
image.fillRoundedRect(LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, 15, 4);
|
||||
image.drawRoundedRect(LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, 45, 4);
|
||||
drawSelectionHighlight(image, LIST_X - 6, y - 1, width - 2 * LIST_X + 12, ROW_HEIGHT - 1, ctx.stack.isFocused(), 4);
|
||||
}
|
||||
const value = !row.enabled ? (selected ? 130 : 90) : selected ? 255 : 200;
|
||||
image.drawText(font, LIST_X, y + 1, truncate(font, row.label, width - 2 * LIST_X), value);
|
||||
}
|
||||
|
||||
image.drawText(font, 20, height - 16, "Scroll: select Click: activate Double-click: back", 110);
|
||||
image.drawText(font, 20, height - 16, `${GESTURE_SCROLL} select ${GESTURE_CLICK} activate ${GESTURE_DOUBLE_CLICK} back`, 110);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -198,6 +199,7 @@ export function createMusicAppWindow(options: InProcessAppOptions): InProcessWin
|
||||
windowId: MUSIC_WINDOW_ID,
|
||||
title: "Music",
|
||||
iconLetter: "M",
|
||||
icon: "music",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(new MusicAppLayer()),
|
||||
|
||||
@@ -32,6 +32,7 @@ export function createNightscoutAppWindow(options: InProcessAppOptions): InProce
|
||||
windowId: NIGHTSCOUT_WINDOW_ID,
|
||||
title: "Nightscout",
|
||||
iconLetter: "Ns",
|
||||
icon: "activity",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(new NightscoutLayer()),
|
||||
|
||||
@@ -20,6 +20,7 @@ export function createNotificationsAppWindow(options: InProcessAppOptions): InPr
|
||||
windowId: NOTIFICATIONS_WINDOW_ID,
|
||||
title: "Notifications",
|
||||
iconLetter: "N",
|
||||
icon: "bell",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(new NotificationsListLayer()),
|
||||
|
||||
@@ -37,6 +37,7 @@ export function createSettingsAppWindow(options: SettingsAppOptions): SettingsAp
|
||||
windowId: SETTINGS_WINDOW_ID,
|
||||
title: "Settings",
|
||||
iconLetter: "Se",
|
||||
icon: "settings",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(createSettingsMenuLayer()),
|
||||
|
||||
@@ -334,6 +334,11 @@ class Shell {
|
||||
return this.windows[this.selectedIndex] ?? this.windows[0];
|
||||
}
|
||||
|
||||
/** Whether a window is the current input target (foreground + focus in-window). */
|
||||
isWindowFocused(windowId: string): boolean {
|
||||
return this.screenOn && this.focus === "window" && this.foregroundWindow()?.windowId === windowId;
|
||||
}
|
||||
|
||||
private handleSidebarInput(event: DashboardInputEvent): ShellInputOutcome {
|
||||
switch (event.type) {
|
||||
case "double-click":
|
||||
|
||||
@@ -42,6 +42,7 @@ export function createTelepromptBrowserWindow(options: TelepromptBrowserOptions)
|
||||
windowId: TELEPROMPT_WINDOW_ID,
|
||||
title: "Teleprompt",
|
||||
iconLetter: "Tp",
|
||||
icon: "file-text",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: browser,
|
||||
@@ -64,6 +65,7 @@ export function createTelepromptDocumentWindow(
|
||||
windowId,
|
||||
title,
|
||||
iconLetter: "Tp",
|
||||
icon: "file-text",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(new TelepromptLayer(text, title)),
|
||||
|
||||
@@ -55,6 +55,7 @@ export function createTranscribeAppWindow(options: TranscribeAppOptions): InProc
|
||||
windowId: TRANSCRIBE_WINDOW_ID,
|
||||
title: "Transcribe",
|
||||
iconLetter: "Tr",
|
||||
icon: "mic",
|
||||
closeable: true,
|
||||
actions,
|
||||
baseLayer: new YieldAtRootLayer(layer),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { makeLetterWindowIcon } from "./chrome-layer";
|
||||
import { windowIcon } from "./chrome-layer";
|
||||
import { type IconName } from "../../graphics/icons";
|
||||
import { shell, type ShellWindow } from "./shell";
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,7 @@ export type WorkerAppReply =
|
||||
windowId: string;
|
||||
title: string;
|
||||
iconLetter: string;
|
||||
icon?: IconName;
|
||||
focus?: boolean;
|
||||
}
|
||||
| { type: "set-title"; windowId: string; title: string }
|
||||
@@ -43,6 +45,8 @@ export type WorkerWindowSpec = {
|
||||
windowId: string;
|
||||
title: string;
|
||||
iconLetter: string;
|
||||
/** Lucide icon name for the sidebar indicator; falls back to iconLetter. */
|
||||
icon?: IconName;
|
||||
/** Foreground and focus the window once its surface exists. */
|
||||
focus?: boolean;
|
||||
};
|
||||
@@ -84,6 +88,7 @@ export class WorkerAppHost {
|
||||
windowId: message.windowId,
|
||||
title: message.title,
|
||||
iconLetter: message.iconLetter,
|
||||
icon: message.icon,
|
||||
focus: message.focus,
|
||||
});
|
||||
break;
|
||||
@@ -134,7 +139,7 @@ export class WorkerAppHost {
|
||||
this.post({ type: "close-window", windowId: spec.windowId });
|
||||
this.options.removeSurface(surfaceId);
|
||||
},
|
||||
drawIcon: makeLetterWindowIcon(spec.iconLetter),
|
||||
drawIcon: windowIcon(spec.icon, spec.iconLetter),
|
||||
handleInput: (event, frameId) => {
|
||||
this.post({ type: "input", windowId: spec.windowId, event, frameId });
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user