From Audacity Wiki
Revision as of 21:02, 10 March 2020 by James (talk | contribs) (edit.)
Jump to: navigation, search

Dialogs and Sizers

Audacity uses wxSizers from wxWidgets library to lay out controls in dialogs. We don't use the sizers directly. Instead we have our own class ShuttleGUI. ShuttleGUI creates controls and sizers and keeps track of their nesting. ShuttleGUI can also exchange data, sending values for display in the dialog, or extracting data from the dialog.

The class ShuttleGUI reduces a great deal of repetitive code.

Constructing a Dialog

Here's an example of constructing a dialog using ShuttleGUI that's in file Echo.cpp for the 'echo effect'.

 170 void EffectEcho::PopulateOrExchange(ShuttleGui & S)
 171 {
 172    S.AddSpace(0, 5);
 174    S.StartMultiColumn(2, wxALIGN_CENTER);
 175    {
 176       S.Validator<FloatingPointValidator<double>>(
 177             3, &delay, NumValidatorStyle::NO_TRAILING_ZEROES,
 178             MIN_Delay, MAX_Delay
 179          )
 180          .AddTextBox(XO("Delay time (seconds):"), wxT(""), 10);
 182       S.Validator<FloatingPointValidator<double>>(
 183             3, &decay, NumValidatorStyle::NO_TRAILING_ZEROES,
 184             MIN_Decay, MAX_Decay)
 185          .AddTextBox(XO("Decay factor:"), wxT(""), 10);
 186    }
 187    S.EndMultiColumn();
 188 }

Here's the dialog it produces:


Rough notes...
- Help Icon links to help system
- Panels used on some dialogs
- Custom controls (NumericTextCtrl) for use in dialogs and toolbars
- Custom validators

Relevant Classes

Here are some more classes relevant to dialogs.