mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-14 00:52:05 +08:00
Add right bottom and left bottom
This commit is contained in:
parent
68a3bcde08
commit
59108ed245
@ -1471,8 +1471,6 @@ CDockContainerWidget::~CDockContainerWidget()
|
|||||||
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget)
|
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();
|
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
||||||
if (OldDockArea)
|
if (OldDockArea)
|
||||||
{
|
{
|
||||||
@ -1534,39 +1532,39 @@ CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDo
|
|||||||
|
|
||||||
// Then handle left and right
|
// Then handle left and right
|
||||||
const auto dockWidgetCenter = DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.center());
|
const auto dockWidgetCenter = DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.center());
|
||||||
const auto calculatedPosition = dockWidgetCenter.x() <= splitterCenter.x() ? CDockWidgetSideTab::Left : CDockWidgetSideTab::Right;
|
const auto calculatedPosition = dockWidgetCenter.x() <= splitterCenter.x() ? CDockWidgetSideTab::LeftTop : CDockWidgetSideTab::RightTop;
|
||||||
if (calculatedPosition == CDockWidgetSideTab::Right)
|
if (calculatedPosition == CDockWidgetSideTab::RightTop)
|
||||||
{
|
{
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar))
|
||||||
{
|
{
|
||||||
return CDockWidgetSideTab::Right;
|
return CDockWidgetSideTab::RightTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar))
|
||||||
{
|
{
|
||||||
return CDockWidgetSideTab::Left;
|
return CDockWidgetSideTab::LeftTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CDockWidgetSideTab::Bottom;
|
return CDockWidgetSideTab::Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calculatedPosition == CDockWidgetSideTab::Left)
|
if (calculatedPosition == CDockWidgetSideTab::LeftTop)
|
||||||
{
|
{
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar))
|
||||||
{
|
{
|
||||||
return CDockWidgetSideTab::Left;
|
return CDockWidgetSideTab::LeftTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar))
|
||||||
{
|
{
|
||||||
return CDockWidgetSideTab::Right;
|
return CDockWidgetSideTab::RightTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CDockWidgetSideTab::Bottom;
|
return CDockWidgetSideTab::Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT_X(false, "CDockContainerWidget::getDockAreaPosition", "Unhandled branch. All positions should be accounted for.");
|
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))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar))
|
||||||
{
|
{
|
||||||
d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical);
|
auto leftLayout = new QVBoxLayout();
|
||||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left], 0, 0);
|
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))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar))
|
||||||
{
|
{
|
||||||
d->SideTabBarWidgets[CDockWidgetSideTab::Right] = new CSideTabBar(this, Qt::Vertical);
|
auto rightLayout = new QVBoxLayout();
|
||||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Right], 0, 2);
|
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))
|
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar))
|
||||||
|
@ -216,7 +216,7 @@ CDockWidgetSideTab::SideTabBarArea CDockWidgetSideTab::sideTabBarArea() const
|
|||||||
return dockAreaWidget->overlayDockContainer()->sideTabBarArea();
|
return dockAreaWidget->overlayDockContainer()->sideTabBarArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Left;
|
return LeftTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -289,14 +289,14 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
|
|||||||
QFontMetrics fm(d->TitleLabel->font());
|
QFontMetrics fm(d->TitleLabel->font());
|
||||||
int Spacing = qRound(fm.height() / 2.0);
|
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->TitleLabel->hide();
|
||||||
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2);
|
d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && area == Right)
|
if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && (area == RightTop || area == RightBottom))
|
||||||
{
|
{
|
||||||
d->TitleLabel->hide();
|
d->TitleLabel->hide();
|
||||||
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -77,8 +77,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum SideTabBarArea
|
enum SideTabBarArea
|
||||||
{
|
{
|
||||||
Left,
|
LeftTop,
|
||||||
Right,
|
LeftBottom,
|
||||||
|
RightTop,
|
||||||
|
RightBottom,
|
||||||
Bottom
|
Bottom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,11 +66,15 @@ struct OverlayDockContainerPrivate
|
|||||||
{
|
{
|
||||||
switch (area)
|
switch (area)
|
||||||
{
|
{
|
||||||
case CDockWidgetSideTab::Left:
|
case CDockWidgetSideTab::LeftBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::LeftTop:
|
||||||
{
|
{
|
||||||
return LeftDockWidgetArea;
|
return LeftDockWidgetArea;
|
||||||
}
|
}
|
||||||
case CDockWidgetSideTab::Right:
|
case CDockWidgetSideTab::RightBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::RightTop:
|
||||||
{
|
{
|
||||||
return RightDockWidgetArea;
|
return RightDockWidgetArea;
|
||||||
}
|
}
|
||||||
@ -82,6 +86,34 @@ struct OverlayDockContainerPrivate
|
|||||||
|
|
||||||
return LeftDockWidgetArea;
|
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
|
}; // struct OverlayDockContainerPrivate
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@ -121,13 +153,17 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWid
|
|||||||
|
|
||||||
switch (area)
|
switch (area)
|
||||||
{
|
{
|
||||||
case CDockWidgetSideTab::Left:
|
case CDockWidgetSideTab::LeftBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::LeftTop:
|
||||||
{
|
{
|
||||||
d->Splitter->addWidget(d->DockArea);
|
d->Splitter->addWidget(d->DockArea);
|
||||||
d->Splitter->addWidget(emptyWidget);
|
d->Splitter->addWidget(emptyWidget);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CDockWidgetSideTab::Right:
|
case CDockWidgetSideTab::RightBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::RightTop:
|
||||||
{
|
{
|
||||||
d->Splitter->addWidget(emptyWidget);
|
d->Splitter->addWidget(emptyWidget);
|
||||||
d->Splitter->addWidget(d->DockArea);
|
d->Splitter->addWidget(d->DockArea);
|
||||||
@ -165,12 +201,15 @@ void COverlayDockContainer::updateMask()
|
|||||||
if (d->Area == CDockWidgetSideTab::Bottom)
|
if (d->Area == CDockWidgetSideTab::Bottom)
|
||||||
{
|
{
|
||||||
setMask(QRect(QPoint(topLeft.x(), topLeft.y() - handleSize), QSize(rect.size().width(), rect.size().height() + handleSize)));
|
setMask(QRect(QPoint(topLeft.x(), topLeft.y() - handleSize), QSize(rect.size().width(), rect.size().height() + handleSize)));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
auto offset = 0;
|
||||||
const auto offset = d->Area == CDockWidgetSideTab::SideTabBarArea::Left ? 0 : handleSize;
|
if (d->Area == CDockWidgetSideTab::SideTabBarArea::RightTop || d->Area == CDockWidgetSideTab::SideTabBarArea::RightBottom)
|
||||||
setMask(QRect(QPoint(topLeft.x() - offset, topLeft.y()), QSize(rect.size().width() + handleSize, rect.size().height())));
|
{
|
||||||
}
|
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;
|
const auto remainingSize = INT_MAX - dockSize;
|
||||||
switch (d->Area)
|
switch (d->Area)
|
||||||
{
|
{
|
||||||
case CDockWidgetSideTab::Left:
|
case CDockWidgetSideTab::LeftBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::LeftTop:
|
||||||
{
|
{
|
||||||
d->Splitter->setSizes({ dockSize, remainingSize });
|
d->Splitter->setSizes({ dockSize, remainingSize });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CDockWidgetSideTab::Right:
|
case CDockWidgetSideTab::RightBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::RightTop:
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case CDockWidgetSideTab::Bottom:
|
case CDockWidgetSideTab::Bottom:
|
||||||
{
|
{
|
||||||
@ -288,7 +331,7 @@ CDockAreaWidget* COverlayDockContainer::dockAreaWidget() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void COverlayDockContainer::moveContentsToParent()
|
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);
|
const auto dockAreaWidget = parentContainer()->dockAreaAt(position);
|
||||||
if (dockAreaWidget != nullptr && !dockAreaWidget->containsCentralWidget())
|
if (dockAreaWidget != nullptr && !dockAreaWidget->containsCentralWidget())
|
||||||
@ -404,11 +447,15 @@ bool COverlayDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarAre
|
|||||||
{
|
{
|
||||||
switch (area)
|
switch (area)
|
||||||
{
|
{
|
||||||
case CDockWidgetSideTab::Left:
|
case CDockWidgetSideTab::LeftBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::LeftTop:
|
||||||
{
|
{
|
||||||
return CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar);
|
return CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar);
|
||||||
}
|
}
|
||||||
case CDockWidgetSideTab::Right:
|
case CDockWidgetSideTab::RightBottom:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::RightTop:
|
||||||
{
|
{
|
||||||
return CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar);
|
return CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar);
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,12 @@ ads--CDockWidgetSideTab {
|
|||||||
qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/
|
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-left: 3px solid grey;
|
||||||
border-bottom: 1px solid white;
|
border-bottom: 1px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--CDockWidgetSideTab[sideTabBarArea="Right"] {
|
ads--CDockWidgetSideTab[sideTabBarArea="RightTop"],[sideTabBarArea="RightBottom"] {
|
||||||
border-right: 3px solid grey;
|
border-right: 3px solid grey;
|
||||||
border-bottom: 1px solid white;
|
border-bottom: 1px solid white;
|
||||||
}
|
}
|
||||||
@ -120,11 +120,11 @@ ads--CDockSplitter::handle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Focus related styling */
|
/* Focus related styling */
|
||||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="Right"] {
|
ads--CDockWidgetSideTab:hover[sideTabBarArea="RightTop"],:hover[sideTabBarArea="RightBottom"] {
|
||||||
border-right: 3px solid palette(highlight);
|
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);
|
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);
|
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);
|
border-left: 3px solid palette(highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user