add direct way to influence the slot shape

This commit is contained in:
inventivetalent
2018-10-17 21:25:32 +02:00
parent 96d0b9edd2
commit 3b89916927

View File

@@ -2456,7 +2456,6 @@ LGraphNode.prototype.addConnection = function(name,type,pos,direction)
* @param {number} minHeight
* @return {number} the total size
*/
LGraphNode.prototype.computeSize = function( minHeight, out )
{
var rows = Math.max( this.inputs ? this.inputs.length : 1, this.outputs ? this.outputs.length : 1);
var size = out || new Float32Array([0,0]);
@@ -4923,7 +4922,7 @@ LGraphCanvas.prototype.drawFrontCanvas = function()
this.renderLink( ctx, this.connecting_pos, [this.canvas_mouse[0],this.canvas_mouse[1]], null, false, null, link_color );
ctx.beginPath();
if( this.connecting_output.type === LiteGraph.EVENT )
if( this.connecting_output.type === LiteGraph.EVENT || this.connecting_output.shape === LiteGraph.BOX_SHAPE )
ctx.rect( (this.connecting_pos[0] - 6) + 0.5, (this.connecting_pos[1] - 5) + 0.5,14,10);
else
ctx.arc( this.connecting_pos[0], this.connecting_pos[1],4,0,Math.PI*2);
@@ -5225,7 +5224,7 @@ LGraphCanvas.prototype.drawNode = function(node, ctx )
ctx.beginPath();
if (slot.type === LiteGraph.EVENT)
if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE)
ctx.rect((pos[0] - 6) + 0.5, (pos[1] - 5) + 0.5,14,10);
else
ctx.arc(pos[0],pos[1],4,0,Math.PI*2);
@@ -5265,7 +5264,7 @@ LGraphCanvas.prototype.drawNode = function(node, ctx )
ctx.beginPath();
//ctx.rect( node.size[0] - 14,i*14,10,10);
if (slot.type === LiteGraph.EVENT)
if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE)
ctx.rect((pos[0] - 6) + 0.5,(pos[1] - 5) + 0.5,14,10);
else
ctx.arc( pos[0],pos[1],4,0, Math.PI*2 );
@@ -5316,7 +5315,7 @@ LGraphCanvas.prototype.drawNode = function(node, ctx )
continue;
ctx.fillStyle = slot.colorOn || this.default_connection_color.input_on;
ctx.beginPath();
if ( slot.type === LiteGraph.EVENT )
if ( slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE)
ctx.rect(0.5, 4 - LiteGraph.NODE_TITLE_HEIGHT + 0.5,14,LiteGraph.NODE_TITLE_HEIGHT - 8);
else
ctx.arc( 0, LiteGraph.NODE_TITLE_HEIGHT * -0.5, 4, 0, Math.PI*2 );
@@ -5335,7 +5334,7 @@ LGraphCanvas.prototype.drawNode = function(node, ctx )
ctx.fillStyle = slot.colorOn || this.default_connection_color.output_on;
ctx.strokeStyle = "black";
ctx.beginPath();
if (slot.type === LiteGraph.EVENT)
if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE)
ctx.rect( node._collapsed_width - 4 + 0.5, 4 - LiteGraph.NODE_TITLE_HEIGHT + 0.5,14,LiteGraph.NODE_TITLE_HEIGHT - 8);
else
ctx.arc( node._collapsed_width, LiteGraph.NODE_TITLE_HEIGHT * -0.5, 4, 0, Math.PI*2 );