Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
479ef4b3
Commit
479ef4b3
authored
Mar 27, 2023
by
comfyanonymous
Browse files
Merge branch 'group-header' of
https://github.com/jn-jairo/ComfyUI
parents
967bfce0
63525ee8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
web/scripts/app.js
web/scripts/app.js
+93
-0
No files found.
web/scripts/app.js
View file @
479ef4b3
...
@@ -371,6 +371,96 @@ class ComfyApp {
...
@@ -371,6 +371,96 @@ class ComfyApp {
});
});
}
}
/**
* Handle mouse
*
* Move group by header
*/
#
addProcessMouseHandler
()
{
const
self
=
this
;
const
origProcessMouseDown
=
LGraphCanvas
.
prototype
.
processMouseDown
;
LGraphCanvas
.
prototype
.
processMouseDown
=
function
(
e
)
{
const
res
=
origProcessMouseDown
.
apply
(
this
,
arguments
);
this
.
selected_group_moving
=
false
;
if
(
this
.
selected_group
&&
!
this
.
selected_group_resizing
)
{
var
font_size
=
this
.
selected_group
.
font_size
||
LiteGraph
.
DEFAULT_GROUP_FONT_SIZE
;
var
height
=
font_size
*
1.4
;
// Move group by header
if
(
LiteGraph
.
isInsideRectangle
(
e
.
canvasX
,
e
.
canvasY
,
this
.
selected_group
.
pos
[
0
],
this
.
selected_group
.
pos
[
1
],
this
.
selected_group
.
size
[
0
],
height
))
{
this
.
selected_group_moving
=
true
;
}
}
return
res
;
}
const
origProcessMouseMove
=
LGraphCanvas
.
prototype
.
processMouseMove
;
LGraphCanvas
.
prototype
.
processMouseMove
=
function
(
e
)
{
const
orig_selected_group
=
this
.
selected_group
;
if
(
this
.
selected_group
&&
!
this
.
selected_group_resizing
&&
!
this
.
selected_group_moving
)
{
this
.
selected_group
=
null
;
}
const
res
=
origProcessMouseMove
.
apply
(
this
,
arguments
);
if
(
orig_selected_group
&&
!
this
.
selected_group_resizing
&&
!
this
.
selected_group_moving
)
{
this
.
selected_group
=
orig_selected_group
;
}
return
res
;
};
}
/**
* Draws group header bar
*/
#
addDrawGroupsHandler
()
{
const
self
=
this
;
const
origDrawGroups
=
LGraphCanvas
.
prototype
.
drawGroups
;
LGraphCanvas
.
prototype
.
drawGroups
=
function
(
canvas
,
ctx
)
{
if
(
!
this
.
graph
)
{
return
;
}
var
groups
=
this
.
graph
.
_groups
;
ctx
.
save
();
ctx
.
globalAlpha
=
0.7
*
this
.
editor_alpha
;
for
(
var
i
=
0
;
i
<
groups
.
length
;
++
i
)
{
var
group
=
groups
[
i
];
if
(
!
LiteGraph
.
overlapBounding
(
this
.
visible_area
,
group
.
_bounding
))
{
continue
;
}
//out of the visible area
ctx
.
fillStyle
=
group
.
color
||
"
#335
"
;
ctx
.
strokeStyle
=
group
.
color
||
"
#335
"
;
var
pos
=
group
.
_pos
;
var
size
=
group
.
_size
;
ctx
.
globalAlpha
=
0.25
*
this
.
editor_alpha
;
ctx
.
beginPath
();
var
font_size
=
group
.
font_size
||
LiteGraph
.
DEFAULT_GROUP_FONT_SIZE
;
ctx
.
rect
(
pos
[
0
]
+
0.5
,
pos
[
1
]
+
0.5
,
size
[
0
],
font_size
*
1.4
);
ctx
.
fill
();
ctx
.
globalAlpha
=
this
.
editor_alpha
;
}
ctx
.
restore
();
const
res
=
origDrawGroups
.
apply
(
this
,
arguments
);
return
res
;
}
}
/**
/**
* Draws node highlights (executing, drag drop) and progress bar
* Draws node highlights (executing, drag drop) and progress bar
*/
*/
...
@@ -518,6 +608,8 @@ class ComfyApp {
...
@@ -518,6 +608,8 @@ class ComfyApp {
canvasEl
.
tabIndex
=
"
1
"
;
canvasEl
.
tabIndex
=
"
1
"
;
document
.
body
.
prepend
(
canvasEl
);
document
.
body
.
prepend
(
canvasEl
);
this
.
#
addProcessMouseHandler
();
this
.
graph
=
new
LGraph
();
this
.
graph
=
new
LGraph
();
const
canvas
=
(
this
.
canvas
=
new
LGraphCanvas
(
canvasEl
,
this
.
graph
));
const
canvas
=
(
this
.
canvas
=
new
LGraphCanvas
(
canvasEl
,
this
.
graph
));
this
.
ctx
=
canvasEl
.
getContext
(
"
2d
"
);
this
.
ctx
=
canvasEl
.
getContext
(
"
2d
"
);
...
@@ -561,6 +653,7 @@ class ComfyApp {
...
@@ -561,6 +653,7 @@ class ComfyApp {
setInterval
(()
=>
localStorage
.
setItem
(
"
workflow
"
,
JSON
.
stringify
(
this
.
graph
.
serialize
())),
1000
);
setInterval
(()
=>
localStorage
.
setItem
(
"
workflow
"
,
JSON
.
stringify
(
this
.
graph
.
serialize
())),
1000
);
this
.
#
addDrawNodeHandler
();
this
.
#
addDrawNodeHandler
();
this
.
#
addDrawGroupsHandler
();
this
.
#
addApiUpdateHandlers
();
this
.
#
addApiUpdateHandlers
();
this
.
#
addDropHandler
();
this
.
#
addDropHandler
();
this
.
#
addPasteHandler
();
this
.
#
addPasteHandler
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment