forked from Blendman974/faceclaw
Context menus: gesture switch between app and system context menus; gesture help text; move items from app to system menu
This commit is contained in:
1 parent
061f50e711
commit
987f442897
15 files changed
+343
-205
No files matched your search
@@ -10,14 +10,15 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { getActiveDisplay } from "../../native/active-display";
|
||||
import { buildSoundSequencePayload, type Step } from "../../ui/sound-effects";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { type MenuItem } from "../../ui/menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import {
|
||||
directionalFallback,
|
||||
@@ -287,9 +288,9 @@ function playSfx(window: BlocksWindow, steps: Step[]): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** The window's long-press menu (sound toggle + default entries). */
|
||||
function openWindowMenu(window: BlocksWindow): void {
|
||||
windowMenu(window).open([
|
||||
/** The window's long-press menu (sound toggle); playing binds long-press to hard drop instead. */
|
||||
function windowMenuItems(window: BlocksWindow): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: window.soundOn ? "Sound: on" : "Sound: off",
|
||||
onSelect: (ctx) => {
|
||||
@@ -298,14 +299,17 @@ function openWindowMenu(window: BlocksWindow): void {
|
||||
if (window.soundOn) playSfx(window, SFX_RESUME);
|
||||
},
|
||||
},
|
||||
...defaultWindowMenuItems(window.windowId, post),
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
function windowMenu(window: BlocksWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
windowId: window.windowId,
|
||||
post,
|
||||
title: () => window.title,
|
||||
items: () => windowMenuItems(window),
|
||||
longPressOpensMenu: () => window.phase !== "playing",
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
@@ -382,7 +386,7 @@ function handleIdleInput(window: BlocksWindow, event: InputEvent, frameId: numbe
|
||||
post({ type: "yield-focus", windowId: window.windowId });
|
||||
return;
|
||||
case "long-press":
|
||||
openWindowMenu(window);
|
||||
windowMenu(window).open();
|
||||
break;
|
||||
default:
|
||||
frameTimings.finishFrame(frameId, "discarded: blocks ignored input");
|
||||
@@ -557,10 +561,7 @@ function updateTickTimer(window: BlocksWindow): void {
|
||||
}
|
||||
|
||||
function paint(window: BlocksWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return singlePlane(paintContent(window));
|
||||
return windowMenu(window).paint();
|
||||
}
|
||||
|
||||
function paintContent(window: BlocksWindow): GrayImage {
|
||||
|
||||
@@ -22,7 +22,7 @@ import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { getActiveDisplay } from "../../native/active-display";
|
||||
import { buildSoundSequencePayload, type Step } from "../../ui/sound-effects";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { MenuItem } from "../../ui/menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import { directionalFallback, GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_LONG_PRESS, type InputEvent } from "../../ui/gestures";
|
||||
@@ -214,8 +214,8 @@ function playSfx(window: FreecellWindow, steps: Step[]): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** The window's long-press menu (game actions + default entries). */
|
||||
function openWindowMenu(window: FreecellWindow): void {
|
||||
/** The window's long-press menu (game actions). */
|
||||
function windowMenuItems(window: FreecellWindow): MenuItem[] {
|
||||
const items: MenuItem[] = [];
|
||||
if (window.undoStack.length > 0 && window.phase === "playing") {
|
||||
items.push({
|
||||
@@ -252,13 +252,16 @@ function openWindowMenu(window: FreecellWindow): void {
|
||||
},
|
||||
},
|
||||
);
|
||||
windowMenu(window).open([...items, ...defaultWindowMenuItems(window.windowId, post)]);
|
||||
return items;
|
||||
}
|
||||
|
||||
function windowMenu(window: FreecellWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
windowId: window.windowId,
|
||||
post,
|
||||
title: () => window.title,
|
||||
items: () => windowMenuItems(window),
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
@@ -330,7 +333,7 @@ function handlePlayingInput(window: FreecellWindow, event: InputEvent, frameId:
|
||||
}
|
||||
break;
|
||||
case "long-press":
|
||||
openWindowMenu(window);
|
||||
windowMenu(window).open();
|
||||
break;
|
||||
default:
|
||||
frameTimings.finishFrame(frameId, "discarded: freecell ignored input");
|
||||
@@ -350,7 +353,7 @@ function handleWonInput(window: FreecellWindow, event: InputEvent, frameId: numb
|
||||
post({ type: "yield-focus", windowId: window.windowId });
|
||||
return;
|
||||
case "long-press":
|
||||
openWindowMenu(window);
|
||||
windowMenu(window).open();
|
||||
break;
|
||||
default:
|
||||
frameTimings.finishFrame(frameId, "discarded: freecell ignored input");
|
||||
@@ -632,19 +635,18 @@ function layoutFor(window: FreecellWindow): Layout {
|
||||
}
|
||||
|
||||
function paint(window: FreecellWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
const planes = singlePlane(paintContent(window));
|
||||
if (window.phase === "won") {
|
||||
// The win box goes on its own plane: card labels are deferred glyphs that
|
||||
// render above their own image's raster, so an overlay drawn into the
|
||||
// board image could not cover them.
|
||||
const overlay = new GrayImage(window.viewportWidth, window.viewportHeight, 0);
|
||||
paintWinOverlay(overlay, window);
|
||||
planes.push({ image: overlay, x: 0, y: 0 });
|
||||
}
|
||||
return planes;
|
||||
return windowMenu(window).paint(() => {
|
||||
const planes = singlePlane(paintContent(window));
|
||||
if (window.phase === "won") {
|
||||
// The win box goes on its own plane: card labels are deferred glyphs
|
||||
// that render above their own image's raster, so an overlay drawn into
|
||||
// the board image could not cover them.
|
||||
const overlay = new GrayImage(window.viewportWidth, window.viewportHeight, 0);
|
||||
paintWinOverlay(overlay, window);
|
||||
planes.push({ image: overlay, x: 0, y: 0 });
|
||||
}
|
||||
return planes;
|
||||
});
|
||||
}
|
||||
|
||||
function paintContent(window: FreecellWindow): GrayImage {
|
||||
|
||||
@@ -15,14 +15,15 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { getActiveDisplay } from "../../native/active-display";
|
||||
import { buildSoundSequencePayload, type Step } from "../../ui/sound-effects";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { type MenuItem } from "../../ui/menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import {
|
||||
directionalFallback,
|
||||
@@ -251,10 +252,10 @@ function playSfx(window: MinesweeperWindow, steps: Step[]): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** The window's long-press menu (game actions + default entries). */
|
||||
function openWindowMenu(window: MinesweeperWindow): void {
|
||||
/** The window's long-press menu (game actions); playing binds long-press to flagging instead. */
|
||||
function windowMenuItems(window: MinesweeperWindow): MenuItem[] {
|
||||
const nextDifficulty = DIFFICULTIES[(window.difficultyIndex + 1) % DIFFICULTIES.length]!;
|
||||
windowMenu(window).open([
|
||||
return [
|
||||
{
|
||||
label: "New game",
|
||||
onSelect: (ctx) => {
|
||||
@@ -280,14 +281,17 @@ function openWindowMenu(window: MinesweeperWindow): void {
|
||||
if (window.soundOn) playSfx(window, SFX_RESUME);
|
||||
},
|
||||
},
|
||||
...defaultWindowMenuItems(window.windowId, post),
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
function windowMenu(window: MinesweeperWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
windowId: window.windowId,
|
||||
post,
|
||||
title: () => window.title,
|
||||
items: () => windowMenuItems(window),
|
||||
longPressOpensMenu: () => window.phase !== "playing",
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
@@ -395,7 +399,7 @@ function handleIdleInput(window: MinesweeperWindow, event: InputEvent, frameId:
|
||||
post({ type: "yield-focus", windowId: window.windowId });
|
||||
return;
|
||||
case "long-press":
|
||||
openWindowMenu(window);
|
||||
windowMenu(window).open();
|
||||
break;
|
||||
default:
|
||||
frameTimings.finishFrame(frameId, "discarded: minesweeper ignored input");
|
||||
@@ -591,10 +595,7 @@ function elapsedMs(window: MinesweeperWindow): number {
|
||||
}
|
||||
|
||||
function paint(window: MinesweeperWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return singlePlane(paintContent(window));
|
||||
return windowMenu(window).paint();
|
||||
}
|
||||
|
||||
function paintContent(window: MinesweeperWindow): GrayImage {
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { getActiveDisplay } from "../../native/active-display";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { type MenuItem } from "../../ui/menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import type { ToolSpec, ToolResult } from "../../assistant/tool-registry";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL, type InputEvent } from "../../ui/gestures";
|
||||
@@ -611,10 +612,28 @@ function describeRouteStatus(): string {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Input
|
||||
|
||||
/** The window's long-press menu: only Stop navigation, and only while a route is up. */
|
||||
function windowMenuItems(win: NavWindow): MenuItem[] {
|
||||
if (phase !== "navigating" && phase !== "arrived") return [];
|
||||
return [
|
||||
{
|
||||
label: "Stop navigation",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
stopNavigation("Navigation stopped.");
|
||||
render();
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function windowMenu(win: NavWindow): WindowMenu {
|
||||
if (!win.menu) {
|
||||
win.menu = new WindowMenu({
|
||||
windowId: win.windowId,
|
||||
post,
|
||||
title: () => win.title,
|
||||
items: () => windowMenuItems(win),
|
||||
size: { width: win.viewportWidth, height: win.viewportHeight },
|
||||
paintBase: () => paintContent(win),
|
||||
isFocused: () => win.focused,
|
||||
@@ -632,18 +651,7 @@ function handleInput(win: NavWindow, event: InputEvent, frameId: number): void {
|
||||
return;
|
||||
}
|
||||
if (event.type === "long-press") {
|
||||
const items = [...defaultWindowMenuItems(win.windowId, post)];
|
||||
if (phase === "navigating" || phase === "arrived") {
|
||||
items.unshift({
|
||||
label: "Stop navigation",
|
||||
onSelect: (ctx: any) => {
|
||||
ctx.stack.pop();
|
||||
stopNavigation("Navigation stopped.");
|
||||
render();
|
||||
},
|
||||
});
|
||||
}
|
||||
windowMenu(win).open(items);
|
||||
windowMenu(win).open();
|
||||
renderAndSubmit(win, frameId);
|
||||
return;
|
||||
}
|
||||
@@ -683,8 +691,7 @@ function handleInput(win: NavWindow, event: InputEvent, frameId: number): void {
|
||||
// Painting
|
||||
|
||||
function paint(win: NavWindow): Plane[] {
|
||||
if (win.menu?.isOpen()) return win.menu.paint();
|
||||
return singlePlane(paintContent(win));
|
||||
return windowMenu(win).paint();
|
||||
}
|
||||
|
||||
function paintContent(win: NavWindow): GrayImage {
|
||||
@@ -701,7 +708,7 @@ function paintIdle(image: GrayImage): void {
|
||||
image.drawText(mediumFont, 24, 16, "Navigate", 245);
|
||||
const busy = phase !== "idle";
|
||||
const hint = isMapboxConfigured()
|
||||
? "Ask the voice assistant to navigate somewhere, or use Voice input from the long-press menu to say a destination."
|
||||
? "Ask the voice assistant to navigate somewhere, or pick Voice input from the system menu (tap, then hold) to say a destination."
|
||||
: "Set a Mapbox token in Settings > API Keys to enable navigation.";
|
||||
image.drawTextWrapped({ font: smallFont, x: 24, y: 64, width: image.width - 48, text: hint, value: 170 });
|
||||
if (statusMessage) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
@@ -29,7 +29,8 @@ import * as frameTimings from "../../native/frame-timings";
|
||||
import { getActiveDisplay } from "../../native/active-display";
|
||||
import { getStringSetting, setStringSetting } from "../../native/settings-store";
|
||||
import { buildSoundSequencePayload, type Step } from "../../ui/sound-effects";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { type MenuItem } from "../../ui/menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import {
|
||||
directionalFallback,
|
||||
@@ -445,9 +446,9 @@ function playSfx(window: PinballWindow, steps: Step[], minor = false): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** The window's long-press menu (game actions + default entries). */
|
||||
function openWindowMenu(window: PinballWindow): void {
|
||||
windowMenu(window).open([
|
||||
/** The window's long-press menu (game actions); playing binds long-press to the nudge instead. */
|
||||
function windowMenuItems(window: PinballWindow): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: "New game",
|
||||
onSelect: (ctx) => {
|
||||
@@ -464,14 +465,17 @@ function openWindowMenu(window: PinballWindow): void {
|
||||
if (window.soundOn) playSfx(window, SFX_RESUME);
|
||||
},
|
||||
},
|
||||
...defaultWindowMenuItems(window.windowId, post),
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
function windowMenu(window: PinballWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
windowId: window.windowId,
|
||||
post,
|
||||
title: () => window.title,
|
||||
items: () => windowMenuItems(window),
|
||||
longPressOpensMenu: () => window.phase !== "playing",
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
@@ -577,7 +581,7 @@ function handleIdleInput(window: PinballWindow, event: InputEvent, frameId: numb
|
||||
post({ type: "yield-focus", windowId: window.windowId });
|
||||
return;
|
||||
case "long-press":
|
||||
openWindowMenu(window);
|
||||
windowMenu(window).open();
|
||||
break;
|
||||
default:
|
||||
frameTimings.finishFrame(frameId, "discarded: pinball ignored input");
|
||||
@@ -948,10 +952,7 @@ function drawFlipper(image: GrayImage, flipper: Flipper): void {
|
||||
}
|
||||
|
||||
function paint(window: PinballWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return singlePlane(paintContent(window));
|
||||
return windowMenu(window).paint();
|
||||
}
|
||||
|
||||
function paintContent(window: PinballWindow): GrayImage {
|
||||
|
||||
@@ -17,7 +17,7 @@ import * as frameTimings from "../../native/frame-timings";
|
||||
import { getActiveDisplay } from "../../native/active-display";
|
||||
import { onSettingsStoreChanged } from "../../native/settings-store";
|
||||
import type { MenuItem } from "../../ui/menu";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import type { ToolResult, ToolSpec } from "../../assistant/tool-registry";
|
||||
import { GESTURE_CLICK, type InputEvent } from "../../ui/gestures";
|
||||
@@ -329,7 +329,10 @@ function maybeRefreshStalePage(): void {
|
||||
function windowMenu(win: RoamWindow): WindowMenu {
|
||||
if (!win.menu) {
|
||||
win.menu = new WindowMenu({
|
||||
windowId: win.windowId,
|
||||
post,
|
||||
title: () => win.title,
|
||||
items: () => menuItems(win),
|
||||
size: { width: win.viewportWidth, height: win.viewportHeight },
|
||||
paintBase: () => paintContent(win),
|
||||
isFocused: () => win.focused,
|
||||
@@ -380,7 +383,7 @@ function menuItems(win: RoamWindow): MenuItem[] {
|
||||
beginSettingEdit(roamApiTokenSetting);
|
||||
},
|
||||
});
|
||||
return [...items, ...defaultWindowMenuItems(win.windowId, post)];
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,7 +424,7 @@ function handleInput(win: RoamWindow, event: InputEvent, frameId: number): void
|
||||
return;
|
||||
}
|
||||
if (event.type === "long-press") {
|
||||
windowMenu(win).open(menuItems(win));
|
||||
windowMenu(win).open();
|
||||
renderAndSubmit(win, frameId);
|
||||
return;
|
||||
}
|
||||
@@ -583,9 +586,9 @@ async function handleRoamTool(name: string, args: any): Promise<ToolResult> {
|
||||
// Painting
|
||||
|
||||
function paint(win: RoamWindow): Plane[] {
|
||||
if (win.menu?.isOpen()) return win.menu.paint();
|
||||
if (editingSetting) return singlePlane(paintSettingEdit(win, editingSetting));
|
||||
return singlePlane(paintContent(win));
|
||||
return windowMenu(win).paint(() =>
|
||||
singlePlane(editingSetting ? paintSettingEdit(win, editingSetting) : paintContent(win)),
|
||||
);
|
||||
}
|
||||
|
||||
/** The "type on the phone" screen shown while a Roam setting is being edited. */
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage, type UiFont } from "../../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getTerminalFontConfig } from "../../graphics/ui-fonts";
|
||||
import { truncateText } from "../../graphics/textwrap";
|
||||
@@ -48,7 +48,7 @@ import { connectionDisplayName, loadConnections, parseConnectionString, saveConn
|
||||
import { TerminalEmulator } from "./terminal-emulator";
|
||||
import { drawListScrollbar, drawSelectionHighlight, scrollToKeepSelectionVisible, type MenuItem } from "../../ui/menu";
|
||||
import { lineStep, listRowHeight } from "../../ui/metrics";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import { appViewportSize } from "../../ui/shell/geometry";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import type { ToolResult, ToolSpec } from "../../assistant/tool-registry";
|
||||
@@ -905,7 +905,10 @@ function reconnectView(window: ViewWindow): void {
|
||||
function windowMenu(window: TerminalWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
windowId: window.windowId,
|
||||
post,
|
||||
title: () => window.title,
|
||||
items: () => windowMenuItems(window),
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
@@ -984,7 +987,6 @@ function windowMenuItems(window: TerminalWindow): MenuItem[] {
|
||||
},
|
||||
);
|
||||
}
|
||||
items.push(...defaultWindowMenuItems(window.windowId, post));
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -999,7 +1001,7 @@ function handleInput(window: TerminalWindow, event: InputEvent, frameId: number)
|
||||
return;
|
||||
}
|
||||
if (event.type === "long-press") {
|
||||
windowMenu(window).open(windowMenuItems(window));
|
||||
windowMenu(window).open();
|
||||
renderAndSubmit(window, frameId);
|
||||
return;
|
||||
}
|
||||
@@ -1457,10 +1459,7 @@ async function launchAndOpenView(control: ControlConnection, preset: string): Pr
|
||||
}
|
||||
|
||||
function paint(window: TerminalWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return singlePlane(paintContent(window));
|
||||
return windowMenu(window).paint();
|
||||
}
|
||||
|
||||
function paintContent(window: TerminalWindow): GrayImage {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { type UiFont, GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
fireTimerNotification,
|
||||
scheduleTimerNotification,
|
||||
} from "../../native/timer-notifications";
|
||||
import { defaultWindowMenuItems, WindowMenu } from "../../ui/window-menu";
|
||||
import { WindowMenu } from "../../ui/window-menu";
|
||||
import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-window";
|
||||
import type { ToolResult, ToolSpec } from "../../assistant/tool-registry";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL, type InputEvent } from "../../ui/gestures";
|
||||
@@ -294,11 +294,17 @@ function refreshWindowsAfterToolChange(): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** The window's long-press menu (default entries only), created lazily. */
|
||||
/**
|
||||
* The window's long-press menu, created lazily. The timer has no entries of
|
||||
* its own, so a long-press opens the shell's system menu in its place.
|
||||
*/
|
||||
function windowMenu(window: TimerWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
windowId: window.windowId,
|
||||
post,
|
||||
title: () => window.title,
|
||||
items: () => [],
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
@@ -317,7 +323,7 @@ function handleInput(window: TimerWindow, event: InputEvent, frameId: number): v
|
||||
return;
|
||||
}
|
||||
if (event.type === "long-press") {
|
||||
windowMenu(window).open(defaultWindowMenuItems(window.windowId, post));
|
||||
windowMenu(window).open();
|
||||
renderAndSubmit(window, frameId);
|
||||
return;
|
||||
}
|
||||
@@ -513,10 +519,7 @@ function updateRenderTimer(window: TimerWindow): void {
|
||||
}
|
||||
|
||||
function paint(window: TimerWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return singlePlane(paintContent(window));
|
||||
return windowMenu(window).paint();
|
||||
}
|
||||
|
||||
function paintContent(window: TimerWindow): GrayImage {
|
||||
|
||||
Reference in new issue
Block a user