mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-02 15:13:50 +01:00
Don't increase width when a toolbar is repeatedly docked and undocked
This commit is contained in:
@@ -80,6 +80,9 @@ enum
|
|||||||
ToolBarCount
|
ToolBarCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// How may pixels padding each side of a floating toolbar
|
||||||
|
enum { ToolBarFloatMargin = 1 };
|
||||||
|
|
||||||
class ToolBar /* not final */ : public wxPanel
|
class ToolBar /* not final */ : public wxPanel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -129,14 +129,19 @@ int ToolDock::GetBarCount()
|
|||||||
//
|
//
|
||||||
// Handle ToolDock events
|
// 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
|
// Adopt the toolbar into our family
|
||||||
bar->Reparent( this );
|
bar->Reparent( this );
|
||||||
mBars[ bar->GetId() ] = bar;
|
mBars[ bar->GetId() ] = bar;
|
||||||
|
|
||||||
// Reset height
|
// Reset size
|
||||||
bar->SetSize( bar->GetSize().x, bar->GetDockedSize().y );
|
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
|
// Park the NEW bar in the correct berth
|
||||||
if( before >= 0 && before < (int)mDockedBars.GetCount() )
|
if( before >= 0 && before < (int)mDockedBars.GetCount() )
|
||||||
|
@@ -60,7 +60,7 @@ class ToolDock final : public wxPanel
|
|||||||
int Find(ToolBar *bar) const;
|
int Find(ToolBar *bar) const;
|
||||||
int GetOrder( ToolBar *bar );
|
int GetOrder( ToolBar *bar );
|
||||||
int GetBarCount();
|
int GetBarCount();
|
||||||
void Dock( ToolBar *bar, int ndx = -1 );
|
void Dock( ToolBar *bar, bool deflate, int ndx = -1 );
|
||||||
void Undock( ToolBar *bar );
|
void Undock( ToolBar *bar );
|
||||||
int PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect );
|
int PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect );
|
||||||
|
|
||||||
|
@@ -136,7 +136,8 @@ class ToolFrame final : public wxFrame
|
|||||||
width += sizerW;
|
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
|
// Attach the sizer and resize the window to fit
|
||||||
SetSizer(s.release());
|
SetSizer(s.release());
|
||||||
@@ -557,7 +558,7 @@ void ToolManager::Reset()
|
|||||||
if( dock != NULL )
|
if( dock != NULL )
|
||||||
{
|
{
|
||||||
// when we dock, we reparent, so bar is no longer a child of floater.
|
// when we dock, we reparent, so bar is no longer a child of floater.
|
||||||
dock->Dock( bar );
|
dock->Dock( bar, false );
|
||||||
Expose( ndx, expose );
|
Expose( ndx, expose );
|
||||||
//OK (and good) to DELETE floater, as bar is no longer in it.
|
//OK (and good) to DELETE floater, as bar is no longer in it.
|
||||||
if( floater )
|
if( floater )
|
||||||
@@ -783,7 +784,7 @@ void ToolManager::ReadConfig()
|
|||||||
ToolBar *t = mBars[ ndx ];
|
ToolBar *t = mBars[ ndx ];
|
||||||
|
|
||||||
// Dock it
|
// Dock it
|
||||||
d->Dock( t );
|
d->Dock( t, false );
|
||||||
|
|
||||||
// Show or hide it
|
// Show or hide it
|
||||||
Expose( t->GetId(), show[ t->GetId() ] );
|
Expose( t->GetId(), show[ t->GetId() ] );
|
||||||
@@ -796,7 +797,7 @@ void ToolManager::ReadConfig()
|
|||||||
ToolBar *t = mBars[ unordered[ dock ][ ord ] ];
|
ToolBar *t = mBars[ unordered[ dock ][ ord ] ];
|
||||||
|
|
||||||
// Dock it
|
// Dock it
|
||||||
d->Dock( t );
|
d->Dock( t, false );
|
||||||
|
|
||||||
// Show or hide the bar
|
// Show or hide the bar
|
||||||
Expose( t->GetId(), show[ t->GetId() ] );
|
Expose( t->GetId(), show[ t->GetId() ] );
|
||||||
@@ -1017,7 +1018,7 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
|||||||
if( mDragDock && !event.ShiftDown() )
|
if( mDragDock && !event.ShiftDown() )
|
||||||
{
|
{
|
||||||
// Trip over...everyone ashore that's going ashore...
|
// Trip over...everyone ashore that's going ashore...
|
||||||
mDragDock->Dock( mDragBar, mDragBefore );
|
mDragDock->Dock( mDragBar, true, mDragBefore );
|
||||||
|
|
||||||
// Done with the floater
|
// Done with the floater
|
||||||
mDragWindow->Destroy();
|
mDragWindow->Destroy();
|
||||||
@@ -1303,7 +1304,7 @@ void ToolManager::HandleEscapeKey()
|
|||||||
// Why don't you leave me alone?
|
// Why don't you leave me alone?
|
||||||
// Well, I feel so break up
|
// Well, I feel so break up
|
||||||
// I want to go home.
|
// I want to go home.
|
||||||
mPrevDock->Dock( mDragBar, mPrevSlot );
|
mPrevDock->Dock( mDragBar, true, mPrevSlot );
|
||||||
|
|
||||||
// Done with the floater
|
// Done with the floater
|
||||||
mDragWindow->Destroy();
|
mDragWindow->Destroy();
|
||||||
|
Reference in New Issue
Block a user