mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +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
|
||||
//
|
||||
bool ToolBar::IsResizable()
|
||||
bool ToolBar::IsResizable() const
|
||||
{
|
||||
return mResizable;
|
||||
}
|
||||
@ -367,7 +367,7 @@ bool ToolBar::IsResizable()
|
||||
//
|
||||
// Returns the dock state of the toolbar
|
||||
//
|
||||
bool ToolBar::IsDocked()
|
||||
bool ToolBar::IsDocked() const
|
||||
{
|
||||
return mDock != NULL;
|
||||
}
|
||||
@ -375,7 +375,7 @@ bool ToolBar::IsDocked()
|
||||
//
|
||||
// Returns the visibility of the toolbar
|
||||
//
|
||||
bool ToolBar::IsVisible()
|
||||
bool ToolBar::IsVisible() const
|
||||
{
|
||||
return mVisible;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
@ -110,9 +113,9 @@ class ToolBar /* not final */ : public wxPanel
|
||||
// NEW virtual:
|
||||
virtual bool Expose(bool show = true);
|
||||
|
||||
bool IsResizable();
|
||||
bool IsVisible();
|
||||
bool IsDocked();
|
||||
bool IsResizable() const;
|
||||
bool IsVisible() const;
|
||||
bool IsDocked() const;
|
||||
bool IsPositioned(){ return mPositioned; };
|
||||
void SetVisible( bool bVisible );
|
||||
void SetPositioned(){ mPositioned = true;};
|
||||
|
@ -121,22 +121,22 @@ void ToolDock::Undock( ToolBar *bar )
|
||||
}
|
||||
}
|
||||
|
||||
int ToolDock::GetBarCount()
|
||||
{
|
||||
return mDockedBars.GetCount();
|
||||
}
|
||||
|
||||
//
|
||||
// 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() )
|
||||
|
@ -59,8 +59,7 @@ class ToolDock final : public wxPanel
|
||||
void Expose( int type, bool show );
|
||||
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 );
|
||||
|
||||
@ -74,18 +73,6 @@ class ToolDock final : public wxPanel
|
||||
|
||||
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();
|
||||
|
||||
int mTotalToolBarHeight;
|
||||
|
@ -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();
|
||||
@ -1087,15 +1088,18 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
||||
// Decide which direction the arrow should point
|
||||
if( r.GetTop() >= dr.GetHeight() )
|
||||
{
|
||||
p.x = dr.GetLeft() + ( dr.GetWidth() / 2 );
|
||||
p.y = dr.GetBottom() - mDown->GetBox().GetHeight();
|
||||
const auto &box = mDown->GetBox();
|
||||
p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
|
||||
- (box.GetWidth() / 2);
|
||||
p.y = dr.GetBottom() - box.GetHeight();
|
||||
mCurrent = mDown;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto &box = mLeft->GetBox();
|
||||
p.x = dr.GetLeft() + r.GetLeft();
|
||||
p.y = dr.GetTop() + r.GetTop() + mLeft->GetBox().GetHeight() / 2;
|
||||
//JKC ( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
|
||||
p.y = dr.GetTop() + r.GetTop() +
|
||||
( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
|
||||
mCurrent = mLeft;
|
||||
}
|
||||
|
||||
@ -1303,7 +1307,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();
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "ToolDock.h"
|
||||
#include "ToolBar.h"
|
||||
|
||||
class wxArrayPtrVoid;
|
||||
class wxBitmap;
|
||||
class wxCommandEvent;
|
||||
class wxFrame;
|
||||
@ -108,7 +107,6 @@ class ToolManager final : public wxEvtHandler
|
||||
bool mTransition;
|
||||
#endif
|
||||
|
||||
wxArrayPtrVoid mDockedBars;
|
||||
ToolDock *mTopDock;
|
||||
ToolDock *mBotDock;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user