aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-07-01 18:55:16 +0200
committerDavid Runge <dave@sleepmap.de>2016-07-01 18:55:16 +0200
commit7eeb8ce12cf515e3cc7811c469b86d94643cafcd (patch)
tree218976d928ddd3ea2f7b89f730d1df8e7e86aa98
parent3ffa70b83f7614d7f6957166cd68aa9496c77ead (diff)
downloadbowelyzer-7eeb8ce12cf515e3cc7811c469b86d94643cafcd.tar.gz
bowelyzer-7eeb8ce12cf515e3cc7811c469b86d94643cafcd.tar.bz2
bowelyzer-7eeb8ce12cf515e3cc7811c469b86d94643cafcd.tar.xz
bowelyzer-7eeb8ce12cf515e3cc7811c469b86d94643cafcd.zip
BowelyzerGUI.sc: Adding save/load Buttons in a separate configView in settingsView. Adding Views for forward/hub/synthServer settings. Making mainView a FlowLayout, to more easily switch to next line.
-rw-r--r--BowelyzerGUI.sc197
1 files changed, 150 insertions, 47 deletions
diff --git a/BowelyzerGUI.sc b/BowelyzerGUI.sc
index f9d0633..0e12738 100644
--- a/BowelyzerGUI.sc
+++ b/BowelyzerGUI.sc
@@ -1,6 +1,6 @@
BowelyzerGUI{
- var mainView, settingsView, channelContainerView,
+ var mainView, <settingsView, channelContainerView,
<channels,
<indicators,
//TODO: move to BowelyzerConfig
@@ -26,50 +26,69 @@ BowelyzerGUI{
//setup the main view, in which all other views reside
setupMainView{
arg config;
- var forwardView, hubView, synthServerView;
+ var forwardView, hubView, synthServerView, configView, layout;
mainView = PageLayout.new("Bowelyzer");
mainView.asView.background = Color.fromHexString("#DBDBDB");
- settingsView = View(mainView.asView, Rect(0,0, mainView.bounds.width/config.at(\inputs).size, 60));
+ layout = mainView.asView.addFlowLayout(2@2, 4@4);
+ //settingsView = View(mainView.asView, Rect(0,0, mainView.bounds.width/config.at(\inputs).size, 60));
+ settingsView = View(mainView.asView, Rect(0, 0, 512, 64));
settingsView.asView.background = Color.fromHexString("#99EF99");
settingsView.layout = HLayout();
settingsView.layout.spacing = 0;
settingsView.layout.margins = [0,0,0,0];
- settingsView.maxSize_(450@60);
- //forward
- forwardView = View(settingsView.asView);
- forwardView.asView.background = Color.grey;
- forwardView.layout = VLayout();
- forwardView.layout.spacing = 0;
- forwardView.layout.margins = [2,0,2,0];
- forwardView.maxSize_(150@60);
- StaticText(forwardView, Rect(0, 0, 150@20)).string_("forward").align_(\center);
- this.setupEZText(forwardView, "address", config.at(\forwardAddress));
- this.setupEZNumber(forwardView, "port", config.at(\forwardPort));
- //hub
- hubView = View(settingsView.asView);
- hubView.asView.background = Color.grey;
- hubView.layout = VLayout();
- hubView.layout.spacing = 0;
- hubView.layout.margins = [2,0,2,0];
- hubView.maxSize_(150@60);
- StaticText(hubView, Rect(0, 0, 150@20)).string_("hub").align_(\center);
- this.setupEZText(hubView, "address", config.at(\hubAddress));
- this.setupEZNumber(hubView, "port", config.at(\hubPort));
+ //settingsView.maxSize_(510@64);
+
+ //config
+ configView = View(settingsView.asView);
+ configView.asView.background = Color.fromHexString("#DDDDEF");
+ configView.layout = VLayout();
+ configView.layout.spacing = 0;
+ configView.layout.margins = [2,2,2,2];
+ configView.name = "config";
+ configView.maxSize_(64@64);
+ this.setupSaveButton(configView);
+ this.setupLoadButton(configView);
+
//synthServer
synthServerView = View(settingsView.asView);
- synthServerView.asView.background = Color.grey;
+ synthServerView.asView.background = Color.fromHexString("#DDDDEF");
synthServerView.layout = VLayout();
synthServerView.layout.spacing = 0;
- synthServerView.layout.margins = [2,0,2,0];
- synthServerView.maxSize_(150@60);
- StaticText(synthServerView, Rect(0, 0, 150@20)).string_("synthServer").align_(\center);
- this.setupEZText(synthServerView, "address", config.at(\synthServerAddress));
- this.setupEZNumber(synthServerView, "port", config.at(\synthServerPort));
-
- //TODO: add headView for hub, forward and scsynth addresses, save and load setup
- //TODO: add Button to save/load setup
- //TODO: add EZText for addresses
- //TODO: add EZNumber for ports
+ synthServerView.layout.margins = [2,2,2,2];
+ synthServerView.name = "synthServer";
+ synthServerView.maxSize_(144@64);
+ StaticText(synthServerView, Rect(0, 0, 140@20)).string_("synthServer").align_(\center);
+ this.setupEZText(synthServerView, "address", config.at(\synthServerAddress)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+ this.setupEZNumber(synthServerView, "port", config.at(\synthServerPort)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+
+ //hub
+ hubView = View(settingsView.asView);
+ hubView.asView.background = Color.fromHexString("#DDDDEF");
+ hubView.layout = VLayout();
+ hubView.layout.spacing = 0;
+ hubView.layout.margins = [2,2,2,2];
+ hubView.name = "hub";
+ hubView.maxSize_(144@64);
+ StaticText(hubView, Rect(0, 0, 140@20)).string_("hub").align_(\center);
+ this.setupEZText(hubView, "address", config.at(\hubAddress)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+ this.setupEZNumber(hubView, "port", config.at(\hubPort)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+
+ //forward
+ forwardView = View(settingsView.asView);
+ forwardView.asView.background = Color.fromHexString("#DDDDEF");
+ forwardView.layout = VLayout();
+ forwardView.layout.spacing = 0;
+ forwardView.layout.margins = [2,2,2,2];
+ forwardView.name = "forward";
+ forwardView.maxSize_(144@64);
+ StaticText(forwardView, Rect(0, 0, 140@20)).string_("forward").align_(\center);
+ this.setupEZText(forwardView, "address", config.at(\forwardAddress)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+ this.setupEZNumber(forwardView, "port", config.at(\forwardPort)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+
+ // go to next line in layout
+ layout.nextLine;
+
+ // container for channelViews
channelContainerView = View(mainView.asView, Rect(0, 0, mainView.bounds.width/config.at(\inputs).size, mainView.bounds.height));
channelContainerView.asView.background = Color.fromHexString("#FEFEFE");
channelContainerView.layout = HLayout();
@@ -99,8 +118,8 @@ BowelyzerGUI{
headView.layout.spacing = 0;
headView.layout.margins = [2,0,0,0];
headView.maxHeight_(26);
- this.setupEZText(headView, "name", name.asString);
- this.setupEZNumber(headView, "input", config.at(\inputs).at(name));
+ this.setupEZText(headView, "name", name.asString).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
+ this.setupEZNumber(headView, "input", config.at(\inputs).at(name)).children.do({|item| if(item.isKindOf(StaticText),{item.align_(\left)})});
//controlMeterContainerView = View(channelView.asView, Rect(0, 0, channelView.bounds.width/config.at(\inputs).size, channelView.bounds.height));
controlMeterContainerView = View(channelView.asView);
@@ -208,6 +227,58 @@ BowelyzerGUI{
.drawsPeak_(true);
}
+ // create a load button, that launches a FileDialog on press
+ setupLoadButton{
+ arg parent;
+ ^Button(parent, Rect(0,0,40,20))
+ .states_([
+ ["load", Color.black, Color.fromHexString("#99FF99")]
+ ])
+ .action_({
+ arg controlUnit;
+ var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
+ type = "/load";
+ FileDialog.new(
+ okFunc: {|path|
+ postln("Sending: ["++type++", "++path++"]");
+ address.sendMsg(type, path.asString);
+ },
+ cancelFunc: {},
+ fileMode: 1,
+ acceptMode: 0,
+ stripResult: true
+ );
+ })
+ .maxSize_(40@20)
+ ;
+ }
+
+ // create a save button, that launches a FileDialog on press
+ setupSaveButton{
+ arg parent;
+ ^Button(parent, Rect(0,0,40,20))
+ .states_([
+ ["save", Color.black, Color.fromHexString("#99FF99")],
+ ])
+ .action_({
+ arg controlUnit;
+ var address = NetAddr.new("127.0.0.1", NetAddr.langPort),
+ type = "/save";
+ FileDialog.new(
+ okFunc: {|path|
+ postln("Sending: ["++type++", "++path++"]");
+ address.sendMsg(type, path.asString);
+ },
+ cancelFunc: {},
+ fileMode: 1,
+ acceptMode: 1,
+ stripResult: true
+ );
+ })
+ .maxSize_(40@20)
+ ;
+ }
+
setupPauseButton{
arg parent;
^Button(parent, Rect(0,0,40,20))
@@ -230,9 +301,18 @@ BowelyzerGUI{
setupEZText{
arg parent, control, value;
+ var bounds = 150@20,
+ labelWidth= 50,
+ textWidth = 50;
+ // resize, depending on surrounding
+ if(control == "address",{
+ bounds = 140@20;
+ labelWidth = 70;
+ textWidth = 70;
+ });
^EZText(
parent: parent,
- bounds: 150@20,
+ bounds: bounds,
label: control,
action: {
arg controlUnit;
@@ -241,23 +321,39 @@ BowelyzerGUI{
name = controlUnit.view.parent.parent.name.asSymbol,
controlName = controlUnit.labelView.string.asSymbol,
controlValue = controlUnit.value;
- address.sendMsg(type, name, controlName, controlValue);
+ if((type == "/synthServer") || (type == "/hub") || (type == "/forward"), {
+ type = type++"Address";
+ postln("Sending: "++"["++type++", "++controlValue++"]");
+ address.sendMsg(type, controlValue);
+ },{
+ postln("Sending: "++"["++type++", "++name++", "++controlName++", "++controlValue++"]");
+ address.sendMsg(type, name, controlName, controlValue);
+ });
},
- labelWidth: 50,
- textWidth: 100,
+ labelWidth: labelWidth,
+ textWidth: textWidth,
initVal:value.asString,
layout: \horz,
margin: nil
)
- .view.maxHeight_(20);
+ .view.maxHeight_(20)
+ ;
}
setupEZNumber{
arg parent, control, value;
- //TODO: make choosing of size and action/message generic
+ var bounds = 100@20,
+ labelWidth = 50,
+ numberWidth = 50;
+ // resize, depending on surrounding
+ if(control == "port",{
+ bounds = 140@20;
+ labelWidth = 70;
+ numberWidth = 70;
+ });
^EZNumber(
parent: parent,
- bounds: 100@20,
+ bounds: bounds,
label: control,
controlSpec: control.asSymbol,
action: {
@@ -267,14 +363,21 @@ BowelyzerGUI{
name = controlUnit.view.parent.parent.name.asSymbol,
controlName = controlUnit.labelView.string.asSymbol,
controlValue = controlUnit.value;
- address.sendMsg(type, name, controlName, controlValue);
+ if((type == "/synthServer") || (type == "/hub") || (type == "/forward"), {
+ type = type++"Port";
+ postln("Sending: "++"["++type++", "++controlValue++"]");
+ address.sendMsg(type, controlValue);
+ },{
+ postln("Sending: "++"["++type++", "++name++", "++controlName++", "++controlValue++"]");
+ address.sendMsg(type, name, controlName, controlValue);
+ });
},
initVal:value,
- //unitWidth:0,
+ labelWidth: labelWidth,
+ numberWidth: numberWidth,
layout: \horz,
margin: nil
)
- //.view.maxSize_(100@20);
.view.maxHeight_(20)
;
}