mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Animations have a speed setting rather than an on/off toggle
This commit is contained in:
1 parent
682a8e964d
commit
9b0bf77d79
15 files changed
+110
-45
No files matched your search
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Speeds offered by the Settings > Customization > Animations settings.
|
||||
* Animation durations are tuned at Normal; the other speeds play them faster
|
||||
* or slower, and Disabled makes them instant.
|
||||
*/
|
||||
export const ANIMATION_SPEEDS = ["disabled", "very-fast", "fast", "normal", "slow"] as const;
|
||||
export type AnimationSpeed = typeof ANIMATION_SPEEDS[number];
|
||||
|
||||
const SPEED_FACTORS: Record<AnimationSpeed, number> = { disabled: 0, "very-fast": 5, fast: 2, normal: 1, slow: 0.5 };
|
||||
const SPEED_LABELS: Record<AnimationSpeed, string> = {
|
||||
disabled: "Disabled", "very-fast": "Very Fast", fast: "Fast", normal: "Normal", slow: "Slow",
|
||||
};
|
||||
|
||||
export function animationSpeedLabel(speed: AnimationSpeed): string {
|
||||
return SPEED_LABELS[speed];
|
||||
}
|
||||
|
||||
export function normalizeAnimationSpeed(value: string | null | undefined): AnimationSpeed {
|
||||
return ANIMATION_SPEEDS.includes(value as AnimationSpeed) ? value as AnimationSpeed : "normal";
|
||||
}
|
||||
|
||||
/** A duration tuned for Normal speed, played at `speed`: whole milliseconds, or 0 when disabled. */
|
||||
export function scaleAnimationDuration(normalMs: number, speed: AnimationSpeed): number {
|
||||
const factor = SPEED_FACTORS[speed];
|
||||
return factor ? Math.max(1, Math.round(normalMs / factor)) : 0;
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from "~/assistant/models";
|
||||
import { isLocalModelReady } from "../native/llama";
|
||||
import { drawRightValueMenuItem, drawToggleMenuItem, MenuItem, openModalMenu } from "./menu";
|
||||
import { ANIMATION_SPEEDS, animationSpeedLabel, scaleAnimationDuration, type AnimationSpeed } from "./animation-speed";
|
||||
import { MENU_ANIMATION_KEY } from "./menu-animation-pref";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep } from "./metrics";
|
||||
import { Layer, type LayerContext } from "./layers";
|
||||
@@ -480,29 +481,34 @@ export const autoBrightnessCurveSetting = new ConfigSettingString({
|
||||
defaultValue: DEFAULT_BRIGHTNESS_CURVE, normalize: normalizeBrightnessCurve, validate: brightnessCurveError,
|
||||
description: "2–16 lux:percent pairs, separated by commas. Percent is within your minimum–maximum range. Start at 0:0, end at 100%, and increase lux without decreasing percent. Incomplete edits stay in the preview; brightness keeps using the last valid curve.",
|
||||
});
|
||||
/** The screen on/off fade at Normal speed. */
|
||||
const SCREEN_FADE_MS = 280;
|
||||
|
||||
export const menuAnimationSetting = new ConfigSettingBoolean({
|
||||
export const menuAnimationSetting = new ConfigSettingEnum<AnimationSpeed>({
|
||||
id: "menu-animation",
|
||||
label: "Menu animation",
|
||||
storageKey: MENU_ANIMATION_KEY,
|
||||
defaultValue: true,
|
||||
description: "Slide the highlight, scroll, and bounce at the ends in menus, lists, and the launcher and Files icon grids. When off, they move instantly.",
|
||||
defaultValue: "normal",
|
||||
values: ANIMATION_SPEEDS,
|
||||
formatValue: animationSpeedLabel,
|
||||
description: "How fast the highlight slides, lists scroll, and the ends bounce in menus, lists, and the launcher and Files icon grids. Disabled moves them instantly.",
|
||||
});
|
||||
|
||||
export const screenFadeSetting = new ConfigSettingBoolean({
|
||||
export const screenFadeSetting = new ConfigSettingEnum<AnimationSpeed>({
|
||||
id: "screen-fade",
|
||||
label: "Screen fade",
|
||||
storageKey: "display.screenFade",
|
||||
defaultValue: true,
|
||||
description: "Fade the display in and out when the screen turns on or off. When off, it switches instantly.",
|
||||
storageKey: "display.screenFadeSpeed",
|
||||
defaultValue: "normal",
|
||||
values: ANIMATION_SPEEDS,
|
||||
formatValue: animationSpeedLabel,
|
||||
description: "How fast the display fades in and out when the screen turns on or off. Disabled switches it instantly.",
|
||||
});
|
||||
|
||||
export function getBrightnessPreferences() {
|
||||
const level = brightnessSettingToLevel(brightnessSetting.get());
|
||||
return { auto: level === null, level: level ?? 50,
|
||||
minimum: Number(autoBrightnessMinSetting.get()), maximum: Number(autoBrightnessMaxSetting.get()),
|
||||
curve: autoBrightnessCurveSetting.getValidValue(), fadeMs: screenFadeSetting.get() ? SCREEN_FADE_MS : 0 };
|
||||
curve: autoBrightnessCurveSetting.getValidValue(), fadeMs: scaleAnimationDuration(SCREEN_FADE_MS, screenFadeSetting.get()) };
|
||||
}
|
||||
|
||||
export const screenTimeoutSetting = new ConfigSettingEnum<ScreenTimeoutSetting>({
|
||||
|
||||
@@ -326,17 +326,17 @@ function batteryIndicatorsMenuItem(): MenuItem {
|
||||
};
|
||||
}
|
||||
|
||||
/** The Customization section's "Animations" row: opens a modal submenu of animation toggles. */
|
||||
/** The Customization section's "Animations" row: opens a modal submenu of animation speeds. */
|
||||
function animationsMenuItem(): MenuItem {
|
||||
return submenuItem(
|
||||
"Animations",
|
||||
(ctx) => {
|
||||
openSettingsSubMenu(ctx, "Animations", [
|
||||
toggleSettingMenuItem(menuAnimationSetting),
|
||||
toggleSettingMenuItem(screenFadeSetting),
|
||||
enumSettingMenuItem(menuAnimationSetting),
|
||||
enumSettingMenuItem(screenFadeSetting),
|
||||
]);
|
||||
},
|
||||
{ description: "Turn off menu and icon-grid motion, or the fade when the screen turns on and off." },
|
||||
{ description: "Speed up, slow down, or turn off menu and icon-grid motion and the fade when the screen turns on and off." },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import { scaleAnimationDuration, type AnimationSpeed } from "./animation-speed";
|
||||
|
||||
/**
|
||||
* Whether menus and icon grids animate on the glasses (Settings > Customization >
|
||||
* How fast menus and icon grids animate on the glasses (Settings > Customization >
|
||||
* Animations > Menu animation). The motion classes can't read the settings
|
||||
* store themselves (it is native, and they load under Node in unit tests),
|
||||
* so ui/menu.ts installs a reader in each isolate that paints menus. Without
|
||||
* one, menus animate.
|
||||
* one, menus animate at Normal speed.
|
||||
*/
|
||||
export const MENU_ANIMATION_KEY = "display.menuAnimation";
|
||||
export const MENU_ANIMATION_KEY = "display.menuAnimationSpeed";
|
||||
|
||||
let readMenuAnimation: () => boolean = () => true;
|
||||
let readMenuAnimationSpeed: () => AnimationSpeed = () => "normal";
|
||||
|
||||
export function menuAnimationEnabled(): boolean {
|
||||
return readMenuAnimation();
|
||||
/** A menu animation's Normal-speed duration at the configured speed; 0 when menu animation is disabled. */
|
||||
export function menuAnimationDurationMs(normalMs: number): number {
|
||||
return scaleAnimationDuration(normalMs, readMenuAnimationSpeed());
|
||||
}
|
||||
|
||||
export function setMenuAnimationReader(read: () => boolean): void {
|
||||
readMenuAnimation = read;
|
||||
export function setMenuAnimationReader(read: () => AnimationSpeed): void {
|
||||
readMenuAnimationSpeed = read;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { menuAnimationEnabled } from "./menu-animation-pref";
|
||||
import { menuAnimationDurationMs } from "./menu-animation-pref";
|
||||
|
||||
/** At Normal menu animation speed; menuAnimationDurationMs scales it to the setting. */
|
||||
export const MENU_HIGHLIGHT_DURATION_MS = 240;
|
||||
export type MenuHighlightAnimation = { dx: number; dy: number; startedAt: number; token: number; durationMs: number };
|
||||
|
||||
@@ -32,9 +33,10 @@ export class MenuHighlightMotion {
|
||||
fromX += this.animation.dx * remaining;
|
||||
fromY += this.animation.dy * remaining;
|
||||
}
|
||||
const eligible = menuAnimationEnabled() && previous && previous.index !== index && this.fromIndex === previous.index &&
|
||||
const durationMs = menuAnimationDurationMs(MENU_HIGHLIGHT_DURATION_MS);
|
||||
const eligible = durationMs > 0 && previous && previous.index !== index && this.fromIndex === previous.index &&
|
||||
(previous.scroll === scroll || scrolling) && previous.width === width && previous.height === height;
|
||||
this.animation = eligible ? { dx: Math.round(fromX - x), dy: Math.round(fromY - y), startedAt: now, token: nextAnimationToken(), durationMs: MENU_HIGHLIGHT_DURATION_MS } : undefined;
|
||||
this.animation = eligible ? { dx: Math.round(fromX - x), dy: Math.round(fromY - y), startedAt: now, token: nextAnimationToken(), durationMs } : undefined;
|
||||
this.fromIndex = null;
|
||||
this.previous = { index, scroll, x, y, width, height };
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { DrawExpression as E, ExprOp } from "../graphics/draw-expression";
|
||||
import { menuAnimationEnabled } from "./menu-animation-pref";
|
||||
import { menuAnimationDurationMs } from "./menu-animation-pref";
|
||||
import { MENU_HIGHLIGHT_DURATION_MS, nextAnimationToken } from "./menu-highlight-motion";
|
||||
|
||||
/** Longest scroll, in pixels, that animates; longer jumps snap. */
|
||||
export const MAX_ANIMATED_SCROLL = 96;
|
||||
/** At Normal menu animation speed, like MENU_HIGHLIGHT_DURATION_MS. */
|
||||
export const MENU_BOUNCE_DURATION_MS = 320;
|
||||
/** Fraction of a bounce spent moving out to the peak; the rest settles back. */
|
||||
const BOUNCE_PEAK = 0.35;
|
||||
@@ -73,20 +74,21 @@ export class MenuScrollMotion {
|
||||
/** Record this paint's settled offset; returns the animation in flight, if any. */
|
||||
paint(scroll: number, box: Box, now: number): MenuScrollAnimation | undefined {
|
||||
const previous = this.previous;
|
||||
const enabled = menuAnimationEnabled();
|
||||
const scrollMs = menuAnimationDurationMs(MENU_HIGHLIGHT_DURATION_MS);
|
||||
const sameBox = !!previous && previous.box.x === box.x && previous.box.y === box.y &&
|
||||
previous.box.width === box.width && previous.box.height === box.height;
|
||||
if (!previous || !sameBox || previous.scroll !== scroll) {
|
||||
const from = previous ? this.offsetAt(previous.scroll, now) : scroll;
|
||||
const eligible = enabled && sameBox && this.navigated && from !== scroll && Math.abs(scroll - from) <= MAX_ANIMATED_SCROLL;
|
||||
const eligible = scrollMs > 0 && sameBox && this.navigated && from !== scroll && Math.abs(scroll - from) <= MAX_ANIMATED_SCROLL;
|
||||
this.animation = eligible
|
||||
? { from, to: scroll, startedAt: now, token: nextAnimationToken(), durationMs: MENU_HIGHLIGHT_DURATION_MS }
|
||||
? { from, to: scroll, startedAt: now, token: nextAnimationToken(), durationMs: scrollMs }
|
||||
: undefined;
|
||||
this.previous = { scroll, box: { ...box } };
|
||||
} else if (this.bounceBy && enabled) {
|
||||
} else if (this.bounceBy && scrollMs > 0) {
|
||||
const from = this.offsetAt(scroll, now);
|
||||
this.animation = Math.abs(scroll - from) <= MAX_ANIMATED_SCROLL
|
||||
? { from, peak: scroll + this.bounceBy, to: scroll, startedAt: now, token: nextAnimationToken(), durationMs: MENU_BOUNCE_DURATION_MS }
|
||||
? { from, peak: scroll + this.bounceBy, to: scroll, startedAt: now, token: nextAnimationToken(),
|
||||
durationMs: menuAnimationDurationMs(MENU_BOUNCE_DURATION_MS) }
|
||||
: undefined;
|
||||
}
|
||||
this.navigated = false;
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage, type UiFont } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { getBooleanSetting } from "../native/settings-store";
|
||||
import { getStringSetting } from "../native/settings-store";
|
||||
import { clamp } from "../util/numeric-util";
|
||||
import { normalizeAnimationSpeed } from "./animation-speed";
|
||||
import { Layer, LayerContext, PaintBelow } from "./layers";
|
||||
import { MENU_ANIMATION_KEY, setMenuAnimationReader } from "./menu-animation-pref";
|
||||
import { Menu, MENU_HIGHLIGHT_FILL, MENU_HIGHLIGHT_STROKE } from "./menu-core";
|
||||
@@ -12,7 +13,7 @@ import { LIST_ROW_TEXT_INSET, centeredTextY, lineStep, listRowHeight, menuTitleH
|
||||
|
||||
// Menu<T> and IconGrid consult this (through their motion classes) at each
|
||||
// paint; a SharedPreferences read, so changes apply to the next navigation.
|
||||
setMenuAnimationReader(() => getBooleanSetting(MENU_ANIMATION_KEY, true));
|
||||
setMenuAnimationReader(() => normalizeAnimationSpeed(getStringSetting(MENU_ANIMATION_KEY, "normal")));
|
||||
|
||||
const DEFAULT_MENU_X = 8;
|
||||
const DEFAULT_MENU_Y = 8;
|
||||
|
||||
@@ -25,6 +25,7 @@ function settingsFixture(store = new Map()) {
|
||||
getBooleanSetting: (k, d) => store.get(k) ?? d, setBooleanSetting: (k, v) => store.set(k, v),
|
||||
};
|
||||
if (id.includes('brightness-curve')) return require('../.test-build/app/g2/brightness-curve.js');
|
||||
if (id.includes('animation-speed')) return require('../.test-build/app/ui/animation-speed.js');
|
||||
return { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] };
|
||||
}};
|
||||
vm.runInNewContext(ts.transpileModule(fs.readFileSync('app/ui/dashboard-settings.ts', 'utf8'), {
|
||||
@@ -36,11 +37,11 @@ test('auto minimum defaults to 20 and preserves a saved preference', () => {
|
||||
assert.equal(settingsFixture().getBrightnessPreferences().minimum, 20);
|
||||
assert.equal(settingsFixture(new Map([['display.autoBrightnessMin', '25']])).getBrightnessPreferences().minimum, 25);
|
||||
});
|
||||
test('the screen fade setting switches the on/off fade between 280 ms and instant', () => {
|
||||
test('the screen fade speed scales the 280 ms on/off fade, or makes it instant', () => {
|
||||
const api = settingsFixture();
|
||||
assert.equal(api.getBrightnessPreferences().fadeMs, 280);
|
||||
api.screenFadeSetting.set(false);
|
||||
assert.equal(api.getBrightnessPreferences().fadeMs, 0);
|
||||
const fadeAt = (speed) => { api.screenFadeSetting.set(speed); return api.getBrightnessPreferences().fadeMs; };
|
||||
assert.deepEqual(['very-fast', 'fast', 'normal', 'slow', 'disabled'].map(fadeAt), [56, 140, 280, 560, 0]);
|
||||
});
|
||||
test('curve drafts preview exactly while brightness keeps the previous valid saved curve', () => {
|
||||
const store = new Map([['display.autoBrightnessCurve', '0:0,2:50,8:100']]);
|
||||
|
||||
@@ -27,7 +27,7 @@ const layers = load('app/ui/layers.ts', {
|
||||
'../native/frame-timings': { spanCurrent: (_name, paint) => paint() },
|
||||
});
|
||||
const menu = load('app/ui/menu.ts', {
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), '../native/settings-store': { getBooleanSetting: (_key, fallback) => fallback },
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
'../graphics/image': graphics, '../graphics/ui-fonts': fonts, '../graphics/textwrap': textwrap,
|
||||
'../util/numeric-util': numeric, './gestures': gestures, './metrics': load('app/ui/metrics.ts'),
|
||||
|
||||
@@ -63,7 +63,8 @@ function loadIconGrid({ lastInputWasWatch = false } = {}) {
|
||||
const menu = load('app/ui/menu.ts', {
|
||||
...common, './layers': {},
|
||||
'./menu-animation-pref': build('ui/menu-animation-pref'),
|
||||
'../native/settings-store': { getBooleanSetting: (_key, fallback) => fallback },
|
||||
'./animation-speed': build('ui/animation-speed'),
|
||||
'../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
});
|
||||
const grid = load('app/ui/icon-grid.ts', {
|
||||
...common,
|
||||
|
||||
@@ -18,7 +18,7 @@ const menuCore=load('app/ui/menu-core.ts',{
|
||||
'../graphics/image':graphics,'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
});
|
||||
const {MenuLayer}=load('app/ui/menu.ts',{
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), '../native/settings-store': { getBooleanSetting: (_key, fallback) => fallback },
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
'../graphics/image':graphics,'../graphics/textwrap':{},'../graphics/ui-fonts':{getDefaultSmallFont:()=>font},
|
||||
'../util/numeric-util':{clamp:(n,a,b)=>Math.max(a,Math.min(b,n))},'./gestures':{},
|
||||
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
@@ -110,3 +110,9 @@ test('shell modal carries its inner menu highlight animation instead of baking i
|
||||
assert.ok(row.y>before.y);assert.ok(row.presentation.displayList.timeline,'the slide stays a timed display list');
|
||||
assert.ok(!image.withDrawsBaked(false).pixels.some(v=>v===255),'selected text is not baked into the modal surface');
|
||||
});
|
||||
test('shell crop widens a fractional rect (TTF-measured status bar) to whole pixels',()=>{
|
||||
const {shellCrop}=require('../.test-build/app/graphics/shell-scene.js'),image=new graphics.GrayImage(576,288,7);
|
||||
const crop=shellCrop(image,400.5,250,175.5,15,2);
|
||||
assert.deepEqual([crop.x,crop.y,crop.image.width,crop.image.height],[400,250,176,15]);
|
||||
assert.ok(crop.image.pixels.every(v=>v===7));
|
||||
});
|
||||
@@ -1,13 +1,13 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { Menu } = require('../.test-build/app/ui/menu-core.js');
|
||||
const { MENU_HIGHLIGHT_DURATION_MS } = require('../.test-build/app/ui/menu-highlight-motion.js');
|
||||
const { MenuHighlightMotion, MENU_HIGHLIGHT_DURATION_MS } = require('../.test-build/app/ui/menu-highlight-motion.js');
|
||||
const { GrayImage } = require('../.test-build/app/graphics/image.js');
|
||||
const { DrawOp, encodeDisplayList, readDisplayList } = require('../.test-build/app/graphics/display-list.js');
|
||||
const { evaluate } = require('../.test-build/app/graphics/draw-expression.js');
|
||||
const { DrawExpression: E } = require('../.test-build/app/graphics/draw-expression.js');
|
||||
const { menuScrollList, slidingHighlightY } = require('../.test-build/app/graphics/menu-scroll-list.js');
|
||||
const { MENU_BOUNCE_DURATION_MS, scrollOffsetExpression } = require('../.test-build/app/ui/menu-scroll-motion.js');
|
||||
const { MenuScrollMotion, MENU_BOUNCE_DURATION_MS, scrollOffsetExpression } = require('../.test-build/app/ui/menu-scroll-motion.js');
|
||||
const { encodePresentation } = require('../.test-build/app/graphics/presentation-wire.js');
|
||||
const { setMenuAnimationReader } = require('../.test-build/app/ui/menu-animation-pref.js');
|
||||
// Also consumed by FrameDisplayListTest.kt.
|
||||
@@ -197,9 +197,9 @@ test('a bounce during a scroll starts from the offset on screen', () => {
|
||||
assert.ok(offsets[0] < offsets[1], 'it starts where the scroll had got to, above its settled offset');
|
||||
});
|
||||
|
||||
test('with menu animation off, scrolls, slides and bounces snap', (t) => {
|
||||
setMenuAnimationReader(() => false);
|
||||
t.after(() => setMenuAnimationReader(() => true));
|
||||
test('with menu animation disabled, scrolls, slides and bounces snap', (t) => {
|
||||
setMenuAnimationReader(() => 'disabled');
|
||||
t.after(() => setMenuAnimationReader(() => 'normal'));
|
||||
const timed = (image) => image.draws.filter((draw) => draw.presentation?.displayList?.timeline);
|
||||
const menu = inkMenu();
|
||||
paint(menu, 1000);
|
||||
@@ -217,6 +217,23 @@ test('with menu animation off, scrolls, slides and bounces snap', (t) => {
|
||||
assert.equal(timed(paint(menu, 5000)).length, 0, 'no bounce');
|
||||
});
|
||||
|
||||
test('menu animation speed scales slide, scroll and bounce durations', (t) => {
|
||||
t.after(() => setMenuAnimationReader(() => 'normal'));
|
||||
for (const [speed, factor] of [['very-fast', 5], ['fast', 2], ['normal', 1], ['slow', 0.5]]) {
|
||||
setMenuAnimationReader(() => speed);
|
||||
const highlight = new MenuHighlightMotion();
|
||||
highlight.paint(0, 0, 10, 20, 100, 20, 0);
|
||||
highlight.navigate(0, false);
|
||||
assert.equal(highlight.paint(1, 0, 10, 40, 100, 20, 100).durationMs, MENU_HIGHLIGHT_DURATION_MS / factor, speed);
|
||||
const scroll = new MenuScrollMotion();
|
||||
scroll.paint(0, BOX, 0);
|
||||
scroll.navigate(false);
|
||||
assert.equal(scroll.paint(20, BOX, 100).durationMs, MENU_HIGHLIGHT_DURATION_MS / factor, speed);
|
||||
scroll.bounce(8);
|
||||
assert.equal(scroll.paint(20, BOX, 1000).durationMs, MENU_BOUNCE_DURATION_MS / factor, speed);
|
||||
}
|
||||
});
|
||||
|
||||
test('scroll lists survive the bridge with animated copy coordinates', () => {
|
||||
const strip = { width: 2, height: 4, pixels: Uint8Array.of(17, 34, 51, 68, 85, 102, 119, 136) };
|
||||
const timeline = { from: 0, to: 2, startedAt: 1000, token: 7, durationMs: MENU_HIGHLIGHT_DURATION_MS };
|
||||
|
||||
@@ -155,7 +155,7 @@ test('Music settings keeps toggles and selection when a new app arrives and supp
|
||||
'../util/numeric-util': { clamp: (n, lo, hi) => Math.max(lo, Math.min(hi, n)) },
|
||||
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
'./metrics': load('app/ui/metrics.ts'), './gestures': {},
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), '../native/settings-store': { getBooleanSetting: (_key, fallback) => fallback },
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
};
|
||||
deps['./menu-core'] = load('app/ui/menu-core.ts', (name) => deps[name]);
|
||||
const menu = load('app/ui/menu.ts', (name) => deps[name]);
|
||||
|
||||
@@ -86,7 +86,7 @@ function ui(fontSize = 12) {
|
||||
'../util/render-freshness': { renderPassAllowsStaleData: () => false },
|
||||
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
'./metrics': load('app/ui/metrics.ts'),
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), '../native/settings-store': { getBooleanSetting: (_key, fallback) => fallback },
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
'./gestures': {},
|
||||
};
|
||||
const requireModule = (name) => {
|
||||
|
||||
@@ -22,7 +22,7 @@ const font = BdfFont.parse(fs.readFileSync(path.join(__dirname, '../app/fonts/te
|
||||
const textwrap = load('app/graphics/textwrap.ts', {});
|
||||
const fonts = { getDefaultSmallFont: () => font };
|
||||
const menu = load('app/ui/menu.ts', {
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), '../native/settings-store': { getBooleanSetting: (_key, fallback) => fallback },
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
'../graphics/image': graphics, '../graphics/textwrap': textwrap, '../graphics/ui-fonts': fonts,
|
||||
'../util/numeric-util': { clamp: (n, lo, hi) => Math.max(lo, Math.min(hi, n)) }, './gestures': {},
|
||||
'./metrics': metrics, './menu-core': menuCore,
|
||||
|
||||
Reference in new issue
Block a user