Merge pull request #100 from aws-lumberyard-dev/LY-105687

LY-105687 LY 2.0 - Main editor - mouse over tab should show a hand
This commit is contained in:
sphrose
2021-05-17 07:58:28 +01:00
committed by GitHub
7 changed files with 107 additions and 7 deletions
@@ -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
@@ -266,6 +266,8 @@ namespace AzQtComponents
QString m_floatingWindowIdentifierPrefix;
QString m_tabContainerIdentifierPrefix;
QCursor m_dragCursor;
};
} // namespace AzQtComponents
@@ -21,6 +21,7 @@
#include <QAction>
#include <QActionEvent>
#include <QApplication>
#include <QHBoxLayout>
#include <QIcon>
#include <QLayout>
@@ -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);
}
@@ -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);
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<g id="Cursor-_x2F_-Grab-release">
<g id="Group" transform="translate(3.366335, 2.000000)">
<g id="Path">
<g>
<path id="path-1" d="M2.4,1v7.5H2.2C1.3,7.9,0,7.8-1.1,8.2l-0.3,0.1c-0.9,0.4-1.3,1.5-0.9,2.4l1.6,4c0.3,0.8,1.1,1.8,1.7,2.5
l0.5,0.4c0.4,0.3,0.7,0.7,1.1,0.9l0.1,0.1L3,18.8l0.3,0.3c0.1,0.3,0.3,0.4,0.3,0.4v0.1l0,0V22h7l0.5-0.9l0.5,0.9h3.3v-2.5l0,0
v-0.1l0.1-0.3l0.1-0.3l0.1-0.3l0.1-0.4l0.3-0.5l0.3-0.5l0.4-0.8l0.1-0.3c0.5-0.5,0.9-1.8,0.9-2.6V7.6c0-1.2-0.4-3.8-2.2-3.8
c-1.1,0-1.3,0.5-1.6,0.8c-0.1-0.3-0.4-1.5-1.7-1.6c-1.1,0-1.6,0.5-1.7,0.9C10,3.5,9.7,2.5,8.4,2.5C7.6,2.5,7.4,2.6,7.1,3
C6.8,2.5,6.1-2,4.6-2C3.3-2,2.4,0,2.4,1z"/>
</g>
<g>
<path id="path-1_1_" d="M2.4,1v7.5H2.2C1.3,7.9,0,7.8-1.1,8.2l-0.3,0.1c-0.9,0.4-1.3,1.5-0.9,2.4l1.6,4c0.3,0.8,1.1,1.8,1.7,2.5
l0.5,0.4c0.4,0.3,0.7,0.7,1.1,0.9l0.1,0.1L3,18.8l0.3,0.3c0.1,0.1,0.3,0.3,0.3,0.3v0.3l0,0V22h7l0.5-0.9l0.5,0.9h3.3v-2.5l0,0
v-0.1l0.1-0.3l0.1-0.3l0.1-0.3l0.1-0.4l0.3-0.5l0.3-0.5l0.4-0.8l0.1-0.3c0.5-0.5,0.9-1.8,0.9-2.6V7.6c0-1.2-0.4-3.8-2.2-3.8
c-1.1,0-1.3,0.5-1.6,0.8c-0.1-0.3-0.4-1.5-1.7-1.6c-1.1,0-1.6,0.5-1.7,0.9C10,3.5,9.7,2.5,8.4,2.5C8,2.5,7.6,3,7.1,3.1
c0,0.3,0.3-2.9-0.3-3.8C6.6-1.1,6.1-2,4.6-2C3.3-2,2.4,0,2.4,1z"/>
</g>
</g>
<path id="Path_1_" class="st0" d="M7.1,6.4V5.3c0-0.5,0.4-1.5,1.3-1.5s1.2,0.9,1.2,1.6c0,2,0,0.5,0,1.3h0.8c0-2.8,0-0.4,0-0.9
c0-0.8,0.5-1.3,1.3-1.3S13,5.1,13,5.9c0,0.5,0,0.9,0,0.9h0.8V6.4c0-0.7,0.3-1.2,1.1-1.2c0.9,0,1.2,0.7,1.3,1.7v1.3v5
c0,0.7-0.3,1.5-0.5,2.1l-0.1,0.3l-0.4,0.8L14.8,17l-0.3,0.4l-0.3,0.4L14,18.2c-0.3,0.5-0.4,0.9-0.4,1.3v0.1v1.2h-1.2l-1.2-2.5
l-1.3,2.5h-5v-1.2c0-0.4-0.4-0.8-0.8-1.5l-0.4-0.4l-0.4-0.4l-0.1-0.1L2.9,17l-0.3-0.3L2,16.1c-0.4-0.4-1.1-0.9-1.3-1.5l-0.3-0.4
l-1.5-4c-0.1-0.3,0-0.7,0.1-0.8c0,0,0,0,0.1-0.1l0.3-0.1c1.1-0.4,2.2,0.1,2.9,1.1l0.1,0.1l1.1,1.7V1c0-0.7,0.7-1.3,1.3-1.3
s1.2,0.7,1.2,1.2c0,3.6,0,5.4,0,5.5H7.1z"/>
<polygon id="Path_2_" points="12.4,10.9 13.7,10.9 13.7,15.8 12.4,15.8 "/>
<polygon id="Path_3_" points="9.9,10.9 11.2,10.9 11.2,15.8 9.9,15.8 "/>
<polygon id="Path_4_" points="7.4,10.9 8.7,10.9 8.7,15.8 7.4,15.8 "/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<style type="text/css">
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
.st1{fill-rule:evenodd;clip-rule:evenodd;}
</style>
<g>
<path class="st0" d="M5.3,4.2V2.2c0-0.6,0.2-1.1,0.6-1.6C6.3,0.1,6.9,0,7.4,0l0,0c1,0,1.7,0.5,2.4,1.1l0.2,0.2l0,0l0.2-0.2
c0.5,0,0.8-0.2,1.1-0.2h0.2c1,0,1.7,0.5,2.4,1.1l0.2,0.2l0,0L14,2c0.3-0.2,0.5-0.3,0.8-0.3H15c1.1,0,1.9,0.5,2.5,1.1L17.7,3l0,0
l0.2-0.2c0.5-0.2,0.8-0.3,1.1-0.3h0.2c1,0,1.7,0.5,2.4,1.1c0.6,0.6,1,1.6,1,2.5l0,0v7.5c0,1-0.5,2.5-1,3.3c0,0-2.2,3.3-2.2,4.5l0,0
V24h-2.9l-0.6-2.2L14.7,24H6.9v-2.4c0-1.1-4.8-4.3-4.8-4.3c-1-0.6-1.6-2.1-1.6-3.2l0,0V8.4c0-1.1,0.5-2.1,1.1-2.9
C2.6,4.6,4,4.1,5.3,4.2L5.3,4.2z"/>
<g>
<path d="M7.4,1C7.9,1,8.5,1.2,9,1.8l0.2,0.2l0.7,0.7L10.5,2C10.7,2,10.8,2,11,1.9c0.1,0,0.2,0,0.2,0h0.2c0.6,0,1.1,0.3,1.7,0.8
l0.2,0.2l0.7,0.7l0.7-0.7l0.1-0.1c0,0,0.1,0,0.1-0.1c0,0,0.1,0,0.1-0.1H15c0.7,0,1.3,0.3,1.8,0.8L17,3.7l0.7,0.7l0.7-0.7
c0.1,0,0.1,0,0.2-0.1c0.1-0.1,0.4-0.1,0.4-0.1h0.2c0.6,0,1.1,0.3,1.7,0.8c0.4,0.4,0.7,1.1,0.7,1.8v7.5c0,0.7-0.4,2.2-0.8,2.8
c-0.7,1.1-2.4,3.7-2.4,5V23h-1.1l-0.4-1.5L16,19l-1.1,2.3L14.1,23H7.9v-1.4c0-0.4,0-1.6-5.2-5.1C2.1,16,1.5,15,1.5,14.1V8.4
c0-0.7,0.3-1.5,0.9-2.2c0.6-0.6,1.5-1,2.4-1c0.1,0,0.2,0,0.4,0l1.1,0.1V4.2V2.2c0-0.4,0.1-0.6,0.3-0.9l0.1-0.1l0.1-0.1
C6.8,1,7.1,1,7.4,1 M14.9,2.7L14.9,2.7L14.9,2.7 M7.4,0C6.9,0,6.3,0.1,5.9,0.6c-0.5,0.5-0.6,1-0.6,1.6v2.1c-0.2,0-0.3,0-0.5,0
c-1.1,0-2.3,0.5-3.2,1.3C1,6.3,0.5,7.3,0.5,8.4v5.7c0,1.1,0.6,2.5,1.6,3.2c0,0,4.8,3.2,4.8,4.3V24h7.8l1.1-2.2l0.6,2.2h2.9v-2.5
c0-1.1,2.2-4.5,2.2-4.5c0.5-0.8,1-2.4,1-3.3V6.1c0-1-0.3-1.9-1-2.5c-0.6-0.6-1.4-1.1-2.4-1.1H19c-0.3,0-0.6,0.2-1.1,0.3L17.7,3
l-0.2-0.2c-0.6-0.6-1.4-1.1-2.5-1.1h-0.2c-0.3,0-0.5,0.2-0.8,0.3l-0.2,0.2L13.7,2c-0.6-0.6-1.4-1.1-2.4-1.1h-0.2
c-0.3,0-0.6,0.2-1.1,0.2L9.9,1.2L9.8,1.1C9.1,0.4,8.3,0,7.4,0L7.4,0z"/>
</g>
<polygon class="st1" points="10.9,10.4 12.5,10.4 12.5,16.8 10.9,16.8 "/>
<polygon class="st1" points="14,10.4 15.6,10.4 15.6,16.8 14,16.8 "/>
<polygon class="st1" points="17.2,10.4 18.8,10.4 18.8,16.8 17.2,16.8 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

@@ -637,5 +637,7 @@
</qresource>
<qresource prefix="/Cursors">
<file alias="Pointer.svg">img/UI20/Cursors/Pointer.svg</file>
<file alias="Grab_release.svg">img/UI20/Cursors/Grab_release.svg</file>
<file alias="Grabbing.svg">img/UI20/Cursors/Grabbing.svg</file>
</qresource>
</RCC>