««Gui for NanoKontrol 2»» by jmasterj89

on 31 Oct'15 13:47 in gui

GUI for NanoKontrol2 (barebone)

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//Gui for NanoKontrol 2 by GlacioArdor

//Gui

(
s.waitForBoot({

var win, defFont, title,
ccs, lbls, syms, trackLbl;

// Main window
// Window.closeAll;

win = Window.new("NanoKontrol2 GUI", Rect(0, 600, 1024, 300), false, true);
win.onClose = {s.freeAll; "NanoKontrol2 GUI window closed.".postln; "".postln};
// win.background = Color.gray(0.9);
//win.alpha = 0.9;
//FreqScope.new;

title = StaticText.new(win, Rect(45, 50, 250, 20));
title.align = \left;
title.font = Font("Arial", 28);
title.string = "nanoKONTROL2";

//Create 8 slider and add labels
ccs = SparseArray.new;
lbls = SparseArray.new;
syms = SparseArray.new;

8.do { |i|
	ccs.put(i, Slider.new(win, Rect(343 + (87 * i), 90, 27, 140)));
	lbls.put(i,
		StaticText.new(win, Rect(335 + (87 * i), 235, 40, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_("CC#0" ++ i)
	);
};

//Create 8 knobs and labels on top
(16 .. 23).do { |i|
	ccs.put(i, Knob.new(win, Rect(335 + (87 * (i-16)), 25, 45, 45)));
	lbls.put(i,
		StaticText.new(win, Rect(335 + (87 * (i-16)), 70, 40, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_("CC#" ++ i)
	);
};

//Create 3 buttons on left of each slider
// for this you need nested loops (there's another trick, but not today)
(32 .. 39).do { |i|
	3.do { |j|
		var ccnum = i + (16 * j);
		ccs.put(ccnum, Button(win, Rect(310 + (87 * (i-32)), 98 + (47 * j), 26, 26)));
		lbls.put(ccnum,
			StaticText.new(win, Rect(302 + (87 * (i-32)), 124 + (47 * j), 40, 20))
			.align_(\center)
			.font_(Font("Arial", 11))
			.string_("CC#" ++ ccnum)
		);
		syms.put(ccnum,
			StaticText.new(win, Rect(303 + (87 * (i-32)), 102 + (47 * j), 40, 20))
			.align_(\center)
			.font_(Font("Arial", 11))
			.string_("SMR".at(j))
		);
	};
};

[43, 44, 42, 41, 45].do { |ccnum, i|
	ccs.put(ccnum, Button(win, Rect(40 + (50 * i), 192, 26, 26)));
	lbls.put(ccnum,
		StaticText.new(win, Rect(35 + (50 * i), 218, 40, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_("CC#" ++ ccnum)
	);
	syms.put(ccnum,
		StaticText.new(win, Rect(40 + (50 * i), 175, 26, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_(#["<<", ">>", "□", ">", "o"].at(i))
	);
};

[46, 60, 61, 62].do { |ccnum, i|
	ccs.put(ccnum, Button(win, Rect(40 + (50 * i), 148, 26, 13)));
	lbls.put(ccnum,
		StaticText.new(win, Rect(35 + (50 * i), 158, 40, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_("CC#" ++ ccnum)
	);
	syms.put(ccnum,
		StaticText.new(win, Rect(36 + (50 * i), 132, 32, 20))
		.align_(\center)
		.font_(Font("Arial", 9))
		.string_(#["CYCLE", "SET", "<", ">"].at(i))
	);
};

[58, 59].do { |ccnum, i|
	ccs.put(ccnum, Button(win, Rect(40 + (50 * i), 104, 26, 13)));
	lbls.put(ccnum,
		StaticText.new(win, Rect(35 + (50 * i), 114, 40, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_("CC#" ++ ccnum)
	);
	syms.put(ccnum,
		StaticText.new(win, Rect(36 + (50 * i), 89, 36, 20))
		.align_(\center)
		.font_(Font("Arial", 11))
		.string_(#["<", ">"].at(i))
	);
};

trackLbl = StaticText.new(win, Rect(63, 89, 30, 20));
trackLbl.align = \center;
trackLbl.font = Font("Arial", 9);
trackLbl.string = "TRACK";

win.front;

}); // end of waitForBoot

)
raw 3290 chars (focus & ctrl+a+c to copy)
reception
comments