Remove second argument of AddWindow(), use Position() instead

This commit is contained in:
Paul Licameli 2017-10-31 19:44:00 -04:00
parent b5ee7676fd
commit 96291c5476
22 changed files with 120 additions and 55 deletions

View File

@ -993,7 +993,7 @@ void NyqBench::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(5, 1);
S.Prop(true);
S.AddWindow(mSplitter, wxEXPAND);
S.Position(wxEXPAND).AddWindow(mSplitter);
S.AddSpace(5, 1);
mSplitter->SetMinSize(wxSize(600, 400));

View File

@ -396,7 +396,8 @@ visit our [[https://forum.audacityteam.org/|forum]].");
html->SetPage(creditStr);
/* locate the html renderer where it fits in the dialogue */
S.Prop(1).Focus().AddWindow( html, wxEXPAND );
S.Prop(1).Position( wxEXPAND ).Focus()
.AddWindow( html );
S.EndVerticalLay();
S.EndNotebookPage();
@ -650,7 +651,9 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
informationStr = FormatHtmlText( informationStr );
html->SetPage(informationStr); // push the page into the html renderer
S.Prop(2).AddWindow( html, wxEXPAND ); // make it fill the page
S.Prop(2)
.Position( wxEXPAND )
.AddWindow( html ); // make it fill the page
// I think the 2 here goes with the StartVerticalLay() call above?
S.EndVerticalLay(); // end window
S.EndNotebookPage(); // end the tab
@ -958,7 +961,9 @@ wxT("POSSIBILITY OF SUCH DAMAGES.\n"));
html->SetPage( PageText );
S.Prop(1).AddWindow( html, wxEXPAND );
S.Prop(1)
.Position( wxEXPAND )
.AddWindow( html );
S.EndVerticalLay();
S.EndNotebookPage();

View File

@ -303,16 +303,18 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
);
S.AddSpace(wxDefaultCoord, 1);
S.Prop(1);
S.AddWindow(vRuler, wxALIGN_RIGHT | wxALIGN_TOP);
S.Prop(1)
.Position(wxALIGN_RIGHT | wxALIGN_TOP)
.AddWindow(vRuler);
S.AddSpace(wxDefaultCoord, 1);
}
S.EndVerticalLay();
mFreqPlot = safenew FreqPlot(this, wxID_ANY);
S.Prop(1)
.Position(wxEXPAND)
.MinSize( { wxDefaultCoord, FREQ_WINDOW_HEIGHT } )
.AddWindow(mFreqPlot, wxEXPAND);
.AddWindow(mFreqPlot);
S.StartHorizontalLay(wxEXPAND, 0);
{
@ -327,14 +329,16 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.Prop(1);
S
.Name(XO("Scroll"))
.AddWindow(mPanScroller, wxALIGN_LEFT | wxTOP);
.Position( wxALIGN_LEFT | wxTOP)
.AddWindow(mPanScroller);
}
S.EndVerticalLay();
S.StartVerticalLay();
{
wxStaticBitmap *zi = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomIn));
S.AddWindow((wxWindow *) zi, wxALIGN_CENTER);
S.Position(wxALIGN_CENTER)
.AddWindow(zi);
S.AddSpace(5);
@ -343,7 +347,8 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.Prop(1);
S
.Name(XO("Zoom"))
.AddWindow(mZoomSlider, wxALIGN_CENTER_HORIZONTAL);
.Position(wxALIGN_CENTER_HORIZONTAL)
.AddWindow(mZoomSlider);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mZoomSlider->SetAccessible(safenew WindowAccessible(mZoomSlider));
@ -352,7 +357,8 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.AddSpace(5);
wxStaticBitmap *zo = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomOut));
S.AddWindow((wxWindow *) zo, wxALIGN_CENTER);
S.Position(wxALIGN_CENTER)
.AddWindow(zo);
}
S.EndVerticalLay();
@ -382,8 +388,9 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
);
S.AddSpace(1, wxDefaultCoord);
S.Prop(1);
S.AddWindow(hRuler, wxALIGN_LEFT | wxALIGN_TOP);
S.Prop(1)
.Position(wxALIGN_LEFT | wxALIGN_TOP)
.AddWindow(hRuler);
S.AddSpace(1, wxDefaultCoord);
}
S.EndHorizontalLay();
@ -502,7 +509,8 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.AddSpace(5);
mProgress = safenew FreqGauge(this, wxID_ANY); //, wxST_SIZEGRIP);
S.AddWindow(mProgress, wxEXPAND);
S.Position(wxEXPAND)
.AddWindow(mProgress);
// Log-frequency axis works for spectrum plots only.
if (mAlg != SpectrumAnalyst::Spectrum)

View File

@ -271,13 +271,13 @@ void ShuttleGuiBase::AddTitle(const wxString &Prompt)
/// Very generic 'Add' function. We can add anything we like.
/// Useful for unique controls
wxWindow * ShuttleGuiBase::AddWindow(wxWindow * pWindow, int Flags )
wxWindow * ShuttleGuiBase::AddWindow(wxWindow * pWindow)
{
if( mShuttleMode != eIsCreating )
return pWindow;
mpWind = pWindow;
SetProportions( 0 );
UpdateSizersCore(false, Flags);
UpdateSizersCore(false, wxALIGN_CENTRE | wxALL);
return pWindow;
}
@ -2042,14 +2042,20 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt)
{
if( mpWind && mpParent )
{
int useFlags = Flags;
if ( !prompt && mItem.mWindowPositionFlags )
// override the given Flags
useFlags = mItem.mWindowPositionFlags;
if( mpSizer){
if( bPrepend )
{
mpSizer->Prepend(mpWind, miProp, Flags,miBorder);
mpSizer->Prepend(mpWind, miProp, useFlags, miBorder);
}
else
{
mpSizer->Add(mpWind, miProp, Flags,miBorder);
mpSizer->Add(mpWind, miProp, useFlags, miBorder);
}
}

View File

@ -215,6 +215,12 @@ struct Item {
return std::move ( *this );
}
Item&& Position( int flags ) &&
{
mWindowPositionFlags = flags;
return std::move( *this );
}
std::function< void(wxWindow*) > mValidatorSetter;
TranslatableString mToolTip;
TranslatableString mName;
@ -224,6 +230,9 @@ struct Item {
long miStyle{};
// Applies to windows, not to subsizers
int mWindowPositionFlags{ 0 };
wxSize mMinSize{ -1, -1 };
bool mHasMinSize{ false };
bool mUseBestSize{ false };
@ -248,8 +257,8 @@ public:
void AddPrompt(const wxString &Prompt);
void AddUnits(const wxString &Prompt);
void AddTitle(const wxString &Prompt);
// Applies wxALL (which affects borders) only when in Flags:
wxWindow * AddWindow(wxWindow * pWindow, int Flags = wxALIGN_CENTRE | wxALL );
wxWindow * AddWindow(wxWindow * pWindow);
wxSlider * AddSlider(const wxString &Prompt, int pos, int Max, int Min = 0);
wxSlider * AddVSlider(const wxString &Prompt, int pos, int Max);
wxSpinCtrl * AddSpinCtrl(const wxString &Prompt, int Value, int Max, int Min);
@ -648,6 +657,12 @@ public:
return *this;
}
ShuttleGui & Position( int flags )
{
std::move( mItem ).Position( flags );
return *this;
}
// Prop() sets the proportion value, defined as in wxSizer::Add().
ShuttleGui & Prop( int iProp ){ ShuttleGuiBase::Prop(iProp); return *this;}; // Has to be here too, to return a ShuttleGui and not a ShuttleGuiBase.

View File

@ -135,7 +135,9 @@ void SplashDialog::Populate( ShuttleGui & S )
wxSize(506, 280),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
mpHtml->SetPage(HelpText( wxT("welcome") ));
S.Prop(1).AddWindow( mpHtml, wxEXPAND );
S.Prop(1)
.Position( wxEXPAND )
.AddWindow( mpHtml );
S.Prop(0).StartMultiColumn(2, wxEXPAND);
S.SetStretchyCol( 1 );// Column 1 is stretchy...
{

View File

@ -925,8 +925,9 @@ void TagsEditor::PopulateOrExchange(ShuttleGui & S)
mGrid->SetColSize(0, tc.GetSize().x);
mGrid->SetColMinimalWidth(0, tc.GetSize().x);
}
S.Prop(1);
S.AddWindow(mGrid, wxEXPAND | wxALL);
S.Prop(1)
.Position(wxEXPAND | wxALL)
.AddWindow(mGrid);
S.StartMultiColumn(4, wxALIGN_CENTER);
{

View File

@ -381,7 +381,8 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
S.ToolTip(XO("Current length of selection."))
/* i18n-hint: changing a quantity "from" one value "to" another */
.Name(XO("from"))
.AddWindow(mpFromLengthCtrl, wxALIGN_LEFT);
.Position(wxALIGN_LEFT)
.AddWindow(mpFromLengthCtrl);
S.AddPrompt(_("New Length:"));
@ -394,7 +395,8 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
/* i18n-hint: changing a quantity "from" one value "to" another */
S.Name(XO("to"))
.AddWindow(mpToLengthCtrl, wxALIGN_LEFT);
.Position(wxALIGN_LEFT)
.AddWindow(mpToLengthCtrl);
}
S.EndMultiColumn();
}

View File

@ -214,8 +214,9 @@ void EffectCompressor::PopulateOrExchange(ShuttleGui & S)
mNoiseFloorDB,
mRatio);
S.Prop(true)
.Position(wxEXPAND | wxALL)
.MinSize( { 400, 200 } )
.AddWindow(mPanel, wxEXPAND | wxALL);
.AddWindow(mPanel);
S.SetBorder(5);
}
S.EndHorizontalLay();

View File

@ -782,16 +782,18 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
);
S.Prop(0).AddSpace(0, 1);
S.Prop(1).AddWindow(mdBRuler, wxEXPAND );
S.Prop(1)
.Position(wxEXPAND)
.AddWindow(mdBRuler);
S.AddSpace(0, 1);
}
S.EndVerticalLay();
mPanel = safenew EqualizationPanel(parent, wxID_ANY, this);
S.Prop(1);
S
S.Prop(1)
.Position(wxEXPAND)
.MinSize( { wxDefaultCoord, wxDefaultCoord } )
.AddWindow(mPanel, wxEXPAND );
.AddWindow(mPanel);
S.SetBorder(5);
S.StartVerticalLay();
@ -839,7 +841,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
);
S.SetBorder(1);
S.Prop(1).AddWindow(mFreqRuler, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxLEFT);
S.Prop(1)
.Position(wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxLEFT)
.AddWindow(mFreqRuler);
S.SetBorder(0);
// Column 3 is empty
@ -857,9 +861,12 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
// Panel used to host the sliders since they will be positioned manually.
//mGraphicPanel = safenew wxPanelWrapper(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, 150));
//S.Prop(1).AddWindow(mGraphicPanel, wxEXPAND);
//S.Prop(1)
//.Position(wxEXPAND)
//.AddWindow(mGraphicPanel);
wxWindow *pParent = S.GetParent();
S.AddSpace(15,0);
for (int i = 0; (i < NUMBER_OF_BANDS) && (kThirdOct[i] <= mHiFreq); ++i)
{
mSliders[i] = safenew wxSliderWrapper(pParent, ID_Slider + i, 0, -20, +20,
@ -880,7 +887,8 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
} )
.ConnectRoot(
wxEVT_ERASE_BACKGROUND, &EffectEqualization::OnErase)
.AddWindow( mSliders[i], wxEXPAND );
.Position(wxEXPAND)
.AddWindow( mSliders[i] );
}
S.AddSpace(15,0);
}

View File

@ -243,7 +243,8 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S)
NumericTextCtrl::Options{}
.AutoPos(true));
S.Name(XO("Duration"))
.AddWindow(mNoiseDurationT, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL);
.Position(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL)
.AddWindow(mNoiseDurationT);
}
S.EndMultiColumn();
}

View File

@ -386,8 +386,9 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.SetBorder(1);
S.AddSpace(1, 1);
S.Prop(1);
S.AddWindow(mdBRuler, wxALIGN_RIGHT | wxTOP);
S.Prop(1)
.Position(wxALIGN_RIGHT | wxTOP)
.AddWindow(mdBRuler);
S.AddSpace(1, 1);
}
S.EndVerticalLay();
@ -399,8 +400,9 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.SetBorder(5);
S.Prop(1)
.Position(wxEXPAND | wxRIGHT)
.MinSize( { -1, -1 } )
.AddWindow(mPanel, wxEXPAND | wxRIGHT);
.AddWindow(mPanel);
S.StartVerticalLay();
{
@ -442,8 +444,9 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
.LabelEdges(true)
);
S.Prop(1);
S.AddWindow(mfreqRuler, wxEXPAND | wxALIGN_LEFT | wxRIGHT);
S.Prop(1)
.Position(wxEXPAND | wxALIGN_LEFT | wxRIGHT)
.AddWindow(mfreqRuler);
S.AddSpace(1, 1);

View File

@ -74,7 +74,8 @@ void EffectSilence::PopulateOrExchange(ShuttleGui & S)
NumericTextCtrl::Options{}
.AutoPos(true));
S.Name(XO("Duration"))
.AddWindow(mDurationT, wxALIGN_CENTER | wxALL);
.Position(wxALIGN_CENTER | wxALL)
.AddWindow(mDurationT);
}
S.EndHorizontalLay();
}

View File

@ -451,7 +451,8 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
NumericTextCtrl::Options{}
.AutoPos(true));
S.Name(XO("Duration"))
.AddWindow(mToneDurationT, wxALIGN_LEFT | wxALL);
.Position(wxALIGN_LEFT | wxALL)
.AddWindow(mToneDurationT);
}
S.EndMultiColumn();

View File

@ -2664,7 +2664,8 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
options);
S
.Name( TranslatableString{ prompt } )
.AddWindow(time, wxALIGN_LEFT | wxALL);
.Position(wxALIGN_LEFT | wxALL)
.AddWindow(time);
}
else if (ctrl.type == NYQ_CTRL_FILE)
{

View File

@ -986,7 +986,8 @@ void Exporter::CreateUserPane(wxWindow *parent)
S.StartStatic(_("Format Options"), 1);
{
mBook = safenew wxSimplebook(S.GetParent());
S.AddWindow(mBook, wxEXPAND);
S.Position(wxEXPAND)
.AddWindow(mBook);
for (const auto &pPlugin : mPlugins)
{

View File

@ -146,7 +146,8 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
RuleTable->EnableDragCell (true);
fillRuleTable = true;
}
S.AddWindow(RuleTable, wxEXPAND | wxALL);
S.Position(wxEXPAND | wxALL)
.AddWindow(RuleTable);
PluginList = S.Id(EIPPluginList).AddListControl(
{ { _("Importer order"), wxLIST_FORMAT_LEFT,

View File

@ -227,12 +227,12 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
wxTE_PROCESS_ENTER);
mFilter->SetName(wxStripMenuCodes(mFilterLabel->GetLabel()));
}
S
S.Position(wxALIGN_NOT | wxALIGN_LEFT)
.ConnectRoot(wxEVT_KEY_DOWN,
&KeyConfigPrefs::OnFilterKeyDown)
.ConnectRoot(wxEVT_CHAR,
&KeyConfigPrefs::OnFilterChar)
.AddWindow(mFilter, wxALIGN_NOT | wxALIGN_LEFT);
.AddWindow(mFilter);
}
S.EndHorizontalLay();
}
@ -245,8 +245,9 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
mView = safenew KeyView(S.GetParent(), CommandsListID);
mView->SetName(_("Bindings"));
}
S.Prop(true);
S.AddWindow(mView, wxEXPAND);
S.Prop(true)
.Position(wxEXPAND)
.AddWindow(mView);
}
S.EndHorizontalLay();

View File

@ -561,8 +561,9 @@ PrefsDialog::PrefsDialog
mCategories->GetTreeCtrl()->SetName(_("Category"));
S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true);
{
S.Prop(1);
S.AddWindow(mCategories, wxEXPAND);
S.Prop(1)
.Position(wxEXPAND)
.AddWindow(mCategories);
{
typedef std::pair<int, int> IntPair;
@ -602,7 +603,9 @@ PrefsDialog::PrefsDialog
const PrefsNode &node = factories[0];
const PrefsPanel::Factory &factory = node.factory;
mUniquePage = factory(this, wxID_ANY);
wxWindow * uniquePageWindow = S.Prop(1).AddWindow(mUniquePage, wxEXPAND);
wxWindow * uniquePageWindow = S.Prop(1)
.Position(wxEXPAND)
.AddWindow(mUniquePage);
// We're not in the wxTreebook, so add the accelerator here
wxAcceleratorEntry entries[1];
#if defined(__WXMAC__)

View File

@ -134,7 +134,8 @@ void LabelTrackMenuTable::OnSetFont(wxCommandEvent &)
lb->SetSelection( make_iterator_range( facenames ).index( facename ));
S
.Name(XO("Face name"))
.AddWindow(lb, wxALIGN_LEFT | wxEXPAND | wxALL);
.Position( wxALIGN_LEFT | wxEXPAND | wxALL )
.AddWindow(lb);
/* i18n-hint: (noun) The size of the typeface*/
S.AddPrompt(_("Face size"));
@ -146,7 +147,8 @@ void LabelTrackMenuTable::OnSetFont(wxCommandEvent &)
8, 48, fontsize);
S
.Name(XO("Face size"))
.AddWindow(sc, wxALIGN_LEFT | wxALL);
.Position( wxALIGN_LEFT | wxALL )
.AddWindow(sc);
}
S.EndMultiColumn();
S.AddStandardButtons();

View File

@ -290,7 +290,8 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id,
size,
ASlider::Options{}
.Style( style ).Line( line ).Page( page ) );
S.AddWindow(mSlider, wxEXPAND);
S.Position(wxEXPAND)
.AddWindow(mSlider);
}
S.EndVerticalLay();

View File

@ -192,7 +192,8 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
else
html->SetPage( HtmlText);
S.Prop(1).Focus().AddWindow( html, wxEXPAND );
S.Prop(1).Focus().Position( wxEXPAND )
.AddWindow( html );
S.Id( wxID_CANCEL ).AddButton( _("Close"), wxALIGN_CENTER, true );
}