Cleanup: Removing monkeypatches for litegraph logic (#5902)

## Summary

Putting the litegraph specific pieces into litegraph itself, using the
CanvasGraph and LiteGraphGlobal to coordinate options.

This was one part of the Image Previews reloading/calculating with every
canvas draw.

## Review Focus

Is this keeping things decoupled enough?
Is this the right place to put things?
Are there assumptions about the options that I'm missing here?

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-5902-WIP-Removing-monkeypatches-for-litegraph-logic-2816d73d3650818b860ec73579b89b54)
by [Unito](https://www.unito.io)

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Alexander Brown
2025-10-03 21:22:42 -07:00
committed by GitHub
parent abf2b3b980
commit 84e6e99f17
13 changed files with 50 additions and 66 deletions

View File

@@ -5194,10 +5194,9 @@ export class LGraphCanvas
const color = node.renderingColor
const bgcolor = node.renderingBgColor
const { low_quality, editor_alpha } = this
ctx.globalAlpha = editor_alpha
ctx.globalAlpha = this.getNodeModeAlpha(node)
if (this.render_shadows && !low_quality) {
if (this.render_shadows && !this.low_quality) {
ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR
ctx.shadowOffsetX = 2 * this.ds.scale
ctx.shadowOffsetY = 2 * this.ds.scale
@@ -5259,7 +5258,7 @@ export class LGraphCanvas
}
}
if (!low_quality) {
if (!this.low_quality) {
node.drawBadges(ctx)
}
@@ -5693,6 +5692,14 @@ export class LGraphCanvas
ctx.globalAlpha = 1
}
private getNodeModeAlpha(node: LGraphNode) {
return node.mode === LGraphEventMode.BYPASS
? 0.2
: node.mode === LGraphEventMode.NEVER
? 0.4
: this.editor_alpha
}
#renderFloatingLinks(
ctx: CanvasRenderingContext2D,
graph: LGraph,
@@ -6044,7 +6051,7 @@ export class LGraphCanvas
): void {
node.drawWidgets(ctx, {
lowQuality: this.low_quality,
editorAlpha: this.editor_alpha
editorAlpha: this.getNodeModeAlpha(node)
})
}