Add toggle link visibility button on canvas menu (#1070)

* Basic link visibility toggle

* Icon change

* nit

* Update litegraph

* nit

* Add playwright test

* Update test expectations [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-10-02 15:23:37 -04:00
committed by GitHub
parent a19f713c57
commit 3a2b2f9e15
11 changed files with 104 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ import { useSettingStore } from '@/stores/settingStore'
import { useToastStore } from '@/stores/toastStore'
import { showTemplateWorkflowsDialog } from '@/services/dialogService'
import { useQueueStore } from './queueStore'
import { LiteGraph } from '@comfyorg/litegraph'
export interface ComfyCommand {
id: string
@@ -15,7 +16,7 @@ export interface ComfyCommand {
label?: string | (() => string)
icon?: string | (() => string)
tooltip?: string | (() => string)
shortcut?: string
versionAdded?: string
}
const getTracker = () =>
@@ -206,6 +207,29 @@ export const useCommandStore = defineStore('command', () => {
function: () => {
app.canvas['read_only'] = !app.canvas['read_only']
}
},
{
id: 'Comfy.Canvas.ToggleLinkVisibility',
icon: 'pi pi-eye',
label: 'Toggle Link Visibility',
versionAdded: '1.3.6',
function: (() => {
let lastLinksRenderMode = LiteGraph.SPLINE_LINK
return () => {
const currentMode = settingStore.get('Comfy.LinkRenderMode')
if (currentMode === LiteGraph.HIDDEN_LINK) {
// If links are hidden, restore the last positive value or default to spline mode
settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode)
} else {
// If links are visible, store the current mode and hide links
lastLinksRenderMode = currentMode
settingStore.set('Comfy.LinkRenderMode', LiteGraph.HIDDEN_LINK)
}
}
})()
}
]