diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 20950f1..1f99d28 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1471,8 +1471,6 @@ CDockContainerWidget::~CDockContainerWidget() CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget) { - Q_ASSERT_X(!DockAreaWidget->isOverlayed(), "CDockContainerWidget::addDockWidget", "Adding a dock widget to an area that is already overlayed is not supported."); - CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget(); if (OldDockArea) { @@ -1534,39 +1532,39 @@ CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDo // Then handle left and right const auto dockWidgetCenter = DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.center()); - const auto calculatedPosition = dockWidgetCenter.x() <= splitterCenter.x() ? CDockWidgetSideTab::Left : CDockWidgetSideTab::Right; - if (calculatedPosition == CDockWidgetSideTab::Right) + const auto calculatedPosition = dockWidgetCenter.x() <= splitterCenter.x() ? CDockWidgetSideTab::LeftTop : CDockWidgetSideTab::RightTop; + if (calculatedPosition == CDockWidgetSideTab::RightTop) { if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) { - return CDockWidgetSideTab::Right; + return CDockWidgetSideTab::RightTop; } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar)) { - return CDockWidgetSideTab::Left; + return CDockWidgetSideTab::LeftTop; } return CDockWidgetSideTab::Bottom; } - if (calculatedPosition == CDockWidgetSideTab::Left) + if (calculatedPosition == CDockWidgetSideTab::LeftTop) { if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar)) { - return CDockWidgetSideTab::Left; + return CDockWidgetSideTab::LeftTop; } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) { - return CDockWidgetSideTab::Right; + return CDockWidgetSideTab::RightTop; } return CDockWidgetSideTab::Bottom; } Q_ASSERT_X(false, "CDockContainerWidget::getDockAreaPosition", "Unhandled branch. All positions should be accounted for."); - return CDockWidgetSideTab::Left; + return CDockWidgetSideTab::LeftTop; } @@ -2046,14 +2044,24 @@ void CDockContainerWidget::createSideTabBarWidgets() { if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar)) { - d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical); - d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left], 0, 0); + auto leftLayout = new QVBoxLayout(); + d->SideTabBarWidgets[CDockWidgetSideTab::LeftTop] = new CSideTabBar(this, Qt::Vertical); + leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::LeftTop]); + leftLayout->addStretch(1); + d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom] = new CSideTabBar(this, Qt::Vertical); + leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom]); + d->Layout->addLayout(leftLayout, 0, 0); } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) { - d->SideTabBarWidgets[CDockWidgetSideTab::Right] = new CSideTabBar(this, Qt::Vertical); - d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Right], 0, 2); + auto rightLayout = new QVBoxLayout(); + d->SideTabBarWidgets[CDockWidgetSideTab::RightTop] = new CSideTabBar(this, Qt::Vertical); + rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::RightTop]); + rightLayout->addStretch(1); + d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom] = new CSideTabBar(this, Qt::Vertical); + rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom]); + d->Layout->addLayout(rightLayout, 0, 2); } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar)) diff --git a/src/DockWidgetSideTab.cpp b/src/DockWidgetSideTab.cpp index d65c172..a782ef5 100644 --- a/src/DockWidgetSideTab.cpp +++ b/src/DockWidgetSideTab.cpp @@ -216,7 +216,7 @@ CDockWidgetSideTab::SideTabBarArea CDockWidgetSideTab::sideTabBarArea() const return dockAreaWidget->overlayDockContainer()->sideTabBarArea(); } - return Left; + return LeftTop; } @@ -289,14 +289,14 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area) QFontMetrics fm(d->TitleLabel->font()); int Spacing = qRound(fm.height() / 2.0); - if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && area == Left) + if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && (area == LeftTop || area == LeftBottom)) { d->TitleLabel->hide(); d->TitleLayout->setContentsMargins(0, 0, 0, 0); d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2); return; } - if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && area == Right) + if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && (area == RightTop || area == RightBottom)) { d->TitleLabel->hide(); d->TitleLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/DockWidgetSideTab.h b/src/DockWidgetSideTab.h index 73fc4c1..92c0d82 100644 --- a/src/DockWidgetSideTab.h +++ b/src/DockWidgetSideTab.h @@ -77,8 +77,10 @@ public: */ enum SideTabBarArea { - Left, - Right, + LeftTop, + LeftBottom, + RightTop, + RightBottom, Bottom }; diff --git a/src/OverlayDockContainer.cpp b/src/OverlayDockContainer.cpp index a661af4..43f7ebe 100644 --- a/src/OverlayDockContainer.cpp +++ b/src/OverlayDockContainer.cpp @@ -66,11 +66,15 @@ struct OverlayDockContainerPrivate { switch (area) { - case CDockWidgetSideTab::Left: + case CDockWidgetSideTab::LeftBottom: + [[fallthrough]]; + case CDockWidgetSideTab::LeftTop: { return LeftDockWidgetArea; } - case CDockWidgetSideTab::Right: + case CDockWidgetSideTab::RightBottom: + [[fallthrough]]; + case CDockWidgetSideTab::RightTop: { return RightDockWidgetArea; } @@ -82,6 +86,34 @@ struct OverlayDockContainerPrivate return LeftDockWidgetArea; } + + /* + * Convenience function to get dock position + */ + QPoint getSimplifiedDockAreaPosition() const + { + switch (Area) + { + case CDockWidgetSideTab::LeftTop: + [[fallthrough]]; + case CDockWidgetSideTab::LeftBottom: + { + return QPoint(1, _this->height() / 2); + } + case CDockWidgetSideTab::RightTop: + [[fallthrough]]; + case CDockWidgetSideTab::RightBottom: + { + return QPoint(_this->width() - 1, _this->height() / 2); + } + case CDockWidgetSideTab::Bottom: + { + return QPoint(_this->width() / 2, _this->height() - 1); + } + } + + return QPoint(); + } }; // struct OverlayDockContainerPrivate //============================================================================ @@ -121,13 +153,17 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWid switch (area) { - case CDockWidgetSideTab::Left: + case CDockWidgetSideTab::LeftBottom: + [[fallthrough]]; + case CDockWidgetSideTab::LeftTop: { d->Splitter->addWidget(d->DockArea); d->Splitter->addWidget(emptyWidget); break; } - case CDockWidgetSideTab::Right: + case CDockWidgetSideTab::RightBottom: + [[fallthrough]]; + case CDockWidgetSideTab::RightTop: { d->Splitter->addWidget(emptyWidget); d->Splitter->addWidget(d->DockArea); @@ -165,12 +201,15 @@ void COverlayDockContainer::updateMask() if (d->Area == CDockWidgetSideTab::Bottom) { setMask(QRect(QPoint(topLeft.x(), topLeft.y() - handleSize), QSize(rect.size().width(), rect.size().height() + handleSize))); + return; } - else - { - const auto offset = d->Area == CDockWidgetSideTab::SideTabBarArea::Left ? 0 : handleSize; - setMask(QRect(QPoint(topLeft.x() - offset, topLeft.y()), QSize(rect.size().width() + handleSize, rect.size().height()))); - } + + auto offset = 0; + if (d->Area == CDockWidgetSideTab::SideTabBarArea::RightTop || d->Area == CDockWidgetSideTab::SideTabBarArea::RightBottom) + { + offset = handleSize; + } + setMask(QRect(QPoint(topLeft.x() - offset, topLeft.y()), QSize(rect.size().width() + handleSize, rect.size().height()))); } //============================================================================ @@ -256,12 +295,16 @@ void COverlayDockContainer::setDockSizeProportion(float SplitterProportion) const auto remainingSize = INT_MAX - dockSize; switch (d->Area) { - case CDockWidgetSideTab::Left: + case CDockWidgetSideTab::LeftBottom: + [[fallthrough]]; + case CDockWidgetSideTab::LeftTop: { d->Splitter->setSizes({ dockSize, remainingSize }); break; } - case CDockWidgetSideTab::Right: + case CDockWidgetSideTab::RightBottom: + [[fallthrough]]; + case CDockWidgetSideTab::RightTop: [[fallthrough]]; case CDockWidgetSideTab::Bottom: { @@ -288,7 +331,7 @@ CDockAreaWidget* COverlayDockContainer::dockAreaWidget() const //============================================================================ void COverlayDockContainer::moveContentsToParent() { - const auto position = mapToGlobal(d->Area == CDockWidgetSideTab::Left ? QPoint(1,height() / 2) : QPoint(width() - 1, height() / 2)); + const auto position = mapToGlobal(d->getSimplifiedDockAreaPosition()); const auto dockAreaWidget = parentContainer()->dockAreaAt(position); if (dockAreaWidget != nullptr && !dockAreaWidget->containsCentralWidget()) @@ -404,11 +447,15 @@ bool COverlayDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarAre { switch (area) { - case CDockWidgetSideTab::Left: + case CDockWidgetSideTab::LeftBottom: + [[fallthrough]]; + case CDockWidgetSideTab::LeftTop: { return CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar); } - case CDockWidgetSideTab::Right: + case CDockWidgetSideTab::RightBottom: + [[fallthrough]]; + case CDockWidgetSideTab::RightTop: { return CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar); } diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css index 661097e..6bbf601 100644 --- a/src/stylesheets/focus_highlighting.css +++ b/src/stylesheets/focus_highlighting.css @@ -27,12 +27,12 @@ ads--CDockWidgetSideTab { qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ } -ads--CDockWidgetSideTab[sideTabBarArea="Left"] { +ads--CDockWidgetSideTab[sideTabBarArea="LeftTop"],[sideTabBarArea="LeftBottom"] { border-left: 3px solid grey; border-bottom: 1px solid white; } -ads--CDockWidgetSideTab[sideTabBarArea="Right"] { +ads--CDockWidgetSideTab[sideTabBarArea="RightTop"],[sideTabBarArea="RightBottom"] { border-right: 3px solid grey; border-bottom: 1px solid white; } @@ -120,11 +120,11 @@ ads--CDockSplitter::handle { } /* Focus related styling */ -ads--CDockWidgetSideTab:hover[sideTabBarArea="Right"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="RightTop"],:hover[sideTabBarArea="RightBottom"] { border-right: 3px solid palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="Left"] { +ads--CDockWidgetSideTab:hover[sideTabBarArea="LeftTop"],:hover[sideTabBarArea="LeftBottom"] { border-left: 3px solid palette(highlight); } @@ -133,11 +133,11 @@ ads--CDockWidgetSideTab:hover[sideTabBarArea="Bottom"] { } -ads--CDockWidgetSideTab[sideTabBarArea="Right"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="RightTop"][focused="true"],[sideTabBarArea="RightBottom"][focused="true"] { border-right: 3px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="Left"][focused="true"] { +ads--CDockWidgetSideTab[sideTabBarArea="LeftTop"][focused="true"],[sideTabBarArea="LeftBottom"][focused="true"] { border-left: 3px solid palette(highlight); }