Merge pull request #230 from RobTheFiveNine/bugfix/buttons-register-two-clicks

Fix widget buttons registering clicks twice
This commit is contained in:
Javi Agenjo
2021-06-21 13:18:18 +02:00
committed by GitHub
7 changed files with 63 additions and 67 deletions

View File

@@ -8855,16 +8855,15 @@ LGraphNode.prototype.executeAction = function(action)
//inside widget
switch (w.type) {
case "button":
if (event.type === "mousemove") {
break;
}
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
if (event.type === "mousedown") {
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
}
break;
case "slider":
var range = w.options.max - w.options.min;

View File

@@ -210,8 +210,8 @@ c,.5,k,n);d&&d._pos&&(d._pos[0]=e[0],d._pos[1]=e[1]);.6<=this.ds.scale&&this.hig
case "number":case "combo":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,.5*h):c.rect(15,b,p-30,h);c.fill();k&&(v.disabled||c.stroke(),c.fillStyle=t,v.disabled||(c.beginPath(),c.moveTo(31,b+5),c.lineTo(21,b+.5*h),c.lineTo(31,b+h-5),c.fill(),c.beginPath(),c.moveTo(p-15-16,b+5),c.lineTo(p-15-6,b+.5*h),c.lineTo(p-15-16,b+h-5),c.fill()),c.fillStyle=m,c.fillText(v.name,35,q+.7*h),c.fillStyle=t,c.textAlign="right","number"==v.type?c.fillText(Number(v.value).toFixed(void 0!==
v.options.precision?v.options.precision:3),p-30-20,q+.7*h):(A=v.value,v.options.values&&(F=v.options.values,F.constructor===Function&&(F=F()),F&&F.constructor!==Array&&(A=F[v.value])),c.fillText(A,p-30-20,q+.7*h)));break;case "string":case "text":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,.5*h):c.rect(15,b,p-30,h);c.fill();k&&(v.disabled||c.stroke(),c.save(),c.beginPath(),c.rect(15,b,p-30,h),c.clip(),c.fillStyle=m,null!=v.name&&c.fillText(v.name,30,q+
.7*h),c.fillStyle=t,c.textAlign="right",c.fillText(String(v.value).substr(0,30),p-30,q+.7*h),c.restore());break;default:v.draw&&v.draw(c,a,p,q,h)}b+=(v.computeSize?v.computeSize(p)[1]:h)+4;c.globalAlpha=this.editor_alpha}c.restore();c.textAlign="left"};l.prototype.processNodeWidgets=function(a,b,c,d){function e(d,e){d.value=e;d.options&&d.options.property&&void 0!==a.properties[d.options.property]&&a.setProperty(d.options.property,e);d.callback&&d.callback(d.value,n,a,b,c)}if(!a.widgets||!a.widgets.length)return null;
for(var g=b[0]-a.pos[0],h=b[1]-a.pos[1],k=a.size[0],n=this,l=this.getCanvasWindow(),t=0;t<a.widgets.length;++t){var m=a.widgets[t];if(m&&!m.disabled){var p=m.computeSize?m.computeSize(k)[1]:f.NODE_WIDGET_HEIGHT,q=m.width||k;if(m==d||!(6>g||g>q-12||h<m.last_y||h>m.last_y+p||void 0===m.last_y)){d=m.value;switch(m.type){case "button":if("mousemove"===c.type)break;m.callback&&setTimeout(function(){m.callback(m,n,a,b,c)},20);this.dirty_canvas=m.clicked=!0;break;case "slider":l=Math.clamp((g-15)/(q-30),
0,1);m.value=m.options.min+(m.options.max-m.options.min)*l;m.callback&&setTimeout(function(){e(m,m.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=m.value;if("mousemove"==c.type&&"number"==m.type)m.value+=.1*c.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);else if("mousedown"==c.type){var r=m.options.values;r&&r.constructor===Function&&(r=m.options.values(m,a));var w=
for(var g=b[0]-a.pos[0],h=b[1]-a.pos[1],k=a.size[0],n=this,l=this.getCanvasWindow(),t=0;t<a.widgets.length;++t){var m=a.widgets[t];if(m&&!m.disabled){var p=m.computeSize?m.computeSize(k)[1]:f.NODE_WIDGET_HEIGHT,q=m.width||k;if(m==d||!(6>g||g>q-12||h<m.last_y||h>m.last_y+p||void 0===m.last_y)){d=m.value;switch(m.type){case "button":"mousedown"===c.type&&(m.callback&&setTimeout(function(){m.callback(m,n,a,b,c)},20),this.dirty_canvas=m.clicked=!0);break;case "slider":l=Math.clamp((g-15)/(q-30),0,1);
m.value=m.options.min+(m.options.max-m.options.min)*l;m.callback&&setTimeout(function(){e(m,m.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=m.value;if("mousemove"==c.type&&"number"==m.type)m.value+=.1*c.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);else if("mousedown"==c.type){var r=m.options.values;r&&r.constructor===Function&&(r=m.options.values(m,a));var w=
null;"number"!=m.type&&(w=r.constructor===Array?r:Object.keys(r));g=40>g?-1:g>q-40?1:0;if("number"==m.type)m.value+=.1*g*(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);else if(g)l=-1,this.last_mouseclick=0,l=r.constructor===Object?w.indexOf(String(m.value))+g:w.indexOf(m.value)+g,l>=w.length&&(l=w.length-1),0>l&&(l=0),m.value=r.constructor===Array?r[l]:l;else{var A=r!=w?Object.values(r):r;
new f.ContextMenu(A,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){r!=w&&(a=A.indexOf(a));this.value=a;e(this,a);n.dirty_canvas=!0;return!1}.bind(m)},l)}}else"mouseup"==c.type&&"number"==m.type&&(g=40>g?-1:g>q-40?1:0,200>c.click_time&&0==g&&this.prompt("Value",m.value,function(a){this.value=Number(a);e(this,this.value)}.bind(m),c));d!=m.value&&setTimeout(function(){e(this,this.value)}.bind(m),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==c.type&&(m.value=
!m.value,setTimeout(function(){e(m,m.value)},20));break;case "string":case "text":"mousedown"==c.type&&this.prompt("Value",m.value,function(a){this.value=a;e(this,a)}.bind(m),c,m.options?m.options.multiline:!1);break;default:m.mouse&&(this.dirty_canvas=m.mouse(c,[g,h],a))}if(d!=m.value){if(a.onWidgetChanged)a.onWidgetChanged(m.name,m.value,d,m);a.graph._version++}return m}}}return null};l.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;

View File

@@ -8855,16 +8855,15 @@ LGraphNode.prototype.executeAction = function(action)
//inside widget
switch (w.type) {
case "button":
if (event.type === "mousemove") {
break;
}
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
if (event.type === "mousedown") {
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
}
break;
case "slider":
var range = w.options.max - w.options.min;
@@ -14879,7 +14878,7 @@ if (typeof exports != "undefined") {
//Converter
function Converter() {
this.addInput("in", "*");
this.addInput("in", "");
this.addOutput("out");
this.size = [80, 30];
}
@@ -17749,7 +17748,7 @@ if (typeof exports != "undefined") {
// Texture Webcam *****************************************
function ImageWebcam() {
this.addOutput("Webcam", "image");
this.properties = { facingMode: "user" };
this.properties = { filterFacingMode: false, facingMode: "user" };
this.boxcolor = "black";
this.frame = 0;
}
@@ -17759,8 +17758,8 @@ if (typeof exports != "undefined") {
ImageWebcam.is_webcam_open = false;
ImageWebcam.prototype.openStream = function() {
if (!navigator.getUserMedia) {
//console.log('getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags');
if (!navigator.mediaDevices.getUserMedia) {
console.log('getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags');
return;
}
@@ -17769,7 +17768,7 @@ if (typeof exports != "undefined") {
// Not showing vendor prefixes.
var constraints = {
audio: false,
video: { facingMode: this.properties.facingMode }
video: !this.properties.filterFacingMode ? true : { facingMode: this.properties.facingMode }
};
navigator.mediaDevices
.getUserMedia(constraints)

View File

@@ -210,8 +210,8 @@ d,.5,r,l);h&&h._pos&&(h._pos[0]=f[0],h._pos[1]=f[1]);.6<=this.ds.scale&&this.hig
case "number":case "combo":d.textAlign="left";d.strokeStyle=m;d.fillStyle=t;d.beginPath();r?d.roundRect(15,b,C-30,l,.5*l):d.rect(15,b,C-30,l);d.fill();r&&(F.disabled||d.stroke(),d.fillStyle=k,F.disabled||(d.beginPath(),d.moveTo(31,b+5),d.lineTo(21,b+.5*l),d.lineTo(31,b+l-5),d.fill(),d.beginPath(),d.moveTo(C-15-16,b+5),d.lineTo(C-15-6,b+.5*l),d.lineTo(C-15-16,b+l-5),d.fill()),d.fillStyle=g,d.fillText(F.name,35,H+.7*l),d.fillStyle=k,d.textAlign="right","number"==F.type?d.fillText(Number(F.value).toFixed(void 0!==
F.options.precision?F.options.precision:3),C-30-20,H+.7*l):(n=F.value,F.options.values&&(q=F.options.values,q.constructor===Function&&(q=q()),q&&q.constructor!==Array&&(n=q[F.value])),d.fillText(n,C-30-20,H+.7*l)));break;case "string":case "text":d.textAlign="left";d.strokeStyle=m;d.fillStyle=t;d.beginPath();r?d.roundRect(15,b,C-30,l,.5*l):d.rect(15,b,C-30,l);d.fill();r&&(F.disabled||d.stroke(),d.save(),d.beginPath(),d.rect(15,b,C-30,l),d.clip(),d.fillStyle=g,null!=F.name&&d.fillText(F.name,30,H+
.7*l),d.fillStyle=k,d.textAlign="right",d.fillText(String(F.value).substr(0,30),C-30,H+.7*l),d.restore());break;default:F.draw&&F.draw(d,a,C,H,l)}b+=(F.computeSize?F.computeSize(C)[1]:l)+4;d.globalAlpha=this.editor_alpha}d.restore();d.textAlign="left"};k.prototype.processNodeWidgets=function(a,b,d,h){function f(f,h){f.value=h;f.options&&f.options.property&&void 0!==a.properties[f.options.property]&&a.setProperty(f.options.property,h);f.callback&&f.callback(f.value,m,a,b,d)}if(!a.widgets||!a.widgets.length)return null;
for(var c=b[0]-a.pos[0],l=b[1]-a.pos[1],r=a.size[0],m=this,t=this.getCanvasWindow(),k=0;k<a.widgets.length;++k){var g=a.widgets[k];if(g&&!g.disabled){var J=g.computeSize?g.computeSize(r)[1]:e.NODE_WIDGET_HEIGHT,F=g.width||r;if(g==h||!(6>c||c>F-12||l<g.last_y||l>g.last_y+J||void 0===g.last_y)){h=g.value;switch(g.type){case "button":if("mousemove"===d.type)break;g.callback&&setTimeout(function(){g.callback(g,m,a,b,d)},20);this.dirty_canvas=g.clicked=!0;break;case "slider":t=Math.clamp((c-15)/(F-30),
0,1);g.value=g.options.min+(g.options.max-g.options.min)*t;g.callback&&setTimeout(function(){f(g,g.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":h=g.value;if("mousemove"==d.type&&"number"==g.type)g.value+=.1*d.deltaX*(g.options.step||1),null!=g.options.min&&g.value<g.options.min&&(g.value=g.options.min),null!=g.options.max&&g.value>g.options.max&&(g.value=g.options.max);else if("mousedown"==d.type){var H=g.options.values;H&&H.constructor===Function&&(H=g.options.values(g,a));var C=
for(var c=b[0]-a.pos[0],l=b[1]-a.pos[1],r=a.size[0],m=this,t=this.getCanvasWindow(),k=0;k<a.widgets.length;++k){var g=a.widgets[k];if(g&&!g.disabled){var J=g.computeSize?g.computeSize(r)[1]:e.NODE_WIDGET_HEIGHT,F=g.width||r;if(g==h||!(6>c||c>F-12||l<g.last_y||l>g.last_y+J||void 0===g.last_y)){h=g.value;switch(g.type){case "button":"mousedown"===d.type&&(g.callback&&setTimeout(function(){g.callback(g,m,a,b,d)},20),this.dirty_canvas=g.clicked=!0);break;case "slider":t=Math.clamp((c-15)/(F-30),0,1);
g.value=g.options.min+(g.options.max-g.options.min)*t;g.callback&&setTimeout(function(){f(g,g.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":h=g.value;if("mousemove"==d.type&&"number"==g.type)g.value+=.1*d.deltaX*(g.options.step||1),null!=g.options.min&&g.value<g.options.min&&(g.value=g.options.min),null!=g.options.max&&g.value>g.options.max&&(g.value=g.options.max);else if("mousedown"==d.type){var H=g.options.values;H&&H.constructor===Function&&(H=g.options.values(g,a));var C=
null;"number"!=g.type&&(C=H.constructor===Array?H:Object.keys(H));c=40>c?-1:c>F-40?1:0;if("number"==g.type)g.value+=.1*c*(g.options.step||1),null!=g.options.min&&g.value<g.options.min&&(g.value=g.options.min),null!=g.options.max&&g.value>g.options.max&&(g.value=g.options.max);else if(c)t=-1,this.last_mouseclick=0,t=H.constructor===Object?C.indexOf(String(g.value))+c:C.indexOf(g.value)+c,t>=C.length&&(t=C.length-1),0>t&&(t=0),g.value=H.constructor===Array?H[t]:t;else{var n=H!=C?Object.values(H):H;
new e.ContextMenu(n,{scale:Math.max(1,this.ds.scale),event:d,className:"dark",callback:function(a,b,d){H!=C&&(a=n.indexOf(a));this.value=a;f(this,a);m.dirty_canvas=!0;return!1}.bind(g)},t)}}else"mouseup"==d.type&&"number"==g.type&&(c=40>c?-1:c>F-40?1:0,200>d.click_time&&0==c&&this.prompt("Value",g.value,function(a){this.value=Number(a);f(this,this.value)}.bind(g),d));h!=g.value&&setTimeout(function(){f(this,this.value)}.bind(g),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==d.type&&(g.value=
!g.value,setTimeout(function(){f(g,g.value)},20));break;case "string":case "text":"mousedown"==d.type&&this.prompt("Value",g.value,function(a){this.value=a;f(this,a)}.bind(g),d,g.options?g.options.multiline:!1);break;default:g.mouse&&(this.dirty_canvas=g.mouse(d,[c,l],a))}if(h!=g.value){if(a.onWidgetChanged)a.onWidgetChanged(g.name,g.value,h,g);a.graph._version++}return g}}}return null};k.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;
@@ -370,7 +370,7 @@ break;case 13:g.buttons[v].pressed&&(n.hat+="down",n.hatmap|=c.DOWN);break;case
c.strokeRect(.5*(q[0]+1)*this.size[0]-4,.5*(q[1]+1)*this.size[1]-4,8,8);g=this.size[1]/this._current_buttons.length;c.fillStyle="#AEB";for(q=0;q<this._current_buttons.length;++q)this._current_buttons[q]&&c.fillRect(0,g*q,6,g)}};c.prototype.onGetOutputs=function(){return[["left_axis","vec2"],["right_axis","vec2"],["left_x_axis","number"],["left_y_axis","number"],["right_x_axis","number"],["right_y_axis","number"],["trigger_left","number"],["trigger_right","number"],["a_button","number"],["b_button",
"number"],["x_button","number"],["y_button","number"],["lb_button","number"],["rb_button","number"],["ls_button","number"],["rs_button","number"],["start_button","number"],["back_button","number"],["a_button_event",g.EVENT],["b_button_event",g.EVENT],["x_button_event",g.EVENT],["y_button_event",g.EVENT],["lb_button_event",g.EVENT],["rb_button_event",g.EVENT],["ls_button_event",g.EVENT],["rs_button_event",g.EVENT],["start_button_event",g.EVENT],["back_button_event",g.EVENT],["hat_left","number"],["hat_right",
"number"],["hat_up","number"],["hat_down","number"],["hat","number"],["button_pressed",g.EVENT]]};g.registerNodeType("input/gamepad",c)})(this);
(function(y){function c(){this.addInput("in","*");this.addOutput("out");this.size=[80,30]}function g(){this.addInput("in");this.addOutput("out");this.size=[80,30]}function q(){this.addInput("in");this.addOutput("out")}function n(){this.addInput("in","number",{locked:!0});this.addOutput("out","number",{locked:!0});this.addOutput("clamped","number",{locked:!0});this.addProperty("in",0);this.addProperty("in_min",0);this.addProperty("in_max",1);this.addProperty("out_min",0);this.addProperty("out_max",
(function(y){function c(){this.addInput("in","");this.addOutput("out");this.size=[80,30]}function g(){this.addInput("in");this.addOutput("out");this.size=[80,30]}function q(){this.addInput("in");this.addOutput("out")}function n(){this.addInput("in","number",{locked:!0});this.addOutput("out","number",{locked:!0});this.addOutput("clamped","number",{locked:!0});this.addProperty("in",0);this.addProperty("in_min",0);this.addProperty("in_max",1);this.addProperty("out_min",0);this.addProperty("out_max",
1);this.size=[120,50]}function v(){this.addOutput("value","number");this.addProperty("min",0);this.addProperty("max",1);this.size=[80,30]}function k(){this.addInput("in","number");this.addOutput("out","number");this.addProperty("min",0);this.addProperty("max",1);this.addProperty("smooth",!0);this.addProperty("seed",0);this.addProperty("octaves",1);this.addProperty("persistence",.8);this.addProperty("speed",1);this.size=[90,30]}function B(){this.addOutput("out","number");this.addProperty("min_time",
1);this.addProperty("max_time",2);this.addProperty("duration",.2);this.size=[90,30];this._blink_time=this._remaining_time=0}function z(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30];this.addProperty("min",0);this.addProperty("max",1)}function G(){this.properties={f:.5};this.addInput("A","number");this.addInput("B","number");this.addOutput("out","number")}function A(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30]}function D(){this.addInput("in",
"number");this.addOutput("out","number");this.size=[80,30]}function e(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30]}function C(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30];this.properties={A:0,B:1}}function E(){this.addInput("in","number",{label:""});this.addOutput("out","number",{label:""});this.size=[80,30];this.addProperty("factor",1)}function x(){this.addInput("v","boolean");this.addInput("A");this.addInput("B");this.addOutput("out")}
@@ -438,14 +438,14 @@ g.desc="select one element from a sequence from a string";g.prototype.onProperty
(function(y){function c(){this.addInput("A","Number");this.addInput("B","Number");this.addInput("C","Number");this.addInput("D","Number");this.values=[[],[],[],[]];this.properties={scale:2}}function g(){this.addOutput("frame","image");this.properties={url:""}}function q(){this.addInput("f","number");this.addOutput("Color","color");this.properties={colorA:"#444444",colorB:"#44AAFF",colorC:"#44FFAA",colorD:"#FFFFFF"}}function n(){this.addInput("","image,canvas");this.size=[200,200]}function v(){this.addInputs([["img1",
"image"],["img2","image"],["fade","number"]]);this.addOutput("","image");this.properties={fade:.5,width:512,height:512}}function k(){this.addInput("","image");this.addOutput("","image");this.properties={width:256,height:256,x:0,y:0,scale:1};this.size=[50,20]}function B(){this.addInput("clear",e.ACTION);this.addOutput("","canvas");this.properties={width:512,height:512,autoclear:!0};this.canvas=document.createElement("canvas");this.ctx=this.canvas.getContext("2d")}function z(){this.addInput("canvas",
"canvas");this.addInput("img","image,canvas");this.addInput("x","number");this.addInput("y","number");this.properties={x:0,y:0,opacity:1}}function G(){this.addInput("canvas","canvas");this.addInput("x","number");this.addInput("y","number");this.addInput("w","number");this.addInput("h","number");this.properties={x:0,y:0,w:10,h:10,color:"white",opacity:1}}function A(){this.addInput("t","number");this.addOutputs([["frame","image"],["t","number"],["d","number"]]);this.properties={url:"",use_proxy:!0}}
function D(){this.addOutput("Webcam","image");this.properties={facingMode:"user"};this.boxcolor="black";this.frame=0}var e=y.LiteGraph;c.title="Plot";c.desc="Plots data over time";c.colors=["#FFF","#F99","#9F9","#99F"];c.prototype.onExecute=function(c){if(!this.flags.collapsed){c=this.size;for(var e=0;4>e;++e){var g=this.getInputData(e);if(null!=g){var k=this.values[e];k.push(g);k.length>c[0]&&k.shift()}}}};c.prototype.onDrawBackground=function(e){if(!this.flags.collapsed){var g=this.size,k=.5*g[1]/
this.properties.scale,n=c.colors,l=.5*g[1];e.fillStyle="#000";e.fillRect(0,0,g[0],g[1]);e.strokeStyle="#555";e.beginPath();e.moveTo(0,l);e.lineTo(g[0],l);e.stroke();if(this.inputs)for(var m=0;4>m;++m){var t=this.values[m];if(this.inputs[m]&&this.inputs[m].link){e.strokeStyle=n[m];e.beginPath();var a=t[0]*k*-1+l;e.moveTo(0,Math.clamp(a,0,g[1]));for(var b=1;b<t.length&&b<g[0];++b)a=t[b]*k*-1+l,e.lineTo(b,Math.clamp(a,0,g[1]));e.stroke()}}}};e.registerNodeType("graphics/plot",c);g.title="Image";g.desc=
"Image loader";g.widgets=[{name:"load",text:"Load",type:"button"}];g.supported_extensions=["jpg","jpeg","png","gif"];g.prototype.onAdded=function(){""!=this.properties.url&&null==this.img&&this.loadImage(this.properties.url)};g.prototype.onDrawBackground=function(c){this.flags.collapsed||this.img&&5<this.size[0]&&5<this.size[1]&&this.img.width&&c.drawImage(this.img,0,0,this.size[0],this.size[1])};g.prototype.onExecute=function(){this.img||(this.boxcolor="#000");this.img&&this.img.width?this.setOutputData(0,
this.img):this.setOutputData(0,null);this.img&&this.img.dirty&&(this.img.dirty=!1)};g.prototype.onPropertyChanged=function(c,e){this.properties[c]=e;"url"==c&&""!=e&&this.loadImage(e);return!0};g.prototype.loadImage=function(c,g){if(""==c)this.img=null;else{this.img=document.createElement("img");"http"==c.substr(0,4)&&e.proxy&&(c=e.proxy+c.substr(c.indexOf(":")+3));this.img.src=c;this.boxcolor="#F95";var k=this;this.img.onload=function(){g&&g(this);console.log("Image loaded, size: "+k.img.width+"x"+
k.img.height);this.dirty=!0;k.boxcolor="#9F9";k.setDirtyCanvas(!0)};this.img.onerror=function(){console.log("error loading the image:"+c)}}};g.prototype.onWidget=function(c,e){"load"==e.name&&this.loadImage(this.properties.url)};g.prototype.onDropFile=function(c){var e=this;this._url&&URL.revokeObjectURL(this._url);this._url=URL.createObjectURL(c);this.properties.url=this._url;this.loadImage(this._url,function(c){e.size[1]=c.height/c.width*e.size[0]})};e.registerNodeType("graphics/image",g);q.title=
"Palette";q.desc="Generates a color";q.prototype.onExecute=function(){var c=[];null!=this.properties.colorA&&c.push(hex2num(this.properties.colorA));null!=this.properties.colorB&&c.push(hex2num(this.properties.colorB));null!=this.properties.colorC&&c.push(hex2num(this.properties.colorC));null!=this.properties.colorD&&c.push(hex2num(this.properties.colorD));var e=this.getInputData(0);null==e&&(e=.5);1<e?e=1:0>e&&(e=0);if(0!=c.length){var g=[0,0,0];if(0==e)g=c[0];else if(1==e)g=c[c.length-1];else{var k=
(c.length-1)*e;e=c[Math.floor(k)];c=c[Math.floor(k)+1];k-=Math.floor(k);g[0]=e[0]*(1-k)+c[0]*k;g[1]=e[1]*(1-k)+c[1]*k;g[2]=e[2]*(1-k)+c[2]*k}for(e=0;e<g.length;e++)g[e]/=255;this.boxcolor=colorToString(g);this.setOutputData(0,g)}};e.registerNodeType("color/palette",q);n.title="Frame";n.desc="Frame viewerew";n.widgets=[{name:"resize",text:"Resize box",type:"button"},{name:"view",text:"View Image",type:"button"}];n.prototype.onDrawBackground=function(c){this.frame&&!this.flags.collapsed&&c.drawImage(this.frame,
0,0,this.size[0],this.size[1])};n.prototype.onExecute=function(){this.frame=this.getInputData(0);this.setDirtyCanvas(!0)};n.prototype.onWidget=function(c,e){"resize"==e.name&&this.frame?(c=this.frame.width,e=this.frame.height,c||null==this.frame.videoWidth||(c=this.frame.videoWidth,e=this.frame.videoHeight),c&&e&&(this.size=[c,e]),this.setDirtyCanvas(!0,!0)):"view"==e.name&&this.show()};n.prototype.show=function(){showElement&&this.frame&&showElement(this.frame)};e.registerNodeType("graphics/frame",
function D(){this.addOutput("Webcam","image");this.properties={filterFacingMode:!1,facingMode:"user"};this.boxcolor="black";this.frame=0}var e=y.LiteGraph;c.title="Plot";c.desc="Plots data over time";c.colors=["#FFF","#F99","#9F9","#99F"];c.prototype.onExecute=function(c){if(!this.flags.collapsed){c=this.size;for(var e=0;4>e;++e){var g=this.getInputData(e);if(null!=g){var k=this.values[e];k.push(g);k.length>c[0]&&k.shift()}}}};c.prototype.onDrawBackground=function(e){if(!this.flags.collapsed){var g=
this.size,k=.5*g[1]/this.properties.scale,n=c.colors,l=.5*g[1];e.fillStyle="#000";e.fillRect(0,0,g[0],g[1]);e.strokeStyle="#555";e.beginPath();e.moveTo(0,l);e.lineTo(g[0],l);e.stroke();if(this.inputs)for(var m=0;4>m;++m){var t=this.values[m];if(this.inputs[m]&&this.inputs[m].link){e.strokeStyle=n[m];e.beginPath();var a=t[0]*k*-1+l;e.moveTo(0,Math.clamp(a,0,g[1]));for(var b=1;b<t.length&&b<g[0];++b)a=t[b]*k*-1+l,e.lineTo(b,Math.clamp(a,0,g[1]));e.stroke()}}}};e.registerNodeType("graphics/plot",c);
g.title="Image";g.desc="Image loader";g.widgets=[{name:"load",text:"Load",type:"button"}];g.supported_extensions=["jpg","jpeg","png","gif"];g.prototype.onAdded=function(){""!=this.properties.url&&null==this.img&&this.loadImage(this.properties.url)};g.prototype.onDrawBackground=function(c){this.flags.collapsed||this.img&&5<this.size[0]&&5<this.size[1]&&this.img.width&&c.drawImage(this.img,0,0,this.size[0],this.size[1])};g.prototype.onExecute=function(){this.img||(this.boxcolor="#000");this.img&&this.img.width?
this.setOutputData(0,this.img):this.setOutputData(0,null);this.img&&this.img.dirty&&(this.img.dirty=!1)};g.prototype.onPropertyChanged=function(c,e){this.properties[c]=e;"url"==c&&""!=e&&this.loadImage(e);return!0};g.prototype.loadImage=function(c,g){if(""==c)this.img=null;else{this.img=document.createElement("img");"http"==c.substr(0,4)&&e.proxy&&(c=e.proxy+c.substr(c.indexOf(":")+3));this.img.src=c;this.boxcolor="#F95";var k=this;this.img.onload=function(){g&&g(this);console.log("Image loaded, size: "+
k.img.width+"x"+k.img.height);this.dirty=!0;k.boxcolor="#9F9";k.setDirtyCanvas(!0)};this.img.onerror=function(){console.log("error loading the image:"+c)}}};g.prototype.onWidget=function(c,e){"load"==e.name&&this.loadImage(this.properties.url)};g.prototype.onDropFile=function(c){var e=this;this._url&&URL.revokeObjectURL(this._url);this._url=URL.createObjectURL(c);this.properties.url=this._url;this.loadImage(this._url,function(c){e.size[1]=c.height/c.width*e.size[0]})};e.registerNodeType("graphics/image",
g);q.title="Palette";q.desc="Generates a color";q.prototype.onExecute=function(){var c=[];null!=this.properties.colorA&&c.push(hex2num(this.properties.colorA));null!=this.properties.colorB&&c.push(hex2num(this.properties.colorB));null!=this.properties.colorC&&c.push(hex2num(this.properties.colorC));null!=this.properties.colorD&&c.push(hex2num(this.properties.colorD));var e=this.getInputData(0);null==e&&(e=.5);1<e?e=1:0>e&&(e=0);if(0!=c.length){var g=[0,0,0];if(0==e)g=c[0];else if(1==e)g=c[c.length-
1];else{var k=(c.length-1)*e;e=c[Math.floor(k)];c=c[Math.floor(k)+1];k-=Math.floor(k);g[0]=e[0]*(1-k)+c[0]*k;g[1]=e[1]*(1-k)+c[1]*k;g[2]=e[2]*(1-k)+c[2]*k}for(e=0;e<g.length;e++)g[e]/=255;this.boxcolor=colorToString(g);this.setOutputData(0,g)}};e.registerNodeType("color/palette",q);n.title="Frame";n.desc="Frame viewerew";n.widgets=[{name:"resize",text:"Resize box",type:"button"},{name:"view",text:"View Image",type:"button"}];n.prototype.onDrawBackground=function(c){this.frame&&!this.flags.collapsed&&
c.drawImage(this.frame,0,0,this.size[0],this.size[1])};n.prototype.onExecute=function(){this.frame=this.getInputData(0);this.setDirtyCanvas(!0)};n.prototype.onWidget=function(c,e){"resize"==e.name&&this.frame?(c=this.frame.width,e=this.frame.height,c||null==this.frame.videoWidth||(c=this.frame.videoWidth,e=this.frame.videoHeight),c&&e&&(this.size=[c,e]),this.setDirtyCanvas(!0,!0)):"view"==e.name&&this.show()};n.prototype.show=function(){showElement&&this.frame&&showElement(this.frame)};e.registerNodeType("graphics/frame",
n);v.title="Image fade";v.desc="Fades between images";v.widgets=[{name:"resizeA",text:"Resize to A",type:"button"},{name:"resizeB",text:"Resize to B",type:"button"}];v.prototype.onAdded=function(){this.createCanvas();var c=this.canvas.getContext("2d");c.fillStyle="#000";c.fillRect(0,0,this.properties.width,this.properties.height)};v.prototype.createCanvas=function(){this.canvas=document.createElement("canvas");this.canvas.width=this.properties.width;this.canvas.height=this.properties.height};v.prototype.onExecute=
function(){var c=this.canvas.getContext("2d");this.canvas.width=this.canvas.width;var e=this.getInputData(0);null!=e&&c.drawImage(e,0,0,this.canvas.width,this.canvas.height);e=this.getInputData(2);null==e?e=this.properties.fade:this.properties.fade=e;c.globalAlpha=e;e=this.getInputData(1);null!=e&&c.drawImage(e,0,0,this.canvas.width,this.canvas.height);c.globalAlpha=1;this.setOutputData(0,this.canvas);this.setDirtyCanvas(!0)};e.registerNodeType("graphics/imagefade",v);k.title="Crop";k.desc="Crop Image";
k.prototype.onAdded=function(){this.createCanvas()};k.prototype.createCanvas=function(){this.canvas=document.createElement("canvas");this.canvas.width=this.properties.width;this.canvas.height=this.properties.height};k.prototype.onExecute=function(){var c=this.getInputData(0);c&&(c.width?(this.canvas.getContext("2d").drawImage(c,-this.properties.x,-this.properties.y,c.width*this.properties.scale,c.height*this.properties.scale),this.setOutputData(0,this.canvas)):this.setOutputData(0,null))};k.prototype.onDrawBackground=
@@ -457,11 +457,11 @@ this._video.dirty=!0;this.setOutputData(0,this._video);this.setOutputData(1,this
(c=e.proxy+c.substr(c.indexOf(":")+3));this._video=document.createElement("video");this._video.src=c;this._video.type="type=video/mp4";this._video.muted=!0;this._video.autoplay=!0;var n=this;this._video.addEventListener("loadedmetadata",function(c){console.log("Duration: "+this.duration+" seconds");console.log("Size: "+this.videoWidth+","+this.videoHeight);n.setDirtyCanvas(!0);this.width=this.videoWidth;this.height=this.videoHeight});this._video.addEventListener("progress",function(c){console.log("video loading...")});
this._video.addEventListener("error",function(c){console.error("Error loading video: "+this.src);if(this.error)switch(this.error.code){case this.error.MEDIA_ERR_ABORTED:console.error("You stopped the video.");break;case this.error.MEDIA_ERR_NETWORK:console.error("Network error - please try again later.");break;case this.error.MEDIA_ERR_DECODE:console.error("Video is broken..");break;case this.error.MEDIA_ERR_SRC_NOT_SUPPORTED:console.error("Sorry, your browser can't play this video.")}});this._video.addEventListener("ended",
function(c){console.log("Video Ended.");this.play()})};A.prototype.onPropertyChanged=function(c,e){this.properties[c]=e;"url"==c&&""!=e&&this.loadVideo(e);return!0};A.prototype.play=function(){this._video&&this._video.videoWidth&&this._video.play()};A.prototype.playPause=function(){this._video&&(this._video.paused?this.play():this.pause())};A.prototype.stop=function(){this._video&&(this._video.pause(),this._video.currentTime=0)};A.prototype.pause=function(){this._video&&(console.log("Video paused"),
this._video.pause())};A.prototype.onWidget=function(c,e){};e.registerNodeType("graphics/video",A);D.title="Webcam";D.desc="Webcam image";D.is_webcam_open=!1;D.prototype.openStream=function(){if(navigator.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:this.properties.facingMode}}).then(this.streamReady.bind(this)).catch(function(e){console.log("Webcam rejected",e);c._webcam_stream=!1;D.is_webcam_open=!1;c.boxcolor="red";c.trigger("stream_error")});
var c=this}};D.prototype.closeStream=function(){if(this._webcam_stream){var c=this._webcam_stream.getTracks();if(c.length)for(var e=0;e<c.length;++e)c[e].stop();D.is_webcam_open=!1;this._video=this._webcam_stream=null;this.boxcolor="black";this.trigger("stream_closed")}};D.prototype.onPropertyChanged=function(c,e){"facingMode"==c&&(this.properties.facingMode=e,this.closeStream(),this.openStream())};D.prototype.onRemoved=function(){this.closeStream()};D.prototype.streamReady=function(c){this._webcam_stream=
c;this.boxcolor="green";var e=this._video;e||(e=document.createElement("video"),e.autoplay=!0,e.srcObject=c,this._video=e,e.onloadedmetadata=function(c){console.log(c);D.is_webcam_open=!0});this.trigger("stream_ready",e)};D.prototype.onExecute=function(){null!=this._webcam_stream||this._waiting_confirmation||this.openStream();if(this._video&&this._video.videoWidth){this._video.frame=++this.frame;this._video.width=this._video.videoWidth;this._video.height=this._video.videoHeight;this.setOutputData(0,
this._video);for(var c=1;c<this.outputs.length;++c)if(this.outputs[c])switch(this.outputs[c].name){case "width":this.setOutputData(c,this._video.videoWidth);break;case "height":this.setOutputData(c,this._video.videoHeight)}}};D.prototype.getExtraMenuOptions=function(c){var e=this;return[{content:e.properties.show?"Hide Frame":"Show Frame",callback:function(){e.properties.show=!e.properties.show}}]};D.prototype.onDrawBackground=function(c){this.flags.collapsed||20>=this.size[1]||!this.properties.show||
!this._video||(c.save(),c.drawImage(this._video,0,0,this.size[0],this.size[1]),c.restore())};D.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["stream_ready",e.EVENT],["stream_closed",e.EVENT],["stream_error",e.EVENT]]};e.registerNodeType("graphics/webcam",D)})(this);
this._video.pause())};A.prototype.onWidget=function(c,e){};e.registerNodeType("graphics/video",A);D.title="Webcam";D.desc="Webcam image";D.is_webcam_open=!1;D.prototype.openStream=function(){if(navigator.mediaDevices.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:this.properties.filterFacingMode?{facingMode:this.properties.facingMode}:!0}).then(this.streamReady.bind(this)).catch(function(e){console.log("Webcam rejected",e);c._webcam_stream=!1;D.is_webcam_open=
!1;c.boxcolor="red";c.trigger("stream_error")});var c=this}else console.log("getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags")};D.prototype.closeStream=function(){if(this._webcam_stream){var c=this._webcam_stream.getTracks();if(c.length)for(var e=0;e<c.length;++e)c[e].stop();D.is_webcam_open=!1;this._video=this._webcam_stream=null;this.boxcolor="black";this.trigger("stream_closed")}};D.prototype.onPropertyChanged=function(c,e){"facingMode"==c&&(this.properties.facingMode=
e,this.closeStream(),this.openStream())};D.prototype.onRemoved=function(){this.closeStream()};D.prototype.streamReady=function(c){this._webcam_stream=c;this.boxcolor="green";var e=this._video;e||(e=document.createElement("video"),e.autoplay=!0,e.srcObject=c,this._video=e,e.onloadedmetadata=function(c){console.log(c);D.is_webcam_open=!0});this.trigger("stream_ready",e)};D.prototype.onExecute=function(){null!=this._webcam_stream||this._waiting_confirmation||this.openStream();if(this._video&&this._video.videoWidth){this._video.frame=
++this.frame;this._video.width=this._video.videoWidth;this._video.height=this._video.videoHeight;this.setOutputData(0,this._video);for(var c=1;c<this.outputs.length;++c)if(this.outputs[c])switch(this.outputs[c].name){case "width":this.setOutputData(c,this._video.videoWidth);break;case "height":this.setOutputData(c,this._video.videoHeight)}}};D.prototype.getExtraMenuOptions=function(c){var e=this;return[{content:e.properties.show?"Hide Frame":"Show Frame",callback:function(){e.properties.show=!e.properties.show}}]};
D.prototype.onDrawBackground=function(c){this.flags.collapsed||20>=this.size[1]||!this.properties.show||!this._video||(c.save(),c.drawImage(this._video,0,0,this.size[0],this.size[1]),c.restore())};D.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["stream_ready",e.EVENT],["stream_closed",e.EVENT],["stream_error",e.EVENT]]};e.registerNodeType("graphics/webcam",D)})(this);
(function(y){function c(){this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",filter:!0};this.size=[c.image_preview_size,c.image_preview_size]}function g(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[c.image_preview_size,c.image_preview_size]}function q(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",generate_mipmaps:!1}}function n(){this.addInput("Texture",
"Texture");this.addInput("TextureB","Texture");this.addInput("value","number");this.addOutput("Texture","Texture");this.help="<p>pixelcode must be vec3, uvcode must be vec2, is optional</p>\t\t<p><strong>uv:</strong> tex. coords</p><p><strong>color:</strong> texture <strong>colorB:</strong> textureB</p><p><strong>time:</strong> scene time <strong>value:</strong> input value</p><p>For multiline you must type: result = ...</p>";this.properties={value:1,pixelcode:"color + colorB * value",uvcode:"",precision:c.DEFAULT};
this.has_error=!1}function v(){this.addOutput("out","Texture");this.properties={code:"",u_value:1,u_color:[1,1,1,1],width:512,height:512,precision:c.DEFAULT};this.properties.code=v.pixel_shader;this._uniforms={u_value:1,u_color:vec4.create(),in_texture:0,texSize:vec4.create(),time:0}}function k(){this.addInput("in","Texture");this.addInput("scale","vec2");this.addInput("offset","vec2");this.addOutput("out","Texture");this.properties={offset:vec2.fromValues(0,0),scale:vec2.fromValues(1,1),precision:c.DEFAULT}}

View File

@@ -8855,16 +8855,15 @@ LGraphNode.prototype.executeAction = function(action)
//inside widget
switch (w.type) {
case "button":
if (event.type === "mousemove") {
break;
}
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
if (event.type === "mousedown") {
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
}
break;
case "slider":
var range = w.options.max - w.options.min;
@@ -14081,7 +14080,7 @@ if (typeof exports != "undefined") {
//Converter
function Converter() {
this.addInput("in", "*");
this.addInput("in", "");
this.addOutput("out");
this.size = [80, 30];
}

View File

@@ -210,8 +210,8 @@ c,.5,n,r);d&&d._pos&&(d._pos[0]=e[0],d._pos[1]=e[1]);.6<=this.ds.scale&&this.hig
case "number":case "combo":c.textAlign="left";c.strokeStyle=r;c.fillStyle=h;c.beginPath();n?c.roundRect(15,b,m-30,g,.5*g):c.rect(15,b,m-30,g);c.fill();n&&(y.disabled||c.stroke(),c.fillStyle=k,y.disabled||(c.beginPath(),c.moveTo(31,b+5),c.lineTo(21,b+.5*g),c.lineTo(31,b+g-5),c.fill(),c.beginPath(),c.moveTo(m-15-16,b+5),c.lineTo(m-15-6,b+.5*g),c.lineTo(m-15-16,b+g-5),c.fill()),c.fillStyle=p,c.fillText(y.name,35,t+.7*g),c.fillStyle=k,c.textAlign="right","number"==y.type?c.fillText(Number(y.value).toFixed(void 0!==
y.options.precision?y.options.precision:3),m-30-20,t+.7*g):(q=y.value,y.options.values&&(w=y.options.values,w.constructor===Function&&(w=w()),w&&w.constructor!==Array&&(q=w[y.value])),c.fillText(q,m-30-20,t+.7*g)));break;case "string":case "text":c.textAlign="left";c.strokeStyle=r;c.fillStyle=h;c.beginPath();n?c.roundRect(15,b,m-30,g,.5*g):c.rect(15,b,m-30,g);c.fill();n&&(y.disabled||c.stroke(),c.save(),c.beginPath(),c.rect(15,b,m-30,g),c.clip(),c.fillStyle=p,null!=y.name&&c.fillText(y.name,30,t+
.7*g),c.fillStyle=k,c.textAlign="right",c.fillText(String(y.value).substr(0,30),m-30,t+.7*g),c.restore());break;default:y.draw&&y.draw(c,a,m,t,g)}b+=(y.computeSize?y.computeSize(m)[1]:g)+4;c.globalAlpha=this.editor_alpha}c.restore();c.textAlign="left"};h.prototype.processNodeWidgets=function(a,b,c,d){function e(d,e){d.value=e;d.options&&d.options.property&&void 0!==a.properties[d.options.property]&&a.setProperty(d.options.property,e);d.callback&&d.callback(d.value,r,a,b,c)}if(!a.widgets||!a.widgets.length)return null;
for(var f=b[0]-a.pos[0],g=b[1]-a.pos[1],n=a.size[0],r=this,h=this.getCanvasWindow(),k=0;k<a.widgets.length;++k){var p=a.widgets[k];if(p&&!p.disabled){var z=p.computeSize?p.computeSize(n)[1]:l.NODE_WIDGET_HEIGHT,t=p.width||n;if(p==d||!(6>f||f>t-12||g<p.last_y||g>p.last_y+z||void 0===p.last_y)){d=p.value;switch(p.type){case "button":if("mousemove"===c.type)break;p.callback&&setTimeout(function(){p.callback(p,r,a,b,c)},20);this.dirty_canvas=p.clicked=!0;break;case "slider":h=Math.clamp((f-15)/(t-30),
0,1);p.value=p.options.min+(p.options.max-p.options.min)*h;p.callback&&setTimeout(function(){e(p,p.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=p.value;if("mousemove"==c.type&&"number"==p.type)p.value+=.1*c.deltaX*(p.options.step||1),null!=p.options.min&&p.value<p.options.min&&(p.value=p.options.min),null!=p.options.max&&p.value>p.options.max&&(p.value=p.options.max);else if("mousedown"==c.type){var m=p.options.values;m&&m.constructor===Function&&(m=p.options.values(p,a));var q=
for(var f=b[0]-a.pos[0],g=b[1]-a.pos[1],n=a.size[0],r=this,h=this.getCanvasWindow(),k=0;k<a.widgets.length;++k){var p=a.widgets[k];if(p&&!p.disabled){var z=p.computeSize?p.computeSize(n)[1]:l.NODE_WIDGET_HEIGHT,t=p.width||n;if(p==d||!(6>f||f>t-12||g<p.last_y||g>p.last_y+z||void 0===p.last_y)){d=p.value;switch(p.type){case "button":"mousedown"===c.type&&(p.callback&&setTimeout(function(){p.callback(p,r,a,b,c)},20),this.dirty_canvas=p.clicked=!0);break;case "slider":h=Math.clamp((f-15)/(t-30),0,1);
p.value=p.options.min+(p.options.max-p.options.min)*h;p.callback&&setTimeout(function(){e(p,p.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=p.value;if("mousemove"==c.type&&"number"==p.type)p.value+=.1*c.deltaX*(p.options.step||1),null!=p.options.min&&p.value<p.options.min&&(p.value=p.options.min),null!=p.options.max&&p.value>p.options.max&&(p.value=p.options.max);else if("mousedown"==c.type){var m=p.options.values;m&&m.constructor===Function&&(m=p.options.values(p,a));var q=
null;"number"!=p.type&&(q=m.constructor===Array?m:Object.keys(m));f=40>f?-1:f>t-40?1:0;if("number"==p.type)p.value+=.1*f*(p.options.step||1),null!=p.options.min&&p.value<p.options.min&&(p.value=p.options.min),null!=p.options.max&&p.value>p.options.max&&(p.value=p.options.max);else if(f)h=-1,this.last_mouseclick=0,h=m.constructor===Object?q.indexOf(String(p.value))+f:q.indexOf(p.value)+f,h>=q.length&&(h=q.length-1),0>h&&(h=0),p.value=m.constructor===Array?m[h]:h;else{var w=m!=q?Object.values(m):m;
new l.ContextMenu(w,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){m!=q&&(a=w.indexOf(a));this.value=a;e(this,a);r.dirty_canvas=!0;return!1}.bind(p)},h)}}else"mouseup"==c.type&&"number"==p.type&&(f=40>f?-1:f>t-40?1:0,200>c.click_time&&0==f&&this.prompt("Value",p.value,function(a){this.value=Number(a);e(this,this.value)}.bind(p),c));d!=p.value&&setTimeout(function(){e(this,this.value)}.bind(p),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==c.type&&(p.value=
!p.value,setTimeout(function(){e(p,p.value)},20));break;case "string":case "text":"mousedown"==c.type&&this.prompt("Value",p.value,function(a){this.value=a;e(this,a)}.bind(p),c,p.options?p.options.multiline:!1);break;default:p.mouse&&(this.dirty_canvas=p.mouse(c,[f,g],a))}if(d!=p.value){if(a.onWidgetChanged)a.onWidgetChanged(p.name,p.value,d,p);a.graph._version++}return p}}}return null};h.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;
@@ -345,7 +345,7 @@ break;case 13:k.buttons[q].pressed&&(t.hat+="down",t.hatmap|=m.DOWN);break;case
k.strokeRect(.5*(m[0]+1)*this.size[0]-4,.5*(m[1]+1)*this.size[1]-4,8,8);t=this.size[1]/this._current_buttons.length;k.fillStyle="#AEB";for(m=0;m<this._current_buttons.length;++m)this._current_buttons[m]&&k.fillRect(0,t*m,6,t)}};m.prototype.onGetOutputs=function(){return[["left_axis","vec2"],["right_axis","vec2"],["left_x_axis","number"],["left_y_axis","number"],["right_x_axis","number"],["right_y_axis","number"],["trigger_left","number"],["trigger_right","number"],["a_button","number"],["b_button",
"number"],["x_button","number"],["y_button","number"],["lb_button","number"],["rb_button","number"],["ls_button","number"],["rs_button","number"],["start_button","number"],["back_button","number"],["a_button_event",q.EVENT],["b_button_event",q.EVENT],["x_button_event",q.EVENT],["y_button_event",q.EVENT],["lb_button_event",q.EVENT],["rb_button_event",q.EVENT],["ls_button_event",q.EVENT],["rs_button_event",q.EVENT],["start_button_event",q.EVENT],["back_button_event",q.EVENT],["hat_left","number"],["hat_right",
"number"],["hat_up","number"],["hat_down","number"],["hat","number"],["button_pressed",q.EVENT]]};q.registerNodeType("input/gamepad",m)})(this);
(function(v){function m(){this.addInput("in","*");this.addOutput("out");this.size=[80,30]}function q(){this.addInput("in");this.addOutput("out");this.size=[80,30]}function k(){this.addInput("in");this.addOutput("out")}function t(){this.addInput("in","number",{locked:!0});this.addOutput("out","number",{locked:!0});this.addOutput("clamped","number",{locked:!0});this.addProperty("in",0);this.addProperty("in_min",0);this.addProperty("in_max",1);this.addProperty("out_min",0);this.addProperty("out_max",
(function(v){function m(){this.addInput("in","");this.addOutput("out");this.size=[80,30]}function q(){this.addInput("in");this.addOutput("out");this.size=[80,30]}function k(){this.addInput("in");this.addOutput("out")}function t(){this.addInput("in","number",{locked:!0});this.addOutput("out","number",{locked:!0});this.addOutput("clamped","number",{locked:!0});this.addProperty("in",0);this.addProperty("in_min",0);this.addProperty("in_max",1);this.addProperty("out_min",0);this.addProperty("out_max",
1);this.size=[120,50]}function w(){this.addOutput("value","number");this.addProperty("min",0);this.addProperty("max",1);this.size=[80,30]}function h(){this.addInput("in","number");this.addOutput("out","number");this.addProperty("min",0);this.addProperty("max",1);this.addProperty("smooth",!0);this.addProperty("seed",0);this.addProperty("octaves",1);this.addProperty("persistence",.8);this.addProperty("speed",1);this.size=[90,30]}function E(){this.addOutput("out","number");this.addProperty("min_time",
1);this.addProperty("max_time",2);this.addProperty("duration",.2);this.size=[90,30];this._blink_time=this._remaining_time=0}function C(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30];this.addProperty("min",0);this.addProperty("max",1)}function B(){this.properties={f:.5};this.addInput("A","number");this.addInput("B","number");this.addOutput("out","number")}function x(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30]}function I(){this.addInput("in",
"number");this.addOutput("out","number");this.size=[80,30]}function l(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30]}function L(){this.addInput("in","number");this.addOutput("out","number");this.size=[80,30];this.properties={A:0,B:1}}function G(){this.addInput("in","number",{label:""});this.addOutput("out","number",{label:""});this.size=[80,30];this.addProperty("factor",1)}function A(){this.addInput("v","boolean");this.addInput("A");this.addInput("B");this.addOutput("out")}

View File

@@ -8853,16 +8853,15 @@ LGraphNode.prototype.executeAction = function(action)
//inside widget
switch (w.type) {
case "button":
if (event.type === "mousemove") {
break;
}
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
if (event.type === "mousedown") {
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
}
break;
case "slider":
var range = w.options.max - w.options.min;