ShuttleGui

Overview
Earlier versions of Audacity ended up with very turgid code for creating and using dialogs and mapping the widget controls to program variables. ShuttleGui makes that code much shorter and more readable. There are plans to use ShuttleGui more widely in Audacity. The intention is also that classes derived from 'Shuttle' can be used in many places where we need to take simple variables from one place to another, for example from GUI to program variables, to preference variables to command line parameters.

Use in Preferences
Shuttle GUI encourages a style of programming in which one function creates the GUI and also (with different options set) carries information from the GUI to component variables or from component variables to the GUI.


 * In preferences code the one function carries variables to/from the preferences store from/to the GUI.
 * In effects code the intention is that (in time) the handling of command line parameters for effects, which are just parameter settings, will be handled in the same way.

The example below shows some typical use of ShuttleGui. Whilst the braces '{', '}' and indenting are not strictly necessary, they help show the structure of the dialog and help to ensure when coding ShuttleGui that calls are paired when necessary. In the following  is of.

S.StartStatic(_("Playback")); {     S.StartMultiColumn(2); {        mPlay = S.Id(PlayID).AddChoice(_("&Device") + wxString(wxT(":")),                             wxEmptyString,                             &empty); }     S.EndMultiColumn; }  S.EndStatic;

Tips

 * The normal spacing between items in a grid sizer is 5 pixels. Use   for closer spacing and   to restore to normal spacing.
 * can be used to add 20 pixels of x space between items in a horizontal layout. It's a bit of a hack though, and plans are to improve   so that sizing proportions become easy enough to use that quick hacks like that aren't needed anymore.
 * Choice selectors may end up bigger than you would like if the choices in them have short text. After creating them using , you can fix this using:  .  The first value is the desired   size (default is 180) the second value is the desired   choice (-1 means use default).
 * You can add a control that is not directly supported by  using.

Questions about how to achieve specific results with ShuttleGui can be left here.