mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 23:30:07 +02:00
Enable yet more docking positions by wrapping the cofiguration
This commit is contained in:
parent
de17c1ac3a
commit
c101f4acdb
@ -441,8 +441,12 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
void ToolDock::VisitLayout(LayoutVisitor &visitor)
|
||||
void ToolDock::VisitLayout(LayoutVisitor &visitor,
|
||||
ToolBarConfiguration *pWrappedConfiguration)
|
||||
{
|
||||
if (pWrappedConfiguration)
|
||||
pWrappedConfiguration->Clear();
|
||||
|
||||
// Get size of our parent since we haven't been sized yet
|
||||
int width, height;
|
||||
GetParent()->GetClientSize( &width, &height );
|
||||
@ -459,10 +463,12 @@ void ToolDock::VisitLayout(LayoutVisitor &visitor)
|
||||
int myBarID { NoBarID };
|
||||
int parentBarID { NoBarID };
|
||||
ToolBar *lastSib {};
|
||||
ToolBar *lastWrappedChild {};
|
||||
wxRect rect;
|
||||
} layout[ ToolBarCount ];
|
||||
|
||||
ToolBar *lastRoot {};
|
||||
ToolBar *lastWrappedRoot {};
|
||||
|
||||
// Process all docked and visible toolbars
|
||||
for ( const auto &place : GetConfiguration() )
|
||||
@ -529,14 +535,26 @@ void ToolDock::VisitLayout(LayoutVisitor &visitor)
|
||||
if (!bTooWide && !bTooHigh)
|
||||
break;
|
||||
|
||||
if (pItem->parentBarID == NoBarID)
|
||||
if (pItem->parentBarID == NoBarID) {
|
||||
pItem = nullptr;
|
||||
pRect = &main;
|
||||
}
|
||||
else {
|
||||
pItem = &layout[ pItem->parentBarID ];
|
||||
pRect = &pItem->rect;
|
||||
}
|
||||
}
|
||||
|
||||
// Record where the toolbar wrapped
|
||||
ToolBar *& sib = pItem ? pItem->lastWrappedChild : lastWrappedRoot;
|
||||
ToolBarConfiguration::Position newPosition {
|
||||
pItem ? mBars[ pItem->myBarID ] : nullptr,
|
||||
sib
|
||||
};
|
||||
sib = ct;
|
||||
if (pWrappedConfiguration)
|
||||
pWrappedConfiguration->Insert(ct, newPosition);
|
||||
|
||||
// Place the toolbar at the upper left part of the rectangle.
|
||||
const auto cpos = pRect->GetPosition();
|
||||
visitor.Visit(ct, cpos);
|
||||
@ -576,7 +594,7 @@ void ToolDock::VisitLayout(LayoutVisitor &visitor)
|
||||
// Let the visitor determine size
|
||||
wxSize sz {};
|
||||
ToolBarConfiguration::Position
|
||||
position { mBars[ item.myBarID ] },
|
||||
position { mBars[ item.myBarID ], item.lastWrappedChild },
|
||||
prevPosition {};
|
||||
visitor.ModifySize(nullptr, globalRect, prevPosition, position, sz);
|
||||
int tw = sz.GetWidth() + toolbarGap;
|
||||
@ -636,7 +654,7 @@ void ToolDock::LayoutToolBars()
|
||||
} sizeSetter {
|
||||
this
|
||||
};
|
||||
VisitLayout(sizeSetter);
|
||||
VisitLayout(sizeSetter, &mWrappedConfiguration);
|
||||
|
||||
// Set tab order
|
||||
{
|
||||
@ -653,7 +671,6 @@ void ToolDock::LayoutToolBars()
|
||||
Refresh( false );
|
||||
}
|
||||
|
||||
//
|
||||
// Determine the position where a NEW bar would be placed
|
||||
//
|
||||
// 'rect' will be the rectangle for the dock marker.
|
||||
@ -750,6 +767,20 @@ ToolBarConfiguration::Position
|
||||
return result;
|
||||
}
|
||||
|
||||
void ToolDock::WrapConfiguration(ToolBarConfiguration &backup)
|
||||
{
|
||||
backup.Clear();
|
||||
backup.Swap(mConfiguration);
|
||||
mConfiguration.Swap(mWrappedConfiguration);
|
||||
}
|
||||
|
||||
void ToolDock::RestoreConfiguration(ToolBarConfiguration &backup)
|
||||
{
|
||||
mWrappedConfiguration.Clear();
|
||||
mWrappedConfiguration.Swap(mConfiguration);
|
||||
mConfiguration.Swap(backup);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the visible/hidden state of a toolbar
|
||||
//
|
||||
|
@ -306,6 +306,13 @@ public:
|
||||
ToolBarConfiguration &GetConfiguration()
|
||||
{ return mConfiguration; }
|
||||
|
||||
// backup gets old contents of the configuration; the configuration is
|
||||
// set to the wrapped configuration.
|
||||
void WrapConfiguration(ToolBarConfiguration &backup);
|
||||
|
||||
// Reverse what was done by WrapConfiguration.
|
||||
void RestoreConfiguration(ToolBarConfiguration &backup);
|
||||
|
||||
protected:
|
||||
|
||||
void OnErase( wxEraseEvent & event );
|
||||
@ -316,7 +323,8 @@ public:
|
||||
|
||||
private:
|
||||
class LayoutVisitor;
|
||||
void VisitLayout(LayoutVisitor &visitor);
|
||||
void VisitLayout(LayoutVisitor &visitor,
|
||||
ToolBarConfiguration *pWrappedConfiguration = nullptr);
|
||||
|
||||
void Updated();
|
||||
|
||||
@ -328,6 +336,9 @@ public:
|
||||
// Stores adjacency relations that we want to realize in the dock layout
|
||||
ToolBarConfiguration mConfiguration;
|
||||
|
||||
// Configuration as modified by the constraint of the main window width
|
||||
ToolBarConfiguration mWrappedConfiguration;
|
||||
|
||||
ToolBar *mBars[ ToolBarCount ];
|
||||
|
||||
public:
|
||||
|
@ -1297,6 +1297,7 @@ void ToolManager::OnGrabber( GrabberEvent & event )
|
||||
mPrevDock = dynamic_cast<ToolDock*>(mDragBar->GetParent());
|
||||
wxASSERT(mPrevDock);
|
||||
mPrevSlot = mPrevDock->GetConfiguration().Find(mDragBar);
|
||||
mPrevDock->WrapConfiguration(mPrevConfiguration);
|
||||
}
|
||||
else
|
||||
mPrevPosition = mDragBar->GetParent()->GetPosition();
|
||||
@ -1358,6 +1359,7 @@ void ToolManager::HandleEscapeKey()
|
||||
// Why don't you leave me alone?
|
||||
// Well, I feel so break up
|
||||
// I want to go home.
|
||||
mPrevDock->RestoreConfiguration(mPrevConfiguration);
|
||||
mPrevDock->Dock( mDragBar, true, mPrevSlot );
|
||||
|
||||
// Done with the floater
|
||||
@ -1392,6 +1394,7 @@ void ToolManager::DoneDragging()
|
||||
mDragBar = NULL;
|
||||
mPrevDock = NULL;
|
||||
mPrevSlot = { ToolBarConfiguration::UnspecifiedPosition };
|
||||
mPrevConfiguration.Clear();
|
||||
mLastPos.x = mBarPos.x = -1;
|
||||
mLastPos.y = mBarPos.y = -1;
|
||||
mTimer.Stop();
|
||||
|
@ -117,6 +117,7 @@ class ToolManager final : public wxEvtHandler
|
||||
ToolDock *mPrevDock {};
|
||||
ToolBarConfiguration::Position mPrevSlot
|
||||
{ ToolBarConfiguration::UnspecifiedPosition };
|
||||
ToolBarConfiguration mPrevConfiguration;
|
||||
|
||||
public:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user