1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-19 14:17:41 +02:00

Don't increase width when a toolbar is repeatedly docked and undocked

This commit is contained in:
Paul Licameli 2016-06-11 16:29:25 -04:00
parent 9e74613a8e
commit 82cf9b3ab6
4 changed files with 19 additions and 10 deletions

View File

@ -80,6 +80,9 @@ enum
ToolBarCount
};
// How may pixels padding each side of a floating toolbar
enum { ToolBarFloatMargin = 1 };
class ToolBar /* not final */ : public wxPanel
{

View File

@ -129,14 +129,19 @@ int ToolDock::GetBarCount()
//
// Handle ToolDock events
//
void ToolDock::Dock( ToolBar *bar, int before )
void ToolDock::Dock( ToolBar *bar, bool deflate, int before )
{
// Adopt the toolbar into our family
bar->Reparent( this );
mBars[ bar->GetId() ] = bar;
// Reset height
bar->SetSize( bar->GetSize().x, bar->GetDockedSize().y );
// Reset size
bar->SetSize(
// Undo the expansion that was applied when un-docking
bar->GetSize().x - (deflate ? 2 * ToolBarFloatMargin : 0),
// Don't need to adjust y the same way.
bar->GetDockedSize().y
);
// Park the NEW bar in the correct berth
if( before >= 0 && before < (int)mDockedBars.GetCount() )

View File

@ -60,7 +60,7 @@ class ToolDock final : public wxPanel
int Find(ToolBar *bar) const;
int GetOrder( ToolBar *bar );
int GetBarCount();
void Dock( ToolBar *bar, int ndx = -1 );
void Dock( ToolBar *bar, bool deflate, int ndx = -1 );
void Undock( ToolBar *bar );
int PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect );

View File

@ -136,7 +136,8 @@ class ToolFrame final : public wxFrame
width += sizerW;
}
SetSize(width + 2, bar->GetDockedSize().y + 2);
SetSize(width + 2 * ToolBarFloatMargin,
bar->GetDockedSize().y + 2 * ToolBarFloatMargin);
// Attach the sizer and resize the window to fit
SetSizer(s.release());
@ -557,7 +558,7 @@ void ToolManager::Reset()
if( dock != NULL )
{
// when we dock, we reparent, so bar is no longer a child of floater.
dock->Dock( bar );
dock->Dock( bar, false );
Expose( ndx, expose );
//OK (and good) to DELETE floater, as bar is no longer in it.
if( floater )
@ -783,7 +784,7 @@ void ToolManager::ReadConfig()
ToolBar *t = mBars[ ndx ];
// Dock it
d->Dock( t );
d->Dock( t, false );
// Show or hide it
Expose( t->GetId(), show[ t->GetId() ] );
@ -796,7 +797,7 @@ void ToolManager::ReadConfig()
ToolBar *t = mBars[ unordered[ dock ][ ord ] ];
// Dock it
d->Dock( t );
d->Dock( t, false );
// Show or hide the bar
Expose( t->GetId(), show[ t->GetId() ] );
@ -1017,7 +1018,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
if( mDragDock && !event.ShiftDown() )
{
// Trip over...everyone ashore that's going ashore...
mDragDock->Dock( mDragBar, mDragBefore );
mDragDock->Dock( mDragBar, true, mDragBefore );
// Done with the floater
mDragWindow->Destroy();
@ -1303,7 +1304,7 @@ void ToolManager::HandleEscapeKey()
// Why don't you leave me alone?
// Well, I feel so break up
// I want to go home.
mPrevDock->Dock( mDragBar, mPrevSlot );
mPrevDock->Dock( mDragBar, true, mPrevSlot );
// Done with the floater
mDragWindow->Destroy();