diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index 800756b..e750264 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -472,19 +472,23 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const { auto Rect = rect(); const QPoint pos = mapFromGlobal(QCursor::pos()); - if (pos.x() < d->sideBarMouseZone(SideBarLeft)) + if ((pos.x() < d->sideBarMouseZone(SideBarLeft)) + && d->AllowedAreas.testFlag(LeftAutoHideArea)) { return LeftAutoHideArea; } - else if (pos.x() > (Rect.width() - d->sideBarMouseZone(SideBarRight))) + else if (pos.x() > (Rect.width() - d->sideBarMouseZone(SideBarRight)) + && d->AllowedAreas.testFlag(RightAutoHideArea)) { return RightAutoHideArea; } - else if (pos.y() < d->sideBarMouseZone(SideBarTop)) + else if (pos.y() < d->sideBarMouseZone(SideBarTop) + && d->AllowedAreas.testFlag(TopAutoHideArea)) { return TopAutoHideArea; } - else if (pos.y() > (Rect.height() - d->sideBarMouseZone(SideBarBottom))) + else if (pos.y() > (Rect.height() - d->sideBarMouseZone(SideBarBottom)) + && d->AllowedAreas.testFlag(BottomAutoHideArea)) { return BottomAutoHideArea; } diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 405ae46..16c7489 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -590,16 +590,22 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos) } int VisibleDockAreas = TopContainer->visibleDockAreaCount(); - DockWidgetAreas AllowedAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas; + DockWidgetAreas AllowedContainerAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas; auto DockArea = TopContainer->dockAreaAt(GlobalPos); // If the dock container contains only one single DockArea, then we need // to respect the allowed areas - only the center area is relevant here because // all other allowed areas are from the container if (VisibleDockAreas == 1 && DockArea) { - AllowedAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea)); + AllowedContainerAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea)); } - ContainerOverlay->setAllowedAreas(AllowedAreas); + + if (DockContainer->features().testFlag(CDockWidget::DockWidgetPinnable)) + { + AllowedContainerAreas |= AutoHideDockAreas; + } + + ContainerOverlay->setAllowedAreas(AllowedContainerAreas); DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer); ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea); diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index ff69e6f..52303ad 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -35,6 +35,7 @@ struct FloatingDragPreviewPrivate { CFloatingDragPreview *_this; QWidget* Content; + CDockWidget::DockWidgetFeatures ContentFeatures; CDockAreaWidget* ContentSourceArea = nullptr; QPoint DragStartMousePosition; CDockManager* DockManager; @@ -79,20 +80,36 @@ struct FloatingDragPreviewPrivate * Returns true, if the content is floatable */ bool isContentFloatable() const + { + return this->ContentFeatures.testFlag(CDockWidget::DockWidgetFloatable); + } + + /** + * Returns true, if the content is pinnable + */ + bool isContentPinnable() const + { + return this->ContentFeatures.testFlag(CDockWidget::DockWidgetPinnable); + } + + /** + * Returns the content features + */ + CDockWidget::DockWidgetFeatures contentFeatures() const { CDockWidget* DockWidget = qobject_cast(Content); - if (DockWidget && DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) + if (DockWidget) { - return true; + return DockWidget->features(); } CDockAreaWidget* DockArea = qobject_cast(Content); - if (DockArea && DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)) + if (DockArea) { - return true; + return DockArea->features(); } - return false; + return CDockWidget::DockWidgetFeatures(); } }; // struct LedArrayPanelPrivate @@ -152,7 +169,7 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos) VisibleDockAreas++; } - DockWidgetAreas AllowedAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas; + DockWidgetAreas AllowedContainerAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas; //ContainerOverlay->enableDropPreview(ContainerDropArea != InvalidDockWidgetArea); auto DockArea = TopContainer->dockAreaAt(GlobalPos); // If the dock container contains only one single DockArea, then we need @@ -160,9 +177,14 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos) // all other allowed areas are from the container if (VisibleDockAreas == 1 && DockArea) { - AllowedAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea)); + AllowedContainerAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea)); } - ContainerOverlay->setAllowedAreas(AllowedAreas); + + if (isContentPinnable()) + { + AllowedContainerAreas |= AutoHideDockAreas; + } + ContainerOverlay->setAllowedAreas(AllowedContainerAreas); ContainerOverlay->enableDropPreview(ContainerDropArea != InvalidDockWidgetArea); if (DockArea && DockArea->isVisible() && VisibleDockAreas >= 0 && DockArea != ContentSourceArea) { @@ -259,6 +281,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) : d(new FloatingDragPreviewPrivate(this)) { d->Content = Content; + d->ContentFeatures = d->contentFeatures(); setAttribute(Qt::WA_DeleteOnClose); if (CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame)) { @@ -278,8 +301,6 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) : setWindowFlags(Flags); #endif - setWindowOpacity(0.6); - // Create a static image of the widget that should get undocked // This is like some kind preview image like it is uses in drag and drop // operations @@ -437,6 +458,7 @@ void CFloatingDragPreview::paintEvent(QPaintEvent* event) } QPainter painter(this); + painter.setOpacity(0.6); if (CDockManager::testConfigFlag(CDockManager::DragPreviewShowsContentPixmap)) { painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap);