diff --git a/src/toolbars/ToolBar.cpp b/src/toolbars/ToolBar.cpp index 422d9c751474a5ad581eeb46972cc3b203ad0df8..21c83ddd3b8a00c2921a4ec49f3b116c6c305b03 100644 --- a/src/toolbars/ToolBar.cpp +++ b/src/toolbars/ToolBar.cpp @@ -459,6 +459,13 @@ void ToolBar::Create( wxWindow *parent ) mVisible = true; } +void ToolBar::SetToDefaultSize(){ + wxSize sz; + sz.SetHeight( -1 ); + sz.SetWidth( GetInitialWidth()); + SetSize( sz ); +} + void ToolBar::ReCreateButtons() { wxSize sz3 = GetSize(); @@ -519,12 +526,18 @@ void ToolBar::ReCreateButtons() sz2.SetWidth(GetMinToolbarWidth()); sz2.y = tbs -1; SetMinSize(sz2); - // Initial size at least as big as minimum. + + // sz2 is now the minimum size. + // sz3 is the size we were. + // When recreating buttons, we want to preserve size. + // But not if that makes the size too small. + + // Size at least as big as minimum. if( sz3.y < sz2.y ) sz3.y = sz2.y; - //if( sz3.x < sz2.x ) - sz3.x = GetInitialWidth(); - //sz.SetWidth(); + if( sz3.x < sz2.x ) + sz3.x = sz2.x; + SetSize(sz3); } else diff --git a/src/toolbars/ToolBar.h b/src/toolbars/ToolBar.h index 7796eadd5f0ded4b9229ca4982c55bd09d99a288..e4a91dc3f5cc16d463f4943334d456935d97cc02 100644 --- a/src/toolbars/ToolBar.h +++ b/src/toolbars/ToolBar.h @@ -96,6 +96,7 @@ class ToolBar /* not final */ : public wxPanelWrapper bool AcceptsFocus() const override { return false; }; + void SetToDefaultSize(); //NEW virtuals: virtual void Create(wxWindow *parent); virtual void EnableDisableButtons() = 0; diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index a3880af7c6d96a31f897a562006f67a9412a0900..fa3bcc8885e03b9a59d0609e88262b65478a18fa 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -546,6 +546,7 @@ void ToolManager::Reset() floater->Destroy(); // Recreate bar buttons (and resize it) + bar->SetToDefaultSize(); bar->ReCreateButtons(); bar->EnableDisableButtons();