mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-07 16:07:44 +02:00
Small fixes for toolbar docking, before the larger project
This commit is contained in:
commit
59c3482798
@ -359,7 +359,7 @@ void ToolBar::SetLabel(const wxString & label)
|
|||||||
//
|
//
|
||||||
// Returns whether the toolbar is resizable or not
|
// Returns whether the toolbar is resizable or not
|
||||||
//
|
//
|
||||||
bool ToolBar::IsResizable()
|
bool ToolBar::IsResizable() const
|
||||||
{
|
{
|
||||||
return mResizable;
|
return mResizable;
|
||||||
}
|
}
|
||||||
@ -367,7 +367,7 @@ bool ToolBar::IsResizable()
|
|||||||
//
|
//
|
||||||
// Returns the dock state of the toolbar
|
// Returns the dock state of the toolbar
|
||||||
//
|
//
|
||||||
bool ToolBar::IsDocked()
|
bool ToolBar::IsDocked() const
|
||||||
{
|
{
|
||||||
return mDock != NULL;
|
return mDock != NULL;
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ bool ToolBar::IsDocked()
|
|||||||
//
|
//
|
||||||
// Returns the visibility of the toolbar
|
// Returns the visibility of the toolbar
|
||||||
//
|
//
|
||||||
bool ToolBar::IsVisible()
|
bool ToolBar::IsVisible() const
|
||||||
{
|
{
|
||||||
return mVisible;
|
return mVisible;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -110,9 +113,9 @@ class ToolBar /* not final */ : public wxPanel
|
|||||||
// NEW virtual:
|
// NEW virtual:
|
||||||
virtual bool Expose(bool show = true);
|
virtual bool Expose(bool show = true);
|
||||||
|
|
||||||
bool IsResizable();
|
bool IsResizable() const;
|
||||||
bool IsVisible();
|
bool IsVisible() const;
|
||||||
bool IsDocked();
|
bool IsDocked() const;
|
||||||
bool IsPositioned(){ return mPositioned; };
|
bool IsPositioned(){ return mPositioned; };
|
||||||
void SetVisible( bool bVisible );
|
void SetVisible( bool bVisible );
|
||||||
void SetPositioned(){ mPositioned = true;};
|
void SetPositioned(){ mPositioned = true;};
|
||||||
|
@ -121,22 +121,22 @@ void ToolDock::Undock( ToolBar *bar )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolDock::GetBarCount()
|
|
||||||
{
|
|
||||||
return mDockedBars.GetCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 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() )
|
||||||
|
@ -59,8 +59,7 @@ class ToolDock final : public wxPanel
|
|||||||
void Expose( int type, bool show );
|
void Expose( int type, bool show );
|
||||||
int Find(ToolBar *bar) const;
|
int Find(ToolBar *bar) const;
|
||||||
int GetOrder( ToolBar *bar );
|
int GetOrder( ToolBar *bar );
|
||||||
int GetBarCount();
|
void Dock( ToolBar *bar, bool deflate, int ndx = -1 );
|
||||||
void Dock( ToolBar *bar, 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 );
|
||||||
|
|
||||||
@ -74,18 +73,6 @@ class ToolDock final : public wxPanel
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReadConfig();
|
|
||||||
void WriteConfig();
|
|
||||||
|
|
||||||
int FlowLayout( int cnt,
|
|
||||||
wxRect boxen[],
|
|
||||||
wxRect ideal[],
|
|
||||||
int i,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height );
|
|
||||||
|
|
||||||
void Updated();
|
void Updated();
|
||||||
|
|
||||||
int mTotalToolBarHeight;
|
int mTotalToolBarHeight;
|
||||||
|
@ -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();
|
||||||
@ -1087,15 +1088,18 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
|||||||
// Decide which direction the arrow should point
|
// Decide which direction the arrow should point
|
||||||
if( r.GetTop() >= dr.GetHeight() )
|
if( r.GetTop() >= dr.GetHeight() )
|
||||||
{
|
{
|
||||||
p.x = dr.GetLeft() + ( dr.GetWidth() / 2 );
|
const auto &box = mDown->GetBox();
|
||||||
p.y = dr.GetBottom() - mDown->GetBox().GetHeight();
|
p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
|
||||||
|
- (box.GetWidth() / 2);
|
||||||
|
p.y = dr.GetBottom() - box.GetHeight();
|
||||||
mCurrent = mDown;
|
mCurrent = mDown;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const auto &box = mLeft->GetBox();
|
||||||
p.x = dr.GetLeft() + r.GetLeft();
|
p.x = dr.GetLeft() + r.GetLeft();
|
||||||
p.y = dr.GetTop() + r.GetTop() + mLeft->GetBox().GetHeight() / 2;
|
p.y = dr.GetTop() + r.GetTop() +
|
||||||
//JKC ( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
|
( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
|
||||||
mCurrent = mLeft;
|
mCurrent = mLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1303,7 +1307,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();
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "ToolDock.h"
|
#include "ToolDock.h"
|
||||||
#include "ToolBar.h"
|
#include "ToolBar.h"
|
||||||
|
|
||||||
class wxArrayPtrVoid;
|
|
||||||
class wxBitmap;
|
class wxBitmap;
|
||||||
class wxCommandEvent;
|
class wxCommandEvent;
|
||||||
class wxFrame;
|
class wxFrame;
|
||||||
@ -108,7 +107,6 @@ class ToolManager final : public wxEvtHandler
|
|||||||
bool mTransition;
|
bool mTransition;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxArrayPtrVoid mDockedBars;
|
|
||||||
ToolDock *mTopDock;
|
ToolDock *mTopDock;
|
||||||
ToolDock *mBotDock;
|
ToolDock *mBotDock;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user