2015-09-09 14:03:24 +02:00
|
|
|
/*
|
2015-09-09 15:13:45 +02:00
|
|
|
This file is part of "Interface Fractures III - Silicon".
|
2015-09-09 15:18:56 +02:00
|
|
|
Copyright (c) 2015 Luka Prinčič, All rights reserved.
|
2015-09-09 15:13:45 +02:00
|
|
|
This program is free software distributed under
|
|
|
|
GNU General Public Licence. See COPYING for more info.
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2015-09-09 14:03:24 +02:00
|
|
|
|
|
|
|
gui_core.scd - takes care of core GUI things: layouts,
|
|
|
|
tabs, window, sizes...
|
|
|
|
|
|
|
|
********************************************************** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// general color palette
|
|
|
|
QtGUI.palette = QPalette.dark;
|
|
|
|
|
|
|
|
~screenWidth = 1348;
|
|
|
|
~screenHeight = 753;
|
|
|
|
|
|
|
|
~pagerbuttonwidth = 90;
|
|
|
|
~pagerbuttonheight = 55;
|
|
|
|
~pagerbuttonpadding = 3;
|
|
|
|
|
|
|
|
~pagerwidth = ~pagerbuttonpadding + ~pagerbuttonwidth * ~tabs.size - ~pagerbuttonpadding;
|
|
|
|
~pagerheight = ~pagerbuttonheight;
|
|
|
|
|
|
|
|
|
|
|
|
// make a window
|
|
|
|
w = Window.new( name: "Interface Fractures III",
|
|
|
|
bounds: Rect(0, 2, ~screenWidth, ~screenHeight),
|
|
|
|
//bounds: w.availableBounds,
|
|
|
|
resizable: true,
|
2015-09-24 09:28:56 +02:00
|
|
|
border: true,
|
2015-09-09 14:03:24 +02:00
|
|
|
server: s,
|
|
|
|
scroll: true
|
|
|
|
).front;
|
2015-09-24 09:28:56 +02:00
|
|
|
//w.fullScreen;
|
2015-09-09 14:03:24 +02:00
|
|
|
postln("~~~ Created window ..." + w.bounds);
|
|
|
|
w.background_(Color.gray(0.2));
|
|
|
|
|
|
|
|
|
|
|
|
~pager = View.new(w, Rect(0,0,100,100))
|
|
|
|
.minHeight_(~pagerheight)
|
|
|
|
.minWidth_(~pagerwidth)
|
|
|
|
.background_(Color.gray(0.4,0.0));
|
|
|
|
|
|
|
|
~content = View.new(w, w.view.bounds)
|
|
|
|
.minWidth_(w.view.bounds.width - 2)
|
|
|
|
.minHeight_(w.view.bounds.height - ~pagerheight - 20)
|
|
|
|
.background_(Color.gray(0.3,0.2));
|
|
|
|
|
|
|
|
w.layout = VLayout( [~pager, align:\top],
|
|
|
|
[~content, align:\center], nil );
|
|
|
|
w.layout.margins = 2;
|
|
|
|
|
|
|
|
~pager.layout = HLayout();//margins=1;
|
|
|
|
~pager.layout.margins = 1;
|
|
|
|
|
|
|
|
// CREATE TABS ---------------------------------------------------------------
|
2015-09-10 21:41:57 +02:00
|
|
|
~tabs = List["main", "chaos", "granul", "players", "processing"];
|
2015-09-09 14:03:24 +02:00
|
|
|
~tab_btns = List();
|
|
|
|
~tab_views = List();
|
|
|
|
~tab_names = Dictionary.new;
|
|
|
|
//~tab_btns_view = View.new();
|
|
|
|
|
|
|
|
// go through all of tabs and make buttons and views
|
|
|
|
~tabs.do(
|
|
|
|
{ |item, i|
|
|
|
|
|
|
|
|
~tab_names.put(item, i);
|
|
|
|
|
|
|
|
// views / containers / pages - - - - -
|
|
|
|
~tab_views.add(
|
|
|
|
View.new(~content,Rect(0, 0, 1344, 700))
|
|
|
|
.background_(Color.gray(0.4,0.4))
|
|
|
|
//.layout(HLayout)
|
|
|
|
.visible_(0);
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
// buttons / tabs - - - - -
|
|
|
|
~tab_btns.add(
|
|
|
|
//Button(~pager, Rect((~pagerbuttonpadding + ~pagerbuttonwidth * i), 0, ~pagerbuttonwidth, ~pagerbuttonheight))
|
|
|
|
Button(~pager, Rect((~pagerbuttonpadding + ~pagerbuttonwidth * i), 0, ~pagerbuttonwidth, ~pagerbuttonheight))
|
|
|
|
.states_([[item],
|
|
|
|
[item, Color.white, Color.gray(0.6)]])
|
|
|
|
.action_({arg btn;
|
|
|
|
switch(btn.value,
|
|
|
|
0, { postln("~~~ Hide:" + item);
|
|
|
|
~tab_views[i].visible = 0; },
|
|
|
|
1, { ~tab_btns.do(
|
|
|
|
{ |b_item,b_i|
|
|
|
|
if (b_i != i, {
|
|
|
|
~tab_btns[b_i].enabled_(1);
|
|
|
|
~tab_btns[b_i].valueAction = 0;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
~tab_btns[i].enabled_(0);
|
|
|
|
postln("~~~ Show:" + item + "\n");
|
|
|
|
~tab_views[i].visible = 1;
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.minHeight_(~pagerbuttonheight).minWidth_(~pagerbuttonwidth);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CLOSING ////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
w.view.keyDownAction_({ |view, char, modifiers, unicode, keycode, key|
|
|
|
|
if (unicode == 27) {
|
|
|
|
postln("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
|
|
|
|
postln("~~~ Cought an ESC key. Closing window, freeing synths...");
|
|
|
|
postln("~~~ Wait, let me see the window bounds:" + w.bounds + "!\n");
|
|
|
|
|
|
|
|
w.close;
|
|
|
|
postln("\n\n<<< So long and thanks for all the fish! >>>"
|
|
|
|
+ "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// free all UGens on server (stop sound, etc)
|
|
|
|
w.onClose_({
|
|
|
|
postln("<<< Platform IDE:" + Platform.ideName);
|
|
|
|
s.freeAll;
|
|
|
|
|
|
|
|
// when running 'standalone' from shell:
|
|
|
|
if (Platform.ideName == "none") {
|
|
|
|
postln("<<< ... sclang is killed. Stockhausen forgives you!");
|
|
|
|
0.exit;
|
|
|
|
} {
|
|
|
|
postln("<<< ... stopping Main.");
|
|
|
|
thisProcess.stop;
|
|
|
|
};
|
|
|
|
postln("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
|
|
|
|
});
|
|
|
|
|
|
|
|
|