SwingOSC – Java-based GUI classes

This class is meant as an emulation of SC2DSlider. last mod: 17-jul-09 sciss
Also refer to JSCView for different behaviour affecting all widgets

different behaviour
knobslightly bigger (15x15 pixels vs. 12x12)
known issues / todo
focus border(FIXED?) not adjusted when resizing the component

 

JSC2DSlider

Note: please use the abstraction layer Slider2D if possible!

A rectangular element that allows you to control two parameters simultaneously by moving a knob horizontally and vertically.

(
    var win;

    win = JSCWindow( "JSC2DSlider", Rect( 100, 100, 340, 140 ), resizable: false );

    n = JSC2DSlider( win, Rect( 20, 20, 80, 80 )).x_( 1 ).y_( 1 );
    n.knobColor_( Color( 0.75, 0.125, 0.25, 0.8 ));
    n = JSC2DSlider( win, Rect( 120, 20, 80, 80 )).x_( 0.5 ).y_( 0.5 );
    n.knobColor_( Color( 0.125, 0.6, 0.25, 0.8 ));
    n = JSC2DSlider( win, Rect( 220, 20, 80, 80 )).x_( 0 ).y_( 0 );
    n.knobColor_( Color( 0.125, 0.25, 0.75, 0.8 ));
    
    win.front;
)

// assign an action function. note that 'n' holds the right most (blue) slider.
n.action = { arg b; ("x = "++b.x++"; y = "++b.y).postln };
n.enabled_( false );
n.enabled_( true );
n.x_( 0.66 );
n.y_( 0.33 );
// snap values
n.step_( 0.25 );
// no snapping
n.step_( 0.0 );

Drag and drop returns and accepts Points. Hold ctrl key to initiate a drag.

default keyboard mappings

Rrandom x/y
Nminimum x/y
Xmaximum x/y
Ccenter x/y
csr left/downdecrease x/y
csr right/upincrease x/y