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 {
|
||||
|
||||
Reference in new issue
Block a user