forked from Blendman974/faceclaw
[verified] merge upstream c162c8e6 into all-features
This commit is contained in:
commit
5790e98d27
176 files changed
+5311
-2307
No files matched your search
@@ -6,8 +6,8 @@
|
||||
*
|
||||
* Glasses-first: launching does NOT take over the phone screen. The phone
|
||||
* stays on the Faceclaw dashboard; an app's phone UI is shown on demand
|
||||
* (window menu -> "Show phone UI", or the app-icon button in the phone's
|
||||
* action bar while the app is foreground on the glasses), overlaying the
|
||||
* (window menu -> "Show phone UI", or the app-icon button in the bar under the
|
||||
* phone's mirror while the app is foreground on the glasses), overlaying the
|
||||
* dashboard, and the Back button or the overlay's close button returns to it.
|
||||
* Apps are kept alive until explicitly closed (no memory eviction yet).
|
||||
*/
|
||||
@@ -40,14 +40,14 @@ type RunningApp = {
|
||||
packageId: string;
|
||||
session: EvenHubSession;
|
||||
webView: EvenHubWebView;
|
||||
/** The app's icon for the phone action bar, rendered on first use. */
|
||||
/** The app's icon for the phone's button bar, rendered on first use. */
|
||||
phoneIcon?: ImageSource | null;
|
||||
};
|
||||
|
||||
/** The phone action bar's button for opening the foreground app's phone UI. */
|
||||
/** The button under the phone's mirror that opens the foreground app's phone UI. */
|
||||
export type PhoneUiButton = { windowId: string; title: string; icon: ImageSource | null };
|
||||
|
||||
/** Pixel size the action-bar icon is rendered at (~21dp at xxhdpi). */
|
||||
/** Pixel size the button's icon is rendered at (~21dp at xxhdpi; shown at 20dp). */
|
||||
const PHONE_ICON_SIZE = 63;
|
||||
|
||||
const running = new Map<string, RunningApp>();
|
||||
@@ -244,7 +244,7 @@ export function hidePhone(): void {
|
||||
|
||||
/**
|
||||
* The foreground glasses window, when it is an EvenHub app whose phone UI
|
||||
* isn't showing: the phone action bar then offers a button to show it.
|
||||
* isn't showing: the bar under the phone's mirror then offers a button to show it.
|
||||
*/
|
||||
export function phoneUiButton(): PhoneUiButton | null {
|
||||
const window = shell.foregroundWindow();
|
||||
@@ -252,7 +252,7 @@ export function phoneUiButton(): PhoneUiButton | null {
|
||||
if (!window || !app || phoneShownWindowId === app.windowId) return null;
|
||||
if (app.phoneIcon === undefined) {
|
||||
// The same artwork as the glasses sidebar (installed icon, else the
|
||||
// generic package icon), drawn white.
|
||||
// generic package icon), drawn white; the button's stylesheet tints it.
|
||||
const image = new GrayImage(PHONE_ICON_SIZE, PHONE_ICON_SIZE, 0);
|
||||
window.drawIcon(image, 0, 0, PHONE_ICON_SIZE);
|
||||
app.phoneIcon = grayImageToWhiteIconSource(image);
|
||||
|
||||
@@ -16,7 +16,11 @@ import { cleanError, installStoreApp } from "./store-install";
|
||||
import { describeUpdate } from "./updates";
|
||||
import { lineStep, listRowHeight } from "../../ui/metrics";
|
||||
|
||||
const X = 18;
|
||||
/** How far an action row's highlight box overhangs the column of text it belongs to, on each side. */
|
||||
const ACTION_BOX_OVERHANG = 5;
|
||||
/** The side-by-side layout: the action menu's label column, and the gap between the details and its box. */
|
||||
const SIDE_MENU_WIDTH = 150;
|
||||
const SIDE_MENU_GAP = 9;
|
||||
|
||||
type DetailAction = "about" | "whats-new" | "primary";
|
||||
const ACTIONS: readonly DetailAction[] = ["about", "whats-new", "primary"];
|
||||
@@ -60,10 +64,15 @@ export class EvenHubStoreDetailLayer implements Layer {
|
||||
paint(ctx: LayerContext): GrayImage {
|
||||
if (!this.detailPromise) void this.ensureDetail(ctx);
|
||||
const font = getDefaultSmallFont();
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const { width, height, padding } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const step = lineStep(font);
|
||||
const actionRowH = listRowHeight(font) + 4;
|
||||
// The action rows' highlight boxes are the outermost thing drawn toward
|
||||
// the edges they reach, so they sit at the padding suggested for those
|
||||
// edges; the details keep to the text column inside the boxes' overhang.
|
||||
const textX = padding.left + ACTION_BOX_OVERHANG;
|
||||
const fullTextWidth = Math.max(0, width - padding.left - padding.right - 2 * ACTION_BOX_OVERHANG);
|
||||
|
||||
const installed = getInstalledEvenHubApp(this.app.packageId);
|
||||
this.primaryLabel = this.working ? "Installing..." : this.primaryActionLabel(installed);
|
||||
@@ -109,26 +118,22 @@ export class EvenHubStoreDetailLayer implements Layer {
|
||||
// Stacked layout (details full-width, actions at the bottom) when it
|
||||
// fits; otherwise the actions become a narrow top-right menu and the
|
||||
// details flow down a left column beside it.
|
||||
const stackedActionTop = height - 6 - ACTIONS.length * actionRowH;
|
||||
const stacked = 8 + linesHeight(buildLines(width - X * 2)) + 6 <= stackedActionTop;
|
||||
const menuW = 150;
|
||||
const menuX = width - menuW - 12;
|
||||
const textWidth = stacked ? width - X * 2 : menuX - X - 14;
|
||||
const stackedActionTop = height - padding.bottom - ACTIONS.length * actionRowH;
|
||||
const stacked = padding.top + linesHeight(buildLines(fullTextWidth)) + 6 <= stackedActionTop;
|
||||
const sideBoxWidth = SIDE_MENU_WIDTH + 2 * ACTION_BOX_OVERHANG;
|
||||
const sideBoxX = width - padding.right - sideBoxWidth;
|
||||
const textWidth = stacked ? fullTextWidth : Math.max(0, sideBoxX - SIDE_MENU_GAP - textX);
|
||||
|
||||
let y = 8;
|
||||
let y = padding.top;
|
||||
for (const line of buildLines(textWidth)) {
|
||||
image.drawText(font, X, y, line.text, line.value);
|
||||
image.drawText(font, textX, y, line.text, line.value);
|
||||
y += step + line.gapAfter;
|
||||
}
|
||||
|
||||
const actionX = stacked ? X : menuX;
|
||||
const actionW = stacked ? textWidth : menuW;
|
||||
const actionTop = stacked ? stackedActionTop : 8;
|
||||
this.actions.paint(
|
||||
image,
|
||||
{ x: actionX - 5, y: actionTop, width: actionW + 10, height: ACTIONS.length * actionRowH - 1 },
|
||||
ctx.stack.isFocused(),
|
||||
);
|
||||
const actionBox = stacked
|
||||
? { x: padding.left, y: stackedActionTop, width: fullTextWidth + 2 * ACTION_BOX_OVERHANG }
|
||||
: { x: sideBoxX, y: padding.top, width: sideBoxWidth };
|
||||
this.actions.paint(image, { ...actionBox, height: ACTIONS.length * actionRowH - 1 }, ctx.stack.isFocused());
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,37 @@ import { EvenHubStoreDetailLayer, type EvenHubStoreDetailOptions } from "./store
|
||||
import { cleanError, installStoreApp } from "./store-install";
|
||||
import { checkForEvenHubUpdates, describeUpdate, type EvenHubAppUpdate } from "./updates";
|
||||
import { lineStep } from "../../ui/metrics";
|
||||
import type { Viewport } from "../../ui/viewport";
|
||||
import { isEvenHubStoreAvailable } from "./glasses-compat";
|
||||
|
||||
const LIST_X = 18;
|
||||
/** Horizontal inset of a row's text from its highlight box; the header's text lines up with it. */
|
||||
const ROW_TEXT_INSET = 6;
|
||||
/** Horizontal gap between tab labels. */
|
||||
const TAB_GAP = 18;
|
||||
/** How far a focused tab's highlight box reaches past its label, sideways and above/below. */
|
||||
const TAB_HIGHLIGHT_PAD_X = 6;
|
||||
const TAB_HIGHLIGHT_PAD_Y = 3;
|
||||
/** Room kept right of the rows for the scrollbar, and the bar's own width. */
|
||||
const SCROLLBAR_GUTTER = 6;
|
||||
const SCROLLBAR_WIDTH = 3;
|
||||
|
||||
/** Header: title + tabs line, then the status/subtitle line, then a small gap. */
|
||||
function headerHeight(font: UiFont): number {
|
||||
return 8 + lineStep(font) + font.lineHeight + 6;
|
||||
/**
|
||||
* Where the header sits in a viewport. Its text shares a column with the
|
||||
* rows' text, whose highlight boxes start at the left edge's padding. The
|
||||
* outermost thing it draws toward the top is a focused tab's highlight box,
|
||||
* so that box sits at the top edge's padding and the title line follows
|
||||
* from it. `bottom` is where the header ends: title + tabs line, then the
|
||||
* status/subtitle line, then a small gap.
|
||||
*/
|
||||
function headerLayout(viewport: Viewport, font: UiFont): { textX: number; textWidth: number; titleY: number; bottom: number } {
|
||||
const { width, padding } = viewport;
|
||||
const titleY = padding.top + TAB_HIGHLIGHT_PAD_Y;
|
||||
return {
|
||||
textX: padding.left + ROW_TEXT_INSET,
|
||||
textWidth: Math.max(0, width - padding.left - padding.right - 2 * ROW_TEXT_INSET),
|
||||
titleY,
|
||||
bottom: titleY + lineStep(font) + font.lineHeight + 6,
|
||||
};
|
||||
}
|
||||
|
||||
/** Row pitch of the two-line app list (title + detail), including the 2px gap between highlights. */
|
||||
@@ -119,8 +141,8 @@ function emptyTab(): TabState {
|
||||
draw: ({ image, item, x, y, width }) => {
|
||||
const font = getDefaultSmallFont();
|
||||
const { title, detail, titleValue } = rowText(item);
|
||||
const textX = x + 6;
|
||||
const textW = width - 12;
|
||||
const textX = x + ROW_TEXT_INSET;
|
||||
const textW = width - 2 * ROW_TEXT_INSET;
|
||||
image.drawText(font, textX, y + 2, truncateText(font, title, textW), titleValue);
|
||||
image.drawText(font, textX, y + 2 + lineStep(font), truncateText(font, detail, textW), 115);
|
||||
},
|
||||
@@ -198,83 +220,93 @@ export class EvenHubStoreLayer implements Layer {
|
||||
}
|
||||
|
||||
const font = getDefaultSmallFont();
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const viewport = ctx.stack.getBaseSize();
|
||||
const { width, height, padding } = viewport;
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const headerH = headerHeight(font);
|
||||
image.drawText(font, LIST_X, 8, "EvenHub", 220);
|
||||
const { textX, textWidth, titleY, bottom: headerBottom } = headerLayout(viewport, font);
|
||||
image.drawText(font, textX, titleY, "EvenHub", 220);
|
||||
|
||||
if (this.showingLogin) {
|
||||
image.drawText(font, LIST_X, 8 + lineStep(font), truncateText(font, this.loginStatus, width - LIST_X * 2), 125);
|
||||
image.drawText(font, textX, titleY + lineStep(font), truncateText(font, this.loginStatus, textWidth), 125);
|
||||
const message = this.loginBusy
|
||||
? "Signing in..."
|
||||
: "Enter your Even account email and password in the phone app.";
|
||||
for (const [index, line] of wrapText(font, message, width - LIST_X * 2).entries()) {
|
||||
image.drawText(font, LIST_X, headerH + 16 + index * lineStep(font), line, 190);
|
||||
for (const [index, line] of wrapText(font, message, textWidth).entries()) {
|
||||
image.drawText(font, textX, headerBottom + 16 + index * lineStep(font), line, 190);
|
||||
}
|
||||
image.drawText(font, LIST_X, height - font.lineHeight - 4, `${GESTURE_CLICK} log in`, 105);
|
||||
image.drawText(font, textX, height - padding.bottom - font.lineHeight, `${GESTURE_CLICK} log in`, 105);
|
||||
return image;
|
||||
}
|
||||
|
||||
this.paintTabs(image, font, ctx);
|
||||
this.paintTabs(image, font, ctx, textX, titleY);
|
||||
|
||||
const tab = this.tabs[this.activeTab];
|
||||
const subtitle = tab.status || this.subtitle(this.activeTab, tab);
|
||||
image.drawText(font, LIST_X, 8 + lineStep(font), truncateText(font, subtitle, width - LIST_X * 2), 125);
|
||||
image.drawText(font, textX, titleY + lineStep(font), truncateText(font, subtitle, textWidth), 125);
|
||||
|
||||
if (tab.rows.length === 0) {
|
||||
const message = tab.loading ? "Loading..." : this.emptyMessage(this.activeTab, tab);
|
||||
for (const [index, line] of wrapText(font, message, width - LIST_X * 2).slice(0, 3).entries()) {
|
||||
image.drawText(font, LIST_X, headerH + 22 + index * lineStep(font), line, 190);
|
||||
for (const [index, line] of wrapText(font, message, textWidth).slice(0, 3).entries()) {
|
||||
image.drawText(font, textX, headerBottom + 22 + index * lineStep(font), line, 190);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
if (height <= headerBottom) return image;
|
||||
|
||||
const rowH = storeRowHeight(font);
|
||||
const visibleRows = Math.max(1, Math.floor((height - headerH - 4) / rowH));
|
||||
// The header stays put, so the list starts right under it with no
|
||||
// padding of its own there. It scrolls, so it runs to the window's
|
||||
// bottom edge, the padding suggested for that edge inside it: the last
|
||||
// row keeps clear of a border there, and a row cut off for scrolling
|
||||
// meets the edge rather than a blank strip. The scrollbar keeps inside
|
||||
// the padding, in a gutter the rows leave free.
|
||||
const listFocused = ctx.stack.isFocused() && this.focus === "list";
|
||||
const menu = tabMenu(tab);
|
||||
const rowsWidth = Math.max(0, width - padding.left - padding.right - SCROLLBAR_GUTTER);
|
||||
menu.paint(
|
||||
image,
|
||||
{ x: LIST_X - 6, y: headerH, width: width - LIST_X * 2 + 12, height: visibleRows * rowH - 2 },
|
||||
{ x: padding.left, y: headerBottom, width: rowsWidth, height: height - headerBottom, padTop: 0, padBottom: padding.bottom },
|
||||
listFocused,
|
||||
);
|
||||
menu.drawScrollbar(image, width - 5, headerH, visibleRows * rowH - 3);
|
||||
menu.drawScrollbar(image, width - padding.right - SCROLLBAR_WIDTH, headerBottom,
|
||||
Math.max(0, height - padding.bottom - headerBottom));
|
||||
return image;
|
||||
}
|
||||
|
||||
/** The notice that replaces the store when the paired glasses can't use it. */
|
||||
private paintUnavailable(ctx: LayerContext): GrayImage {
|
||||
const font = getDefaultSmallFont();
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
image.drawText(font, LIST_X, 8, "EvenHub", 220);
|
||||
const viewport = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(viewport.width, viewport.height, 0);
|
||||
const { textX, textWidth, titleY, bottom: headerBottom } = headerLayout(viewport, font);
|
||||
image.drawText(font, textX, titleY, "EvenHub", 220);
|
||||
if (this.unavailablePackageName) {
|
||||
const status = `${this.unavailablePackageName}'s package is missing.`;
|
||||
image.drawText(font, LIST_X, 8 + lineStep(font), truncateText(font, status, width - LIST_X * 2), 125);
|
||||
image.drawText(font, textX, titleY + lineStep(font), truncateText(font, status, textWidth), 125);
|
||||
}
|
||||
const message = "Using the Even Realities app store requires Even Realities glasses.";
|
||||
for (const [index, line] of wrapText(font, message, width - LIST_X * 2).entries()) {
|
||||
image.drawText(font, LIST_X, headerHeight(font) + 16 + index * lineStep(font), line, 190);
|
||||
for (const [index, line] of wrapText(font, message, textWidth).entries()) {
|
||||
image.drawText(font, textX, headerBottom + 16 + index * lineStep(font), line, 190);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/** Tab labels to the right of the title; the active one is bright and underlined. */
|
||||
private paintTabs(image: GrayImage, font: UiFont, ctx: LayerContext): void {
|
||||
/** Tab labels to the right of the title (at titleX, titleY); the active one is bright and underlined. */
|
||||
private paintTabs(image: GrayImage, font: UiFont, ctx: LayerContext, titleX: number, titleY: number): void {
|
||||
const tabsFocused = ctx.stack.isFocused() && this.focus === "tabs";
|
||||
let x = LIST_X + font.measureText("EvenHub") + 28;
|
||||
let x = titleX + font.measureText("EvenHub") + 28;
|
||||
for (const tab of TABS) {
|
||||
const label = this.tabLabel(tab.id);
|
||||
const w = font.measureText(label);
|
||||
const active = tab.id === this.activeTab;
|
||||
if (active) {
|
||||
if (tabsFocused) {
|
||||
drawSelectionHighlight(image, x - 6, 5, w + 12, font.lineHeight + 6, true, 4);
|
||||
drawSelectionHighlight(image, x - TAB_HIGHLIGHT_PAD_X, titleY - TAB_HIGHLIGHT_PAD_Y,
|
||||
w + 2 * TAB_HIGHLIGHT_PAD_X, font.lineHeight + 2 * TAB_HIGHLIGHT_PAD_Y, true, 4);
|
||||
} else {
|
||||
image.fillRect(x, 8 + font.lineHeight + 1, w, 1, 150);
|
||||
image.fillRect(x, titleY + font.lineHeight + 1, w, 1, 150);
|
||||
}
|
||||
}
|
||||
image.drawText(font, x, 8, label, active ? 235 : 120);
|
||||
image.drawText(font, x, titleY, label, active ? 235 : 120);
|
||||
x += w + TAB_GAP;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user