mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-21 14:50:06 +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;
|
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;
|
int ord;
|
||||||
gPrefs->Read( wxT("Order"), &ord, -1 );
|
gPrefs->Read( wxT("Order"), &ord, -1 );
|
||||||
// Index was written 1-based
|
// 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,8 +376,8 @@ void ToolDock::Undock( ToolBar *bar )
|
|||||||
if( mConfiguration.Contains( bar ) )
|
if( mConfiguration.Contains( bar ) )
|
||||||
{
|
{
|
||||||
mConfiguration.Remove( bar );
|
mConfiguration.Remove( bar );
|
||||||
mBars[ bar->GetId() ] = nullptr;
|
|
||||||
}
|
}
|
||||||
|
mBars[ bar->GetId() ] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -403,13 +403,14 @@ void ToolDock::Dock( ToolBar *bar, bool deflate, ToolBarConfiguration::Position
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Park the NEW bar in the correct berth
|
// Park the NEW bar in the correct berth
|
||||||
if (!mConfiguration.Contains(bar))
|
if (!mConfiguration.Contains(bar) && bar->IsVisible())
|
||||||
mConfiguration.Insert( bar, position );
|
mConfiguration.Insert( bar, position );
|
||||||
|
|
||||||
// Inform toolbar of change
|
// Inform toolbar of change
|
||||||
bar->SetDocked( this, false );
|
bar->SetDocked( this, false );
|
||||||
|
|
||||||
// Rearrange our world
|
// Rearrange our world
|
||||||
|
if (bar->IsVisible())
|
||||||
LayoutToolBars();
|
LayoutToolBars();
|
||||||
Updated();
|
Updated();
|
||||||
}
|
}
|
||||||
|
@ -681,6 +681,7 @@ void ToolManager::ReadConfig()
|
|||||||
{
|
{
|
||||||
wxString oldpath = gPrefs->GetPath();
|
wxString oldpath = gPrefs->GetPath();
|
||||||
wxArrayInt unordered[ DockCount ];
|
wxArrayInt unordered[ DockCount ];
|
||||||
|
std::vector<ToolBar*> dockedAndHidden;
|
||||||
bool show[ ToolBarCount ];
|
bool show[ ToolBarCount ];
|
||||||
int width[ ToolBarCount ];
|
int width[ ToolBarCount ];
|
||||||
int height[ ToolBarCount ];
|
int height[ ToolBarCount ];
|
||||||
@ -808,6 +809,9 @@ void ToolManager::ReadConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// make a note of docked and hidden toolbars
|
||||||
|
if (!show[ndx])
|
||||||
|
dockedAndHidden.push_back(bar);
|
||||||
|
|
||||||
if (!ordered)
|
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
|
// Restore original config path
|
||||||
gPrefs->SetPath( oldpath );
|
gPrefs->SetPath( oldpath );
|
||||||
|
|
||||||
@ -958,8 +969,10 @@ void ToolManager::WriteConfig()
|
|||||||
bool bo = mBotDock->GetConfiguration().Contains( bar );
|
bool bo = mBotDock->GetConfiguration().Contains( bar );
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
gPrefs->Write( wxT("Dock"), (int) (to ? TopDockID : bo ? BotDockID : NoDockID ));
|
ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars
|
||||||
auto dock = to ? mTopDock : bo ? mBotDock : nullptr;
|
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
|
ToolBarConfiguration::Write
|
||||||
(dock ? &dock->GetConfiguration() : nullptr, bar);
|
(dock ? &dock->GetConfiguration() : nullptr, bar);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user