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