From 7315af547f00fdf9f454978860869923516a035d Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 25 Jun 2016 23:34:26 -0400 Subject: [PATCH] Bug1424: Better positioned scrubbing tool bar with legacy .cfg file --- src/toolbars/ToolManager.cpp | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index fa50ab039..f367b01f6 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -835,10 +835,51 @@ void ToolManager::ReadConfig() d->LoadConfig(); // Add all unordered toolbars + bool deviceWasPositioned = false; for( int ord = 0; ord < (int) unordered[ dock ].GetCount(); ord++ ) { ToolBar *t = mBars[ unordered[ dock ][ ord ] ]; + if (deviceWasPositioned && + t->GetType() == DeviceBarID) + continue; + + if (someFound && + t->GetType() == ScrubbingBarID) { + // Special case code to put the NEW scrubbing toolbar where we + // want it, when audacity.cfg is present from an older version + ToolBar *lastRoot {}; + + // Change from the ideal configuration to the constrained one, + // just as when dragging and dropping + ToolBarConfiguration dummy; + mTopDock->WrapConfiguration(dummy); + + // Start a NEW row with just the scrubbing toolbar + auto &configuration = mTopDock->GetConfiguration(); + for (const auto place : configuration) + if (place.position.rightOf == nullptr) + lastRoot = place.pTree->pBar; + ToolBarConfiguration::Position position { + nullptr, lastRoot, false + }; + mTopDock->Dock(t, false, position); + + // Reposition the device toolbar, if it was docked above, + // right of scrubbing + const auto deviceToolBar = mBars[ DeviceBarID ]; + if (deviceToolBar->GetDock() == mTopDock) { + deviceToolBar->GetDock()->Undock(deviceToolBar); + position = { t, nullptr }; + mTopDock->Dock(deviceToolBar, false, position); + + // Remember not to place the device toolbar again + deviceWasPositioned = true; + } + + continue; + } + // Dock it d->Dock( t, false );