diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp index f60a98f392..7a76781cd7 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp @@ -1615,14 +1615,16 @@ namespace AzQtComponents } // Handle snapping to the screen edges/other floating windows while dragging - QScreen* screen = Utilities::ScreenAtPoint(globalPos); + QScreen* screen = QApplication::screenAt(globalPos); - AdjustForSnapping(placeholder, screen); + if (screen) + { + AdjustForSnapping(placeholder, screen); + m_state.setPlaceholder(placeholder, screen); - m_state.setPlaceholder(placeholder, screen); - - m_ghostWidget->Enable(); - RepaintFloatingIndicators(); + m_ghostWidget->Enable(); + RepaintFloatingIndicators(); + } } return m_dropZoneState.dragging(); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp index 6894e5b011..04387875df 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -76,7 +77,32 @@ namespace AzQtComponents window->setScreen(screen); } - setGeometry(targetRect); + QPoint midPoint = targetRect.topLeft() + QPoint(targetRect.width() / 2, targetRect.height() / 2); + QScreen* pointScreen = QApplication::screenAt(midPoint); + QRect rect(targetRect); + + if (!pointScreen || pointScreen != screen) + { + if (midPoint.x() >= QCursor::pos().x()) + { + rect.setLeft(rect.left() - rect.width()); + rect.setTop(rect.top() - rect.height()); + m_paintMode = PaintMode::BOTTOMRIGHT; + } + else + { + rect.setRight(rect.right() + rect.width()); + rect.setTop(rect.top() - rect.height()); + m_paintMode = PaintMode::BOTTOMLEFT; + } + } + else + { + m_paintMode = PaintMode::FULL; + } + + setGeometry(rect); + setPixmapVisible(true); if (needsRepaint) { @@ -135,7 +161,27 @@ namespace AzQtComponents yOffset = widgetSize.height() - aspectRatioHeight; } - painter.drawPixmap(QRect(0, yOffset, widgetSize.width(), aspectRatioHeight), m_pixmap); + switch (m_paintMode) + { + case PaintMode::FULL: + { + painter.drawPixmap(QRect(0, yOffset, widgetSize.width(), aspectRatioHeight), m_pixmap); + } + break; + + case PaintMode::BOTTOMLEFT: + { + painter.drawPixmap(QRect(0, (widgetSize.height() + yOffset) / 2, widgetSize.width() / 2, aspectRatioHeight / 2), m_pixmap); + } + break; + + case PaintMode::BOTTOMRIGHT: + { + painter.drawPixmap(QRect(widgetSize.width() / 2, (widgetSize.height() + yOffset) / 2, widgetSize.width() / 2, aspectRatioHeight / 2), m_pixmap); + } + break; + } + if (m_clipToWidgets) { painter.restore(); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h index cadcbd9c8a..6649c6d848 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h @@ -45,5 +45,14 @@ namespace AzQtComponents QPixmap m_pixmap; bool m_visible = false; // maintain our own flag, so that we're always ready to render ignoring Qt's widget caching system bool m_clipToWidgets = false; + + enum class PaintMode + { + FULL = 0, + BOTTOMLEFT, + BOTTOMRIGHT + }; + + PaintMode m_paintMode = PaintMode::FULL; }; } // namespace AzQtComponents