aboutsummaryrefslogtreecommitdiffstats
path: root/classes/BowelyzerGUI.sc
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-07-10 17:02:54 +0200
committerDavid Runge <dave@sleepmap.de>2016-07-10 17:02:54 +0200
commitba885b3716e6180d3ac1d81049f0a2ebccd042fa (patch)
treee2e1f684d05f19ca0b589be5c7dddd994204a297 /classes/BowelyzerGUI.sc
parent4b4d19ebbdf6e5737931a18315666c505b10c4a2 (diff)
downloadbowelyzer-ba885b3716e6180d3ac1d81049f0a2ebccd042fa.tar.gz
bowelyzer-ba885b3716e6180d3ac1d81049f0a2ebccd042fa.tar.bz2
bowelyzer-ba885b3716e6180d3ac1d81049f0a2ebccd042fa.tar.xz
bowelyzer-ba885b3716e6180d3ac1d81049f0a2ebccd042fa.zip
classes/BowelyzerGUI.sc: Implementing channel selector as EZPopUpMenu. Providing complete BowelyzerConfig instance on BowelyzerGUI init, to also get access to configFilePath for display. Refactoring action of 'save as' Button into separate function for easier access, when no configuration file is setup yet. classes/Bowelyzer.sc: Initializing BowelyzerGUI with complete BowelyzerConfig instance. Calling 'save as' if there is no configuration file setup yet.
Diffstat (limited to 'classes/BowelyzerGUI.sc')
-rw-r--r--classes/BowelyzerGUI.sc132
1 files changed, 85 insertions, 47 deletions
diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc
index 02a621a..457abf7 100644
--- a/classes/BowelyzerGUI.sc
+++ b/classes/BowelyzerGUI.sc
@@ -21,7 +21,7 @@ BowelyzerGUI{
configViewSize,
meterViewWidth = 54,
meterViewHeight = 700,
- headViewHeight = 24,
+ headViewHeight = 30,
headViewWidth = 300,
controlsViewWidth = 246,
controlsViewHeight = 700
@@ -29,7 +29,7 @@ BowelyzerGUI{
*new{
arg config;
- ^super.new.init(config)
+ ^super.new.init(config);
}
init{
@@ -40,16 +40,16 @@ BowelyzerGUI{
configViewSize = 64@64;
controlMeterContainerViewSize = controlMeterContainerViewWidth@controlMeterContainerViewHeight;
channelViewSize = channelViewWidth@channelViewHeight;
- channels = Set.new(config.at(\inputs).size);
- indicators = Dictionary.new(config.at(\inputs).size);
- this.setupMainView(config);
+ channels = Set.new(config.config.at(\inputs).size);
+ indicators = Dictionary.new(config.config.at(\inputs).size);
+ this.setupMainView(config.config, config.configFilePath);
this.setupChannelAddButton(channelContainerView);
- this.setupChannelViews(config);
+ this.setupChannelViews(config.config);
}
//setup the main view, in which all other views reside
setupMainView{
- arg config;
+ arg config, configFilePath;
var channelScrollView, configView, layout;
mainView = PageLayout.new("Bowelyzer");
mainView.asView.background = Color.fromHexString("#DBDBDB");
@@ -74,7 +74,7 @@ BowelyzerGUI{
configView.layout.margins = settingsSubViewMargins;
configView.name = "config";
configView.maxSize_(configViewSize);
- this.setupSaveButton(configView);
+ this.setupSaveButton(configView, configFilePath);
this.setupSaveAsButton(configView);
this.setupLoadButton(configView);
@@ -211,19 +211,16 @@ BowelyzerGUI{
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);
+ 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.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.setupEZPopUpMenu(headView, "input", Server.default.options.numInputBusChannels, config.at(\inputs).at(name));
this.setupChannelCloseButton(headView, name);
}.play(AppClock);
@@ -255,7 +252,6 @@ BowelyzerGUI{
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];
@@ -368,23 +364,40 @@ BowelyzerGUI{
// create a save button, that launches a FileDialog on press
setupSaveButton{
- arg parent;
+ arg parent, file, state = 1;
^Button(parent, Rect(0, 0, buttonWidth, buttonHeight))
.states_([
- //TODO: set Color depending on whether config file is not ""
- ["save", Color.black, Color.fromHexString("#99FF99")],
+ ["save", Color.black, Color.fromHexString("#99FF99")]
])
.action_({
- arg controlUnit;
- var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
- type = "/save";
- postln("Sending: ["++type++"]");
- address.sendMsg(type);
- })
+ arg controlUnit;
+ var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
+ type = "/save";
+ postln("Sending: ["++type++"]");
+ address.sendMsg(type);
+ })
+ .value_(1)
.maxSize_(buttonWidth@buttonHeight)
;
}
+ // open a FileDialog to send a path via OSC to save config to that file
+ saveAsAction{
+ 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
+ );
+ }
+
// create a save button, that launches a FileDialog on press
setupSaveAsButton{
arg parent;
@@ -392,21 +405,7 @@ BowelyzerGUI{
.states_([
["save as", Color.black, Color.fromHexString("#99FF99")],
])
- .action_({
- 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
- );
- })
+ .action_({this.saveAsAction})
.maxSize_(buttonWidth@buttonHeight)
;
}
@@ -486,7 +485,8 @@ BowelyzerGUI{
});
if(control == "name", {
bounds = 140@buttonHeight;
- textWidth = 84;
+ labelWidth = 34;
+ textWidth = 106;
});
^EZText(
parent: parent,
@@ -521,6 +521,50 @@ BowelyzerGUI{
}
// setup a StaticText and a NumberBox
+ setupEZPopUpMenu{
+ arg parent, control, inputs, value;
+ var bounds = 120@buttonHeight,
+ labelWidth = 34,
+ menu = EZPopUpMenu.new(
+ parentView: parent,
+ bounds: bounds,
+ label: control,
+ initVal:value,
+ labelWidth: labelWidth,
+ labelHeight: buttonHeight
+ ),
+ action = {
+ arg controlUnit;
+ var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
+ type = "/"++controlUnit.view.parent.name.asString,
+ name = controlUnit.view.parent.parent.name.asSymbol,
+ controlName = controlUnit.labelView.string.asSymbol,
+ controlValue = controlUnit.value;
+ postln("Sending: "++"["++type++", "++name++", "++controlName++", "++controlValue++"]");
+ address.sendMsg(type, name, controlName, controlValue);
+ };
+
+ // create state for each input
+ inputs.do({|i|
+ menu.addItem(i.asSymbol, action);
+ });
+ // set bounds properly
+ menu.view.bounds_(bounds);
+ // set alignment and bounds for StaticText
+ menu.view.children.do({|item|
+ if(item.isKindOf(StaticText),{
+ item.align_(\left);
+ item.bounds_(labelWidth@buttonHeight);
+ });
+ });
+ ^menu
+ .value_(value)
+ .view.maxSize_(bounds).bounds_(bounds)
+ .asView.name_(control)
+ ;
+ }
+
+ // setup a StaticText and a NumberBox
setupEZNumber{
arg parent, control, value;
var bounds = 144@buttonHeight,
@@ -532,12 +576,6 @@ BowelyzerGUI{
labelWidth = 70;
numberWidth = 70;
});
- //TODO: use EZPopupMenu
- if(control == "input", {
- bounds = 124@buttonHeight;
- labelWidth = 48;
- numberWidth = 76;
- });
^EZNumber(
parent: parent,
bounds: bounds,