From 9a8c3dff8958c5e94dc2aaaa4ac62f7f21e8faa9 Mon Sep 17 00:00:00 2001 From: bymyself Date: Mon, 27 Jan 2025 01:41:08 -0700 Subject: [PATCH] Remove scaling of context menus (#431) * remove scaling of context menus based on graph scale * deprecate scale in interface * Add option to restore old context scaling behaviour Revert "remove scaling of context menus based on graph scale" This reverts commit d91ecaa86c671aea272844c3900a18da1af7bf01. * Update test expectations --------- Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com> --- src/ContextMenu.ts | 4 +++- src/LiteGraphGlobal.ts | 3 +++ src/interfaces.ts | 1 + test/__snapshots__/litegraph.test.ts.snap | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ContextMenu.ts b/src/ContextMenu.ts index 6dd5d54c8e..9614e4ce16 100644 --- a/src/ContextMenu.ts +++ b/src/ContextMenu.ts @@ -181,7 +181,9 @@ export class ContextMenu { root.style.left = left + "px" root.style.top = top + "px" - if (options.scale) root.style.transform = `scale(${Math.round(options.scale * 4) * 0.25})` + if (LiteGraph.context_menu_scaling && options.scale) { + root.style.transform = `scale(${Math.round(options.scale * 4) * 0.25})` + } } addItem( diff --git a/src/LiteGraphGlobal.ts b/src/LiteGraphGlobal.ts index 7bda51d8eb..d5b3b10b9f 100644 --- a/src/LiteGraphGlobal.ts +++ b/src/LiteGraphGlobal.ts @@ -257,6 +257,9 @@ export class LiteGraphGlobal { /** If `true`, the old "eye-melting-red" error indicator will be used for nodes */ use_legacy_node_error_indicator = false + /** Whether to scale context with the graph when zooming in. Zooming out never makes context menus smaller. */ + context_menu_scaling = false + // TODO: Remove legacy accessors LGraph = LGraph LLink = LLink diff --git a/src/interfaces.ts b/src/interfaces.ts index 1696b9c788..b7cecbfa8c 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -273,6 +273,7 @@ export interface IContextMenuOptions extends IContextMenuBase { scroll_speed?: number left?: number top?: number + /** @deprecated Context menus no longer scale using transform */ scale?: number node?: LGraphNode autoopen?: boolean diff --git a/test/__snapshots__/litegraph.test.ts.snap b/test/__snapshots__/litegraph.test.ts.snap index 9c932a83af..496319b065 100644 --- a/test/__snapshots__/litegraph.test.ts.snap +++ b/test/__snapshots__/litegraph.test.ts.snap @@ -142,6 +142,7 @@ LiteGraphGlobal { "auto_sort_node_types": false, "catch_exceptions": true, "click_do_break_link_to": false, + "context_menu_scaling": false, "ctrl_alt_click_do_break_link": true, "ctrl_shift_v_paste_connect_unselected_outputs": true, "debug": false,