Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node bypass color #971

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions browser_tests/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ test.describe('Node Interaction', () => {
await comfyPage.nextFrame()
await expect(comfyPage.canvas).toHaveScreenshot('nodes-unpinned.png')
})

test('Can bypass/unbypass nodes with keyboard shortcut', async ({
comfyPage
}) => {
await comfyPage.select2Nodes()
await comfyPage.canvas.press('Control+b')
await comfyPage.nextFrame()
await expect(comfyPage.canvas).toHaveScreenshot('nodes-bypassed.png')
await comfyPage.canvas.press('Control+b')
await comfyPage.nextFrame()
await expect(comfyPage.canvas).toHaveScreenshot('nodes-unbypassed.png')
})
})

test.describe('Group Interaction', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1551,21 +1551,24 @@ export class ComfyApp {

const origDrawNode = LGraphCanvas.prototype.drawNode
LGraphCanvas.prototype.drawNode = function (node, ctx) {
var editor_alpha = this.editor_alpha
var old_color = node.color
var old_bgcolor = node.bgcolor
const editor_alpha = this.editor_alpha
const old_color = node.color
const old_bgcolor = node.bgcolor

if (node.mode === 2) {
// never
this.editor_alpha = 0.4
}

// ComfyUI's custom node mode enum value 4 => bypass/never.
let bgColor: string
// @ts-expect-error
if (node.mode === 4) {
// never
node.bgcolor = '#FF00FF'
bgColor = '#FF00FF'
this.editor_alpha = 0.2
} else {
bgColor = old_bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR
}

const adjustments: ColorAdjustOptions = {}
Expand All @@ -1582,10 +1585,7 @@ export class ComfyApp {
}
}

node.bgcolor = adjustColor(
old_bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR,
adjustments
)
node.bgcolor = adjustColor(bgColor, adjustments)

const res = origDrawNode.apply(this, arguments)

Expand Down