IF3Si/scd/gui_core.scd

147 lines
3.6 KiB
Plaintext

/*
part of: Interface Fractures III - Silicon
(c) Luka Prinčič / Nova deViator
nova@deviator.si
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,
border: false,
server: s,
scroll: true
).front;
w.fullScreen;
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 ---------------------------------------------------------------
~tabs = List["chaos", "granul", "players", "processing", "main"];
~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");
});