These are very newbie baby steps in the construction of a something bigger, a powerful flexible interface for a touch-screen device. Novels are being written one word at the time, right?
The following is a snippet of code that I needed to write in order to test a TABs-like behaviour in SuperCollider QT GUI system. Essentially, I was curious if it’s possible to show and hide whole windows/areas of different widgets using a tabs-like paging system – something we’re all used to now from browsers, for example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
( // 2 tabs proof of concept, hiding and showing views ~gwin = Window.new("Test visibility", Rect(120, 420, 500, 200)); ~gwin.front; ~viewOne = View.new(~gwin, Rect(50,50,280,140)) .background_(Color.gray(0.4,1)) .visible_(0); Slider(~viewOne, Rect(5,50,20,50)); ~viewTwo = View.new(~gwin, Rect(50,50,280,140)) .background_(Color.gray(0.4,1)) .visible_(0); Slider2D(~viewTwo, Rect(20,20,100,100)); b = Button(~gwin, Rect(50, 10, 80, 35)) .states_([ ["one"], ["one", Color.white, Color.gray(0.4)] ]) .action_({arg butt; switch(butt.value, 0, { ~viewOne.visible = 0; postln("off") }, 1, { ~viewOne.visible = 1; postln("on"); b.enabled_(0); c.enabled_(1); ~viewTwo.visible = 0; c.valueAction = 0; } ); butt.value.postln; }); c = Button(~gwin, Rect(140, 10, 80, 35)) .states_([ ["two"], ["two", Color.white, Color.gray(0.4,1)] ]) .action_({arg butt; switch(butt.value, 0, { ~viewTwo.visible = 0; postln("off") }, 1, { ~viewTwo.visible = 1; postln("on"); c.enabled_(0); b.enabled_(1); ~viewOne.visible = 0; b.valueAction = 0; } ); butt.value.postln; }); ) |