From 320bdb2926d28376a308333c08918def44f3e1f6 Mon Sep 17 00:00:00 2001 From: George Michael Brower Date: Mon, 18 Apr 2011 17:35:27 -0700 Subject: [PATCH] Pass only a single parameter to gui.add to automatically add all of its properties --- index.html | 2 +- src/DAT/GUI/ControllerNumber.js | 8 ++++---- src/DAT/GUI/GUI.js | 8 ++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 94a8f87..450f659 100644 --- a/index.html +++ b/index.html @@ -30,9 +30,9 @@ prettyPrint(); var fizzyText = new FizzyText("dat.gui"); - var gui = new DAT.GUI(); + // Text field gui.add(fizzyText, "message"); diff --git a/src/DAT/GUI/ControllerNumber.js b/src/DAT/GUI/ControllerNumber.js index 191a86c..dc555eb 100644 --- a/src/DAT/GUI/ControllerNumber.js +++ b/src/DAT/GUI/ControllerNumber.js @@ -116,7 +116,7 @@ DAT.GUI.ControllerNumber = function() { numberField.addEventListener('mousewheel', function(e) { e.preventDefault(); - _this.setValue(_this.getValue() + Math.abs(e.wheelDeltaY) / e.wheelDeltaY * step); + _this.setValue(_this.getValue() + Math.abs(e.wheelDeltaY) / e.wheelDeltaY * _this.getStep()); return false; }, false); @@ -140,11 +140,11 @@ DAT.GUI.ControllerNumber = function() { _this.setValue(newVal); break; case 38: // up - newVal = _this.getValue() + step; + newVal = _this.getValue() + _this.getStep(); _this.setValue(newVal); break; case 40: // down - newVal = _this.getValue() - step; + newVal = _this.getValue() - _this.getStep(); _this.setValue(newVal); break; } @@ -192,7 +192,7 @@ DAT.GUI.ControllerNumber = function() { draggedNumberField = true; e.preventDefault(); - var newVal = _this.getValue() + dy * step; + var newVal = _this.getValue() + dy * _this.getStep(); _this.setValue(newVal); return false; diff --git a/src/DAT/GUI/GUI.js b/src/DAT/GUI/GUI.js index 28ee4f1..6693c18 100644 --- a/src/DAT/GUI/GUI.js +++ b/src/DAT/GUI/GUI.js @@ -275,6 +275,14 @@ DAT.GUI = function(parameters) { this.add = function() { + if (arguments.length == 1) { + var toReturn = []; + for (var i in arguments[0]) { + toReturn.push(_this.add(arguments[0], i)); + } + return toReturn; + } + var object = arguments[0]; var propertyName = arguments[1];