From 9404a289542d8f651bd5f3c8e04b6d7bafb5860e Mon Sep 17 00:00:00 2001 From: "lllucius@gmail.com" Date: Sat, 20 Dec 2014 20:08:45 +0000 Subject: [PATCH] Fix missing toolbars at startup on Linux The problem was that on Linux (not Windows or Mac) menu events are generated when checking the menu items in the toolbar menu. Becuase of the recent changes I made and how the toolbars are being shown (toggled) when the toolbar menu is checked, they were simply being hidden. Actually, the were being shown and then hidden because of the toggle. So, with this change I made exposing toolbars a bit more deterministic. The menus still use a toggle, but the ToolManager now shows or hides the bars explicitly during setup, so the menu toggle issue is resolved. --- src/Menus.cpp | 8 +++--- src/toolbars/ToolDock.cpp | 25 ------------------ src/toolbars/ToolDock.h | 1 - src/toolbars/ToolManager.cpp | 51 +++++++----------------------------- src/toolbars/ToolManager.h | 2 +- 5 files changed, 15 insertions(+), 72 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 29d412954..3f2fd9b4d 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -5114,8 +5114,8 @@ void AudacityProject::OnShowMeterToolBar() { if( !mToolManager->IsVisible( MeterBarID ) ) { - mToolManager->Hide( PlayMeterBarID ); - mToolManager->Hide( RecordMeterBarID ); + mToolManager->Expose( PlayMeterBarID, false ); + mToolManager->Expose( RecordMeterBarID, false ); } mToolManager->ShowHide( MeterBarID ); ModifyToolbarMenus(); @@ -5125,7 +5125,7 @@ void AudacityProject::OnShowRecordMeterToolBar() { if( !mToolManager->IsVisible( RecordMeterBarID ) ) { - mToolManager->Hide( MeterBarID ); + mToolManager->Expose( MeterBarID, false ); } mToolManager->ShowHide( RecordMeterBarID ); ModifyToolbarMenus(); @@ -5135,7 +5135,7 @@ void AudacityProject::OnShowPlayMeterToolBar() { if( !mToolManager->IsVisible( PlayMeterBarID ) ) { - mToolManager->Hide( MeterBarID ); + mToolManager->Expose( MeterBarID, false ); } mToolManager->ShowHide( PlayMeterBarID ); ModifyToolbarMenus(); diff --git a/src/toolbars/ToolDock.cpp b/src/toolbars/ToolDock.cpp index 76e1cc208..c1d1ee2ab 100644 --- a/src/toolbars/ToolDock.cpp +++ b/src/toolbars/ToolDock.cpp @@ -416,31 +416,6 @@ int ToolDock::PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect ) return tindx; } -// -// Toggles the visible/hidden state of a toolbar -// -void ToolDock::ShowHide( int type ) -{ - ToolBar *t = mBars[ type ]; - - // Maintain the docked array - if( t->IsVisible() ) - { - mDockedBars.Remove( t ); - } - else - { - mDockedBars.Add( t ); - } - - // Make it (dis)appear - t->Expose( !t->IsVisible() ); - - // Update the layout - LayoutToolBars(); - Updated(); -} - // // Set the visible/hidden state of a toolbar // diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h index ba3e03e87..d0146e25a 100644 --- a/src/toolbars/ToolDock.h +++ b/src/toolbars/ToolDock.h @@ -54,7 +54,6 @@ class ToolDock:public wxPanel ~ToolDock(); void LayoutToolBars(); - void ShowHide( int type ); void Expose( int type, bool show ); int GetOrder( ToolBar *bar ); int GetBarCount(); diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 61da33197..bb7f856a3 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -546,7 +546,7 @@ void ToolManager::Reset() floater->CentreOnParent( ); floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 )); bar->SetDocked( NULL, false ); - bar->Expose( false ); + Expose( ndx, false ); } } @@ -715,11 +715,11 @@ void ToolManager::ReadConfig() bar->SetPositioned(); } - // Show or hide it - bar->Expose( show[ ndx ] ); - // Inform toolbar of change bar->SetDocked( NULL, false ); + + // Show or hide it + Expose( ndx, show[ ndx ] ); } // Change back to the bar root @@ -746,16 +746,9 @@ void ToolManager::ReadConfig() // Dock it d->Dock( t ); - - // Hide the bar - if( !show[ t->GetId() ] ) - { - d->ShowHide( t->GetId() ); - } - else - { - t->Expose( show[ ndx ] ); - } + + // Show or hide it + Expose( t->GetId(), show[ t->GetId() ] ); } } @@ -767,15 +760,8 @@ void ToolManager::ReadConfig() // Dock it d->Dock( t ); - // Hide the bar - if( !show[ t->GetId() ] ) - { - d->ShowHide( t->GetId() ); - } - else - { - t->Expose( show[ ndx ] ); - } + // Show or hide the bar + Expose( t->GetId(), show[ t->GetId() ] ); } } @@ -915,24 +901,7 @@ bool ToolManager::IsVisible( int type ) // void ToolManager::ShowHide( int type ) { - ToolBar *t = mBars[ type ]; - - // Handle docked and floaters differently - if( t->IsDocked() ) - { - t->GetDock()->ShowHide( type ); - } - else - { - t->Expose( !t->IsVisible() ); - } -} - -void ToolManager::Hide( int type ) -{ - if( !IsVisible( type ) ) - return; - ShowHide( type ); + Expose( type, !mBars[ type ]->IsVisible() ); } // diff --git a/src/toolbars/ToolManager.h b/src/toolbars/ToolManager.h index 770a739d0..8ea472d16 100644 --- a/src/toolbars/ToolManager.h +++ b/src/toolbars/ToolManager.h @@ -57,7 +57,7 @@ class ToolManager:public wxEvtHandler bool IsVisible( int type ); void ShowHide( int type ); - void Hide( int type ); + void Expose( int type, bool show ); ToolBar *GetToolBar( int type ) const;