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
7e51bbd0
"comfy/git@developer.sourcefind.cn:chenpangpang/ComfyUI.git" did not exist on "89507f8adff4aff4507b6f35a67717badaecd4ac"
Commit
7e51bbd0
authored
May 04, 2023
by
pythongosssss
Browse files
automatic calculation of image pos from widgets
parent
fcf513e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
17 deletions
+31
-17
web/scripts/app.js
web/scripts/app.js
+30
-9
web/scripts/widgets.js
web/scripts/widgets.js
+1
-8
No files found.
web/scripts/app.js
View file @
7e51bbd0
...
...
@@ -263,6 +263,34 @@ export class ComfyApp {
*/
#
addDrawBackgroundHandler
(
node
)
{
const
app
=
this
;
function
getImageTop
(
node
)
{
let
shiftY
;
if
(
node
.
imageOffset
!=
null
)
{
shiftY
=
node
.
imageOffset
;
}
else
{
if
(
node
.
widgets
?.
length
)
{
const
w
=
node
.
widgets
[
node
.
widgets
.
length
-
1
];
shiftY
=
w
.
last_y
;
if
(
w
.
computeSize
)
{
shiftY
+=
w
.
computeSize
()[
1
]
+
4
;
}
else
{
shiftY
+=
LiteGraph
.
NODE_WIDGET_HEIGHT
+
4
;
}
}
else
{
shiftY
=
node
.
computeSize
()[
1
];
}
}
return
shiftY
;
}
node
.
prototype
.
setSizeForImage
=
function
()
{
const
minHeight
=
getImageTop
(
this
)
+
220
;
if
(
this
.
size
[
1
]
<
minHeight
)
{
this
.
setSize
([
this
.
size
[
0
],
minHeight
]);
}
};
node
.
prototype
.
onDrawBackground
=
function
(
ctx
)
{
if
(
!
this
.
flags
.
collapsed
)
{
const
output
=
app
.
nodeOutputs
[
this
.
id
+
""
];
...
...
@@ -283,9 +311,7 @@ export class ComfyApp {
).
then
((
imgs
)
=>
{
if
(
this
.
images
===
output
.
images
)
{
this
.
imgs
=
imgs
.
filter
(
Boolean
);
if
(
this
.
size
[
1
]
<
100
)
{
this
.
size
[
1
]
=
250
;
}
this
.
setSizeForImage
?.();
app
.
graph
.
setDirtyCanvas
(
true
);
}
});
...
...
@@ -310,12 +336,7 @@ export class ComfyApp {
this
.
imageIndex
=
imageIndex
=
0
;
}
let
shiftY
;
if
(
this
.
imageOffset
!=
null
)
{
shiftY
=
this
.
imageOffset
;
}
else
{
shiftY
=
this
.
computeSize
()[
1
];
}
const
shiftY
=
getImageTop
(
this
);
let
dw
=
this
.
size
[
0
];
let
dh
=
this
.
size
[
1
];
...
...
web/scripts/widgets.js
View file @
7e51bbd0
...
...
@@ -261,20 +261,13 @@ export const ComfyWidgets = {
let
uploadWidget
;
function
showImage
(
name
)
{
// Position the image somewhere sensible
if
(
!
node
.
imageOffset
)
{
node
.
imageOffset
=
uploadWidget
.
last_y
?
uploadWidget
.
last_y
+
25
:
75
;
}
const
img
=
new
Image
();
img
.
onload
=
()
=>
{
node
.
imgs
=
[
img
];
app
.
graph
.
setDirtyCanvas
(
true
);
};
img
.
src
=
`/view?filename=
${
name
}
&type=input`
;
if
((
node
.
size
[
1
]
-
node
.
imageOffset
)
<
100
)
{
node
.
size
[
1
]
=
250
+
node
.
imageOffset
;
}
node
.
setSizeForImage
?.();
}
// Add our own callback to the combo widget to render an image when it changes
...
...
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