mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-22 06:37:00 +08:00
Bottom menu wip
This commit is contained in:
parent
16ba362746
commit
9f5eb4b59d
@ -55,11 +55,11 @@ export class ComfyApp {
|
|||||||
this.ui = new ComfyUI(this);
|
this.ui = new ComfyUI(this);
|
||||||
this.logging = new ComfyLogging(this);
|
this.logging = new ComfyLogging(this);
|
||||||
this.workflowManager = new ComfyWorkflowManager(this);
|
this.workflowManager = new ComfyWorkflowManager(this);
|
||||||
this.menu = new ComfyAppMenu(this);
|
|
||||||
this.bodyTop = $el("div.comfyui-body-top", { parent: document.body });
|
this.bodyTop = $el("div.comfyui-body-top", { parent: document.body });
|
||||||
this.bodyLeft = $el("div.comfyui-body-left", { parent: document.body });
|
this.bodyLeft = $el("div.comfyui-body-left", { parent: document.body });
|
||||||
this.bodyRight = $el("div.comfyui-body-right", { parent: document.body });
|
this.bodyRight = $el("div.comfyui-body-right", { parent: document.body });
|
||||||
this.bodyBottom = $el("div.comfyui-body-bottom", { parent: document.body });
|
this.bodyBottom = $el("div.comfyui-body-bottom", { parent: document.body });
|
||||||
|
this.menu = new ComfyAppMenu(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of extensions that are registered with the app
|
* List of extensions that are registered with the app
|
||||||
@ -1560,7 +1560,7 @@ export class ComfyApp {
|
|||||||
|
|
||||||
this.#addAfterConfigureHandler();
|
this.#addAfterConfigureHandler();
|
||||||
|
|
||||||
const canvas = (this.canvas = new LGraphCanvas(canvasEl, this.graph));
|
this.canvas = new LGraphCanvas(canvasEl, this.graph);
|
||||||
this.ctx = canvasEl.getContext("2d");
|
this.ctx = canvasEl.getContext("2d");
|
||||||
|
|
||||||
LiteGraph.release_link_on_empty_shows_menu = true;
|
LiteGraph.release_link_on_empty_shows_menu = true;
|
||||||
@ -1568,22 +1568,14 @@ export class ComfyApp {
|
|||||||
|
|
||||||
this.graph.start();
|
this.graph.start();
|
||||||
|
|
||||||
function resizeCanvas() {
|
|
||||||
// Limit minimal scale to 1, see https://github.com/comfyanonymous/ComfyUI/pull/845
|
|
||||||
const scale = Math.max(window.devicePixelRatio, 1);
|
|
||||||
|
|
||||||
// Clear fixed width and height while calculating rect so it uses 100% instead
|
|
||||||
canvasEl.height = canvasEl.width = "";
|
|
||||||
const { width, height } = canvasEl.getBoundingClientRect();
|
|
||||||
canvasEl.width = Math.round(width * scale);
|
|
||||||
canvasEl.height = Math.round(height * scale);
|
|
||||||
canvasEl.getContext("2d").scale(scale, scale);
|
|
||||||
canvas.draw(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the canvas fills the window
|
// Ensure the canvas fills the window
|
||||||
resizeCanvas();
|
this.resizeCanvas();
|
||||||
window.addEventListener("resize", resizeCanvas);
|
window.addEventListener("resize", () => this.resizeCanvas());
|
||||||
|
const ro = new ResizeObserver(() => this.resizeCanvas());
|
||||||
|
ro.observe(this.bodyTop);
|
||||||
|
ro.observe(this.bodyLeft);
|
||||||
|
ro.observe(this.bodyRight);
|
||||||
|
ro.observe(this.bodyBottom);
|
||||||
|
|
||||||
await this.#invokeExtensionsAsync("init");
|
await this.#invokeExtensionsAsync("init");
|
||||||
await this.registerNodes();
|
await this.registerNodes();
|
||||||
@ -1632,6 +1624,19 @@ export class ComfyApp {
|
|||||||
await this.#invokeExtensionsAsync("setup");
|
await this.#invokeExtensionsAsync("setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resizeCanvas() {
|
||||||
|
// Limit minimal scale to 1, see https://github.com/comfyanonymous/ComfyUI/pull/845
|
||||||
|
const scale = Math.max(window.devicePixelRatio, 1);
|
||||||
|
|
||||||
|
// Clear fixed width and height while calculating rect so it uses 100% instead
|
||||||
|
this.canvasEl.height = this.canvasEl.width = "";
|
||||||
|
const { width, height } = this.canvasEl.getBoundingClientRect();
|
||||||
|
this.canvasEl.width = Math.round(width * scale);
|
||||||
|
this.canvasEl.height = Math.round(height * scale);
|
||||||
|
this.canvasEl.getContext("2d").scale(scale, scale);
|
||||||
|
this.canvas.draw(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers nodes with the graph
|
* Registers nodes with the graph
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -102,6 +102,7 @@ export class ComfyPopup extends EventTarget {
|
|||||||
|
|
||||||
update = () => {
|
update = () => {
|
||||||
const rect = this.target.getBoundingClientRect();
|
const rect = this.target.getBoundingClientRect();
|
||||||
|
this.element.style.setProperty("--bottom", "unset");
|
||||||
if (this.position === "absolute") {
|
if (this.position === "absolute") {
|
||||||
if (this.horizontal === "left") {
|
if (this.horizontal === "left") {
|
||||||
this.element.style.setProperty("--left", rect.left + "px");
|
this.element.style.setProperty("--left", rect.left + "px");
|
||||||
@ -109,9 +110,19 @@ export class ComfyPopup extends EventTarget {
|
|||||||
this.element.style.setProperty("--left", rect.right - this.element.clientWidth + "px");
|
this.element.style.setProperty("--left", rect.right - this.element.clientWidth + "px");
|
||||||
}
|
}
|
||||||
this.element.style.setProperty("--top", rect.bottom + "px");
|
this.element.style.setProperty("--top", rect.bottom + "px");
|
||||||
|
this.element.style.setProperty("--limit", rect.bottom + "px");
|
||||||
} else {
|
} else {
|
||||||
this.element.style.setProperty("--left", 0 + "px");
|
this.element.style.setProperty("--left", 0 + "px");
|
||||||
this.element.style.setProperty("--top", rect.height + "px");
|
this.element.style.setProperty("--top", rect.height + "px");
|
||||||
|
this.element.style.setProperty("--limit", rect.height + "px");
|
||||||
|
}
|
||||||
|
|
||||||
|
const thisRect = this.element.getBoundingClientRect();
|
||||||
|
if (thisRect.height < 30) {
|
||||||
|
// Move up instead
|
||||||
|
this.element.style.setProperty("--top", "unset");
|
||||||
|
this.element.style.setProperty("--bottom", rect.height + 5 + "px");
|
||||||
|
this.element.style.setProperty("--limit", rect.height + 5 + "px");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ export class ComfyAppMenu {
|
|||||||
{
|
{
|
||||||
primary: getSaveButton(),
|
primary: getSaveButton(),
|
||||||
mode: "hover",
|
mode: "hover",
|
||||||
|
position: "absolute"
|
||||||
},
|
},
|
||||||
getSaveButton("Save"),
|
getSaveButton("Save"),
|
||||||
new ComfyButton({
|
new ComfyButton({
|
||||||
@ -133,19 +134,22 @@ export class ComfyAppMenu {
|
|||||||
showOnMobile(this.mobileMenuButton).element,
|
showOnMobile(this.mobileMenuButton).element,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
document.body.prepend(this.element);
|
|
||||||
|
|
||||||
app.ui.settings.addSetting({
|
app.ui.settings.addSetting({
|
||||||
id: "Comfy.UseNewMenu",
|
id: "Comfy.UseNewMenu",
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
name: "[Beta] Use new menu and workflow management",
|
name: "[Beta] Use new menu and workflow management",
|
||||||
type: "boolean",
|
type: "combo",
|
||||||
|
options: ["Disabled", "Top", "Bottom"],
|
||||||
onChange: async (v) => {
|
onChange: async (v) => {
|
||||||
if (v) {
|
if (v) {
|
||||||
document.body.style.display = "grid";
|
document.body.style.display = "grid";
|
||||||
app.ui.menuContainer.style.display = "none";
|
app.ui.menuContainer.style.display = "none";
|
||||||
this.element.style.removeProperty("display");
|
this.element.style.removeProperty("display");
|
||||||
|
if (v === "Bottom") {
|
||||||
|
app.bodyBottom.append(this.element);
|
||||||
|
} else {
|
||||||
|
app.bodyTop.prepend(this.element);
|
||||||
|
}
|
||||||
this.calculateSizeBreak();
|
this.calculateSizeBreak();
|
||||||
} else {
|
} else {
|
||||||
document.body.style.removeProperty("display");
|
document.body.style.removeProperty("display");
|
||||||
|
|||||||
@ -43,8 +43,9 @@
|
|||||||
left: var(--left);
|
left: var(--left);
|
||||||
right: var(--right);
|
right: var(--right);
|
||||||
top: var(--top);
|
top: var(--top);
|
||||||
|
bottom: var(--bottom);
|
||||||
z-index: 2000;
|
z-index: 2000;
|
||||||
max-height: calc(100vh - var(--top) - 10px);
|
max-height: calc(100vh - var(--limit) - 10px);
|
||||||
box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.3);
|
box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +134,8 @@
|
|||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
order: 0;
|
order: 0;
|
||||||
grid-column: 1/-1;
|
grid-column: 1/-1;
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 90vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comfyui-menu>* {
|
.comfyui-menu>* {
|
||||||
@ -436,7 +439,7 @@
|
|||||||
background-color: var(--content-bg);
|
background-color: var(--content-bg);
|
||||||
color: var(--content-fg);
|
color: var(--content-fg);
|
||||||
min-width: 170px;
|
min-width: 170px;
|
||||||
min-height: 100px;
|
min-height: 435px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -622,6 +625,15 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comfyui-body-bottom .lt-lg.comfyui-menu > .comfyui-menu-mobile-collapse {
|
||||||
|
order: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfyui-body-bottom .lt-lg.comfyui-menu > .comfyui-menu-button {
|
||||||
|
top: unset;
|
||||||
|
bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.lt-lg.comfyui-menu > .comfyui-menu-mobile-collapse.comfyui-button-group {
|
.lt-lg.comfyui-menu > .comfyui-menu-mobile-collapse.comfyui-button-group {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
@ -661,6 +673,10 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lt-lg.comfyui-menu .comfyui-workflows-popup {
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
/** Small */
|
/** Small */
|
||||||
.lt-md .comfyui-workflows-button-inner {
|
.lt-md .comfyui-workflows-button-inner {
|
||||||
width: unset !important;
|
width: unset !important;
|
||||||
@ -680,3 +696,6 @@
|
|||||||
.lt-sm .comfyui-interrupt-button {
|
.lt-sm .comfyui-interrupt-button {
|
||||||
margin-right: 45px;
|
margin-right: 45px;
|
||||||
}
|
}
|
||||||
|
.comfyui-body-bottom .lt-sm.comfyui-menu > .comfyui-menu-button{
|
||||||
|
bottom: 41px;
|
||||||
|
}
|
||||||
@ -63,6 +63,7 @@ body {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
order: 2;
|
order: 2;
|
||||||
|
grid-column: 1/-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comfyui-body-right {
|
.comfyui-body-right {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user