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

[sc-dev] Asynchronicity and docs



I adopted a section from the old GUI intro, which seems rather confusing
to me. see below.
Firstly, stringBounds in th SwingGUI kit is currently not asynchronous.
It is calculated using a factor. Secondly, it seems to me that
asynchronicity is a general point which concerns using the SwingOSC
Server, and should perhaps be mentioned in separate section concerning
the  SwingGUI scheme.  If something is really asynchronous, then you
actually need to wait for a reponse before you continue, like with
OSCResponderNode. (And indeed, the Swing kit  uses OSCResponderNode
transparently in its gui init classes).

So I would prefer to leave this out here, and would ask someone with
indepth knowledge of the swing library to write a paragraph about how to
treat timing when using the swing kit.

thanks,

jostM




*stringBounds( string, font )

Returns a Rect object describing the bounds occupied by the given string
if it was painted using the given font. Note that this method is
asynchronous in SwingOSC, hence it is advised to use it inside a
Routine. Example:

    (
    {
        var text = "Test", bounds, font, fonts, rect = Rect.new, total =
Rect.new;
       
        fonts = Font.availableFonts;
        w = Window.new( "String Bounds", resizable: false );
        w.view.background = Color.blue;
        10.do({
            font        = Font.new( fonts.choose, exprand( 6, 36 ));
            bounds    = GUI.stringBounds( text, font );
            rect.set( rect.right, rect.bottom, bounds.width + 4,
bounds.height + 2 );
            StaticText.new( w, rect )
                .font_( font ).align_( \center ).string_( text
).background_( Color.white );
            total    = total.union( rect );
        });
        w.bounds = total.moveTo( 200, 200 );
        w.front;
    }.fork( AppClock );
    )


_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/