[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] MIDIKeyboard not placed properly by FlowLayout



Hi Thor,

  The problem is that the userView does not update the MIDIKeyboard's bounds.  Creating mouseTracker 
at the beginning and setting the MIDIKeyboard's bounds to the mouseTracker's (which may have been placed
by a decorator) seems to fix it (see below).

RJK


initMIDIKeyboard { arg w, argbounds, argoctaves=3, argstartnote;
var r, pix, pen;
octaves = argoctaves ? 4;
bounds = argbounds ? Rect(20, 10, 364, 60);


if((win= w).isNil, {
win = GUI.window.new("MIDI Keyboard",
Rect(10, 250, bounds.left + bounds.width + 40, bounds.top + bounds.height+30));
win.front
});
mouseTracker = GUI.userView.new(win, bounds);
bounds = mouseTracker.bounds;

pen = GUI.pen;

// creation of MIDI key  code

// mouseTracker = GUI.userView.new(win, bounds)
mouseTracker
.canFocus_(false)

On Feb 19, 2008, at 10:07 PM, paul wrote:

Hi List /Thor,

I just found this - using latest release 3.2RC6:

// this MIDIKeyboard is displayed ok
(
a = SCWindow.new;
a.front;

b = SCCompositeView(a,Rect(0,0,500,500));
b.decorator = FlowLayout(b.bounds);

m = MIDIKeyboard.new(b, Rect(0, 0, 300, 80), 4, 48);
m.keyDownAction_({arg note; note.postln;});

SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));

)

// this MIDIKeyboard is displayed wrongly - not being placed by the decorator
(
a = SCWindow.new;
a.front;

b = SCCompositeView(a,Rect(0,0,500,500));
b.decorator = FlowLayout(b.bounds);

SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));
SC2DSlider(b,Rect(0,0,100,100));

m = MIDIKeyboard.new(b, Rect(0, 0, 300, 80), 4, 48);
m.keyDownAction_({arg note; note.postln;});

)

Cheers,

Paul
_______________________________________________
Sc-devel mailing list