Dont reorder open workflows

Allow elements around canvas
This commit is contained in:
pythongosssss 2024-03-23 21:13:19 +00:00
parent c3c76dffe8
commit ea611cf8c9
6 changed files with 54 additions and 13 deletions

View File

@ -56,6 +56,10 @@ export class ComfyApp {
this.logging = new ComfyLogging(this);
this.workflowManager = new ComfyWorkflowManager(this);
this.menu = new ComfyAppMenu(this);
this.bodyTop = $el("div.comfyui-body-top", { parent: document.body });
this.bodyLeft = $el("div.comfyui-body-left", { parent: document.body });
this.bodyRight = $el("div.comfyui-body-right", { parent: document.body });
this.bodyBottom = $el("div.comfyui-body-bottom", { parent: document.body });
/**
* List of extensions that are registered with the app

View File

@ -33,7 +33,7 @@ function getClipPath(node, element, elRect) {
}
const widgetRect = element.getBoundingClientRect();
const clipX = intersection[0] - widgetRect.x / scale + "px";
const clipX = elRect.left + intersection[0] - widgetRect.x / scale + "px";
const clipY = elRect.top + intersection[1] - widgetRect.y / scale + "px";
const clipWidth = intersection[2] + "px";
const clipHeight = intersection[3] + "px";
@ -262,8 +262,8 @@ LGraphNode.prototype.addDOMWidget = function (name, type, element, options) {
Object.assign(element.style, {
transformOrigin: "0 0",
transform: scale,
left: `${transform.a + transform.e}px`,
top: `${transform.d + transform.f + + elRect.top}px`,
left: `${transform.a + transform.e + elRect.left}px`,
top: `${transform.d + transform.f + elRect.top}px`,
width: `${widgetWidth - margin * 2}px`,
height: `${(widget.computedHeight ?? 50) - margin * 2}px`,
position: "absolute",

View File

@ -130,6 +130,8 @@
gap: 8px;
box-sizing: border-box;
z-index: 1000;
order: 0;
grid-column: 1/-1;
}
.comfyui-menu>* {
@ -318,7 +320,7 @@
margin-bottom: 5px;
}
.comfyui-workflows-open li:first-of-type {
.comfyui-workflows-open .active {
font-weight: bold;
}
@ -361,6 +363,7 @@
user-select: none;
}
.comfyui-workflows-tree-file.active::before,
.comfyui-workflows-tree li:hover::before,
.comfyui-workflows-tree-file:hover::before {
content: "";
@ -373,6 +376,11 @@
z-index: -1;
}
.comfyui-workflows-tree-file.active::before {
background-color: var(--primary-bg);
color: var(--primary-fg);
}
.comfyui-workflows-tree-file.running:not(:hover)::before {
content: "";
position: absolute;

View File

@ -368,6 +368,9 @@ export class ComfyWorkflowsContent {
if (w.unsaved) {
wrapper.element.classList.add("unsaved");
}
if(w === this.app.workflowManager.activeWorkflow) {
wrapper.element.classList.add("active");
}
this.openFiles.set(w, wrapper);
return wrapper.element;

View File

@ -20,6 +20,8 @@ export class ComfyWorkflowManager extends EventTarget {
/** @type {string | null} */
#activePromptId = null;
#unsavedCount = 0;
#activeWorkflow;
/** @type {Record<string, ComfyWorkflow>} */
workflowLookup = {};
/** @type {Array<ComfyWorkflow>} */
@ -30,7 +32,7 @@ export class ComfyWorkflowManager extends EventTarget {
queuedPrompts = {};
get activeWorkflow() {
return this.openWorkflows[0];
return this.#activeWorkflow ?? this.openWorkflows[0];
}
get activePromptId() {
@ -145,14 +147,13 @@ export class ComfyWorkflowManager extends EventTarget {
}
const index = this.openWorkflows.indexOf(workflow);
if (index !== -1) {
// Swapping to an open workflow
this.openWorkflows.unshift(this.openWorkflows.splice(index, 1)[0]);
} else {
if (index === -1) {
// Opening a new workflow
this.openWorkflows.unshift(workflow);
this.openWorkflows.push(workflow);
}
this.#activeWorkflow = workflow;
setStorageValue("Comfy.PreviousWorkflow", this.activeWorkflow.path ?? "");
this.dispatchEvent(new CustomEvent("changeWorkflow"));
}
@ -203,7 +204,8 @@ export class ComfyWorkflowManager extends EventTarget {
workflow.changeTracker = null;
this.openWorkflows.splice(this.openWorkflows.indexOf(workflow), 1);
if (this.openWorkflows.length) {
await this.openWorkflows[0].load();
this.#activeWorkflow = this.openWorkflows[0];
await this.#activeWorkflow.load();
} else {
// Load default
await this.app.loadGraphData();

View File

@ -40,13 +40,37 @@ body {
overflow: hidden;
background-color: var(--bg-color);
color: var(--fg-color);
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: auto 1fr auto;
grid-template-rows: auto auto 1fr auto;
}
.comfyui-body-top {
order: 0;
grid-column: 1/-1;
z-index: 10;
}
.comfyui-body-left {
order: 1;
z-index: 10;
}
#graph-canvas {
width: 100%;
height: 100%;
order: 2;
}
.comfyui-body-right {
order: 3;
z-index: 10;
}
.comfyui-body-bottom {
order: 4;
grid-column: 1/-1;
z-index: 10;
}
.comfy-multiline-input {