mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 16:49:41 +02:00
Fix for #1554: toolbars open undocked if previously hidden
Summary of fix: 1. In ToolManger::WriteConfig, for a docked toolbar which is hidden, the dock number is not set to the dock number rather than 0 (undocked) 2. In ToolManger::ReadConfig, for a hidden docked toolbar in the config, the toolbar is docked, but is not included in the dock's configuration.
This commit is contained in:
parent
731a2ac40c
commit
048c1b8c5a
@ -237,7 +237,11 @@ bool ToolBarConfiguration::Read
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if (pConfiguration) {
|
||||
// Future: might remember visibility in the configuration, not forgetting
|
||||
// positions of hidden bars.
|
||||
gPrefs->Read( wxT("Show"), &visible, defaultVisible);
|
||||
|
||||
if (pConfiguration && visible) {
|
||||
int ord;
|
||||
gPrefs->Read( wxT("Order"), &ord, -1 );
|
||||
// Index was written 1-based
|
||||
@ -267,10 +271,6 @@ bool ToolBarConfiguration::Read
|
||||
}
|
||||
}
|
||||
|
||||
// Future: might remember visibility in the configuration, not forgetting
|
||||
// positions of hidden bars.
|
||||
gPrefs->Read( wxT("Show"), &visible, defaultVisible);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -376,8 +376,8 @@ void ToolDock::Undock( ToolBar *bar )
|
||||
if( mConfiguration.Contains( bar ) )
|
||||
{
|
||||
mConfiguration.Remove( bar );
|
||||
mBars[ bar->GetId() ] = nullptr;
|
||||
}
|
||||
mBars[ bar->GetId() ] = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
@ -403,14 +403,15 @@ void ToolDock::Dock( ToolBar *bar, bool deflate, ToolBarConfiguration::Position
|
||||
);
|
||||
|
||||
// Park the NEW bar in the correct berth
|
||||
if (!mConfiguration.Contains(bar))
|
||||
if (!mConfiguration.Contains(bar) && bar->IsVisible())
|
||||
mConfiguration.Insert( bar, position );
|
||||
|
||||
// Inform toolbar of change
|
||||
bar->SetDocked( this, false );
|
||||
|
||||
// Rearrange our world
|
||||
LayoutToolBars();
|
||||
if (bar->IsVisible())
|
||||
LayoutToolBars();
|
||||
Updated();
|
||||
}
|
||||
|
||||
|
@ -681,6 +681,7 @@ void ToolManager::ReadConfig()
|
||||
{
|
||||
wxString oldpath = gPrefs->GetPath();
|
||||
wxArrayInt unordered[ DockCount ];
|
||||
std::vector<ToolBar*> dockedAndHidden;
|
||||
bool show[ ToolBarCount ];
|
||||
int width[ ToolBarCount ];
|
||||
int height[ ToolBarCount ];
|
||||
@ -808,6 +809,9 @@ void ToolManager::ReadConfig()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// make a note of docked and hidden toolbars
|
||||
if (!show[ndx])
|
||||
dockedAndHidden.push_back(bar);
|
||||
|
||||
if (!ordered)
|
||||
{
|
||||
@ -917,6 +921,13 @@ void ToolManager::ReadConfig()
|
||||
}
|
||||
}
|
||||
|
||||
// hidden docked toolbars
|
||||
for (auto bar : dockedAndHidden) {
|
||||
bar->SetVisible(false );
|
||||
bar->GetDock()->Dock(bar, false);
|
||||
bar->Expose(false);
|
||||
}
|
||||
|
||||
// Restore original config path
|
||||
gPrefs->SetPath( oldpath );
|
||||
|
||||
@ -958,8 +969,10 @@ void ToolManager::WriteConfig()
|
||||
bool bo = mBotDock->GetConfiguration().Contains( bar );
|
||||
|
||||
// Save
|
||||
gPrefs->Write( wxT("Dock"), (int) (to ? TopDockID : bo ? BotDockID : NoDockID ));
|
||||
auto dock = to ? mTopDock : bo ? mBotDock : nullptr;
|
||||
ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars
|
||||
gPrefs->Write( wxT("Dock"), static_cast<int>(dock == mTopDock ? TopDockID : dock == mBotDock ? BotDockID : NoDockID ));
|
||||
|
||||
dock = to ? mTopDock : bo ? mBotDock : nullptr; // dock for shown toolbars
|
||||
ToolBarConfiguration::Write
|
||||
(dock ? &dock->GetConfiguration() : nullptr, bar);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user