1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-30 07:29:29 +02:00

Some small fixes for dragging of toolbars

This commit is contained in:
Paul Licameli 2018-09-15 18:24:29 -04:00
commit 20b7a495ce
2 changed files with 24 additions and 21 deletions

View File

@ -147,22 +147,27 @@ void ToolBarConfiguration::Insert(ToolBar *bar, Position position)
// Insert as a leaf, or as an internal node?
if (adopt && position.adopt) {
// Existing child of parent become its grandchild
// TODO: is it ever correct to adopt more than one, depending on
// heights? Could an inserted tall bar adopt two short ones?
// Existing children of parent become grandchildren
// Make NEW node
Tree tree;
tree.pBar = bar;
// Do adoption
tree.children.push_back(Tree{});
auto &child = tree.children.back();
child.pBar = iter->pBar;
child.children.swap(iter->children);
const auto barHeight = bar->GetSize().GetY() + toolbarGap;
auto totalHeight = 0;
while (iter != pForest->end() &&
barHeight >=
(totalHeight += (iter->pBar->GetSize().GetY() + toolbarGap))) {
tree.children.push_back(Tree{});
auto &child = tree.children.back();
child.pBar = iter->pBar;
child.children.swap(iter->children);
iter = pForest->erase(iter);
}
// Put the node in the tree
iter = pForest->insert(iter, Tree{});
(*iter).swap(tree);
}
else
@ -435,11 +440,6 @@ void ToolDock::Dock( ToolBar *bar, bool deflate, ToolBarConfiguration::Position
// Inform toolbar of change
bar->SetDocked( this, false );
// Rearrange our world
if (bar->IsVisible())
LayoutToolBars();
Updated();
}
// Initial docking of bars
@ -453,6 +453,7 @@ void ToolDock::LoadConfig()
// configuration
Expose( bar->GetId(), true );
}
Updated();
}
// A policy object for the skeleton routine below
@ -842,10 +843,6 @@ void ToolDock::Expose( int type, bool show )
// Make it (dis)appear
t->Expose( show );
// Update the layout
LayoutToolBars();
Updated();
}
//

View File

@ -538,6 +538,13 @@ void ToolManager::Reset()
else
dock = mTopDock;
// PRL: Destroy the tool frame before recreating buttons.
// This fixes some subtle sizing problems on macOs.
bar->Reparent( dock );
//OK (and good) to DELETE floater, as bar is no longer in it.
if( floater )
floater->Destroy();
// Recreate bar buttons (and resize it)
bar->ReCreateButtons();
bar->EnableDisableButtons();
@ -571,9 +578,6 @@ void ToolManager::Reset()
// when we dock, we reparent, so bar is no longer a child of floater.
dock->Dock( bar, false, position );
Expose( ndx, expose );
//OK (and good) to DELETE floater, as bar is no longer in it.
if( floater )
floater->Destroy();
}
else
{
@ -606,7 +610,6 @@ void ToolManager::Reset()
// It would be nice to show them again, but hardly essential as
// they will show up again on the next play.
// SetVUMeters(AudacityProject *p);
LayoutToolBars();
Updated();
}
@ -1057,6 +1060,7 @@ bool ToolManager::IsVisible( int type )
void ToolManager::ShowHide( int type )
{
Expose( type, !mBars[ type ]->IsVisible() );
Updated();
}
//
@ -1142,6 +1146,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
{
// Trip over...everyone ashore that's going ashore...
mDragDock->Dock( mDragBar, true, mDragBefore );
Updated();
mDragWindow->ClearBar();
// Done with the floater
@ -1457,6 +1462,7 @@ void ToolManager::HandleEscapeKey()
// I want to go home.
mPrevDock->RestoreConfiguration(mPrevConfiguration);
mPrevDock->Dock( mDragBar, true, mPrevSlot );
Updated();
// Done with the floater
mDragWindow->ClearBar();