From c3e0dad854184458b1e7907009bebde207c1328f Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 10 Jul 2016 18:48:25 +0200 Subject: classes/BowelyzerGUI.sc: Refactoring the initialization and removal of configView into two separate functions. Moving towards using layout.insert for inserting Views into the settingsView layout. --- classes/BowelyzerGUI.sc | 57 +++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'classes') diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc index 457abf7..bc5cb0a 100644 --- a/classes/BowelyzerGUI.sc +++ b/classes/BowelyzerGUI.sc @@ -50,7 +50,7 @@ BowelyzerGUI{ //setup the main view, in which all other views reside setupMainView{ arg config, configFilePath; - var channelScrollView, configView, layout; + var channelScrollView, layout; mainView = PageLayout.new("Bowelyzer"); mainView.asView.background = Color.fromHexString("#DBDBDB"); layout = mainView.asView.addFlowLayout(0@0, 0@0); @@ -65,23 +65,13 @@ BowelyzerGUI{ settingsView.layout = HLayout(); settingsView.layout.spacing = 0; settingsView.layout.margins = [0,0,0,0]; - - //config - configView = View(settingsView.asView); - configView.asView.background = Color.fromHexString("#DDDDEF"); - configView.layout = VLayout(); - configView.layout.spacing = 0; - configView.layout.margins = settingsSubViewMargins; - configView.name = "config"; - configView.maxSize_(configViewSize); - this.setupSaveButton(configView, configFilePath); - this.setupSaveAsButton(configView); - this.setupLoadButton(configView); - - this.setupAddressesAndPorts(settingsView.asView, config); + this.setupConfigView; + this.setupAddressesAndPorts(config); // go to next line in layout layout.nextLine; + + // scrollview for channels 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)+buttonWidth, channelViewHeight)); @@ -92,13 +82,36 @@ BowelyzerGUI{ channelContainerView.name = \channelContainerView; } + // setup the config View with Buttons to save and load configurations + setupConfigView{ + var configView = View(); + configView.asView.background = Color.fromHexString("#DDDDEF"); + configView.layout = VLayout(); + configView.layout.spacing = 0; + configView.layout.margins = settingsSubViewMargins; + configView.name = "config"; + configView.maxSize_(configViewSize); + this.setupSaveButton(configView); + this.setupSaveAsButton(configView); + this.setupLoadButton(configView); + settingsView.layout.insert(configView, 0); + } + + removeConfigView{ + settingsView.children.do({|setting, i| + if(setting.isKindOf(View) && (setting.name == "config"),{ + setting.remove; + }); + }); + } + // setup Views for addresses and ports setupAddressesAndPorts{ - arg parent, config; + arg config; var forwardView, hubView, synthServerView; //synthServer - synthServerView = View(parent, Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y)); + synthServerView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y)); synthServerView.asView.background = Color.fromHexString("#DDDDEF"); synthServerView.layout = VLayout(); synthServerView.layout.spacing = 0; @@ -122,9 +135,10 @@ BowelyzerGUI{ item.align_(\right); }); }); + settingsView.layout.insert(synthServerView, 1); //hub - hubView = View(parent, Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y)); + hubView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y)); hubView.asView.background = Color.fromHexString("#DDDDEF"); hubView.layout = VLayout(); hubView.layout.spacing = 0; @@ -148,9 +162,10 @@ BowelyzerGUI{ item.align_(\right); }); }); + settingsView.layout.insert(hubView, 2); //forward - forwardView = View(parent, Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y)); + forwardView = View(bounds: Rect(0, 0, settingsSubViewSize.x, settingsSubViewSize.y)); forwardView.asView.background = Color.fromHexString("#DDDDEF"); forwardView.layout = VLayout(); forwardView.layout.spacing = 0; @@ -174,6 +189,7 @@ BowelyzerGUI{ item.align_(\right); }); }); + settingsView.layout.insert(forwardView, 3); } // remove Views for addresses and ports @@ -364,7 +380,7 @@ BowelyzerGUI{ // create a save button, that launches a FileDialog on press setupSaveButton{ - arg parent, file, state = 1; + arg parent; ^Button(parent, Rect(0, 0, buttonWidth, buttonHeight)) .states_([ ["save", Color.black, Color.fromHexString("#99FF99")] @@ -376,7 +392,6 @@ BowelyzerGUI{ postln("Sending: ["++type++"]"); address.sendMsg(type); }) - .value_(1) .maxSize_(buttonWidth@buttonHeight) ; } -- cgit v1.2.3-70-g09d2