Skip to content

Commit

Permalink
Remove scaling of context menus (#431)
Browse files Browse the repository at this point in the history
* 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 d91ecaa.

* Update test expectations

---------

Co-authored-by: filtered <[email protected]>
  • Loading branch information
christian-byrne and webfiltered authored Jan 27, 2025
1 parent f48cbb6 commit 9a8c3df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions src/LiteGraphGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/__snapshots__/litegraph.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9a8c3df

Please sign in to comment.