From 7661d179ba864f54527997ce56c9181cd1504f9d Mon Sep 17 00:00:00 2001 From: James Crook Date: Thu, 27 Apr 2017 09:51:34 +0100 Subject: [PATCH] Send size event after repopulating MeterToolbar buttons. If we don't do this, it does not regain its former size, if it is floating. --- src/prefs/PrefsDialog.cpp | 2 ++ src/toolbars/MeterToolBar.cpp | 6 +++++- src/toolbars/ToolBar.cpp | 13 ++++++++----- src/toolbars/ToolDock.h | 3 ++- src/toolbars/ToolManager.cpp | 3 ++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index ba61fde45..672d29618 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -394,6 +394,8 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) return; } + // flush now so toolbars will know their position. + gPrefs->Flush(); if (mCategories) { // Now apply the changes for (size_t i = 0; i < mCategories->GetPageCount(); i++) { diff --git a/src/toolbars/MeterToolBar.cpp b/src/toolbars/MeterToolBar.cpp index a0479eee6..229076a77 100644 --- a/src/toolbars/MeterToolBar.cpp +++ b/src/toolbars/MeterToolBar.cpp @@ -173,6 +173,10 @@ void MeterToolBar::UpdatePrefs() // Give base class a chance ToolBar::UpdatePrefs(); + + wxSizeEvent e; + GetParent()->GetEventHandler()->AddPendingEvent( e ); + } void MeterToolBar::RegenerateTooltips() @@ -226,7 +230,7 @@ void MeterToolBar::OnSize( wxSizeEvent & event) //WXUNUSED(event) ) mRecordMeter->SetMinSize( wxSize( width, height )); } if( mPlayMeter ) { - mPlayMeter->SetMinSize( wxSize( width, height )); + mPlayMeter->SetMinSize( wxSize( width, height)); mSizer->SetItemPosition( mPlayMeter, pos ); } diff --git a/src/toolbars/ToolBar.cpp b/src/toolbars/ToolBar.cpp index 0c8f7175d..706352759 100644 --- a/src/toolbars/ToolBar.cpp +++ b/src/toolbars/ToolBar.cpp @@ -484,9 +484,6 @@ void ToolBar::ReCreateButtons() // Use a box sizer for laying out controls ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND); - // (Re)Establish dock state - SetDocked(GetDock(), false); - // Go add all the rest of the gadgets Populate(); @@ -498,6 +495,10 @@ void ToolBar::ReCreateButtons() ms->Add(mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1); mResizer->SetToolTip(_("Click and drag to resize toolbar")); } + + // Set dock after possibly creating resizer. + // (Re)Establish dock state + SetDocked(GetDock(), false); // Set the sizer SetSizerAndFit(ms.release()); @@ -585,8 +586,10 @@ void ToolBar::SetDocked( ToolDock *dock, bool pushed ) // void ToolBar::Updated() { - wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() ); - GetParent()->GetEventHandler()->AddPendingEvent( e ); + if( IsDocked() ) + GetDock()->Updated(); + //wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() ); + //GetParent()->GetEventHandler()->AddPendingEvent( e ); } // diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h index bda379eaf..dbba69d6f 100644 --- a/src/toolbars/ToolDock.h +++ b/src/toolbars/ToolDock.h @@ -309,6 +309,7 @@ public: // Reverse what was done by WrapConfiguration. void RestoreConfiguration(ToolBarConfiguration &backup); + void Updated(); protected: @@ -323,7 +324,7 @@ public: void VisitLayout(LayoutVisitor &visitor, ToolBarConfiguration *pWrappedConfiguration = nullptr); - void Updated(); + int mTotalToolBarHeight; wxWindow *mParent; diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 97db021f7..66caccd86 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -170,8 +170,9 @@ void ToolFrame::OnGrabber( GrabberEvent & event ) void ToolFrame::OnToolBarUpdate( wxCommandEvent & event ) { // Resize floater window to exactly contain toolbar + // use actual size rather than minimum size. if (mBar) - mBar->GetParent()->SetClientSize( mBar->GetMinSize() ); + mBar->GetParent()->SetClientSize( mBar->GetSize() );// ->GetMinSize() ); // Allow it to propagate to our parent event.Skip();