Hey,
i would like to put StaticText in the top left corner of each view of the HLayout and not quite happy with declaring fixed pixels on the screen. Is there a way to make the position of the StaticText in dependency of the Position of the View in the HLayout?
In Addition: can the text variables put together in one variable “texts” to set for example the size and font of the text for all of the texts. Do I have to declare a function for this? thanks.
//var txt = txt.font = Font("Monaco", 11);
var durtxt = StaticText(window, Rect(20, 10, 200, 20)).string_("durations").front;
var reptxt = StaticText(window, Rect(415, 10, 200, 20)).string_("repetitions").front;
var ntstxt = StaticText(window, Rect(810, 10, 200, 20)).string_("notes").front;
code:
(
~getRandomSet = {
arg set;
var numSteps = rrand(10,30);
set = set ? ();
set.putAll((
durations: {exprand(0.1,2)}!numSteps,
repetitions: {5.rand}!numSteps,
notes: {rrand(-24,24)}!numSteps,
// added motif here
motif: {rrand(-12,12)}!5
));
};
~viewSet = {
arg set;
var window = Window.closeAll.new("Mark Fell Sequencer", Rect.new(700, 450, 1200, 400));
//var txt = txt.font = Font("Monaco", 11);
var durtxt = StaticText(window, Rect(20, 10, 200, 20)).string_("durations").front;
var reptxt = StaticText(window, Rect(415, 10, 200, 20)).string_("repetitions").front;
var ntstxt = StaticText(window, Rect(810, 10, 200, 20)).string_("notes").front;
var sliders = (
durations: MultiSliderView().background_(Color.rand),
repetitions: MultiSliderView().background_(Color.rand),
notes: MultiSliderView().background_(Color.rand)
);
var specs = (
durations: ControlSpec(0.01,10,\exp),
repetitions: ControlSpec(0,10,\lin,1),
notes: ControlSpec(30,100,\lin,0.5), //quarter-tones
);
var updater = {
loop{
sliders.keysValuesDo{
arg k,sl;
sl.value = specs[k].unmap(set[k]);
};
0.1.wait;
};
}.fork(AppClock);
sliders.keysValuesDo{
arg k,sl;
sl.action = { set[k] = specs[k].map(sl.value).postln };
sl.elasticMode_(1); // makes the squares fit evenly
sl.showIndex = true; // cursor mode
};
window.view.layout = HLayout(*[\durations,\repetitions,\notes].collect(sliders[_]));
window.onClose = { updater.free };
window.front.alwaysOnTop_(true);
};
)
a = ~getRandomSet.();
~viewSet.(a);