From 52a2ea1b919c3716da78833ed291bda23c251cc0 Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 14 Jul 2016 13:06:07 +0200 Subject: classes/BowelyzerGUI.sc: Setting all View names to type String (eliminating many asSymbol references). Removing buttonWidth from the width calculation of channelContainerView. Introducing a global toggle Button in buttonView beneath channel add Button, able to toggle all channels on/off simultaneously. Externalizing channel toggle Button state with setCurrentToggleState and global toggle Button state with setCurrentGlobalToggleState. --- classes/BowelyzerGUI.sc | 118 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 96 insertions(+), 22 deletions(-) diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc index 31dea20..862d999 100644 --- a/classes/BowelyzerGUI.sc +++ b/classes/BowelyzerGUI.sc @@ -64,6 +64,7 @@ BowelyzerGUI{ settingsView.layout = HLayout(); settingsView.layout.spacing = 4; settingsView.layout.margins = [0,0,0,0]; + settingsView.name = "settingsView"; this.setupConfigView; this.setupConfigFilePathView(configFilePath); @@ -83,8 +84,10 @@ BowelyzerGUI{ buttonView.layout = VLayout(); buttonView.layout.spacing = 4; buttonView.layout.margins = [4,4,4,4]; + buttonView.name = "buttonView"; buttonView.layout.insert(this.setupChannelAddButton, 0); - buttonView.layout.insert(nil, 1); + buttonView.layout.insert(this.setupGlobalToggleButton, 1); + buttonView.layout.insert(nil, 2); lowerView.layout.insert(buttonView, 0); // scrollview for channels @@ -92,12 +95,12 @@ BowelyzerGUI{ .autohidesScrollers_(false) .hasBorder_(true); // container for channelViews - channelContainerView = View(parent: channelScrollView, bounds: Rect(0, 0, (channelViewWidth*config.at(\inputs).size)+buttonWidth, channelViewHeight)); + channelContainerView = View(parent: channelScrollView, bounds: Rect(0, 0, (channelViewWidth*config.at(\inputs).size), channelViewHeight)); channelContainerView.asView.background = Color.fromHexString("#FEFEFE"); channelContainerView.layout = HLayout(); channelContainerView.layout.spacing = 0; channelContainerView.layout.margins = [0,0,0,0]; - channelContainerView.name = \channelContainerView; + channelContainerView.name = "channelContainerView"; lowerView.layout.insert(channelScrollView, 1); } @@ -273,9 +276,11 @@ BowelyzerGUI{ setChannelName{ arg name, update; { + name = name.asString; + update = update.asString; channels.do({|channel| - if(channel.name.asSymbol == name.asSymbol, { - channel.name = update.asSymbol; + if(channel.name == name, { + channel.name = update; }); }); }.defer; @@ -285,18 +290,17 @@ BowelyzerGUI{ setChannelText{ arg name, update; { + name = name.asString; + update = update.asString; channels.do({|channel| - if(channel.name.asSymbol == name.asSymbol, { - ("Channel found: "++name).postln; + if(channel.name == name, { channel.children.do({|channelChild| - if(channelChild.name.asSymbol == \inputs, { - ("headView found").postln; + if(channelChild.name == "inputs", { channelChild.children.do({|headView| if(headView.name == "name", { - ("TextField for name found").postln; headView.children.do({|nameView| if(nameView.isKindOf(TextField), { - nameView.string_(("\""++update++"\"").asString); + nameView.string_("\""++update++"\""); }); }); }); @@ -313,7 +317,7 @@ BowelyzerGUI{ arg name, config; var channelView, headView, controlMeterContainerView, meterView, controlsView, controlsFromConfig, levelIndicator; { - channelContainerView.maxSize_(((channelViewWidth*config.at(\inputs).size)+buttonWidth)@channelViewHeight); + channelContainerView.maxSize_((channelViewWidth*config.at(\inputs).size)@channelViewHeight); channelContainerView.asView.bounds_(Rect(0, 0, (channelViewWidth*config.at(\inputs).size)+buttonWidth, channelViewHeight)); channelView = View(channelContainerView.asView, Rect(0, 0, channelViewWidth, channelViewHeight)); @@ -352,7 +356,7 @@ BowelyzerGUI{ meterView = View(controlMeterContainerView.asView, Rect(0,0, meterViewWidth, meterViewHeight)); meterView.asView.background = Color.fromHexString("#EEEFEE"); - meterView.name = \meterView; + meterView.name = "meterView"; meterView.layout = VLayout(); meterView.maxWidth = meterViewWidth; meterView.layout.spacing = 0; @@ -407,7 +411,7 @@ BowelyzerGUI{ }); }); // resize the channelContainerView according to new amount of channels - channelContainerView.maxSize_(((channelViewWidth*channelSize)+buttonWidth)@channelViewHeight); + channelContainerView.maxSize_((channelViewWidth*channelSize)@channelViewHeight); }.defer; } @@ -415,7 +419,7 @@ BowelyzerGUI{ setupOSCIndicator{ arg parent; ^View(parent, Rect(0, 0, buttonWidth, buttonHeight)) - .name_(\OSCIndicator) + .name_("OSCIndicator") .background_(Color.fromHexString("#EEEFEE")) .maxSize_(buttonWidth@buttonHeight) .visible_(true) @@ -438,17 +442,18 @@ BowelyzerGUI{ addOSCIndicatorFadeOutTask{ arg name; { + name = name.asString; indicators.put( name.asSymbol, Task({ channels.do({|channel| - if(channel.name.asSymbol == name,{ + if(channel.name == name,{ channel.children.do({|channelChild| - if(channelChild.name.asSymbol == \meterAndControls,{ + if(channelChild.name == "meterAndControls",{ channelChild.children.do({|meterAndControls| - if(meterAndControls.name.asSymbol == \meterView, { + if(meterAndControls.name == "meterView", { meterAndControls.children.do({|meterView| - if(meterView.isKindOf(View) && meterView.name.asSymbol == \OSCIndicator, { + if(meterView.isKindOf(View) && meterView.name == "OSCIndicator", { meterView.background_(Color.fromHexString("#99FF99")); fadeOutSteps.do({|item,i| meterView.background_(meterView.background.blend(Color.fromHexString("#EEEFEE"), (fadeOutTime/fadeOutSteps))); @@ -624,6 +629,75 @@ BowelyzerGUI{ ; } + // setup a button to mute (toggle) all channels simultaneously + setupGlobalToggleButton{ + ^Button(bounds: Rect(0, 0, buttonWidth, buttonWidth)) + .states_([ + ["on", Color.black, Color.fromHexString("#99FF99")], + ["off", Color.black, Color.fromHexString("#FF9999")] + ]) + .action_({ + arg controlUnit; + var address = NetAddr.new("127.0.0.1", NetAddr.langPort), + type = "/toggle_all", + controlValue = controlUnit.value; + postln("Sending: [ "++type++", "++controlValue++" ]"); + address.sendMsg(type, controlValue); + }) + .minSize_(buttonWidth@buttonWidth) + .maxSize_(buttonWidth@buttonWidth) + .name_("toggle_all") + ; + } + + // set the state of the global toggle Button + setCurrentGlobalToggleState{ + arg state; + { + lowerView.children.do({|lowerChild| + if(lowerChild.isKindOf(View) && (lowerChild.name == "buttonView"), { + lowerChild.children.do({|button| + if(button.isKindOf(Button) && (button.name == "toggle_all"), { + if(state, { + button.value_(0); + },{ + button.value_(1); + }); + }); + }); + }); + }); + }.defer; + } + + // set the state of toggle Button of a named channel + setCurrentToggleState{ + arg name, state; + { + name = name.asString; + channels.do({|channel| + if(channel.isKindOf(View) && (channel.name == name), { + channel.children.do({|channelChild| + if(channelChild.isKindOf(View) && (channelChild.name == "meterAndControls"), { + channelChild.children.do({|meterAndControls| + if(meterAndControls.isKindOf(View) && (meterAndControls.name == "meterView"),{ + meterAndControls.children.do({|meterView| + if(meterView.isKindOf(Button), { + if(state,{ + meterView.value_(0); + },{ + meterView.value_(1); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }.defer; + } // setup a StaticText and a TextField setupEZText{ arg parent, control, value; @@ -835,11 +909,11 @@ BowelyzerGUI{ arg name, level, peak; { channels.do({|channel| - if(channel.name.asSymbol == name,{ + if(channel.name == name.asString,{ channel.children.do({|channelChild| - if(channelChild.name.asSymbol == \meterAndControls,{ + if(channelChild.name == "meterAndControls", { channelChild.children.do({|meterAndControls| - if(meterAndControls.name.asSymbol == \meterView, { + if(meterAndControls.name == "meterView", { meterAndControls.children.do({|meterView| if(meterView.isKindOf(LevelIndicator), { meterView.value = level; -- cgit v1.2.3-70-g09d2