diff options
author | David Runge <dave@sleepmap.de> | 2016-07-24 17:30:12 +0200 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2016-07-24 17:30:12 +0200 |
commit | 7d17cc0d6e9113e9e6f395348a6c614a676247b4 (patch) | |
tree | 4b7315b50363182c2d9c05567fc0b1cb8d21d898 | |
parent | 1b67ccd396de4d26c484c430b4111d4d9c3ba237 (diff) | |
download | bowelyzer-7d17cc0d6e9113e9e6f395348a6c614a676247b4.tar.gz bowelyzer-7d17cc0d6e9113e9e6f395348a6c614a676247b4.tar.bz2 bowelyzer-7d17cc0d6e9113e9e6f395348a6c614a676247b4.tar.xz bowelyzer-7d17cc0d6e9113e9e6f395348a6c614a676247b4.zip |
classes/BowelyzerGUI.sc: Adding BowelyzerConfig class constants for GUI controls. Moving the creation of knobs, sliders and rangers to a separate function.
-rw-r--r-- | classes/BowelyzerGUI.sc | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc index ff55d4b..b769203 100644 --- a/classes/BowelyzerGUI.sc +++ b/classes/BowelyzerGUI.sc @@ -25,7 +25,8 @@ BowelyzerGUI{ headViewWidth = 300, controlsViewWidth = 246, controlsViewHeight = 700, - controlGroups = #["general", "amplitude", "pitch", "hf"], +// controlGroups = #["general", "amplitude", "pitch", "hf"], +// controlGroupGeneral = #[\sendReplyFreq, \freqRange, ], sliderWidth = 238, sliderHeight = 40 ; @@ -368,18 +369,18 @@ BowelyzerGUI{ this.setupLevelIndicator(meterView); 0.01.wait; // add Buttons for each subset of controls - controlGroups.do({|group| + BowelyzerConfig.controlGroupsGUI.do({|group| this.setupControlsGroupButton(group, controlsSelectorView); }); 0.01.wait; // add controls in groups - controlGroups.do({|group| + BowelyzerConfig.controlGroupsGUI.do({|group| this.setupControlsGroup(group, name, config, controlsView); 0.005.wait; }); 0.01.wait; // show only the general controls - this.showControlsByType(controlGroups[0], controlsSelectorView.children, controlsView); + this.showControlsByType(BowelyzerConfig.controlGroupsGUI[0], controlsSelectorView.children, controlsView); }.play(AppClock); // add channelView to the container and the global Dictionary for better access @@ -415,28 +416,21 @@ BowelyzerGUI{ controlsSubView.layout.spacing = 4; controlsSubView.layout.margins = [0,0,0,0]; controlsSubView.maxWidth_(controlsViewWidth-8); - config.at(\controls).at(name).order.do({|control, i| - var value = config.at(\controls).at(name).at(control), - controlIs = BowelyzerConfig.controlContainedIn(control); - //TODO: move selection of correct control type to function - if(group == "general",{ - if(control == \sendReplyFreq, { - switch( - controlIs.asSymbol, - //TODO: move special settings for EZGUI elements to functions - \knob, {this.setupEZKnob(controlsSubView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})}, - \slider, {this.setupEZSlider(controlsSubView, control, value)}, - \ranger, {this.setupEZRanger(controlsSubView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})} - ); + + if(group != \general, { + config.at(\controls).at(name).order.do({|controlName, i| + var value = config.at(\controls).at(name).at(controlName), + type = BowelyzerConfig.controlContainedIn(controlName); + if(controlName.asString.beginsWith(group.asString), { + this.setupControlFromConfig(controlsSubView, type, controlName, value); }); - },{ - if(control.asString.beginsWith(group),{ - switch( - controlIs.asSymbol, - \knob, {this.setupEZKnob(controlsSubView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})}, - \slider, {this.setupEZSlider(controlsSubView, control, value)}, - \ranger, {this.setupEZRanger(controlsSubView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})} - ); + }); + },{ + config.at(\controls).at(name).order.do({|controlName, i| + var value = config.at(\controls).at(name).at(controlName), + type = BowelyzerConfig.controlContainedIn(controlName); + if(BowelyzerConfig.generalControlGroupGUI.includes(controlName), { + this.setupControlFromConfig(controlsSubView, type, controlName, value); }); }); }); @@ -444,6 +438,17 @@ BowelyzerGUI{ controlsSubView.minSize_((controlsViewWidth-8)@(controlsSubView.children.size*(sliderHeight+4))); } + //setup a control from configuration (adhering to its type) + setupControlFromConfig{ + arg parent, type, name, value; + switch( + type.asSymbol, + \knob, {this.setupEZKnob(parent, name, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})}, + \slider, {this.setupEZSlider(parent, name, value)}, + \ranger, {this.setupEZRanger(parent, name, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})} + ); + } + // show only the controls of a certain type showControlsByType{ arg name, buttons, controls; |