mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-06 08:00:05 +00:00
show corner of groups
This commit is contained in:
@@ -5871,7 +5871,7 @@ LGraphCanvas.prototype.drawGroups = function(canvas, ctx)
|
||||
var size = group._size;
|
||||
ctx.globalAlpha = 0.25;
|
||||
ctx.beginPath();
|
||||
ctx.rect( pos[0], pos[1], size[0], size[1] );
|
||||
ctx.rect( pos[0] + 0.5, pos[1] + 0.5, size[0], size[1] );
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.stroke();
|
||||
@@ -6680,7 +6680,7 @@ LGraphCanvas.onMenuNodeColors = function( value, options, e, menu, node )
|
||||
delete node.color;
|
||||
delete node.bgcolor;
|
||||
}
|
||||
node.setDirtyCanvas(true);
|
||||
node.setDirtyCanvas(true,true);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
4
build/litegraph.min.js
vendored
4
build/litegraph.min.js
vendored
@@ -144,7 +144,7 @@ h.options.min);b.fillStyle=d==h?"#89A":"#678";b.fillRect(10,m,q*(f-20),k);b.stro
|
||||
26,c+k-5),b.fill(),e&&(b.fillStyle="#999",b.fillText(h.name,30,m+0.7*k),b.fillStyle="#DDD",b.textAlign="right","number"==h.type?b.fillText(Number(h.value).toFixed(void 0!==h.options.precision?h.options.precision:3),f-40,m+0.7*k):b.fillText(h.value,f-40,m+0.7*k))}c+=k+4}b.textAlign="left"};d.prototype.processNodeWidgets=function(a,c,b,d){if(!a.widgets||!a.widgets.length)return null;for(var f=c[0]-a.pos[0],k=c[1]-a.pos[1],e=a.size[0],n=this,h=0;h<a.widgets.length;++h){var m=a.widgets[h];if(m==d||6<
|
||||
f&&f<e-12&&k>m.last_y&&k<m.last_y+l.NODE_WIDGET_HEIGHT){switch(m.type){case "button":m.callback&&setTimeout(function(){m.callback(m,n,a,c)},20);this.dirty_canvas=m.clicked=!0;break;case "slider":b=Math.clamp((f-10)/(e-20),0,1);m.value=m.options.min+(m.options.max-m.options.min)*b;m.callback&&setTimeout(function(){m.callback(m.value,n,a,c)},20);this.dirty_canvas=!0;break;case "number":case "combo":"mousemove"==b.type&&"number"==m.type?(m.value+=0.1*b.deltaX*(m.options.step||1),null!=m.options.min&&
|
||||
m.value<m.options.min&&(m.value=m.options.min),null!=m.options.max&&m.value>m.options.max&&(m.value=m.options.max)):"mousedown"==b.type&&(b=40>f?-1:f>e-40?1:0,"number"==m.type?(m.value+=0.1*b*(m.options.step||1),null!=m.options.min&&m.value<m.options.min&&(m.value=m.options.min),null!=m.options.max&&m.value>m.options.max&&(m.value=m.options.max)):b&&(b=m.options.values.indexOf(m.value)+b,b>=m.options.values.length&&(b=0),0>b&&(b=m.options.values.length-1),m.value=m.options.values[b])),m.callback&&
|
||||
setTimeout(function(){m.callback(m.value,n,a,c)},20),this.dirty_canvas=!0}return m}}return null};d.prototype.drawGroups=function(a,c){if(this.graph){var b=this.graph._groups;c.save();c.globalAlpha=0.5;c.font="24px Arial";for(var d=0;d<b.length;++d){var f=b[d];if(s(this.visible_area,f._bounding)){c.fillStyle=f.color||"#335";c.strokeStyle=f.color||"#335";var k=f._pos,e=f._size;c.globalAlpha=0.25;c.beginPath();c.rect(k[0],k[1],e[0],e[1]);c.fill();c.globalAlpha=1;c.stroke();c.beginPath();c.moveTo(k[0]+
|
||||
setTimeout(function(){m.callback(m.value,n,a,c)},20),this.dirty_canvas=!0}return m}}return null};d.prototype.drawGroups=function(a,c){if(this.graph){var b=this.graph._groups;c.save();c.globalAlpha=0.5;c.font="24px Arial";for(var d=0;d<b.length;++d){var f=b[d];if(s(this.visible_area,f._bounding)){c.fillStyle=f.color||"#335";c.strokeStyle=f.color||"#335";var k=f._pos,e=f._size;c.globalAlpha=0.25;c.beginPath();c.rect(k[0]+0.5,k[1]+0.5,e[0],e[1]);c.fill();c.globalAlpha=1;c.stroke();c.beginPath();c.moveTo(k[0]+
|
||||
e[0],k[1]+e[1]);c.lineTo(k[0]+e[0]-10,k[1]+e[1]);c.lineTo(k[0]+e[0],k[1]+e[1]-10);c.fill();c.fillText(f.title,k[0]+4,k[1]+24)}}c.restore()}};d.prototype.resize=function(a,c){if(!a&&!c){var b=this.canvas.parentNode;a=b.offsetWidth;c=b.offsetHeight}if(this.canvas.width!=a||this.canvas.height!=c)this.canvas.width=a,this.canvas.height=c,this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height,this.setDirty(!0,!0)};d.prototype.switchLiveMode=function(a){if(a){var c=this,b=this.live_mode?
|
||||
1.1:0.9;this.live_mode&&(this.live_mode=!1,this.editor_alpha=0.1);var d=setInterval(function(){c.editor_alpha*=b;c.dirty_canvas=!0;c.dirty_bgcanvas=!0;1>b&&0.01>c.editor_alpha&&(clearInterval(d),1>b&&(c.live_mode=!0));1<b&&0.99<c.editor_alpha&&(clearInterval(d),c.editor_alpha=1)},1)}else this.live_mode=!this.live_mode,this.dirty_bgcanvas=this.dirty_canvas=!0};d.prototype.onNodeSelectionChange=function(a){};d.prototype.touchHandler=function(a){var c=a.changedTouches[0],b="";switch(a.type){case "touchstart":b=
|
||||
"mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var d=this.getCanvasWindow(),f=d.document.createEvent("MouseEvent");f.initMouseEvent(b,!0,!0,d,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null);c.target.dispatchEvent(f);a.preventDefault()};d.onGroupAdd=function(a,c,b){a=d.active_canvas;a.getCanvasWindow();c=new l.LGraphGroup;c.pos=a.convertEventToCanvas(b);a.graph.add(c)};d.onMenuAdd=function(a,c,b,e){function f(a,c){var b=e.getFirstEvent(),
|
||||
@@ -164,7 +164,7 @@ n,h=h+("<option value='"+l+"' "+(l==a.properties[c]?"selected":"")+">"+e.values[
|
||||
q.addEventListener("click",function(a){f(!!q.checked)});else if(q=m.querySelector("input"))q.value=void 0!==a.properties[c]?a.properties[c]:"",q.addEventListener("keydown",function(a){13==a.keyCode&&(d(),a.preventDefault(),a.stopPropagation())});m.querySelector("button").addEventListener("click",d)}};d.prototype.createDialog=function(a,c){c=c||{};var b=document.createElement("div");b.className="graphdialog";b.innerHTML=a;var d=this.canvas.getBoundingClientRect(),f=-20,k=-20;d&&(f-=d.left,k-=d.top);
|
||||
c.position?(f+=c.position[0],k+=c.position[1]):c.event?(f+=c.event.pageX,k+=c.event.pageY):(f+=0.5*this.canvas.width,k+=0.5*this.canvas.height);b.style.left=f+"px";b.style.top=k+"px";this.canvas.parentNode.appendChild(b);b.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return b};d.onMenuNodeCollapse=function(a,c,b,d,f){f.collapse()};d.onMenuNodePin=function(a,c,b,d,f){f.pin()};d.onMenuNodeMode=function(a,c,b,d,f){new l.ContextMenu(["Always","On Event","On Trigger","Never"],{event:b,
|
||||
callback:function(a){if(f)switch(a){case "On Event":f.mode=l.ON_EVENT;break;case "On Trigger":f.mode=l.ON_TRIGGER;break;case "Never":f.mode=l.NEVER;break;default:f.mode=l.ALWAYS}},parentMenu:d,node:f});return!1};d.onMenuNodeColors=function(a,c,b,e,f){if(!f)throw"no node for color";c=[];c.push({value:null,content:"<span style='display: block; padding-left: 4px;'>No color</span>"});for(var k in d.node_colors)a=d.node_colors[k],a={value:k,content:"<span style='display: block; color: #999; padding-left: 4px; border-left: 8px solid "+
|
||||
a.color+"; background-color:"+a.bgcolor+"'>"+k+"</span>"},c.push(a);new l.ContextMenu(c,{event:b,callback:function(a){f&&((a=a.value?d.node_colors[a.value]:null)?f.constructor===l.LGraphGroup?f.color=a.groupcolor:(f.color=a.color,f.bgcolor=a.bgcolor):(delete f.color,delete f.bgcolor),f.setDirtyCanvas(!0))},parentMenu:e,node:f});return!1};d.onMenuNodeShapes=function(a,c,b,d,f){if(!f)throw"no node passed";new l.ContextMenu(l.VALID_SHAPES,{event:b,callback:function(a){f&&(f.shape=a,f.setDirtyCanvas(!0))},
|
||||
a.color+"; background-color:"+a.bgcolor+"'>"+k+"</span>"},c.push(a);new l.ContextMenu(c,{event:b,callback:function(a){f&&((a=a.value?d.node_colors[a.value]:null)?f.constructor===l.LGraphGroup?f.color=a.groupcolor:(f.color=a.color,f.bgcolor=a.bgcolor):(delete f.color,delete f.bgcolor),f.setDirtyCanvas(!0,!0))},parentMenu:e,node:f});return!1};d.onMenuNodeShapes=function(a,c,b,d,f){if(!f)throw"no node passed";new l.ContextMenu(l.VALID_SHAPES,{event:b,callback:function(a){f&&(f.shape=a,f.setDirtyCanvas(!0))},
|
||||
parentMenu:d,node:f});return!1};d.onMenuNodeRemove=function(a,c,b,d,f){if(!f)throw"no node passed";!1!==f.removable&&(f.graph.remove(f),f.setDirtyCanvas(!0,!0))};d.onMenuNodeClone=function(a,c,b,d,f){!1!=f.clonable&&(a=f.clone())&&(a.pos=[f.pos[0]+5,f.pos[1]+5],f.graph.add(a),f.setDirtyCanvas(!0,!0))};d.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",
|
||||
bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};d.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:d.onMenuAdd},{content:"Add Group",
|
||||
callback:d.onGroupAdd}],this._graph_stack&&0<this._graph_stack.length&&(a=[{content:"Close subgraph",callback:this.closeSubgraph.bind(this)},null].concat(a)));if(this.getExtraMenuOptions){var c=this.getExtraMenuOptions(this,a);c&&(a=a.concat(c))}return a};d.prototype.getNodeMenuOptions=function(a){var c=null,c=a.getMenuOptions?a.getMenuOptions(this):[{content:"Inputs",has_submenu:!0,disabled:!0,callback:d.showMenuNodeOptionalInputs},{content:"Outputs",has_submenu:!0,disabled:!0,callback:d.showMenuNodeOptionalOutputs},
|
||||
|
||||
@@ -5869,7 +5869,7 @@ LGraphCanvas.prototype.drawGroups = function(canvas, ctx)
|
||||
var size = group._size;
|
||||
ctx.globalAlpha = 0.25;
|
||||
ctx.beginPath();
|
||||
ctx.rect( pos[0], pos[1], size[0], size[1] );
|
||||
ctx.rect( pos[0] + 0.5, pos[1] + 0.5, size[0], size[1] );
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.stroke();
|
||||
@@ -6678,7 +6678,7 @@ LGraphCanvas.onMenuNodeColors = function( value, options, e, menu, node )
|
||||
delete node.color;
|
||||
delete node.bgcolor;
|
||||
}
|
||||
node.setDirtyCanvas(true);
|
||||
node.setDirtyCanvas(true,true);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user