hey, im currently working on an object prototype and storing keys and knobs in an IdentityDictionary. I would like to create a GridLayout or VLayout / HLayout with these.
The following code does create the desired result of an 4 row x 3 column knob matrix.
(
var knobs = Array.fill(12, { Knob.new() });
var layout = GridLayout.rows(*knobs.clump(3));
var window = Window.new().layout = layout;
window.front;
)
however if i create a sorted array from the IdentityDictionary:
~dict = ~modMatrix.paramViews;
-> IdentityDictionary[ (mod1_1 -> a Knob), (mod2_3 -> a Knob), (mod1_0 -> a Knob), (mod1_3 -> a Knob), (mod2_1 -> a Knob),
(mod0_1 -> a Knob), (mod0_2 -> a Knob), (mod0_3 -> a Knob), (mod0_0 -> a Knob), (mod2_2 -> a Knob),
(mod2_0 -> a Knob), (mod1_2 -> a Knob) ]
~array = ~dict.asSortedArray;
-> [ [ mod0_0, a Knob ], [ mod0_1, a Knob ], [ mod0_2, a Knob ], [ mod0_3, a Knob ], [ mod1_0, a Knob ], [ mod1_1, a Knob ], [ mod1_2, a Knob ], [ mod1_3, a Knob ], [ mod2_0, a Knob ], [ mod2_1, a Knob ], [ mod2_2, a Knob ], [ mod2_3, a Knob ] ]
and collect the knobs:
~knobs = 3.collect{ |n|
4.collect{ |k|
var knob;
knob = ~array[n+k][1];
};
}.flat;
-> [ a Knob, a Knob, a Knob, a Knob, a Knob, a Knob, a Knob, a Knob, a Knob, a Knob, a Knob, a Knob ]
and then run:
(
var layout = GridLayout.rows(*~knobs.clump(3));
var window = Window.new().layout = layout;
window.front;
)
i get a really different result:
and when i evaluate it again, even no knobs at all:
Could somebody help me out with that? many thanks