aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-07-09 06:26:59 +0200
committerDavid Runge <dave@sleepmap.de>2016-07-09 06:26:59 +0200
commitf31e3b3ba212b0ea8feab61d4810ebaa97bb9c64 (patch)
tree658fce3f41aaff21902d294e10875be4e3ee8f86 /classes
parent8c1385e53c8c422b94e9f53a4c555e906a2564f2 (diff)
downloadbowelyzer-f31e3b3ba212b0ea8feab61d4810ebaa97bb9c64.tar.gz
bowelyzer-f31e3b3ba212b0ea8feab61d4810ebaa97bb9c64.tar.bz2
bowelyzer-f31e3b3ba212b0ea8feab61d4810ebaa97bb9c64.tar.xz
bowelyzer-f31e3b3ba212b0ea8feab61d4810ebaa97bb9c64.zip
classes/BowelyzerGUI.sc: Adding Button to add a new channel and adding its size to the width of channelContainerView. Refactoring channel creation into a single function. Fixing the use of EZSlider by setting a orientation for the Slider object after creation.
Diffstat (limited to 'classes')
-rw-r--r--classes/BowelyzerGUI.sc193
1 files changed, 111 insertions, 82 deletions
diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc
index ad4507c..403c911 100644
--- a/classes/BowelyzerGUI.sc
+++ b/classes/BowelyzerGUI.sc
@@ -14,8 +14,8 @@ BowelyzerGUI{
controlMeterContainerViewHeight = 700,
controlMeterContainerViewWidth = 300,
controlMeterContainerViewSize,
- buttonHeight = 20,
- buttonWidth = 48,
+ <buttonHeight = 20,
+ <buttonWidth = 48,
settingsSubViewMargins = #[2,2,2,2],
settingsSubViewSize,
settingsViewSize,
@@ -44,6 +44,7 @@ BowelyzerGUI{
channels = Set.new(config.at(\inputs).size);
indicators = Dictionary.new(config.at(\inputs).size);
this.setupMainView(config);
+ this.setupChannelAddButton(channelContainerView);
this.setupChannelViews(config);
}
@@ -134,101 +135,109 @@ BowelyzerGUI{
// go to next line in layout
layout.nextLine;
- channelScrollView = ScrollView(mainView.asView, Rect(0,0,mainView.bounds.width, mainView.bounds.height-settingsView.bounds.height)).autohidesScrollers_(false).hasBorder_(true);
+ channelScrollView = ScrollView(mainView.asView, Rect(0 , 0, mainView.bounds.width, mainView.bounds.height-settingsView.bounds.height)).autohidesScrollers_(false).hasBorder_(true);
// container for channelViews
- channelContainerView = View(parent: channelScrollView, bounds: Rect(0, 0, channelViewWidth*config.at(\inputs).size, channelViewHeight));
+ channelContainerView = View(parent: channelScrollView, bounds: Rect(0, 0, (channelViewWidth*config.at(\inputs).size)+buttonWidth, 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.minSize_(channelViewWidth@channelViewHeight);
- channelContainerView.maxSize_((channelViewWidth*config.at(\inputs).size)@channelViewHeight);
+ //channelContainerView.maxSize_(((channelViewWidth*config.at(\inputs).size)+buttonWidth)@channelViewHeight);
}
//setup channel views
setupChannelViews{
arg config;
- var channelView, headView, controlMeterContainerView, meterView, controlsView, controlsFromConfig, levelIndicator;
config.at(\inputs).keysValuesDo({|name, input|
- channelView = View(mainView.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_(300@700);
- 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 = 0;
- headView.layout.margins = [2,0,2,0];
- headView.maxHeight_(buttonHeight);
- this.setupEZText(headView, "name", name.asString).children.do({|item|
- if(item.isKindOf(StaticText),{item.align_(\left)});
- if(item.isKindOf(TextField),{item.align_(\right)});
- });
- this.setupEZNumber(headView, "input", config.at(\inputs).at(name)).children.do({|item|
- if(item.isKindOf(StaticText),{item.align_(\left)});
- if(item.isKindOf(NumberBox),{item.align_(\right)});
- });
- this.setupChannelCloseButton(headView, name);
-
- 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);
-
- // 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.maxWidth = controlsViewWidth;
- 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 unit;
- 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)})})},
- \ranger, {this.setupEZRanger(controlsView, control, value, \controls, name).view.children.do({|item| if(item.isKindOf(NumberBox),{item.align_(\right)})})}
- );
- });
- // add channelView to the container and the global Dictionary for better access
- channelContainerView.layout.add(channelView);
- channels.add(channelView);
+ this.setupChannelView(name, config);
});
}
+ // setup a single channel View by name
+ 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 = 0;
+ headView.layout.margins = [2,0,2,0];
+ headView.maxHeight_(buttonHeight);
+ this.setupEZText(headView, "name", name.asString).children.do({|item|
+ if(item.isKindOf(StaticText),{item.align_(\left)});
+ if(item.isKindOf(TextField),{item.align_(\right)});
+ });
+ this.setupEZNumber(headView, "input", config.at(\inputs).at(name)).children.do({|item|
+ if(item.isKindOf(StaticText),{item.align_(\left)});
+ if(item.isKindOf(NumberBox),{item.align_(\right)});
+ });
+ this.setupChannelCloseButton(headView, name);
+
+ 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);
+
+ // 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.maxWidth = controlsViewWidth;
+ 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);
+ }
+
// setup a OSC indicator view (one on each channel)
setupOSCIndicator{
arg parent;
@@ -399,6 +408,25 @@ BowelyzerGUI{
;
}
+ // setup a button to add a channel
+ setupChannelAddButton{
+ arg parent;
+ ^Button(parent, Rect(0, 0, buttonWidth, buttonWidth))
+ .states_([
+ ["+", Color.black, Color.fromHexString("#99FF99")]
+ ])
+ .action_({
+ arg controlUnit;
+ var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
+ type = "/add";
+ postln("Sending: ["++type++"]");
+ address.sendMsg(type);
+ })
+ .maxSize_(buttonWidth@buttonWidth)
+ .name_("add")
+ ;
+ }
+
// setup a StaticText and a TextField
setupEZText{
arg parent, control, value;
@@ -459,6 +487,7 @@ BowelyzerGUI{
labelWidth = 70;
numberWidth = 70;
});
+ //TODO: use EZPopupMenu
if(control == "input", {
bounds = 124@buttonHeight;
labelWidth = 48;