Skip to content

Commit ca1d754

Browse files
authored
Merge branch 'master' into allow-equations-in-number-inputs
2 parents 2a7f8d4 + 492b7a5 commit ca1d754

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/litegraph.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9732,13 +9732,17 @@ LGraphNode.prototype.executeAction = function(action)
97329732
ctx.fillRect(margin, y, widget_width - margin * 2, H);
97339733
var range = w.options.max - w.options.min;
97349734
var nvalue = (w.value - w.options.min) / range;
9735-
ctx.fillStyle = active_widget == w ? "#89A" : "#678";
9735+
if(nvalue < 0.0) nvalue = 0.0;
9736+
if(nvalue > 1.0) nvalue = 1.0;
9737+
ctx.fillStyle = w.options.hasOwnProperty("slider_color") ? w.options.slider_color : (active_widget == w ? "#89A" : "#678");
97369738
ctx.fillRect(margin, y, nvalue * (widget_width - margin * 2), H);
97379739
if(show_text && !w.disabled)
97389740
ctx.strokeRect(margin, y, widget_width - margin * 2, H);
97399741
if (w.marker) {
97409742
var marker_nvalue = (w.marker - w.options.min) / range;
9741-
ctx.fillStyle = "#AA9";
9743+
if(marker_nvalue < 0.0) marker_nvalue = 0.0;
9744+
if(marker_nvalue > 1.0) marker_nvalue = 1.0;
9745+
ctx.fillStyle = w.options.hasOwnProperty("marker_color") ? w.options.marker_color : "#AA9";
97429746
ctx.fillRect( margin + marker_nvalue * (widget_width - margin * 2), y, 2, H );
97439747
}
97449748
if (show_text) {
@@ -9905,6 +9909,7 @@ LGraphNode.prototype.executeAction = function(action)
99059909
case "slider":
99069910
var range = w.options.max - w.options.min;
99079911
var nvalue = Math.clamp((x - 15) / (widget_width - 30), 0, 1);
9912+
if(w.options.read_only) break;
99089913
w.value = w.options.min + (w.options.max - w.options.min) * nvalue;
99099914
if (w.callback) {
99109915
setTimeout(function() {
@@ -10019,7 +10024,6 @@ LGraphNode.prototype.executeAction = function(action)
1001910024
case "text":
1002010025
if (event.type == LiteGraph.pointerevents_method+"down") {
1002110026
this.prompt("Value",w.value,function(v) {
10022-
this.value = v;
1002310027
inner_value_change(this, v);
1002410028
}.bind(w),
1002510029
event,w.options ? w.options.multiline : false );
@@ -10044,6 +10048,9 @@ LGraphNode.prototype.executeAction = function(action)
1004410048
}//end for
1004510049

1004610050
function inner_value_change(widget, value) {
10051+
if(widget.type == "number"){
10052+
value = Number(value);
10053+
}
1004710054
widget.value = value;
1004810055
if ( widget.options && widget.options.property && node.properties[widget.options.property] !== undefined ) {
1004910056
node.setProperty( widget.options.property, value );

src/nodes/logic.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@
9393
logicAnd.title = "AND";
9494
logicAnd.desc = "Return true if all inputs are true";
9595
logicAnd.prototype.onExecute = function() {
96-
ret = true;
96+
var ret = true;
9797
for (inX in this.inputs){
9898
if (!this.getInputData(inX)){
99-
ret = false;
99+
var ret = false;
100100
break;
101101
}
102102
}
@@ -119,7 +119,7 @@
119119
logicOr.title = "OR";
120120
logicOr.desc = "Return true if at least one input is true";
121121
logicOr.prototype.onExecute = function() {
122-
ret = false;
122+
var ret = false;
123123
for (inX in this.inputs){
124124
if (this.getInputData(inX)){
125125
ret = true;
@@ -159,8 +159,8 @@
159159
logicCompare.title = "bool == bool";
160160
logicCompare.desc = "Compare for logical equality";
161161
logicCompare.prototype.onExecute = function() {
162-
last = null;
163-
ret = true;
162+
var last = null;
163+
var ret = true;
164164
for (inX in this.inputs){
165165
if (last === null) last = this.getInputData(inX);
166166
else

0 commit comments

Comments
 (0)