forked from Blendman974/faceclaw
Glanceboard has separately configurable font
This commit is contained in:
1 parent
def027943c
commit
4bc3551135
12 files changed
+187
-65
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import { UiFontOverride } from "../../graphics/ui-fonts";
|
||||
|
||||
/**
|
||||
* The font Glanceboard widgets paint with: the Glanceboard's own Font
|
||||
* setting, or the Display UI font while that is unset. Its small, medium and
|
||||
* large roles carry the same line-height guarantees as getDefault*Font.
|
||||
*/
|
||||
export const glanceFont = new UiFontOverride("glanceboard.font");
|
||||
@@ -2,6 +2,7 @@ import { GrayImage } from "../../graphics/image";
|
||||
import { truncateText, wrapText } from "../../graphics/textwrap";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { enumSettingMenuItem, onAnySettingChanged, toggleSettingMenuItem } from "../../ui/dashboard-settings";
|
||||
import { uiFontOverridePickerMenuItem } from "../../ui/font-picker";
|
||||
import { type InputEvent } from "../../ui/gestures";
|
||||
import { type Layer, type LayerContext } from "../../ui/layers";
|
||||
import { drawSelectionHighlight, isMenuItemDisabled, MenuLayer, openModalMenu, type MenuItem } from "../../ui/menu";
|
||||
@@ -10,6 +11,7 @@ import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "../../ui/metrics";
|
||||
import { createInProcessWindow, type InProcessAppOptions, type InProcessWindow } from "../../ui/shell/in-process-window";
|
||||
import { shell } from "../../ui/shell/shell";
|
||||
import { GlanceBoard } from "./board";
|
||||
import { glanceFont } from "./glance-font";
|
||||
import {
|
||||
clearConflictingSlots,
|
||||
glanceboardEnabledSetting,
|
||||
@@ -298,7 +300,7 @@ function openSlotPicker(ctx: LayerContext, slotIndex: number): void {
|
||||
openModalMenu(ctx, setting.label, items, Math.max(0, setting.values.indexOf(current)));
|
||||
}
|
||||
|
||||
/** Settings: layout, sleep gestures, duration, slot lines, and stereo depth. */
|
||||
/** Settings: layout, sleep gestures, duration, slot lines, widget font, and stereo depth. */
|
||||
function openGlanceSettings(ctx: LayerContext): void {
|
||||
const items: MenuItem[] = [
|
||||
enumSettingMenuItem(glanceLayoutSetting),
|
||||
@@ -306,6 +308,11 @@ function openGlanceSettings(ctx: LayerContext): void {
|
||||
toggleSettingMenuItem(glanceShowOnLongPressSetting),
|
||||
toggleSettingMenuItem(glanceShowOnHeadTiltSetting),
|
||||
toggleSettingMenuItem(glanceShowLinesSetting),
|
||||
uiFontOverridePickerMenuItem(glanceFont, {
|
||||
title: "Glanceboard font",
|
||||
description:
|
||||
"Typeface for the Glanceboard's widgets. Same as UI font follows the Font setting in Settings > Display.",
|
||||
}),
|
||||
enumSettingMenuItem(glanceDepthSetting),
|
||||
];
|
||||
ctx.stack.push(new MenuLayer("Glanceboard settings", items, pageMenuLayout(ctx.stack.getBaseSize().width)));
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type GrayImage, type UiFont } from "../../../graphics/image";
|
||||
import { truncateText } from "../../../graphics/textwrap";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../../graphics/ui-fonts";
|
||||
import { hasCalendarPermission } from "../../../native/calendar-permissions";
|
||||
import { getCalendarReadState, onCalendarChanged, readUpcomingEvents, type CalendarEvent } from "../../../native/calendar";
|
||||
import { lineStep } from "../../../ui/metrics";
|
||||
import { dayHeaderLabel, formatEventTime } from "../../calendar/calendar";
|
||||
import { glanceFont } from "../glance-font";
|
||||
import { type GlanceWidget } from "../widget";
|
||||
|
||||
const PAD = 8;
|
||||
@@ -38,8 +38,8 @@ export class CalendarWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
paint(image: GrayImage): void {
|
||||
const small = getDefaultSmallFont();
|
||||
const medium = getDefaultMediumFont();
|
||||
const small = glanceFont.small();
|
||||
const medium = glanceFont.medium();
|
||||
const step = lineStep(small);
|
||||
const textWidth = image.width - 2 * PAD;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { type GrayImage } from "../../../graphics/image";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../../graphics/ui-fonts";
|
||||
import { hasLocationPermission } from "../../../native/location-permissions";
|
||||
import { addCompassListener, COMPASS_CHANGED, setCompassEnabled } from "../../../native/compass";
|
||||
import { isCompassCalibrated, normalizeHeading } from "../../compass/calibration";
|
||||
import { cardinalDirection, createCompassBackground, drawCompassRose, layoutCompassRose, TICK_HEIGHT } from "../../compass/compass-rose";
|
||||
import { getDeclinationAvailability, onDeclinationChanged, refreshDeclination } from "../../compass/declination";
|
||||
import { getNorthReference, resolveHeading } from "../../compass/heading";
|
||||
import { glanceFont } from "../glance-font";
|
||||
import { type GlanceWidget } from "../widget";
|
||||
|
||||
/** Owner token for the refcounted magnetometer, distinct from the Compass app's. */
|
||||
@@ -63,8 +63,8 @@ export class CompassWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
paint(image: GrayImage): void {
|
||||
const medium = getDefaultMediumFont();
|
||||
const small = getDefaultSmallFont();
|
||||
const medium = glanceFont.medium();
|
||||
const small = glanceFont.small();
|
||||
const { width, height } = image;
|
||||
const heading = this.rawHeading === null ? null : resolveHeading(this.rawHeading).displayDegrees;
|
||||
const headingText = heading === null ? "--°" : `${Math.round(heading)}° ${cardinalDirection(heading)}`;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { GrayImage } from "../../../graphics/image";
|
||||
import { renderIcon } from "../../../graphics/icons";
|
||||
import { getDefaultMediumFont, getDefaultSmallFont } from "../../../graphics/ui-fonts";
|
||||
import { truncateText } from "../../../graphics/textwrap";
|
||||
import { mediaControllerBridge, type MediaControllerState } from "../../../native/media-controller";
|
||||
import { clamp } from "../../../util/numeric-util";
|
||||
import { glanceFont } from "../glance-font";
|
||||
import { type GlanceWidget } from "../widget";
|
||||
|
||||
const PAD = 8;
|
||||
@@ -75,8 +75,8 @@ export class MusicWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
paint(image: GrayImage): void {
|
||||
const medium = getDefaultMediumFont();
|
||||
const small = getDefaultSmallFont();
|
||||
const medium = glanceFont.medium();
|
||||
const small = glanceFont.small();
|
||||
const media = mediaControllerBridge.snapshot();
|
||||
this.media = media;
|
||||
if (!media.available || (!media.title && !media.artist)) {
|
||||
@@ -142,7 +142,7 @@ export class MusicWidget implements GlanceWidget {
|
||||
image.drawRect(dx - 1, dy - 1, this.art.width + 2, this.art.height + 2, 60);
|
||||
} else {
|
||||
image.drawRect(ART_X, artY, ART_SIZE, ART_SIZE, 60);
|
||||
const font = getDefaultSmallFont();
|
||||
const font = glanceFont.small();
|
||||
image.drawText(font, ART_X + Math.round((ART_SIZE - font.measureText("no art")) / 2),
|
||||
artY + Math.round((ART_SIZE - font.lineHeight) / 2), "no art", 90);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { GrayImage } from "../../../graphics/image";
|
||||
import { getDefaultLargeFont, getDefaultSmallFont } from "../../../graphics/ui-fonts";
|
||||
import { truncateText } from "../../../graphics/textwrap";
|
||||
import { nightscoutBridge, type NightscoutState } from "../../../native/nightscout-bridge";
|
||||
import { isNightscoutSettingsConfigured, loadNightscoutThresholds } from "../../../ui/dashboard-settings";
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
formatDelta,
|
||||
isNightscoutPointStale,
|
||||
} from "../../nightscout/nightscout";
|
||||
import { glanceFont } from "../glance-font";
|
||||
import { type GlanceWidget } from "../widget";
|
||||
|
||||
const PAD = 8;
|
||||
@@ -48,8 +48,8 @@ export class NightscoutWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
paint(image: GrayImage): void {
|
||||
const small = getDefaultSmallFont();
|
||||
const large = getDefaultLargeFont();
|
||||
const small = glanceFont.small();
|
||||
const large = glanceFont.large();
|
||||
const state = this.state;
|
||||
const nowMs = Date.now();
|
||||
const step = lineStep(small);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { BATTERY_ICON_WIDTH, drawBattery } from "../../../graphics/battery";
|
||||
import { type GrayImage, type UiFont } from "../../../graphics/image";
|
||||
import { getDefaultLargeFont, getDefaultMediumFont, getDefaultSmallFont } from "../../../graphics/ui-fonts";
|
||||
import { onAndroidNotificationPosted, readActiveNotificationIcons } from "../../../native/notification-icons";
|
||||
import { readPhoneBatteryState } from "../../../native/phone-battery";
|
||||
import { formatClockDate, formatClockTime } from "../../../ui/clock-format";
|
||||
@@ -20,6 +19,7 @@ import { truncateText } from "../../../graphics/textwrap";
|
||||
import { timerEngine } from "../../timer/timer-engine";
|
||||
import { formatCountdown, sortTimers, timerDisplayName, timerPhase, timerRemainingMs } from "../../timer/timer-model";
|
||||
import { lineStep } from "../../../ui/metrics";
|
||||
import { glanceFont } from "../glance-font";
|
||||
import { type GlanceWidget } from "../widget";
|
||||
|
||||
const PAD = 8;
|
||||
@@ -97,9 +97,9 @@ export class SystemCardWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
paint(image: GrayImage): void {
|
||||
const large = getDefaultLargeFont();
|
||||
const medium = getDefaultMediumFont();
|
||||
const small = getDefaultSmallFont();
|
||||
const large = glanceFont.large();
|
||||
const medium = glanceFont.medium();
|
||||
const small = glanceFont.small();
|
||||
const now = new Date();
|
||||
|
||||
// Clock and date down the left; batteries take the right edge.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { type GrayImage } from "../../../graphics/image";
|
||||
import { truncateText } from "../../../graphics/textwrap";
|
||||
import { getDefaultSmallFont } from "../../../graphics/ui-fonts";
|
||||
import { lineStep } from "../../../ui/metrics";
|
||||
import { onWorkerStateChanged, readWorkerState } from "../../../ui/shell/worker-state";
|
||||
import {
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
TERMINAL_SESSIONS_STATE_KEY,
|
||||
type TerminalSessionsSnapshot,
|
||||
} from "../../terminal/session-list";
|
||||
import { glanceFont } from "../glance-font";
|
||||
import { type GlanceWidget } from "../widget";
|
||||
|
||||
const PAD = 8;
|
||||
@@ -72,7 +72,7 @@ export class TerminalWidget implements GlanceWidget {
|
||||
}
|
||||
|
||||
paint(image: GrayImage): void {
|
||||
const font = getDefaultSmallFont();
|
||||
const font = glanceFont.small();
|
||||
const step = lineStep(font);
|
||||
const textWidth = image.width - 2 * PAD;
|
||||
const snapshot = this.snapshot;
|
||||
|
||||
Reference in new issue
Block a user