diff options
Diffstat (limited to 'classes/BowelyzerGUI.sc')
-rw-r--r-- | classes/BowelyzerGUI.sc | 231 |
1 files changed, 160 insertions, 71 deletions
diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc index fd20cab..ff55d4b 100644 --- a/classes/BowelyzerGUI.sc +++ b/classes/BowelyzerGUI.sc @@ -24,7 +24,10 @@ BowelyzerGUI{ headViewHeight = 30, headViewWidth = 300, controlsViewWidth = 246, - controlsViewHeight = 700 + controlsViewHeight = 700, + controlGroups = #["general", "amplitude", "pitch", "hf"], + sliderWidth = 238, + sliderHeight = 40 ; *new{ @@ -164,14 +167,7 @@ BowelyzerGUI{ synthServerView.name = "synthServer"; synthServerView.minSize_(settingsSubViewSize); StaticText(synthServerView, Rect(0, 0, 140@buttonHeight)).string_("synthServer").align_(\center); - this.setupEZText(synthServerView, "address", config.at(\synthServerAddress)).children.do({|item| - if(item.isKindOf(StaticText),{ - item.align_(\left); - }); - if(item.isKindOf(TextField),{ - item.align_(\right); - }); - }); + this.setupEZText(synthServerView, "address", config.at(\synthServerAddress)); this.setupEZNumber(synthServerView, "port", config.at(\synthServerPort)).children.do({|item| if(item.isKindOf(StaticText),{ item.align_(\left); @@ -196,14 +192,7 @@ BowelyzerGUI{ hubView.name = "hub"; hubView.minSize_(settingsSubViewSize); StaticText(hubView, Rect(0, 0, 140@buttonHeight)).string_("hub").align_(\center); - this.setupEZText(hubView, "address", config.at(\hubAddress)).children.do({|item| - if(item.isKindOf(StaticText),{ - item.align_(\left); - }); - if(item.isKindOf(TextField),{ - item.align_(\right); - }); - }); + this.setupEZText(hubView, "address", config.at(\hubAddress)); this.setupEZNumber(hubView, "port", config.at(\hubPort)).children.do({|item| if(item.isKindOf(StaticText),{ item.align_(\left); @@ -228,14 +217,7 @@ BowelyzerGUI{ forwardView.name = "forward"; forwardView.minSize_(settingsSubViewSize); StaticText(forwardView, Rect(0, 0, 140@buttonHeight)).string_("forward").align_(\center); - this.setupEZText(forwardView, "address", config.at(\forwardAddress)).children.do({|item| - if(item.isKindOf(StaticText),{ - item.align_(\left); - }); - if(item.isKindOf(TextField),{ - item.align_(\right); - }); - }); + this.setupEZText(forwardView, "address", config.at(\forwardAddress)); this.setupEZNumber(forwardView, "port", config.at(\forwardPort)).children.do({|item| if(item.isKindOf(StaticText),{ item.align_(\left); @@ -315,7 +297,7 @@ BowelyzerGUI{ // setup a single channel View by name setupChannelView{ arg name, config; - var channelView, headView, controlMeterContainerView, meterView, controlsView, controlsFromConfig, levelIndicator; + var channelView, headView, controlMeterContainerView, meterView, controlsView, controlsSelectorView, levelIndicator; { channelContainerView.maxSize_((channelViewWidth*config.at(\inputs).size)@channelViewHeight); channelContainerView.asView.bounds_(Rect(0, 0, (channelViewWidth*config.at(\inputs).size)+buttonWidth, channelViewHeight)); @@ -337,18 +319,10 @@ BowelyzerGUI{ headView.layout.spacing = 4; headView.layout.margins = [4,0,4,0]; headView.maxHeight_(headViewHeight); - Routine{ - 0.5.wait; - this.setupEZText(headView, "name", name.asString).children.do({|item| - if(item.isKindOf(StaticText),{item.align_(\left)}); - if(item.isKindOf(TextField),{item.align_(\right)}); - }); - this.setupEZPopUpMenu(headView, "input", Server.default.options.numInputBusChannels, config.at(\inputs).at(name)); - this.setupChannelCloseButton(headView, name); - }.play(AppClock); controlMeterContainerView = View(channelView.asView, Rect(0, 0, controlMeterContainerViewWidth, controlMeterContainerViewHeight)); controlMeterContainerView.asView.background = Color.fromHexString("#DDDDEF"); + controlMeterContainerView.asView.background = Color.red; controlMeterContainerView.name = "meterAndControls"; controlMeterContainerView.layout = HLayout(); controlMeterContainerView.layout.spacing = 0; @@ -362,41 +336,139 @@ BowelyzerGUI{ meterView.layout.spacing = 0; meterView.layout.margins = [2,0,2,0]; - //setup a toggle button for each channel - this.setupPauseButton(meterView, config.at(\controls).at(name).at(\active)); - - // setup a small View as indicator for incoming/outgoing OSC messages for each input - this.setupOSCIndicator(meterView); - this.addOSCIndicatorFadeOutTask(name); - - // setup LevelIndicator for each input - this.setupLevelIndicator(meterView); - + // add a View for the controls of a channel controlsView = View(controlMeterContainerView.asView, Rect(0,0, controlsViewWidth, controlsViewHeight)); controlsView.asView.background = Color.fromHexString("#EEEFEE"); controlsView.name = "controls"; controlsView.layout = VLayout(); controlsView.layout.spacing = 0; - controlsView.layout.margins = [2,0,2,0]; - - //TODO: add ranger for amplitude and pitch threshold/region - //TODO: rearrange sliders/rangers/knobs in groups (maybe even tabs) - config.at(\controls).at(name).order.do({|control, i| - var value = config.at(\controls).at(name).at(control), - controlIs = BowelyzerConfig.controlContainedIn(control); - switch( - controlIs.asSymbol, - \knob, {this.setupEZKnob(controlsView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})}, - \slider, {this.setupEZSlider(controlsView, control, value).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)}); if(item.isKindOf(Slider), {item.orientation_(\horizontal)});})}, - \ranger, {this.setupEZRanger(controlsView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})} - ); - }); + controlsView.layout.margins = [4,0,4,0]; + // add a View for selecting subsets of the channel's controls + controlsSelectorView = View(controlsView.asView, Rect(0, 0, controlsViewWidth, 40)); + controlsSelectorView.minSize_(controlsViewWidth@40); + controlsSelectorView.addFlowLayout(4@4, 2@2); + controlsSelectorView.name = "controlsSelector"; + // add all controls to their parents + Routine{ + 0.01.wait; + this.setupEZText(headView, "name", name.asString); + 0.01.wait; + this.setupEZPopUpMenu(headView, "input", Server.default.options.numInputBusChannels, config.at(\inputs).at(name)); + 0.01.wait; + this.setupChannelCloseButton(headView, name); + 0.01.wait; + //setup a toggle button for each channel + this.setupPauseButton(meterView, config.at(\controls).at(name).at(\active)); + 0.01.wait; + // setup a small View as indicator for incoming/outgoing OSC messages for each input + this.setupOSCIndicator(meterView); + this.addOSCIndicatorFadeOutTask(name); + 0.01.wait; + // setup LevelIndicator for each input + this.setupLevelIndicator(meterView); + 0.01.wait; + // add Buttons for each subset of controls + controlGroups.do({|group| + this.setupControlsGroupButton(group, controlsSelectorView); + }); + 0.01.wait; + // add controls in groups + controlGroups.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); + }.play(AppClock); + // add channelView to the container and the global Dictionary for better access channelContainerView.layout.add(channelView); channels.add(channelView); }.defer; } + // setup a Button for a control group by name + setupControlsGroupButton{ + arg group, parent; + Button(parent: parent, bounds: Rect(0, 0, buttonWidth, buttonHeight)) + .states_([ + [group.asString, Color.black, Color.fromHexString("#99FF99")] + ]) + .action_({ + arg controlUnit; + this.showControlsByType(controlUnit.string, controlUnit.parent.children, controlUnit.parent.parent); + }) + .maxSize_(buttonWidth@buttonHeight) + .name_(group.asString++"Button") + ; + } + + // setup a View for a control group by name + setupControlsGroup{ + arg group, name, config, parent; + var controlsSubView = View( + parent: parent + ); + controlsSubView.name = group.asString++"Controls"; + controlsSubView.layout = VLayout(); + 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(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)})})} + ); + }); + }); + }); + controlsSubView.maxSize_((controlsViewWidth-8)@(controlsSubView.children.size*(sliderHeight+4))); + controlsSubView.minSize_((controlsViewWidth-8)@(controlsSubView.children.size*(sliderHeight+4))); + } + + // show only the controls of a certain type + showControlsByType{ + arg name, buttons, controls; + { + buttons.do({|button| + if(button.isKindOf(Button) && (button.name != (name++"Button")), { + button.states_([[button.string, Color.black, Color.fromHexString("#EEEFEE")]]); + },{ + button.states_([[button.string, Color.black, Color.fromHexString("#99FF99")]]); + }); + }); + // unset visibility for all other controlSubViews but this one + controls.children.do({|control| + if(control.isKindOf(View) && (control.name == (name++"Controls")), { + control.visible_(true); + },{ + if(control.name != "controlsSelector", { + control.visible_(false); + }); + }); + }); + controls.layout.insert(nil, -1); + }.defer; + } + // remove a channelView by name, resizing the enclosing channelContainerView to current amount of channels removeChannelView{ arg name, channelSize; @@ -695,12 +767,14 @@ BowelyzerGUI{ }); }.defer; } + // setup a StaticText and a TextField setupEZText{ arg parent, control, value; var bounds = 144@buttonHeight, labelWidth= 48, - textWidth = 96; + textWidth = 96, + unit; // resize, depending on surrounding if(control == "address",{ bounds = 140@buttonHeight; @@ -712,7 +786,7 @@ BowelyzerGUI{ labelWidth = 34; textWidth = 106; }); - ^EZText( + unit = EZText( parent: parent, bounds: bounds, label: control, @@ -738,10 +812,13 @@ BowelyzerGUI{ initVal:value.asString, layout: \horz, margin: nil - ) - .view.maxHeight_(buttonHeight) - .asView.name_(control) - ; + ); + unit.view.maxHeight_(buttonHeight); + unit.view.name_(control); + unit.view.children.do({|item| + if(item.isKindOf(StaticText),{item.align_(\left)}); + if(item.isKindOf(TextField),{item.align_(\right)}); + }); } // setup a StaticText and a NumberBox @@ -800,6 +877,7 @@ BowelyzerGUI{ labelWidth = 70; numberWidth = 70; }); + // TODO: move special settings for children to this function ^EZNumber( parent: parent, bounds: bounds, @@ -836,16 +914,17 @@ BowelyzerGUI{ // setup a Slider, a StaticText and a NumberBox for a Synth setting setupEZSlider{ arg parent, control, value; - ^EZSlider( + var unit; + unit = EZSlider( parent: parent, - bounds: 236@40, + bounds: sliderWidth@sliderHeight, label: control, controlSpec: control.asSymbol, action: { arg controlUnit; var address = NetAddr.new("127.0.0.1", NetAddr.langPort), - type = "/"++controlUnit.view.parent.name.asString, - name = controlUnit.view.parent.parent.parent.name.asSymbol, + type = "/"++controlUnit.view.parent.parent.name.asString, + name = controlUnit.view.parent.parent.parent.parent.name.asSymbol, controlName = controlUnit.labelView.string.asSymbol, controlValue = controlUnit.value; address.sendMsg(type, name, controlName, controlValue); @@ -853,8 +932,18 @@ BowelyzerGUI{ numberWidth: 70, layout: \line2, margin: nil - ) - ; + ); + unit.view.children.do({|item| + if(item.isKindOf(NumberBox), { + item.align_(\right); + }); + if(item.isKindOf(Slider), { + item.orientation_(\horizontal); + item.minWidth_(sliderWidth); + item.maxHeight_(20); + item.minHeight_(20); + }); + }); } setupEZRanger{ |