@@ -8578,6 +8578,7 @@ LGraphNode.prototype.executeAction = function(action)
85788578 ctx . textAlign = "left" ;
85798579 if ( w . disabled )
85808580 ctx . globalAlpha *= 0.5 ;
8581+ var widget_width = w . width || width ;
85818582
85828583 switch ( w . type ) {
85838584 case "button" :
@@ -8586,13 +8587,13 @@ LGraphNode.prototype.executeAction = function(action)
85868587 w . clicked = false ;
85878588 this . dirty_canvas = true ;
85888589 }
8589- ctx . fillRect ( margin , y , width - margin * 2 , H ) ;
8590+ ctx . fillRect ( margin , y , widget_width - margin * 2 , H ) ;
85908591 if ( show_text && ! w . disabled )
8591- ctx . strokeRect ( margin , y , width - margin * 2 , H ) ;
8592+ ctx . strokeRect ( margin , y , widget_width - margin * 2 , H ) ;
85928593 if ( show_text ) {
85938594 ctx . textAlign = "center" ;
85948595 ctx . fillStyle = text_color ;
8595- ctx . fillText ( w . name , width * 0.5 , y + H * 0.7 ) ;
8596+ ctx . fillText ( w . name , widget_width * 0.5 , y + H * 0.7 ) ;
85968597 }
85978598 break ;
85988599 case "toggle" :
@@ -8601,15 +8602,15 @@ LGraphNode.prototype.executeAction = function(action)
86018602 ctx . fillStyle = background_color ;
86028603 ctx . beginPath ( ) ;
86038604 if ( show_text )
8604- ctx . roundRect ( margin , posY , width - margin * 2 , H , H * 0.5 ) ;
8605+ ctx . roundRect ( margin , posY , widget_width - margin * 2 , H , H * 0.5 ) ;
86058606 else
8606- ctx . rect ( margin , posY , width - margin * 2 , H ) ;
8607+ ctx . rect ( margin , posY , widget_width - margin * 2 , H ) ;
86078608 ctx . fill ( ) ;
86088609 if ( show_text && ! w . disabled )
86098610 ctx . stroke ( ) ;
86108611 ctx . fillStyle = w . value ? "#89A" : "#333" ;
86118612 ctx . beginPath ( ) ;
8612- ctx . arc ( width - margin * 2 , y + H * 0.5 , H * 0.36 , 0 , Math . PI * 2 ) ;
8613+ ctx . arc ( widget_width - margin * 2 , y + H * 0.5 , H * 0.36 , 0 , Math . PI * 2 ) ;
86138614 ctx . fill ( ) ;
86148615 if ( show_text ) {
86158616 ctx . fillStyle = secondary_text_color ;
@@ -8622,31 +8623,31 @@ LGraphNode.prototype.executeAction = function(action)
86228623 w . value
86238624 ? w . options . on || "true"
86248625 : w . options . off || "false" ,
8625- width - 40 ,
8626+ widget_width - 40 ,
86268627 y + H * 0.7
86278628 ) ;
86288629 }
86298630 break ;
86308631 case "slider" :
86318632 ctx . fillStyle = background_color ;
8632- ctx . fillRect ( margin , y , width - margin * 2 , H ) ;
8633+ ctx . fillRect ( margin , y , widget_width - margin * 2 , H ) ;
86338634 var range = w . options . max - w . options . min ;
86348635 var nvalue = ( w . value - w . options . min ) / range ;
86358636 ctx . fillStyle = active_widget == w ? "#89A" : "#678" ;
8636- ctx . fillRect ( margin , y , nvalue * ( width - margin * 2 ) , H ) ;
8637+ ctx . fillRect ( margin , y , nvalue * ( widget_width - margin * 2 ) , H ) ;
86378638 if ( show_text && ! w . disabled )
8638- ctx . strokeRect ( margin , y , width - margin * 2 , H ) ;
8639+ ctx . strokeRect ( margin , y , widget_width - margin * 2 , H ) ;
86398640 if ( w . marker ) {
86408641 var marker_nvalue = ( w . marker - w . options . min ) / range ;
86418642 ctx . fillStyle = "#AA9" ;
8642- ctx . fillRect ( margin + marker_nvalue * ( width - margin * 2 ) , y , 2 , H ) ;
8643+ ctx . fillRect ( margin + marker_nvalue * ( widget_width - margin * 2 ) , y , 2 , H ) ;
86438644 }
86448645 if ( show_text ) {
86458646 ctx . textAlign = "center" ;
86468647 ctx . fillStyle = text_color ;
86478648 ctx . fillText (
86488649 w . name + " " + Number ( w . value ) . toFixed ( 3 ) ,
8649- width * 0.5 ,
8650+ widget_width * 0.5 ,
86508651 y + H * 0.7
86518652 ) ;
86528653 }
@@ -8658,9 +8659,9 @@ LGraphNode.prototype.executeAction = function(action)
86588659 ctx . fillStyle = background_color ;
86598660 ctx . beginPath ( ) ;
86608661 if ( show_text )
8661- ctx . roundRect ( margin , posY , width - margin * 2 , H , H * 0.5 ) ;
8662+ ctx . roundRect ( margin , posY , widget_width - margin * 2 , H , H * 0.5 ) ;
86628663 else
8663- ctx . rect ( margin , posY , width - margin * 2 , H ) ;
8664+ ctx . rect ( margin , posY , widget_width - margin * 2 , H ) ;
86648665 ctx . fill ( ) ;
86658666 if ( show_text ) {
86668667 if ( ! w . disabled )
@@ -8674,9 +8675,9 @@ LGraphNode.prototype.executeAction = function(action)
86748675 ctx . lineTo ( margin + 16 , posY + H - 5 ) ;
86758676 ctx . fill ( ) ;
86768677 ctx . beginPath ( ) ;
8677- ctx . moveTo ( width - margin - 16 , posY + 5 ) ;
8678- ctx . lineTo ( width - margin - 6 , posY + H * 0.5 ) ;
8679- ctx . lineTo ( width - margin - 16 , posY + H - 5 ) ;
8678+ ctx . moveTo ( widget_width - margin - 16 , posY + 5 ) ;
8679+ ctx . lineTo ( widget_width - margin - 6 , posY + H * 0.5 ) ;
8680+ ctx . lineTo ( widget_width - margin - 16 , posY + H - 5 ) ;
86808681 ctx . fill ( ) ;
86818682 }
86828683 ctx . fillStyle = secondary_text_color ;
@@ -8690,7 +8691,7 @@ LGraphNode.prototype.executeAction = function(action)
86908691 ? w . options . precision
86918692 : 3
86928693 ) ,
8693- width - margin * 2 - 20 ,
8694+ widget_width - margin * 2 - 20 ,
86948695 y + H * 0.7
86958696 ) ;
86968697 } else {
@@ -8705,7 +8706,7 @@ LGraphNode.prototype.executeAction = function(action)
87058706 }
87068707 ctx . fillText (
87078708 v ,
8708- width - margin * 2 - 20 ,
8709+ widget_width - margin * 2 - 20 ,
87098710 y + H * 0.7
87108711 ) ;
87118712 }
@@ -8718,14 +8719,14 @@ LGraphNode.prototype.executeAction = function(action)
87188719 ctx . fillStyle = background_color ;
87198720 ctx . beginPath ( ) ;
87208721 if ( show_text )
8721- ctx . roundRect ( margin , posY , width - margin * 2 , H , H * 0.5 ) ;
8722+ ctx . roundRect ( margin , posY , widget_width - margin * 2 , H , H * 0.5 ) ;
87228723 else
8723- ctx . rect ( margin , posY , width - margin * 2 , H ) ;
8724+ ctx . rect ( margin , posY , widget_width - margin * 2 , H ) ;
87248725 ctx . fill ( ) ;
87258726 if ( show_text ) {
87268727 ctx . save ( ) ;
87278728 ctx . beginPath ( ) ;
8728- ctx . rect ( margin , posY , width - margin * 2 , H ) ;
8729+ ctx . rect ( margin , posY , widget_width - margin * 2 , H ) ;
87298730 ctx . clip ( ) ;
87308731
87318732 ctx . stroke ( ) ;
@@ -8735,17 +8736,17 @@ LGraphNode.prototype.executeAction = function(action)
87358736 }
87368737 ctx . fillStyle = text_color ;
87378738 ctx . textAlign = "right" ;
8738- ctx . fillText ( String ( w . value ) . substr ( 0 , 30 ) , width - margin * 2 , y + H * 0.7 ) ; //30 chars max
8739+ ctx . fillText ( String ( w . value ) . substr ( 0 , 30 ) , widget_width - margin * 2 , y + H * 0.7 ) ; //30 chars max
87398740 ctx . restore ( ) ;
87408741 }
87418742 break ;
87428743 default :
87438744 if ( w . draw ) {
8744- w . draw ( ctx , node , width , y , H ) ;
8745+ w . draw ( ctx , node , widget_width , y , H ) ;
87458746 }
87468747 break ;
87478748 }
8748- posY += ( w . computeSize ? w . computeSize ( width ) [ 1 ] : H ) + 4 ;
8749+ posY += ( w . computeSize ? w . computeSize ( widget_width ) [ 1 ] : H ) + 4 ;
87498750 ctx . globalAlpha = this . editor_alpha ;
87508751
87518752 }
@@ -8778,14 +8779,15 @@ LGraphNode.prototype.executeAction = function(action)
87788779 if ( ! w || w . disabled )
87798780 continue ;
87808781 var widget_height = w . computeSize ? w . computeSize ( width ) [ 1 ] : LiteGraph . NODE_WIDGET_HEIGHT ;
8782+ var widget_width = w . width || width ;
87818783 //outside
87828784 if ( w != active_widget &&
8783- ( x < 6 || x > width - 12 || y < w . last_y || y > w . last_y + widget_height ) )
8785+ ( x < 6 || x > widget_width - 12 || y < w . last_y || y > w . last_y + widget_height ) )
87848786 continue ;
87858787
87868788 var old_value = w . value ;
87878789
8788- //if ( w == active_widget || (x > 6 && x < width - 12 && y > w.last_y && y < w.last_y + widget_height) ) {
8790+ //if ( w == active_widget || (x > 6 && x < widget_width - 12 && y > w.last_y && y < w.last_y + widget_height) ) {
87898791 //inside widget
87908792 switch ( w . type ) {
87918793 case "button" :
@@ -8802,7 +8804,7 @@ LGraphNode.prototype.executeAction = function(action)
88028804 break ;
88038805 case "slider" :
88048806 var range = w . options . max - w . options . min ;
8805- var nvalue = Math . clamp ( ( x - 10 ) / ( width - 20 ) , 0 , 1 ) ;
8807+ var nvalue = Math . clamp ( ( x - 10 ) / ( widget_width - 20 ) , 0 , 1 ) ;
88068808 w . value =
88078809 w . options . min +
88088810 ( w . options . max - w . options . min ) * nvalue ;
@@ -8834,7 +8836,7 @@ LGraphNode.prototype.executeAction = function(action)
88348836 if ( w . type != "number" )
88358837 values_list = values . constructor === Array ? values : Object . keys ( values ) ;
88368838
8837- var delta = x < 40 ? - 1 : x > width - 40 ? 1 : 0 ;
8839+ var delta = x < 40 ? - 1 : x > widget_width - 40 ? 1 : 0 ;
88388840 if ( w . type == "number" ) {
88398841 w . value += delta * 0.1 * ( w . options . step || 1 ) ;
88408842 if ( w . options . min != null && w . value < w . options . min ) {
@@ -8881,7 +8883,7 @@ LGraphNode.prototype.executeAction = function(action)
88818883 } //end mousedown
88828884 else if ( event . type == "mouseup" && w . type == "number" )
88838885 {
8884- var delta = x < 40 ? - 1 : x > width - 40 ? 1 : 0 ;
8886+ var delta = x < 40 ? - 1 : x > widget_width - 40 ? 1 : 0 ;
88858887 if ( event . click_time < 200 && delta == 0 ) {
88868888 this . prompt ( "Value" , w . value , function ( v ) {
88878889 this . value = Number ( v ) ;
0 commit comments