Keep resolution controls inside node frame
This commit is contained in:
@@ -133,8 +133,11 @@ function render(node, root) {
|
||||
function setup(node) {
|
||||
node.resizable = false;
|
||||
const root=document.createElement("div"); root.className="dumas-res";
|
||||
const widget=node.addDOMWidget("dumas_resolution_ui", "custom", root, {serialize:false, getValue:()=>read(node), setValue:()=>{}, getMinHeight:()=>250});
|
||||
widget.computeLayoutSize=()=>({minHeight:250,minWidth:1});
|
||||
const widget=node.addDOMWidget("dumas_resolution_ui", "custom", root, {serialize:false, getValue:()=>read(node), setValue:()=>{}, getMinHeight:()=>430});
|
||||
// Keep the LiteGraph frame at least as tall as the rendered controls.
|
||||
// The DOM widget otherwise keeps its old compact minimum and overhangs
|
||||
// the node even when the node itself is marked non-resizable.
|
||||
widget.computeLayoutSize=()=>({minHeight:430,minWidth:1});
|
||||
root.addEventListener("click", (event) => {
|
||||
const button=event.target.closest("button"); if (!button) return;
|
||||
const s=read(node), id=button.dataset.id;
|
||||
@@ -147,7 +150,7 @@ function setup(node) {
|
||||
render(node,root);
|
||||
});
|
||||
root.addEventListener("change", (event) => { const key=event.target.dataset.key; if(!key)return; const s=read(node), value=key==="batch" ? Math.max(1,Math.min(64,Number(event.target.value)||1)) : Math.max(1,Math.min(16384,Number(event.target.value)||1)); s[key]=value; if(s.mode==="custom") { s.w=snap(clamp(s.custom_w),s.snap); s.h=snap(clamp(s.custom_h),s.snap); } else if(s.mode==="custom_ratio") { [s.w,s.h]=ratioPair(s.w,s.custom_ratio_w,s.custom_ratio_h,s.snap); } write(node,s); render(node,root); });
|
||||
node._dumasResolutionRoot=root; node.size=[300,390]; queueMicrotask(()=>render(node,root));
|
||||
node._dumasResolutionRoot=root; node.size=[300,470]; queueMicrotask(()=>render(node,root));
|
||||
}
|
||||
|
||||
const originalGraphToPrompt=app.graphToPrompt?.bind(app);
|
||||
@@ -161,7 +164,7 @@ app.registerExtension({
|
||||
if(nodeData?.name!==CLASS)return;
|
||||
const oldConfigure=nodeType.prototype.onConfigure;
|
||||
nodeType.prototype.onConfigure=function(...args){const result=oldConfigure?.apply(this,args); if(this._dumasResolutionRoot)render(this,this._dumasResolutionRoot); return result;};
|
||||
nodeType.prototype.onResize=function(){this.size=[300,390];};
|
||||
nodeType.prototype.onResize=function(){this.size=[300,470];};
|
||||
},
|
||||
nodeCreated(node){if(node.comfyClass===CLASS)setup(node);},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user