initial wip code to update cursor states

Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
hultonha
2021-10-14 18:23:55 +01:00
parent 716c561cb7
commit 1d6542c274
6 changed files with 58 additions and 0 deletions
@@ -256,6 +256,14 @@ namespace AzToolsFramework
// If our focus changes, go ahead and reset all input devices.
HandleFocusChange(event);
if (eventType == QEvent::FocusOut)
{
if (m_capturingCursor)
{
qApp->restoreOverrideCursor();
}
}
// If we focus in on the source widget and the mouse is contained in its
// bounds, refresh the cached cursor position to ensure it is up to date (this
// ensures cursor positions are refreshed correctly with context menu focus changes)
@@ -264,6 +272,11 @@ namespace AzToolsFramework
const auto globalCursorPosition = QCursor::pos();
if (m_sourceWidget->geometry().contains(globalCursorPosition))
{
if (m_capturingCursor)
{
qApp->setOverrideCursor(Qt::ForbiddenCursor);
}
HandleMouseMoveEvent(globalCursorPosition);
}
}
@@ -452,4 +465,22 @@ namespace AzToolsFramework
}
}
}
void QtEventToAzInputMapper::PushCursor(/*enum*/)
{
if (!m_overrideCursor)
{
qApp->setOverrideCursor(Qt::ForbiddenCursor);
m_overrideCursor = true;
}
}
void QtEventToAzInputMapper::PopCursor()
{
if (m_overrideCursor)
{
qApp->restoreOverrideCursor();
m_overrideCursor = false;
}
}
} // namespace AzToolsFramework
@@ -55,6 +55,9 @@ namespace AzToolsFramework
//! like a dolly or rotation, where mouse movement is important but cursor location is not.
void SetCursorCaptureEnabled(bool enabled);
void PushCursor(/*enum*/);
void PopCursor();
// QObject overrides...
bool eventFilter(QObject* object, QEvent* event) override;
@@ -164,6 +167,8 @@ namespace AzToolsFramework
bool m_enabled = true;
// Flags whether or not the cursor is being constrained to the source widget (for invisible mouse movement).
bool m_capturingCursor = false;
//
bool m_overrideCursor = true;
// Our viewport-specific AZ devices. We control their internal input channel states.
AZStd::unique_ptr<EditorQtMouseDevice> m_mouseDevice;