forked from Blendman974/faceclaw
Adapt layouts for Rayneo screen resolution
This commit is contained in:
1 parent
4d101eefe1
commit
dee60bbcd2
34 files changed
+721
-202
No files matched your search
@@ -3,9 +3,9 @@
|
||||
* page: to scale in real-display pixels, simplified, and drawn brighter
|
||||
* than the real chrome, which they shrink to a few pixels.
|
||||
*/
|
||||
import { G2_LENS_WIDTH, type GrayImage } from "../../graphics/image";
|
||||
import type { GrayImage } from "../../graphics/image";
|
||||
import { statusBarPositionSetting, type AppSwitcherPosition } from "../../ui/dashboard-settings";
|
||||
import { SIDEBAR_WIDTH, SWITCHER_ROW_HEIGHT, MIN_WINDOW_HEIGHT, TOP_BAR_HEIGHT } from "../../ui/shell/geometry";
|
||||
import { MIN_WINDOW_HEIGHT, screenHeight, screenWidth, SIDEBAR_WIDTH, SWITCHER_ROW_HEIGHT, TOP_BAR_HEIGHT } from "../../ui/shell/geometry";
|
||||
|
||||
export const AREA_OUTLINE = 30;
|
||||
const CHROME_LINE = 100;
|
||||
@@ -80,14 +80,14 @@ export function drawLayout(d: Diagram, position: AppSwitcherPosition, band: Diag
|
||||
switch (position) {
|
||||
case "left":
|
||||
case "right": {
|
||||
const stripLeft = position === "left" ? 0 : G2_LENS_WIDTH - SIDEBAR_WIDTH;
|
||||
const stripLeft = position === "left" ? 0 : screenWidth() - SIDEBAR_WIDTH;
|
||||
const contentLeft = position === "left" ? SIDEBAR_WIDTH : 0;
|
||||
const windowWidth = G2_LENS_WIDTH - SIDEBAR_WIDTH;
|
||||
const windowWidth = screenWidth() - SIDEBAR_WIDTH;
|
||||
drawStatusBar(d, contentLeft, top, windowWidth, TOP_BAR_HEIGHT - 1);
|
||||
drawContent(d, contentLeft, top + TOP_BAR_HEIGHT, windowWidth, height - TOP_BAR_HEIGHT, 1);
|
||||
// The strip keeps to the 288px band's height, even beside taller windows.
|
||||
// The strip keeps to the min band's height (288px, or the whole short screen), even beside taller windows.
|
||||
const separator = position === "left" ? SIDEBAR_WIDTH - 1 : stripLeft;
|
||||
d.vline(separator, top + TOP_BAR_HEIGHT, MIN_WINDOW_HEIGHT - TOP_BAR_HEIGHT, CHROME_LINE);
|
||||
d.vline(separator, top + TOP_BAR_HEIGHT, diagramBandHeight("left") - TOP_BAR_HEIGHT, CHROME_LINE);
|
||||
// One column of icons against the separator.
|
||||
const column = position === "left" ? SIDEBAR_WIDTH - 36 : stripLeft;
|
||||
for (let slot = 0; slot < 4; slot++) drawIcon(d, column + 2, top + TOP_BAR_HEIGHT + 10 + slot * 40, slot === 0);
|
||||
@@ -131,11 +131,11 @@ export function drawLayout(d: Diagram, position: AppSwitcherPosition, band: Diag
|
||||
}
|
||||
}
|
||||
|
||||
/** A bottom row or popup layout's window: centred at 576 wide and framed, or the panel's width without a frame. */
|
||||
/** A bottom row or popup layout's window: centred, SIDEBAR_WIDTH narrower, framed; or the screen's width without a frame. */
|
||||
function windowSpan(band: DiagramBand): { left: number; width: number; framed: boolean } {
|
||||
return band.fullWidth
|
||||
? { left: 0, width: G2_LENS_WIDTH, framed: false }
|
||||
: { left: SIDEBAR_WIDTH / 2, width: G2_LENS_WIDTH - SIDEBAR_WIDTH, framed: true };
|
||||
? { left: 0, width: screenWidth(), framed: false }
|
||||
: { left: SIDEBAR_WIDTH / 2, width: screenWidth() - SIDEBAR_WIDTH, framed: true };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,5 +173,16 @@ function drawContent(d: Diagram, x: number, y: number, width: number, height: nu
|
||||
}
|
||||
}
|
||||
|
||||
/** Real-display rows the Layout page's diagrams cover: a 288px band and a bottom switcher row under it. */
|
||||
export const LAYOUT_AREA_HEIGHT = MIN_WINDOW_HEIGHT + SWITCHER_ROW_HEIGHT;
|
||||
/**
|
||||
* Real-display rows the Layout page's diagrams cover: a 288px band and a
|
||||
* bottom switcher row under it, or the whole screen where that is shorter
|
||||
* (the RayNeo iO's 220 rows).
|
||||
*/
|
||||
export function layoutAreaHeight(): number {
|
||||
return Math.min(MIN_WINDOW_HEIGHT + SWITCHER_ROW_HEIGHT, screenHeight());
|
||||
}
|
||||
|
||||
/** A layout's min-height band within the diagram area: 288px, less a bottom row where the screen is short. */
|
||||
export function diagramBandHeight(position: AppSwitcherPosition): number {
|
||||
return Math.min(MIN_WINDOW_HEIGHT, layoutAreaHeight() - (position === "bottom" ? SWITCHER_ROW_HEIGHT : 0));
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { G2_LENS_WIDTH, type GrayImage, type UiFont } from "../../graphics/image";
|
||||
import { appSwitcherPositionSetting, type AppSwitcherPosition } from "../../ui/dashboard-settings";
|
||||
import type { GrayImage, UiFont } from "../../graphics/image";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, type AppSwitcherPosition } from "../../ui/dashboard-settings";
|
||||
import type { InputEvent } from "../../ui/gestures";
|
||||
import { MENU_HIGHLIGHT_FILL, MENU_HIGHLIGHT_STROKE } from "../../ui/menu-core";
|
||||
import { MIN_WINDOW_HEIGHT } from "../../ui/shell/geometry";
|
||||
import { AREA_OUTLINE, Diagram, drawLayout, LAYOUT_AREA_HEIGHT } from "./layout-diagram";
|
||||
import { screenWidth } from "../../ui/shell/geometry";
|
||||
import { AREA_OUTLINE, Diagram, diagramBandHeight, drawLayout, layoutAreaHeight } from "./layout-diagram";
|
||||
import { onboardingFont } from "./onboarding-fonts";
|
||||
import { drawPageHeading, type OnboardingNav, type OnboardingPage } from "./onboarding-page";
|
||||
|
||||
@@ -19,8 +19,13 @@ const ROW_GAP = 6;
|
||||
const DEPTH_SUBTITLE = "Customizable Depth";
|
||||
/** Grid order, in rows of two: the layouts with depth on top. */
|
||||
const LAYOUT_ORDER: readonly AppSwitcherPosition[] = ["bottom", "popup", "left", "right"];
|
||||
/** Selected on the first visit, and marked. */
|
||||
const RECOMMENDED_LAYOUT: AppSwitcherPosition = "bottom";
|
||||
/**
|
||||
* Selected on the first visit, and marked: Bottom on the G2, whose 480 rows
|
||||
* leave room for the row; a side strip on the RayNeo iO, whose 220 can't.
|
||||
*/
|
||||
export function recommendedLayout(): AppSwitcherPosition {
|
||||
return glassesTypeSetting.get() === "rayneo-io" ? "left" : "bottom";
|
||||
}
|
||||
|
||||
/** Whether a layout leaves the side margins the display's stereo depth shifts into (geometry.ts uiDepth). */
|
||||
export function layoutHasDepth(position: AppSwitcherPosition): boolean {
|
||||
@@ -29,7 +34,7 @@ export function layoutHasDepth(position: AppSwitcherPosition): boolean {
|
||||
|
||||
/**
|
||||
* The app switcher position, as a 2×2 grid of captioned diagrams of each
|
||||
* layout, Bottom (recommended, and selected at first) and Popup on top;
|
||||
* layout, Bottom and Popup on top, the recommended one selected at first;
|
||||
* swipes move through them in reading order, a tap saves the selected one.
|
||||
* The page is immersive, so the diagrams get 40% of the display's width
|
||||
* each. Choosing a layout reflows open windows (the dashboard controller
|
||||
@@ -38,7 +43,7 @@ export function layoutHasDepth(position: AppSwitcherPosition): boolean {
|
||||
export class LayoutPage implements OnboardingPage {
|
||||
readonly immersive = true;
|
||||
/** Kept across visits, so going back returns to the last choice. */
|
||||
private selected = LAYOUT_ORDER.indexOf(RECOMMENDED_LAYOUT);
|
||||
private selected = LAYOUT_ORDER.indexOf(recommendedLayout());
|
||||
|
||||
paint(image: GrayImage, focused: boolean): void {
|
||||
const top = drawPageHeading(
|
||||
@@ -53,11 +58,11 @@ export class LayoutPage implements OnboardingPage {
|
||||
// Short of DIAGRAM_SCALE only where two rows of cells wouldn't fit.
|
||||
const scale = Math.min(
|
||||
DIAGRAM_SCALE,
|
||||
((available - ROW_GAP) / 2 - 2 * CELL_PADDING - captionHeight) / LAYOUT_AREA_HEIGHT,
|
||||
((image.width - COLUMN_GAP) / 2 - 2 * CELL_PADDING) / G2_LENS_WIDTH,
|
||||
((available - ROW_GAP) / 2 - 2 * CELL_PADDING - captionHeight) / layoutAreaHeight(),
|
||||
((image.width - COLUMN_GAP) / 2 - 2 * CELL_PADDING) / screenWidth(),
|
||||
);
|
||||
const diagramWidth = Math.round(G2_LENS_WIDTH * scale);
|
||||
const diagramHeight = Math.round(LAYOUT_AREA_HEIGHT * scale);
|
||||
const diagramWidth = Math.round(screenWidth() * scale);
|
||||
const diagramHeight = Math.round(layoutAreaHeight() * scale);
|
||||
const cellWidth = diagramWidth + 2 * CELL_PADDING;
|
||||
const cellHeight = diagramHeight + 2 * CELL_PADDING + captionHeight;
|
||||
const left = Math.round((image.width - 2 * cellWidth - COLUMN_GAP) / 2);
|
||||
@@ -75,7 +80,7 @@ export class LayoutPage implements OnboardingPage {
|
||||
image.drawText(font, x + Math.round((cellWidth - font.measureText(text)) / 2), textY, text, value);
|
||||
const captionTop = y + CELL_PADDING + diagramHeight + CAPTION_GAP;
|
||||
const name = appSwitcherPositionSetting.displayValue(position);
|
||||
const caption = position === RECOMMENDED_LAYOUT ? `${name} (Recommended)` : name;
|
||||
const caption = position === recommendedLayout() ? `${name} (Recommended)` : name;
|
||||
centre(caption, title, captionTop, selected ? 255 : 190);
|
||||
if (layoutHasDepth(position)) {
|
||||
centre(DEPTH_SUBTITLE, subtitle, captionTop + title.lineHeight, selected ? 210 : 150);
|
||||
@@ -103,12 +108,14 @@ export class LayoutPage implements OnboardingPage {
|
||||
}
|
||||
|
||||
/**
|
||||
* A layout's diagram: the 288px band, with the popup switcher open. Only a
|
||||
* bottom switcher row takes rows under the band; without one, the band sits
|
||||
* centred in their place, as the band and row share the screen's slack.
|
||||
* A layout's diagram: the min-height band, with the popup switcher open.
|
||||
* Only a bottom switcher row takes rows under the band; without one, the
|
||||
* band sits centred in their place, as the band and row share the screen's
|
||||
* slack (none on a screen as short as the RayNeo iO's: the band fills it).
|
||||
*/
|
||||
function drawLayoutDiagram(d: Diagram, position: AppSwitcherPosition): void {
|
||||
d.outline(0, 0, G2_LENS_WIDTH, LAYOUT_AREA_HEIGHT, AREA_OUTLINE, 12);
|
||||
const top = position === "bottom" ? 0 : (LAYOUT_AREA_HEIGHT - MIN_WINDOW_HEIGHT) / 2;
|
||||
drawLayout(d, position, { top, height: MIN_WINDOW_HEIGHT, fullWidth: false }, true);
|
||||
d.outline(0, 0, screenWidth(), layoutAreaHeight(), AREA_OUTLINE, 12);
|
||||
const height = diagramBandHeight(position);
|
||||
const top = position === "bottom" ? 0 : (layoutAreaHeight() - height) / 2;
|
||||
drawLayout(d, position, { top, height, fullWidth: false }, true);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { installedFontPath } from "../../graphics/installed-fonts";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { TtfFont } from "../../graphics/ttf-font";
|
||||
import {
|
||||
defaultUiFontSize,
|
||||
fontSelectionLabel,
|
||||
getDefaultSmallFont,
|
||||
getUiFontSelection,
|
||||
@@ -25,8 +26,6 @@ const ROW_GAP = 2;
|
||||
const NOTE_GAP = 8;
|
||||
/** The sizes offered here; Settings has the full range. */
|
||||
const SIZE_CHOICES = FONT_SIZE_CHOICES.filter((size) => size >= 12 && size <= 18);
|
||||
/** Selected on the first visit, and marked. */
|
||||
const RECOMMENDED_SIZE = 16;
|
||||
const RECOMMENDED_NOTE = "Recommended";
|
||||
/** Drawn while they fit, so smaller sizes visibly show more words. */
|
||||
const PREVIEW_PARAGRAPHS = [
|
||||
@@ -41,7 +40,8 @@ type Face =
|
||||
| { kind: "fixed"; label: string };
|
||||
|
||||
/**
|
||||
* The UI font's size, 12 to 18px (16 recommended, and selected at first),
|
||||
* The UI font's size, 12 to 18px (the default size recommended, and
|
||||
* selected at first: 16px, or 14px on the RayNeo iO),
|
||||
* beside a preview of text in the selected size. The face and weight stay
|
||||
* as they are (they live in the Settings font picker); a bitmap face has
|
||||
* only one size, so the page just says so. The size is saved on tap, not
|
||||
@@ -67,7 +67,7 @@ export class TextSizePage implements OnboardingPage {
|
||||
if (sizes.length) {
|
||||
this.face = { kind: "sized", file: selection.file, path, sizes };
|
||||
// The recommended size the first time; on a return, what was left selected.
|
||||
this.sizeMenu.setItems(sizes, nearestIndex(sizes, this.sizeMenu.selectedItem ?? RECOMMENDED_SIZE));
|
||||
this.sizeMenu.setItems(sizes, nearestIndex(sizes, this.sizeMenu.selectedItem ?? defaultUiFontSize()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ export class TextSizePage implements OnboardingPage {
|
||||
const body = onboardingFont("body");
|
||||
const label = sizeLabel(size);
|
||||
image.drawText(body, x + 10, y + LIST_ROW_TEXT_INSET, label, selected ? 255 : 190);
|
||||
if (size !== RECOMMENDED_SIZE) return;
|
||||
if (size !== defaultUiFontSize()) return;
|
||||
const detail = onboardingFont("detail");
|
||||
const noteY = y + Math.round((height - detail.lineHeight) / 2);
|
||||
image.drawText(detail, x + 10 + body.measureText(label) + NOTE_GAP, noteY, RECOMMENDED_NOTE, selected ? 210 : 150);
|
||||
|
||||
Reference in new issue
Block a user