Toolbox/Dialogs
From Audacity Wiki
This page of developer code and/or digital audio documentation is part of a collection of pages for learning about our code. We aim to increasingly add interactive diagrams to these pages and over time connect better to the doxygen documentation. |
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); 173 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); 181 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.