-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollidingTab.sc
107 lines (92 loc) · 2.84 KB
/
CollidingTab.sc
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
/*
Colliding, a simple SuperCollider environment for learning and live coding
(c) Gerard Roma, 2013-2019
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
CollidingTab{
var <tab, <id;
var <state = 0, <prevState = 0;
var <textView, <volumeSlider;
var <track;
var compileButton, playButton, stopButton, qwertyButton;
var msgBox;
*new{|tabView, control, tabId|
^super.new.init(tabView, control, tabId);
}
state_{|aState|
prevState = state;
switch(aState)
{0}{tab.label=" " ++ id ++ " "} // saved
{1}{tab.label="((" ++ id ++ "))"} // playing
{2}{tab.label="~" ++ id ++ "~"}; // unsaved
state = aState;
tab.focus;
}
save{|path|
var filePath = path ++ id ++ ".cld";
var file;
file = File(filePath, "w");
file.write(textView.string);
file.close;
}
init{|tabView,control, tabId|
id = tabId;
track = CollidingTrack.new;
tab = tabView.add(" " ++ id ++ " ").closable_(true)
.onRemove_({|t|
track.stop;
control.removeTab(this);
});
track.tab = this;
tab.focus;
tab.flow({|w|
textView = TextView(w, Rect(10, 10, 840, 460))
.font_(Colliding.textFont)
.keyDownAction_{|v, c, m, u, k|
control.tabKeyDown(this, v, c, m, u, k);
};
volumeSlider = Slider(w, Rect(800, 0, 50, 460)).action_({|v|
control.trackVolume(this, v);
}).value_(0.5);
w.startRow;
compileButton = Button(w, Rect(905, 10, 50, 30))
.states_([["✓"]])
.action_({
control.compile(this, textView, false);
})
.font_(Colliding.symbolFont);
playButton = Button(w, Rect(905, 60, 50, 30))
.states_([["▸"]])
.action_({
control.compile(this, textView, true);
}).font_(Colliding.symbolFont);
stopButton = Button(w, Rect(905, 110, 50, 30))
.states_([["■"]])
.action_({
control.stopTrack(this,textView);
}).font_(Colliding.symbolFont);
qwertyButton = Button(w,Rect(905, 160, 50, 30))
.states_([["⌨"]])
.action_({
control.qwertyButton(this);
}).font_(Colliding.symbolFont);
msgBox = StaticText(w, Rect(905, 220, 620, 40))
.stringColor_(Color.black)
.background_(Color.gray);
});
this.post("ready");
}
post{|str|
msgBox.string_(str);
}
}