1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +02:00

wxWidgets docs recommend: don't SetSizeHints on non-top-level windows

This commit is contained in:
Paul Licameli 2018-01-30 01:06:23 -05:00
parent c67a47e3e6
commit 7ccd35d219
9 changed files with 29 additions and 22 deletions

View File

@ -671,7 +671,8 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S)
// Keep dialog from getting too wide // Keep dialog from getting too wide
int w = r.GetWidth() - (GetClientSize().GetWidth() - mEffects->GetSize().GetWidth()); int w = r.GetWidth() - (GetClientSize().GetWidth() - mEffects->GetSize().GetWidth());
mEffects->SetSizeHints(wxSize(wxMin(maxW, w), 200), wxSize(w, -1)); mEffects->SetMinSize({ std::min(maxW, w), 200 });
mEffects->SetMaxSize({ w, -1 });
RegenerateEffectsList(ID_ShowAll); RegenerateEffectsList(ID_ShowAll);

View File

@ -397,7 +397,7 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt,
choices, choices,
Style( 0 ) ); Style( 0 ) );
pChoice->SetSizeHints( 180,-1);// Use -1 for 'default size' - Platform specific. pChoice->SetMinSize( { 180, -1 } );// Use -1 for 'default size' - Platform specific.
#ifdef __WXMAC__ #ifdef __WXMAC__
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control // so that name can be set on a standard control
@ -2347,7 +2347,7 @@ void ShuttleGuiBase::SetSizeHints( wxWindow *window, const wxArrayStringEx & ite
maxw += 50; maxw += 50;
#endif #endif
window->SetSizeHints( maxw, -1 ); window->SetMinSize( { maxw, -1 } );
} }
void ShuttleGuiBase::SetSizeHints( const wxArrayStringEx & items ) void ShuttleGuiBase::SetSizeHints( const wxArrayStringEx & items )

View File

@ -1104,14 +1104,15 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
//S.GetParent()->Layout(); //S.GetParent()->Layout();
wxSize sz = szrV->GetMinSize(); wxSize sz = szrV->GetMinSize();
sz += wxSize( 30, 0); sz += wxSize( 30, 0);
mUIParent->SetSizeHints(sz); mUIParent->SetMinSize(sz);
} }
else{ else{
mPanel->Show( true ); mPanel->Show( true );
szrV->Show(szr1, true); szrV->Show(szr1, true);
mUIParent->SetSizeHints(mUIParent->GetBestSize()); mUIParent->SetMinSize(mUIParent->GetBestSize());
} }
ForceRecalc(); ForceRecalc();
return; return;
} }
@ -2304,7 +2305,7 @@ void EffectEqualization::UpdateCurves()
// Allow the control to resize // Allow the control to resize
if( mCurve ) if( mCurve )
mCurve->SetSizeHints(-1, -1); mCurve->SetMinSize({-1, -1});
// Set initial curve // Set initial curve
setCurve( mCurveName ); setCurve( mCurveName );

View File

@ -1500,10 +1500,10 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
// Try to give the window a sensible default/minimum size // Try to give the window a sensible default/minimum size
wxSize sz1 = marginSizer->GetMinSize(); wxSize sz1 = marginSizer->GetMinSize();
wxSize sz2 = mParent->GetMinSize(); wxSize sz2 = mParent->GetMinSize();
w->SetSizeHints(wxSize(wxMin(sz1.x, sz2.x), wxMin(sz1.y, sz2.y))); w->SetMinSize( { std::min(sz1.x, sz2.x), std::min(sz1.y, sz2.y) } );
// And let the parent reduce to the NEW minimum if possible // And let the parent reduce to the NEW minimum if possible
mParent->SetSizeHints(-1, -1); mParent->SetMinSize({ -1, -1 });
return true; return true;
} }

View File

@ -1829,10 +1829,10 @@ bool LV2Effect::BuildPlain()
// Try to give the window a sensible default/minimum size // Try to give the window a sensible default/minimum size
wxSize sz1 = innerSizer->GetMinSize(); wxSize sz1 = innerSizer->GetMinSize();
wxSize sz2 = mParent->GetMinSize(); wxSize sz2 = mParent->GetMinSize();
w->SetSizeHints(wxSize(-1, wxMin(sz1.y, sz2.y))); w->SetMinSize( { -1, std::min(sz1.y, sz2.y) } );
// And let the parent reduce to the NEW minimum if possible // And let the parent reduce to the NEW minimum if possible
mParent->SetSizeHints(w->GetMinSize()); mParent->SetMinSize(w->GetMinSize());
TransferDataToWindow(); TransferDataToWindow();

View File

@ -630,7 +630,7 @@ PrefsDialog::PrefsDialog
mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem()); mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
#endif #endif
// mCategories->SetSizeHints(-1, -1, 790, 600); // 790 = 800 - (border * 2) // mCategories->SetMaxSize({ 790, 600 }); // 790 = 800 - (border * 2)
Layout(); Layout();
Fit(); Fit();
wxSize sz = GetSize(); wxSize sz = GetSize();

View File

@ -271,8 +271,8 @@ void AButton::Init(wxWindow * parent,
mFocusRect = GetClientRect().Deflate( 3, 3 ); mFocusRect = GetClientRect().Deflate( 3, 3 );
mForceFocusRect = false; mForceFocusRect = false;
SetSizeHints(mImages[0].mArr[0].GetMinSize(), SetMinSize(mImages[0].mArr[0].GetMinSize());
mImages[0].mArr[0].GetMaxSize()); SetMaxSize(mImages[0].mArr[0].GetMaxSize());
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
SetName( wxT("") ); SetName( wxT("") );

View File

@ -380,7 +380,8 @@ void ExpandingToolBar::Fit()
mCurrentDrawerSize = wxSize(mExtraSize.x, 0); mCurrentDrawerSize = wxSize(mExtraSize.x, 0);
mCurrentTotalSize = baseWindowSize; mCurrentTotalSize = baseWindowSize;
SetSizeHints(mCurrentTotalSize, mCurrentTotalSize); SetMinSize(mCurrentTotalSize);
SetMaxSize(mCurrentTotalSize);
SetSize(mCurrentTotalSize); SetSize(mCurrentTotalSize);
} }
@ -434,7 +435,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize)
if (mFrameParent) { if (mFrameParent) {
// If we're in a tool window // If we're in a tool window
SetSizeHints(mCurrentTotalSize, mCurrentTotalSize); SetMinSize(mCurrentTotalSize);
SetMaxSize(mCurrentTotalSize);
SetSize(mCurrentTotalSize); SetSize(mCurrentTotalSize);
GetParent()->Fit(); GetParent()->Fit();
@ -443,7 +445,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize)
if (mDialogParent) { if (mDialogParent) {
// If we're in a dialog // If we're in a dialog
SetSizeHints(mCurrentTotalSize, mCurrentTotalSize); SetMinSize(mCurrentTotalSize);
SetMaxSize(mCurrentTotalSize);
SetSize(mCurrentTotalSize); SetSize(mCurrentTotalSize);
GetParent()->Fit(); GetParent()->Fit();
@ -457,7 +460,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize)
mExtraPanel->Show(); mExtraPanel->Show();
} }
mExtraPanel->SetSizeHints(mCurrentDrawerSize, mCurrentDrawerSize); mExtraPanel->SetMinSize(mCurrentDrawerSize);
mExtraPanel->SetMaxSize(mCurrentDrawerSize);
mExtraPanel->SetSize(mCurrentDrawerSize); mExtraPanel->SetSize(mCurrentDrawerSize);
if (mCurrentDrawerSize.y == 0) if (mCurrentDrawerSize.y == 0)
@ -680,8 +684,8 @@ ToolBarGrabber::ToolBarGrabber(wxWindow *parent,
images[1], images[1],
magicColor); magicColor);
SetSizeHints(mImageRoll[0].GetMinSize(), SetMinSize(mImageRoll[0].GetMinSize());
mImageRoll[1].GetMaxSize()); SetMaxSize(mImageRoll[1].GetMaxSize());
#endif #endif
mState = 0; mState = 0;
} }
@ -1094,7 +1098,8 @@ void ToolBarArea::Fit(bool horizontal, bool vertical)
maxSize != mMaxSize) { maxSize != mMaxSize) {
mMinSize = minSize; mMinSize = minSize;
mMaxSize = maxSize; mMaxSize = maxSize;
SetSizeHints(mMinSize, mMaxSize); SetMinSize(mMinSize);
SetMaxSize(mMaxSize);
} }
if (actualSize != mActualSize) { if (actualSize != mActualSize) {
mActualSize = actualSize; mActualSize = actualSize;

View File

@ -435,8 +435,8 @@ ImageRollPanel::ImageRollPanel(wxWindow *parent,
//mImageRoll(imgRoll), //mImageRoll(imgRoll),
mLogicalFunction(wxCOPY) mLogicalFunction(wxCOPY)
{ {
// SetSizeHints(mImageRoll.GetMinSize(), // SetMinSize(mImageRoll.GetMinSize());
// mImageRoll.GetMaxSize()); // SetMaxSize(mImageRoll.GetMaxSize());
} }
void ImageRollPanel::SetLogicalFunction(int /*wxRasterOperationMode*/ func) void ImageRollPanel::SetLogicalFunction(int /*wxRasterOperationMode*/ func)