File tree Expand file tree Collapse file tree 5 files changed +45
-1
lines changed Expand file tree Collapse file tree 5 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 16
16
@mousedown =" repeat('Comfy.Canvas.ZoomOut')"
17
17
@mouseup =" stopRepeat"
18
18
/>
19
+ <hr />
19
20
<Button
20
21
severity =" secondary"
21
22
icon =" pi pi-expand"
22
23
v-tooltip.left =" t('graphCanvasMenu.resetView')"
23
24
@click =" () => commandStore.execute('Comfy.Canvas.ResetView')"
24
25
/>
26
+ <Button
27
+ severity =" secondary"
28
+ icon =" pi pi-arrow-down-left-and-arrow-up-right-to-center"
29
+ v-tooltip.left =" t('graphCanvasMenu.fitView')"
30
+ @click =" () => commandStore.execute('Comfy.Canvas.FitView')"
31
+ />
25
32
<Button
26
33
severity =" secondary"
27
34
v-tooltip.left ="
@@ -96,4 +103,9 @@ const stopRepeat = () => {
96
103
margin : 0 ;
97
104
border-radius : 0 ;
98
105
}
106
+
107
+ .p-buttongroup-vertical hr {
108
+ margin : 0 ;
109
+ border-color : var (--p-panel-border-color );
110
+ }
99
111
</style >
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ const messages = {
111
111
zoomIn : 'Zoom In' ,
112
112
zoomOut : 'Zoom Out' ,
113
113
resetView : 'Reset View' ,
114
+ fitView : 'Fit View' ,
114
115
selectMode : 'Select Mode' ,
115
116
panMode : 'Pan Mode' ,
116
117
toggleLinkVisibility : 'Toggle Link Visibility'
@@ -225,6 +226,7 @@ const messages = {
225
226
zoomIn : '放大' ,
226
227
zoomOut : '缩小' ,
227
228
resetView : '重置视图' ,
229
+ fitView : 'Fit View' ,
228
230
selectMode : '选择模式' ,
229
231
panMode : '平移模式' ,
230
232
toggleLinkVisibility : '切换链接可见性'
@@ -342,6 +344,7 @@ const messages = {
342
344
zoomIn : 'Увеличить' ,
343
345
zoomOut : 'Уменьшить' ,
344
346
resetView : 'Сбросить вид' ,
347
+ fitView : 'Fit View' ,
345
348
selectMode : 'Выбрать режим' ,
346
349
panMode : 'Режим панорамирования' ,
347
350
toggleLinkVisibility : 'Переключить видимость ссылок'
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import { ComfyAppMenu } from './ui/menu/index'
27
27
import { getStorageValue } from './utils'
28
28
import { ComfyWorkflowManager , ComfyWorkflow } from './workflows'
29
29
import {
30
+ LGraphGroup ,
30
31
LGraphCanvas ,
31
32
LGraph ,
32
33
LGraphNode ,
@@ -2977,7 +2978,22 @@ export class ComfyApp {
2977
2978
public goToNode ( nodeId : NodeId ) {
2978
2979
const graphNode = this . graph . getNodeById ( nodeId )
2979
2980
if ( ! graphNode ) return
2980
- this . canvas . animateToNode ( graphNode )
2981
+ this . canvas . animateToBounds ( LGraphGroup . createBounds ( [ graphNode ] ) )
2982
+ }
2983
+
2984
+ /**
2985
+ * Fits the view to the selected nodes with animation.
2986
+ * If nothing is selected, the view is fitted around all nodes in the graph.
2987
+ */
2988
+ fitView ( ) {
2989
+ let selection : LGraphNode [ ]
2990
+ selection = Array . from ( app . canvas . selectedItems . values ( ) )
2991
+ . map ( ( i ) => this . graph . getNodeById ( i . id ) )
2992
+ . filter ( ( i ) => i !== null )
2993
+ if ( selection . length === 0 ) {
2994
+ selection = this . graph . nodes
2995
+ }
2996
+ this . canvas . animateToBounds ( LGraphGroup . createBounds ( selection ) )
2981
2997
}
2982
2998
}
2983
2999
Original file line number Diff line number Diff line change @@ -295,6 +295,12 @@ export const useCommandStore = defineStore('command', () => {
295
295
app . canvas . setDirty ( true , true )
296
296
}
297
297
} ,
298
+ {
299
+ id : 'Comfy.Canvas.FitView' ,
300
+ icon : 'pi pi-arrow-down-left-and-arrow-up-right-to-center' ,
301
+ label : 'Fit view to selected nodes' ,
302
+ function : ( ) => app . fitView ( )
303
+ } ,
298
304
{
299
305
id : 'Comfy.Canvas.ToggleLock' ,
300
306
icon : 'pi pi-lock' ,
Original file line number Diff line number Diff line change @@ -130,6 +130,13 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
130
130
commandId : 'Comfy.Canvas.ZoomOut' ,
131
131
targetSelector : '#graph-canvas'
132
132
} ,
133
+ {
134
+ combo : {
135
+ key : '.'
136
+ } ,
137
+ commandId : 'Comfy.Canvas.FitView' ,
138
+ targetSelector : '#graph-canvas'
139
+ } ,
133
140
{
134
141
combo : {
135
142
key : 'p'
You can’t perform that action at this time.
0 commit comments