## SwingOSC – Java-based GUI classes

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

# JSCHLayoutView

Note: please use the abstraction layer GUI.hLayoutView if possible! (see GUI)

A container view that lays out all its children horizontally from left to right. For the vertical version, see JSCVLayoutView.

    (
    q = 10;
    w = JSCWindow.new;

    h = JSCHLayoutView(w,Rect(0,0,300,300));

    Array.fill(q,{ arg i;
        JSCRangeSlider(h,Rect(0,0,20,75)).hi_(i / q); // .step_( 0.1 );
    });

    w.front
    )

### elastic

    // note: children can never exceed the bounds
    // of their parent container in swing !!
    (
    q = 10;
    w = JSCWindow.new;

    h = JSCHLayoutView(w,Rect(0,0,300,300));
    h.background = Color.red(alpha:0.2);
    h.resize = 5; // elastic
    Array.fill(q,{  arg i;
        var s;
        s = JSCRangeSlider(h,Rect(0,0,20,75)).hi_( i / q );
        s
    });

    w.front
    )

    //Contents are elastic
    (
    q = 10;
    w = JSCWindow.new;
    h = JSCHLayoutView(w,Rect(0,0,300,300));
    h.background = Color.red(alpha:0.2);
    h.resize = 5; // elastic
    Array.fill(q,{  arg i;
        var s;
        s = JSCRangeSlider(h,Rect(0,0,20,75)).hi_( i / q );
        s.resize = 5; // elastic
        s
    });

    w.front
    )

    //set minWidth on contents
    (
    q = 5;
    w = JSCWindow.new;

    h = JSCHLayoutView(w,Rect(0,0,300,300));
    h.background = Color.red(alpha:0.2);
    h.resize = 5; // elastic

    Array.fill(q,{  arg i;
        var s;
        s = JSCRangeSlider(h,Rect(0,0,20,75)).hi_( i / 5 );
        if(i < 2,{
            s.resize = 5; // some elastic
            s.setProperty(\minWidth,20);
        },{
            s.resize = 1; // some not elastic
        });
        s
    });

    w.front
    )

    (
    q = 5;
    w = JSCWindow.new;

    h = JSCHLayoutView(w,Rect(0,0,300,300));
    h.background = Color.red(alpha:0.2);
    h.resize = 5; // elastic

    Array.fill(q,{  arg i;
    	var s;
    	s = JSCRangeSlider(h,Rect(0,0,20,75));

    	s.hi = i / 5;
    	s.resize = 5;
    	s.setProperty(\minWidth,20);
    	s.setProperty(\maxWidth,40);
    	s
    });

    w.front
    )

### Text flows

Note: `JSCStaticText` doesn't do line wrapping as its cocoa counterpart!

    (
    q = 5;
    w = JSCWindow.new;

    h = JSCHLayoutView(w,Rect(0,0,300,300));
    h.resize = 5; // elastic

    Array.fill(q,{  arg i;
        var s;
        s =     JSCStaticText(h,120@20).string_("abcdefg");

        s.resize = 5;
        s.setProperty(\minWidth,10);
        s.setProperty(\maxWidth,80);

        // not working
        s.setProperty(\maxHeight,10);
        s.setProperty(\minHeight,10);

        s.background = Color.white;
        s
    });

    w.front
    )

### spacing

Default spacing between components is 4 pixels. You can alter this value but setting the 'spacing' property:

    (
    q = 10;
    w = JSCWindow.new;

    h = JSCHLayoutView(w,Rect(0,0,300,300));
    h.spacing = 0;  // no padding

    Array.fill(q,{
        JSCRangeSlider(h,Rect(0,0,20,75))
    });

    w.front
    )

    h.spacing = 8;