Skip to content

Commit

Permalink
Move button loc
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Aug 28, 2024
1 parent 7fe211f commit 9d26e3e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
28 changes: 28 additions & 0 deletions src/scripts/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { ComfySettingsDialog } from './ui/settings'
import { ComfyApp, app } from './app'
import { TaskItem } from '@/types/apiTypes'
import { showSettingsDialog } from '@/services/dialogService'
import { useToastStore } from '@/stores/toastStore'
import { LGraphGroup } from '@comfyorg/litegraph'
import { useSettingStore } from '@/stores/settingStore'

export const ComfyDialog = _ComfyDialog

Expand Down Expand Up @@ -756,6 +759,31 @@ export class ComfyUI {
onclick: async () => {
app.resetView()
}
}),
$el('button', {
id: 'comfy-group-selected-nodes-button',
textContent: 'Group',
hidden: true,
onclick: () => {
if (
!app.canvas.selected_nodes ||
Object.keys(app.canvas.selected_nodes).length === 0
) {
useToastStore().add({
severity: 'error',
summary: 'No nodes selected',
detail: 'Please select nodes to group',
life: 3000
})
return
}
const group = new LGraphGroup()
const padding = useSettingStore().get(
'Comfy.GroupSelectedNodes.Padding'
)
group.addNodes(Object.values(app.canvas.selected_nodes), padding)
app.canvas.graph.add(group)
}
})
]) as HTMLDivElement

Expand Down
33 changes: 1 addition & 32 deletions src/scripts/ui/menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { ComfyWorkflowsMenu } from './workflows'
import { getInterruptButton } from './interruptButton'
import './menu.css'
import type { ComfySettingsDialog } from '../settings'
import { useToastStore } from '@/stores/toastStore'
import { LGraphGroup } from '@comfyorg/litegraph'
import { useSettingStore } from '@/stores/settingStore'

type MenuPosition = 'Disabled' | 'Top' | 'Bottom'

Expand Down Expand Up @@ -91,33 +88,6 @@ export class ComfyAppMenu {
app
})
)
const groupSelectedNodesButton = new ComfyButton({
icon: 'group',
content: 'Group',
tooltip: 'Group selected nodes',
action: () => {
if (
!app.canvas.selected_nodes ||
Object.keys(app.canvas.selected_nodes).length === 0
) {
useToastStore().add({
severity: 'error',
summary: 'No nodes selected',
detail: 'Please select nodes to group',
life: 3000
})
return
}
const group = new LGraphGroup()
const padding = useSettingStore().get(
'Comfy.GroupSelectedNodes.Padding'
)
group.addNodes(Object.values(app.canvas.selected_nodes), padding)
app.canvas.graph.add(group)
}
})
groupSelectedNodesButton.element.id = 'comfy-group-selected-nodes-button'
groupSelectedNodesButton.hidden = true

this.actionsGroup = new ComfyButtonGroup(
new ComfyButton({
Expand Down Expand Up @@ -152,8 +122,7 @@ export class ComfyAppMenu {
api.dispatchEvent(new CustomEvent('graphCleared'))
}
}
}),
groupSelectedNodesButton
})
)
// Keep the settings group as there are custom scripts attaching extra
// elements to it.
Expand Down

0 comments on commit 9d26e3e

Please sign in to comment.