Added option to auto hide a DockWidget or a DockArea to a specific sidebar location
This commit is contained in:
@@ -1241,60 +1241,60 @@ SideBarLocation CDockAreaWidget::calculateSideTabBarArea() const
|
||||
int BorderDistance[4];
|
||||
|
||||
int Distance = qAbs(ContentRect.topLeft().y() - DockAreaRect.topLeft().y());
|
||||
BorderDistance[SideBarLocation::Top] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::Top])
|
||||
BorderDistance[SideBarLocation::SideBarTop] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::SideBarTop])
|
||||
{
|
||||
borders |= BorderTop;
|
||||
}
|
||||
|
||||
Distance = qAbs(ContentRect.bottomRight().y() - DockAreaRect.bottomRight().y());
|
||||
BorderDistance[SideBarLocation::Bottom] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::Bottom])
|
||||
BorderDistance[SideBarLocation::SideBarBottom] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::SideBarBottom])
|
||||
{
|
||||
borders |= BorderBottom;
|
||||
}
|
||||
|
||||
Distance = qAbs(ContentRect.topLeft().x() - DockAreaRect.topLeft().x());
|
||||
BorderDistance[SideBarLocation::Left] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::Left])
|
||||
BorderDistance[SideBarLocation::SideBarLeft] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::SideBarLeft])
|
||||
{
|
||||
borders |= BorderLeft;
|
||||
}
|
||||
|
||||
Distance = qAbs(ContentRect.bottomRight().x() - DockAreaRect.bottomRight().x());
|
||||
BorderDistance[SideBarLocation::Right] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::Right])
|
||||
BorderDistance[SideBarLocation::SideBarRight] = (Distance < MinBorderDistance) ? 0 : Distance;
|
||||
if (!BorderDistance[SideBarLocation::SideBarRight])
|
||||
{
|
||||
borders |= BorderRight;
|
||||
}
|
||||
|
||||
auto SideTab = SideBarLocation::Right;
|
||||
auto SideTab = SideBarLocation::SideBarRight;
|
||||
switch (borders)
|
||||
{
|
||||
// 1. It's touching all borders
|
||||
case BorderAll: SideTab = HorizontalOrientation ? SideBarLocation::Bottom : SideBarLocation::Right; break;
|
||||
case BorderAll: SideTab = HorizontalOrientation ? SideBarLocation::SideBarBottom : SideBarLocation::SideBarRight; break;
|
||||
|
||||
// 2. It's touching 3 borders
|
||||
case BorderVerticalBottom : SideTab = SideBarLocation::Bottom; break;
|
||||
case BorderVerticalTop : SideTab = SideBarLocation::Top; break;
|
||||
case BorderHorizontalLeft: SideTab = SideBarLocation::Left; break;
|
||||
case BorderHorizontalRight: SideTab = SideBarLocation::Right; break;
|
||||
case BorderVerticalBottom : SideTab = SideBarLocation::SideBarBottom; break;
|
||||
case BorderVerticalTop : SideTab = SideBarLocation::SideBarTop; break;
|
||||
case BorderHorizontalLeft: SideTab = SideBarLocation::SideBarLeft; break;
|
||||
case BorderHorizontalRight: SideTab = SideBarLocation::SideBarRight; break;
|
||||
|
||||
// 3. Its touching horizontal or vertical borders
|
||||
case BorderVertical : SideTab = SideBarLocation::Bottom; break;
|
||||
case BorderHorizontal: SideTab = SideBarLocation::Right; break;
|
||||
case BorderVertical : SideTab = SideBarLocation::SideBarBottom; break;
|
||||
case BorderHorizontal: SideTab = SideBarLocation::SideBarRight; break;
|
||||
|
||||
// 4. Its in a corner
|
||||
case BorderTopLeft : SideTab = HorizontalOrientation ? SideBarLocation::Top : SideBarLocation::Left; break;
|
||||
case BorderTopRight : SideTab = HorizontalOrientation ? SideBarLocation::Top : SideBarLocation::Right; break;
|
||||
case BorderBottomLeft : SideTab = HorizontalOrientation ? SideBarLocation::Bottom : SideBarLocation::Left; break;
|
||||
case BorderBottomRight : SideTab = HorizontalOrientation ? SideBarLocation::Bottom : SideBarLocation::Right; break;
|
||||
case BorderTopLeft : SideTab = HorizontalOrientation ? SideBarLocation::SideBarTop : SideBarLocation::SideBarLeft; break;
|
||||
case BorderTopRight : SideTab = HorizontalOrientation ? SideBarLocation::SideBarTop : SideBarLocation::SideBarRight; break;
|
||||
case BorderBottomLeft : SideTab = HorizontalOrientation ? SideBarLocation::SideBarBottom : SideBarLocation::SideBarLeft; break;
|
||||
case BorderBottomRight : SideTab = HorizontalOrientation ? SideBarLocation::SideBarBottom : SideBarLocation::SideBarRight; break;
|
||||
|
||||
// 5 Ists touching only one border
|
||||
case BorderLeft: SideTab = SideBarLocation::Left; break;
|
||||
case BorderRight: SideTab = SideBarLocation::Right; break;
|
||||
case BorderTop: SideTab = SideBarLocation::Top; break;
|
||||
case BorderBottom: SideTab = SideBarLocation::Bottom; break;
|
||||
case BorderLeft: SideTab = SideBarLocation::SideBarLeft; break;
|
||||
case BorderRight: SideTab = SideBarLocation::SideBarRight; break;
|
||||
case BorderTop: SideTab = SideBarLocation::SideBarTop; break;
|
||||
case BorderBottom: SideTab = SideBarLocation::SideBarBottom; break;
|
||||
}
|
||||
|
||||
return SideTab;
|
||||
@@ -1302,7 +1302,7 @@ SideBarLocation CDockAreaWidget::calculateSideTabBarArea() const
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaWidget::setAutoHide(bool Enable)
|
||||
void CDockAreaWidget::setAutoHide(bool Enable, SideBarLocation Location)
|
||||
{
|
||||
if (!isAutoHideFeatureEnabled())
|
||||
{
|
||||
@@ -1318,7 +1318,7 @@ void CDockAreaWidget::setAutoHide(bool Enable)
|
||||
return;
|
||||
}
|
||||
|
||||
auto area = calculateSideTabBarArea();
|
||||
auto area = (SideBarNone == Location) ? calculateSideTabBarArea() : Location;
|
||||
for (const auto DockWidget : openedDockWidgets())
|
||||
{
|
||||
if (Enable == isAutoHide())
|
||||
@@ -1337,14 +1337,14 @@ void CDockAreaWidget::setAutoHide(bool Enable)
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaWidget::toggleAutoHide()
|
||||
void CDockAreaWidget::toggleAutoHide(SideBarLocation Location)
|
||||
{
|
||||
if (!isAutoHideFeatureEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setAutoHide(!isAutoHide());
|
||||
setAutoHide(!isAutoHide(), Location);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user