mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-25 05:49:02 +08:00
Add top area
This commit is contained in:
parent
ac8cf863a0
commit
f9b62234b0
@ -80,6 +80,10 @@ struct AutoHideDockContainerPrivate
|
||||
{
|
||||
return BottomDockWidgetArea;
|
||||
}
|
||||
case CDockWidgetSideTab::Top:
|
||||
{
|
||||
return TopDockWidgetArea;
|
||||
}
|
||||
}
|
||||
|
||||
return LeftDockWidgetArea;
|
||||
@ -106,6 +110,10 @@ struct AutoHideDockContainerPrivate
|
||||
{
|
||||
return QPoint(_this->width() / 2, _this->height() - 1);
|
||||
}
|
||||
case CDockWidgetSideTab::Top:
|
||||
{
|
||||
return QPoint(_this->width() / 2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return QPoint();
|
||||
@ -125,6 +133,11 @@ struct AutoHideDockContainerPrivate
|
||||
return QRect(QPoint(topLeft.x(), topLeft.y() - handleSize), QSize(rect.size().width(), rect.size().height() + handleSize));
|
||||
}
|
||||
|
||||
if (SideTabBarArea == CDockWidgetSideTab::Top)
|
||||
{
|
||||
return QRect(QPoint(topLeft.x(), topLeft.y()), QSize(rect.size().width(), rect.size().height() + handleSize));
|
||||
}
|
||||
|
||||
auto offset = 0;
|
||||
if (SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::RightTop || SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::RightBottom)
|
||||
{
|
||||
@ -150,7 +163,7 @@ CDockContainerWidget* CAutoHideDockContainer::parentContainer() const
|
||||
|
||||
//============================================================================
|
||||
CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) :
|
||||
QSplitter(area == CDockWidgetSideTab::Bottom ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent),
|
||||
QSplitter((area == CDockWidgetSideTab::Bottom || area == CDockWidgetSideTab::Top) ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent),
|
||||
d(new AutoHideDockContainerPrivate(this))
|
||||
{
|
||||
d->DockManager = DockManager;
|
||||
@ -170,6 +183,12 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockW
|
||||
|
||||
switch (area)
|
||||
{
|
||||
case CDockWidgetSideTab::Top:
|
||||
{
|
||||
addWidget(d->DockArea);
|
||||
addWidget(emptyWidget);
|
||||
break;
|
||||
}
|
||||
case CDockWidgetSideTab::LeftBottom:
|
||||
case CDockWidgetSideTab::LeftTop:
|
||||
{
|
||||
@ -469,6 +488,10 @@ bool CAutoHideDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarAr
|
||||
{
|
||||
return CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar);
|
||||
}
|
||||
case CDockWidgetSideTab::Top:
|
||||
{
|
||||
return CDockManager::testConfigFlag(CDockManager::DockContainerHasTopSideBar);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1440,7 +1440,7 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p
|
||||
d->Layout->setContentsMargins(0, 0, 0, 0);
|
||||
d->Layout->setSpacing(0);
|
||||
d->Layout->setColumnStretch(1, 1);
|
||||
d->Layout->setRowStretch(0, 1);
|
||||
d->Layout->setRowStretch(1, 1);
|
||||
setLayout(d->Layout);
|
||||
|
||||
// The function d->newSplitter() accesses the config flags from dock
|
||||
@ -1523,16 +1523,21 @@ CAutoHideDockContainer* CDockContainerWidget::createAndInitializeAutoHideDockWid
|
||||
//============================================================================
|
||||
CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDockAreaWidget* DockAreaWidget)
|
||||
{
|
||||
// Handle bottom case
|
||||
// Handle bottom case and top case
|
||||
// It's bottom if the width is wider than the height, and if it's below 50% of the window
|
||||
const auto dockWidgetFrameGeometry = DockAreaWidget->frameGeometry();
|
||||
const auto splitterCenter = rootSplitter()->mapToGlobal(rootSplitter()->frameGeometry().center());
|
||||
|
||||
if (dockWidgetFrameGeometry.width() > dockWidgetFrameGeometry.height()
|
||||
&& DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y() > splitterCenter.y()
|
||||
&& CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar))
|
||||
if (dockWidgetFrameGeometry.width() > dockWidgetFrameGeometry.height())
|
||||
{
|
||||
return CDockWidgetSideTab::Bottom;
|
||||
if (DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y() > splitterCenter.y() && CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar))
|
||||
{
|
||||
return CDockWidgetSideTab::Bottom;
|
||||
}
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasTopSideBar))
|
||||
{
|
||||
return CDockWidgetSideTab::Top;
|
||||
}
|
||||
}
|
||||
|
||||
// Then handle left and right
|
||||
@ -2040,7 +2045,7 @@ void CDockContainerWidget::createRootSplitter()
|
||||
return;
|
||||
}
|
||||
d->RootSplitter = d->newSplitter(Qt::Horizontal);
|
||||
d->Layout->addWidget(d->RootSplitter, 0, 1); // Add it to the center - the 0 and 2 indexes are used for the SideTabBar widgets
|
||||
d->Layout->addWidget(d->RootSplitter, 1, 1); // Add it to the center - the 0 and 2 indexes are used for the SideTabBar widgets
|
||||
}
|
||||
|
||||
|
||||
@ -2055,7 +2060,7 @@ void CDockContainerWidget::createSideTabBarWidgets()
|
||||
leftLayout->addStretch(1);
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom] = new CSideTabBar(this, Qt::Vertical);
|
||||
leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom]);
|
||||
d->Layout->addLayout(leftLayout, 0, 0);
|
||||
d->Layout->addLayout(leftLayout, 1, 0);
|
||||
}
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar))
|
||||
@ -2066,13 +2071,19 @@ void CDockContainerWidget::createSideTabBarWidgets()
|
||||
rightLayout->addStretch(1);
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom] = new CSideTabBar(this, Qt::Vertical);
|
||||
rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom]);
|
||||
d->Layout->addLayout(rightLayout, 0, 2);
|
||||
d->Layout->addLayout(rightLayout, 1, 2);
|
||||
}
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar))
|
||||
{
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Bottom] = new CSideTabBar(this, Qt::Horizontal);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Bottom], 1, 1);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Bottom], 2, 1);
|
||||
}
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockContainerHasTopSideBar))
|
||||
{
|
||||
d->SideTabBarWidgets[CDockWidgetSideTab::Top] = new CSideTabBar(this, Qt::Horizontal);
|
||||
d->Layout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Top], 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,15 +229,18 @@ public:
|
||||
DockContainerHasLeftSideBar = 0x01, //!< If the flag is set left side bar will prioritize showing icons only over text
|
||||
DockContainerHasRightSideBar = 0x02, //!< If the flag is set right side bar will prioritize showing icons only over text
|
||||
DockContainerHasBottomSideBar = 0x04, //!< If the flag is set right side bar will prioritize showing icons only over text
|
||||
DockAreaHasAutoHideButton = 0x08, //!< If the flag is set each dock area has a auto hide menu button
|
||||
LeftSideBarPrioritizeIconOnly = 0x10, //!< If the flag is set each container will have a left side bar
|
||||
RightSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set each container will have a right side bar
|
||||
BottomSideBarPrioritizeIconOnly = 0x40, //!< If the flag is set bottom side bar will prioritize showing icons only over text
|
||||
AutoHideDockAreaHasTitle = 0x80, //!< If the flag is set overlay dock area title bar will show the window title
|
||||
DockContainerHasTopSideBar = 0x08, //!< If the flag is set right side bar will prioritize showing icons only over text
|
||||
DockAreaHasAutoHideButton = 0x10, //!< If the flag is set each dock area has a auto hide menu button
|
||||
LeftSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set each container will have a left side bar
|
||||
RightSideBarPrioritizeIconOnly = 0x40, //!< If the flag is set each container will have a right side bar
|
||||
BottomSideBarPrioritizeIconOnly = 0x80, //!< If the flag is set bottom side bar will prioritize showing icons only over text
|
||||
TopSideBarPrioritizeIconOnly = 0x100, //!< If the flag is set bottom side bar will prioritize showing icons only over text
|
||||
AutoHideDockAreaHasTitle = 0x200, //!< If the flag is set overlay dock area title bar will show the window title
|
||||
|
||||
DefaultAutoHideConfig = DockContainerHasLeftSideBar
|
||||
DefaultAutoHideConfig = DockContainerHasLeftSideBar | BottomSideBarPrioritizeIconOnly | TopSideBarPrioritizeIconOnly
|
||||
| DockContainerHasRightSideBar
|
||||
| DockContainerHasBottomSideBar
|
||||
| DockContainerHasTopSideBar
|
||||
| DockAreaHasAutoHideButton
|
||||
| AutoHideDockAreaHasTitle, ///< the default configuration for left and right side bars
|
||||
};
|
||||
|
@ -106,7 +106,7 @@ struct DockWidgetSideTabPrivate
|
||||
}
|
||||
else if (Orientation == Qt::Horizontal)
|
||||
{
|
||||
TitleLayout->setContentsMargins(Spacing / 2, Spacing / 2, Spacing, Spacing);
|
||||
TitleLayout->setContentsMargins(Spacing / 2, Spacing, Spacing, Spacing);
|
||||
if (IconLabel)
|
||||
{
|
||||
IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, 0, Spacing / 2);
|
||||
@ -276,7 +276,7 @@ void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation)
|
||||
//============================================================================
|
||||
void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
|
||||
{
|
||||
setOrientation(area == Bottom ? Qt::Horizontal : Qt::Vertical);
|
||||
setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical);
|
||||
|
||||
d->updateContentsMargins();
|
||||
|
||||
@ -304,6 +304,13 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
|
||||
return;
|
||||
}
|
||||
if (CDockManager::testConfigFlag(CDockManager::BottomSideBarPrioritizeIconOnly) && area == Bottom)
|
||||
{
|
||||
d->TitleLabel->hide();
|
||||
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||
d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing);
|
||||
return;
|
||||
}
|
||||
if (CDockManager::testConfigFlag(CDockManager::TopSideBarPrioritizeIconOnly) && area == Top)
|
||||
{
|
||||
d->TitleLabel->hide();
|
||||
d->TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
*/
|
||||
enum SideTabBarArea
|
||||
{
|
||||
Top,
|
||||
LeftTop,
|
||||
LeftBottom,
|
||||
RightTop,
|
||||
|
@ -27,17 +27,22 @@ ads--CDockWidgetSideTab {
|
||||
qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="0"],[sideTabBarArea="1"] {
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="0"] {
|
||||
border-top: 3px solid grey;
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="1"],[sideTabBarArea="2"] {
|
||||
border-left: 3px solid grey;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="2"],[sideTabBarArea="3"] {
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="3"],[sideTabBarArea="4"] {
|
||||
border-right: 3px solid grey;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="4"] {
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="5"] {
|
||||
border-bottom: 3px solid grey;
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
@ -120,27 +125,39 @@ ads--CDockSplitter::handle {
|
||||
}
|
||||
|
||||
/* Focus related styling */
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="0"],:hover[sideTabBarArea="1"] {
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="0"] {
|
||||
border-top: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="1"],:hover[sideTabBarArea="2"] {
|
||||
border-left: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="2"],:hover[sideTabBarArea="3"] {
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="3"],:hover[sideTabBarArea="4"] {
|
||||
border-right: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="4"] {
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="5"] {
|
||||
border-bottom: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="0"][focused="true"],[sideTabBarArea="1"][focused="true"] {
|
||||
ads--CDockWidgetSideTab:hover[sideTabBarArea="0"][focused="true"] {
|
||||
border-top: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="0"][focused="true"] {
|
||||
border-top: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="1"][focused="true"],[sideTabBarArea="2"][focused="true"] {
|
||||
border-left: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="2"][focused="true"],[sideTabBarArea="3"][focused="true"] {
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="3"][focused="true"],[sideTabBarArea="4"][focused="true"] {
|
||||
border-right: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="4"][focused="true"] {
|
||||
ads--CDockWidgetSideTab[sideTabBarArea="5"][focused="true"] {
|
||||
border-bottom: 3px solid palette(highlight);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user