Enable autosize by widget instead of namespace.
Also adds a padding option which, if supplied is summed with the calculated width when auto-sizing is applied.
This commit is contained in:
@@ -298,6 +298,7 @@ class CustomCFGKeyframeSimpleNode:
|
||||
"optional": {
|
||||
"prev_custom_cfg": ("CUSTOM_CFG",),
|
||||
"cfg_extras": ("CFG_EXTRAS",),
|
||||
"autosize": ("ADEAUTOSIZE", {"padding": 10}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-8
@@ -1,14 +1,31 @@
|
||||
import { app } from '../../../scripts/app.js'
|
||||
app.registerExtension({
|
||||
name: "AnimateDiffEvolved.autosize",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if(nodeData?.name?.startsWith("ADE_") ||
|
||||
nodeData?.name?.startsWith("ACN_")) {
|
||||
let origOnCreated = nodeType.prototype.onNodeCreated
|
||||
nodeType.prototype.onNodeCreated = function() {
|
||||
const r = origOnCreated ? origOnCreated.apply(this) : undefined;
|
||||
this.setSize(this.computeSize(0));
|
||||
return r
|
||||
async nodeCreated(node) {
|
||||
if(node.adeAutosize) {
|
||||
let size = node.computeSize(0);
|
||||
size[0] += node.adeAutosize?.padding || 0;
|
||||
node.setSize(size);
|
||||
}
|
||||
},
|
||||
async getCustomWidgets() {
|
||||
return {
|
||||
ADEAUTOSIZE(node, inputName, inputData) {
|
||||
let w = {
|
||||
name : inputName,
|
||||
type : "ADE.AUTOSIZE",
|
||||
value : "",
|
||||
options : {"serialize": false},
|
||||
computeSize : function(width) {
|
||||
return [0, -4];
|
||||
}
|
||||
}
|
||||
node.adeAutosize = inputData[1];
|
||||
if (!node.widgets) {
|
||||
node.widgets = []
|
||||
}
|
||||
node.widgets.push(w)
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user