aboutsummaryrefslogtreecommitdiffstats
path: root/classes/BowelyzerGUI.sc
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-07-10 20:10:46 +0200
committerDavid Runge <dave@sleepmap.de>2016-07-10 20:10:46 +0200
commitf1b95d253283fe451d525d9386e60880f38a2160 (patch)
tree237a7a5fb461cbab88da7f79a8239f9cdb822c13 /classes/BowelyzerGUI.sc
parent393dde90a4b7f3cdabf8b704057c0f8ea2982ca0 (diff)
downloadbowelyzer-f1b95d253283fe451d525d9386e60880f38a2160.tar.gz
bowelyzer-f1b95d253283fe451d525d9386e60880f38a2160.tar.bz2
bowelyzer-f1b95d253283fe451d525d9386e60880f38a2160.tar.xz
bowelyzer-f1b95d253283fe451d525d9386e60880f38a2160.zip
classes/Bowelyzer.sc: Refactoring all GUI functions, formerly using defer to BowelyzerGUI, where they are all deferred to AppClock. classes/BowelyzerGUI.sc: Adding helper functions to properly defer all needed functionality to AppClock. Renaming setChannelName to setChannelText. The function setChannelName now renames the channelView, whereas setChannelText renames the TextField of a channel.
Diffstat (limited to 'classes/BowelyzerGUI.sc')
-rw-r--r--classes/BowelyzerGUI.sc455
1 files changed, 256 insertions, 199 deletions
diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc
index 5fc0eda..48b1688 100644
--- a/classes/BowelyzerGUI.sc
+++ b/classes/BowelyzerGUI.sc
@@ -109,96 +109,99 @@ BowelyzerGUI{
setupAddressesAndPorts{
arg config;
var forwardView, hubView, synthServerView;
-
- //synthServer
- synthServerView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y));
- synthServerView.asView.background = Color.fromHexString("#DDDDEF");
- synthServerView.layout = VLayout();
- synthServerView.layout.spacing = 0;
- synthServerView.layout.margins = settingsSubViewMargins;
- synthServerView.name = "synthServer";
- synthServerView.maxSize_(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.setupEZNumber(synthServerView, "port", config.at(\synthServerPort)).children.do({|item|
- if(item.isKindOf(StaticText),{
- item.align_(\left);
- });
- if(item.isKindOf(NumberBox),{
- item.align_(\right);
- });
- });
- settingsView.layout.insert(synthServerView, 1);
-
- //hub
- hubView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y));
- hubView.asView.background = Color.fromHexString("#DDDDEF");
- hubView.layout = VLayout();
- hubView.layout.spacing = 0;
- hubView.layout.margins = settingsSubViewMargins;
- hubView.name = "hub";
- hubView.maxSize_(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.setupEZNumber(hubView, "port", config.at(\hubPort)).children.do({|item|
- if(item.isKindOf(StaticText),{
- item.align_(\left);
+ {
+ //synthServer
+ synthServerView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y));
+ synthServerView.asView.background = Color.fromHexString("#DDDDEF");
+ synthServerView.layout = VLayout();
+ synthServerView.layout.spacing = 0;
+ synthServerView.layout.margins = settingsSubViewMargins;
+ synthServerView.name = "synthServer";
+ synthServerView.maxSize_(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);
+ });
});
- if(item.isKindOf(NumberBox),{
- item.align_(\right);
+ this.setupEZNumber(synthServerView, "port", config.at(\synthServerPort)).children.do({|item|
+ if(item.isKindOf(StaticText),{
+ item.align_(\left);
+ });
+ if(item.isKindOf(NumberBox),{
+ item.align_(\right);
+ });
});
- });
- settingsView.layout.insert(hubView, 2);
-
- //forward
- forwardView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y));
- forwardView.asView.background = Color.fromHexString("#DDDDEF");
- forwardView.layout = VLayout();
- forwardView.layout.spacing = 0;
- forwardView.layout.margins = settingsSubViewMargins;
- forwardView.name = "forward";
- forwardView.maxSize_(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);
+ settingsView.layout.insert(synthServerView, 1);
+
+ //hub
+ hubView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y));
+ hubView.asView.background = Color.fromHexString("#DDDDEF");
+ hubView.layout = VLayout();
+ hubView.layout.spacing = 0;
+ hubView.layout.margins = settingsSubViewMargins;
+ hubView.name = "hub";
+ hubView.maxSize_(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);
+ });
});
- if(item.isKindOf(TextField),{
- item.align_(\right);
+ this.setupEZNumber(hubView, "port", config.at(\hubPort)).children.do({|item|
+ if(item.isKindOf(StaticText),{
+ item.align_(\left);
+ });
+ if(item.isKindOf(NumberBox),{
+ item.align_(\right);
+ });
});
- });
- this.setupEZNumber(forwardView, "port", config.at(\forwardPort)).children.do({|item|
- if(item.isKindOf(StaticText),{
- item.align_(\left);
+ settingsView.layout.insert(hubView, 2);
+
+ //forward
+ forwardView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y));
+ forwardView.asView.background = Color.fromHexString("#DDDDEF");
+ forwardView.layout = VLayout();
+ forwardView.layout.spacing = 0;
+ forwardView.layout.margins = settingsSubViewMargins;
+ forwardView.name = "forward";
+ forwardView.maxSize_(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);
+ });
});
- if(item.isKindOf(NumberBox),{
- item.align_(\right);
+ this.setupEZNumber(forwardView, "port", config.at(\forwardPort)).children.do({|item|
+ if(item.isKindOf(StaticText),{
+ item.align_(\left);
+ });
+ if(item.isKindOf(NumberBox),{
+ item.align_(\right);
+ });
});
- });
- settingsView.layout.insert(forwardView, 3);
+ settingsView.layout.insert(forwardView, 3);
+ }.defer;
}
// remove Views for addresses and ports
removeAddressesAndPorts{
- settingsView.children.do({|setting, i|
- if(setting.isKindOf(View) && ((setting.name == "hub") || (setting.name == "synthServer") || (setting.name == "forward")),{
- setting.remove;
+ {
+ settingsView.children.do({|setting, i|
+ if(setting.isKindOf(View) && ((setting.name == "hub") || (setting.name == "synthServer") || (setting.name == "forward")),{
+ setting.remove;
+ });
});
- });
+ }.defer;
}
// setup channel views
@@ -209,11 +212,24 @@ BowelyzerGUI{
});
}
+ // set the View name of a given channel to a given String
setChannelName{
arg name, update;
{
channels.do({|channel|
if(channel.name.asSymbol == name.asSymbol, {
+ channel.name = update.asSymbol;
+ });
+ });
+ }.defer;
+ }
+
+ // set the TextField of a channel to a given String
+ setChannelText{
+ arg name, update;
+ {
+ channels.do({|channel|
+ if(channel.name.asSymbol == name.asSymbol, {
("Channel found: "++name).postln;
channel.children.do({|channelChild|
if(channelChild.name.asSymbol == \inputs, {
@@ -239,83 +255,103 @@ BowelyzerGUI{
setupChannelView{
arg name, config;
var channelView, headView, controlMeterContainerView, meterView, controlsView, controlsFromConfig, levelIndicator;
- channelView = View(channelContainerView.asView, Rect(0, 0, channelViewWidth, channelViewHeight));
- channelView.asView.background = Color.fromHexString("#FEEFEF");
- channelView.name = name.asString;
- channelView.layout = VLayout();
- channelView.layout.spacing = 0;
- channelView.layout.margins = [2,0,2,0];
- channelView.maxSize_(channelViewWidth@channelViewHeight);
- channelView.deleteOnClose_(true);
-
- // adding name textfield of input
- headView = View(channelView.asView, Rect(0, 0, headViewWidth, headViewHeight));
- headView.asView.background = Color.fromHexString("#DDEFDD");
- headView.name = \inputs;
- headView.layout = HLayout();
- 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)});
+ {
+ channelContainerView.maxSize_(((channelViewWidth*config.at(\inputs).size)+buttonWidth)@channelViewHeight);
+ channelContainerView.asView.bounds_(Rect(0, 0, (channelViewWidth*config.at(\inputs).size)+buttonWidth, channelViewHeight));
+
+ channelView = View(channelContainerView.asView, Rect(0, 0, channelViewWidth, channelViewHeight));
+ channelView.asView.background = Color.fromHexString("#FEEFEF");
+ channelView.name = name.asString;
+ channelView.layout = VLayout();
+ channelView.layout.spacing = 0;
+ channelView.layout.margins = [2,0,2,0];
+ channelView.maxSize_(channelViewWidth@channelViewHeight);
+ channelView.deleteOnClose_(true);
+
+ // adding name textfield of input
+ headView = View(channelView.asView, Rect(0, 0, headViewWidth, headViewHeight));
+ headView.asView.background = Color.fromHexString("#DDEFDD");
+ headView.name = \inputs;
+ headView.layout = HLayout();
+ 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.name = \meterAndControls;
+ controlMeterContainerView.layout = HLayout();
+ controlMeterContainerView.layout.spacing = 0;
+ controlMeterContainerView.layout.margins = [0,0,0,0];
+
+ meterView = View(controlMeterContainerView.asView, Rect(0,0, meterViewWidth, meterViewHeight));
+ meterView.asView.background = Color.fromHexString("#EEEFEE");
+ meterView.name = \meterView;
+ meterView.layout = VLayout();
+ meterView.maxWidth = meterViewWidth;
+ 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);
+
+ 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)
+ //Routine{
+ config.at(\controls).at(name).order.do({|control, i|
+ var value = config.at(\controls).at(name).at(control),
+ controlIs = BowelyzerConfig.controlContainedIn(control);
+ //(0.1).wait;
+ 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)})})}
+ );
});
- 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.name = \meterAndControls;
- controlMeterContainerView.layout = HLayout();
- controlMeterContainerView.layout.spacing = 0;
- controlMeterContainerView.layout.margins = [0,0,0,0];
-
- meterView = View(controlMeterContainerView.asView, Rect(0,0, meterViewWidth, meterViewHeight));
- meterView.asView.background = Color.fromHexString("#EEEFEE");
- meterView.name = \meterView;
- meterView.layout = VLayout();
- meterView.maxWidth = meterViewWidth;
- 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);
-
- 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)
- //Routine{
- config.at(\controls).at(name).order.do({|control, i|
- var value = config.at(\controls).at(name).at(control),
- controlIs = BowelyzerConfig.controlContainedIn(control);
- //(0.1).wait;
- 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)})})}
- );
- });
- //}.play(AppClock);
- // add channelView to the container and the global Dictionary for better access
- channelContainerView.layout.add(channelView);
- channels.add(channelView);
+ //}.play(AppClock);
+ // add channelView to the container and the global Dictionary for better access
+ channelContainerView.layout.add(channelView);
+ channels.add(channelView);
+ }.defer;
+ }
+
+ // remove a channelView by name, resizing the enclosing channelContainerView to current amount of channels
+ removeChannelView{
+ arg name, channelSize;
+ {
+ channels.do({|channel,i|
+ if(channel.name == name.asString, {
+ channel.remove;
+ channels.remove(channel);
+ });
+ });
+ // resize the channelContainerView according to new amount of channels
+ channelContainerView.maxSize_(((channelViewWidth*channelSize)+buttonWidth)@channelViewHeight);
+ }.defer;
}
// setup a OSC indicator view (one on each channel)
@@ -329,26 +365,40 @@ BowelyzerGUI{
;
}
+ // ping an OSC indicator by name, restarting its fadeout Task
+ pingOSCIndicator{
+ arg name;
+ {
+ if(indicators.includesKey(name),{
+ indicators.at(name).stop;
+ indicators.at(name).reset;
+ indicators.at(name).start(AppClock);
+ });
+ }.defer;
+ }
+
// setup tasks for changing the OSC indicator color (on receiving a message)
addOSCIndicatorFadeOutTask{
arg name;
- indicators.put(
- name.asSymbol,
- Task({
- channels.do({|channel|
- if(channel.name.asSymbol == name,{
- channel.children.do({|channelChild|
- if(channelChild.name.asSymbol == \meterAndControls,{
- channelChild.children.do({|meterAndControls|
- if(meterAndControls.name.asSymbol == \meterView, {
- meterAndControls.children.do({|meterView|
- if(meterView.isKindOf(View) && meterView.name.asSymbol == \OSCIndicator, {
- meterView.background_(Color.fromHexString("#99FF99"));
- fadeOutSteps.do({|item,i|
- meterView.background_(meterView.background.blend(Color.fromHexString("#EEEFEE"), (fadeOutTime/fadeOutSteps)));
- (fadeOutTime/fadeOutSteps).wait;
+ {
+ indicators.put(
+ name.asSymbol,
+ Task({
+ channels.do({|channel|
+ if(channel.name.asSymbol == name,{
+ channel.children.do({|channelChild|
+ if(channelChild.name.asSymbol == \meterAndControls,{
+ channelChild.children.do({|meterAndControls|
+ if(meterAndControls.name.asSymbol == \meterView, {
+ meterAndControls.children.do({|meterView|
+ if(meterView.isKindOf(View) && meterView.name.asSymbol == \OSCIndicator, {
+ meterView.background_(Color.fromHexString("#99FF99"));
+ fadeOutSteps.do({|item,i|
+ meterView.background_(meterView.background.blend(Color.fromHexString("#EEEFEE"), (fadeOutTime/fadeOutSteps)));
+ (fadeOutTime/fadeOutSteps).wait;
+ });
+ meterView.background_(Color.fromHexString("#EEEFEE"));
});
- meterView.background_(Color.fromHexString("#EEEFEE"));
});
});
});
@@ -356,20 +406,23 @@ BowelyzerGUI{
});
});
});
- });
- })
- );
+ })
+ );
+ }.defer;
}
// free an OSCIndicatorFadeOutTask by name
freeOSCIndicatorFadeOutTask{
arg name;
- if(indicators.includesKey(name.asSymbol), {
- indicators.at(name).stop;
- indicators.removeAt(name);
- });
+ {
+ if(indicators.includesKey(name.asSymbol), {
+ indicators.at(name).stop;
+ indicators.removeAt(name);
+ });
+ }.defer;
}
+ // setup a new LevelIndicator
setupLevelIndicator{
arg parent;
^LevelIndicator(
@@ -427,16 +480,18 @@ BowelyzerGUI{
arg controlUnit;
var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
type = "/saveas";
- FileDialog.new(
- okFunc: {|path|
- postln("Sending: ["++type++", "++path++"]");
- address.sendMsg(type, path.asString);
- },
- cancelFunc: {},
- fileMode: 0,
- acceptMode: 1,
- stripResult: true
- );
+ {
+ FileDialog.new(
+ okFunc: {|path|
+ postln("Sending: ["++type++", "++path++"]");
+ address.sendMsg(type, path.asString);
+ },
+ cancelFunc: {},
+ fileMode: 0,
+ acceptMode: 1,
+ stripResult: true
+ );
+ }.defer;
}
// create a save button, that launches a FileDialog on press
@@ -721,16 +776,18 @@ BowelyzerGUI{
// set LevelIndicator values for given channel
setLevel{
arg name, level, peak;
- channels.do({|channel|
- if(channel.name.asSymbol == name,{
- channel.children.do({|channelChild|
- if(channelChild.name.asSymbol == \meterAndControls,{
- channelChild.children.do({|meterAndControls|
- if(meterAndControls.name.asSymbol == \meterView, {
- meterAndControls.children.do({|meterView|
- if(meterView.isKindOf(LevelIndicator), {
- meterView.value = level;
- meterView.peakLevel = peak;
+ {
+ channels.do({|channel|
+ if(channel.name.asSymbol == name,{
+ channel.children.do({|channelChild|
+ if(channelChild.name.asSymbol == \meterAndControls,{
+ channelChild.children.do({|meterAndControls|
+ if(meterAndControls.name.asSymbol == \meterView, {
+ meterAndControls.children.do({|meterView|
+ if(meterView.isKindOf(LevelIndicator), {
+ meterView.value = level;
+ meterView.peakLevel = peak;
+ });
});
});
});
@@ -738,7 +795,7 @@ BowelyzerGUI{
});
});
});
- });
+ }.defer;
}
}