diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp index 6cea9324c4..1a7512a4fc 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.cpp @@ -159,6 +159,8 @@ namespace AzQtComponents // Timer for updating our hovered drop zone opacity QObject::connect(m_dropZoneHoverFadeInTimer, &QTimer::timeout, this, &FancyDocking::onDropZoneHoverFadeInUpdate); m_dropZoneHoverFadeInTimer->setInterval(g_FancyDockingConstants.dropZoneHoverFadeUpdateIntervalMS); + QIcon dragIcon = QIcon(QStringLiteral(":/Cursors/Grabbing.svg")); + m_dragCursor = QCursor(dragIcon.pixmap(16), 5, 2); } FancyDocking::~FancyDocking() @@ -1884,6 +1886,8 @@ namespace AzQtComponents return; } + QApplication::setOverrideCursor(m_dragCursor); + QPoint relativePressPos = pressPos; // If we are dragging a floating window, we need to grab a reference to its @@ -3565,6 +3569,11 @@ namespace AzQtComponents */ void FancyDocking::clearDraggingState() { + if (QApplication::overrideCursor()) + { + QApplication::restoreOverrideCursor(); + } + m_ghostWidget->hide(); // Release the mouse and keyboard from our main window since we grab them when we start dragging diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.h b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.h index a466ce7087..20b90ad25c 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDocking.h @@ -266,6 +266,8 @@ namespace AzQtComponents QString m_floatingWindowIdentifierPrefix; QString m_tabContainerIdentifierPrefix; + + QCursor m_dragCursor; }; } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.cpp index 895785f47b..48fb47d7e6 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -419,6 +420,14 @@ namespace AzQtComponents // a mouse move. The paint handler updates the close button's visibility setAttribute(Qt::WA_Hover); AzQtComponents::Style::addClass(this, g_emptyStyleClass); + + QIcon icon = QIcon(QStringLiteral(":/Cursors/Grab_release.svg")); + m_hoverCursor = QCursor(icon.pixmap(16), 5, 2); + + icon = QIcon(QStringLiteral(":/Cursors/Grabbing.svg")); + m_dragCursor = QCursor(icon.pixmap(16), 5, 2); + + this->setCursor(m_hoverCursor); } void TabBar::setHandleOverflow(bool handleOverflow) @@ -455,6 +464,11 @@ namespace AzQtComponents { if (mouseEvent->buttons() & Qt::LeftButton) { + if (!QApplication::overrideCursor() || *QApplication::overrideCursor() != m_dragCursor) + { + QApplication::setOverrideCursor(m_dragCursor); + } + m_lastMousePress = mouseEvent->pos(); } @@ -469,6 +483,7 @@ namespace AzQtComponents // selected tab is moved around. The close button is not explicitly rendered for the // moved tab during this operation. We need to make sure not to set it visible again // while the tab is moving. This flag makes sure it happens. + m_movingTab = true; } @@ -479,6 +494,13 @@ namespace AzQtComponents void TabBar::mouseReleaseEvent(QMouseEvent* mouseEvent) { + // Ensure we don't reset the cursor in the case of a dummy event being sent from DockTabWidget to trigger the animation. + Qt::MouseButtons realButtons = QApplication::mouseButtons(); + if (QApplication::overrideCursor() && !(realButtons & Qt::LeftButton)) + { + QApplication::restoreOverrideCursor(); + } + if (m_movingTab && !(mouseEvent->buttons() & Qt::LeftButton)) { // When a moving tab is released, there is a short animation to put the moving tab @@ -632,13 +654,7 @@ namespace AzQtComponents { QPoint p = tabRect(i).topLeft(); - int rightPadding = g_closeButtonPadding; - if (m_overflowing == Overflowing) - { - rightPadding = 0; - } - - p.setX(p.x() + tabRect(i).width() - rightPadding - g_closeButtonWidth); + p.setX(p.x() + tabRect(i).width() - g_closeButtonPadding - g_closeButtonWidth); p.setY(p.y() + 1 + (tabRect(i).height() - g_closeButtonWidth) / 2); tabBtn->move(p); } diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.h b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.h index 3f12f79907..e86deef7b4 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/TabWidget.h @@ -203,6 +203,9 @@ namespace AzQtComponents bool m_movingTab = false; QPoint m_lastMousePress; + QCursor m_dragCursor; + QCursor m_hoverCursor; + void resetOverflow(); void overflowIfNeeded(); void showCloseButtonAt(int index); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/Cursors/Grab_release.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/Cursors/Grab_release.svg new file mode 100644 index 0000000000..ad89e7d1b1 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/Cursors/Grab_release.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/Cursors/Grabbing.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/Cursors/Grabbing.svg new file mode 100644 index 0000000000..96de4e997b --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/Cursors/Grabbing.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc index b995874a41..8ea4755a24 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc @@ -637,5 +637,7 @@ img/UI20/Cursors/Pointer.svg + img/UI20/Cursors/Grab_release.svg + img/UI20/Cursors/Grabbing.svg