From cbe2abf0b1d1be5218a3beb72f7fc541a90571e4 Mon Sep 17 00:00:00 2001 From: Joseph El-Khouri Date: Thu, 10 Nov 2016 09:32:44 -0500 Subject: [PATCH] UI: Fix scrolling while preview is locked As reboot pointed out, it's assumed that the intention of a locked preview is to prevent editing the scene. Because scrolling the preview does not have any interaction with the scene and its sources, you should be able to still scroll around and look at different parts of your preview while the preview is locked. There is also a bugfix included: previously, if you were to right click while space bar was held down, you would be stuck in scroll mode until spacebar is pressed/released again. This gets around it by forcing scroll mode to end when a right click is issued on the preview. --- UI/window-basic-preview.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index c265afbf1..01cd73026 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -380,8 +380,7 @@ void OBSBasicPreview::GetStretchHandleData(const vec2 &pos) void OBSBasicPreview::keyPressEvent(QKeyEvent *event) { - if (locked || - GetScalingMode() == ScalingMode::Window || + if (GetScalingMode() == ScalingMode::Window || event->isAutoRepeat()) { OBSQTDisplay::keyPressEvent(event); return; @@ -416,6 +415,19 @@ void OBSBasicPreview::keyReleaseEvent(QKeyEvent *event) void OBSBasicPreview::mousePressEvent(QMouseEvent *event) { + if (scrollMode && GetScalingMode() != ScalingMode::Window && + event->button() == Qt::LeftButton) { + setCursor(Qt::ClosedHandCursor); + scrollingFrom.x = event->x(); + scrollingFrom.y = event->y(); + return; + } + + if (event->button() == Qt::RightButton) { + scrollMode = false; + setCursor(Qt::ArrowCursor); + } + if (locked) { OBSQTDisplay::mousePressEvent(event); return; @@ -430,13 +442,6 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event) OBSQTDisplay::mousePressEvent(event); - if (scrollMode && GetScalingMode() != ScalingMode::Window) { - setCursor(Qt::ClosedHandCursor); - scrollingFrom.x = event->x(); - scrollingFrom.y = event->y(); - return; - } - if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton) return; @@ -500,14 +505,14 @@ void OBSBasicPreview::ProcessClick(const vec2 &pos) void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event) { + if (scrollMode) + setCursor(Qt::OpenHandCursor); + if (locked) { OBSQTDisplay::mouseReleaseEvent(event); return; } - if (scrollMode) - setCursor(Qt::OpenHandCursor); - if (mouseDown) { vec2 pos = GetMouseEventPos(event); @@ -998,9 +1003,6 @@ void OBSBasicPreview::StretchItem(const vec2 &pos) void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) { - if (locked) - return; - if (scrollMode && event->buttons() == Qt::LeftButton) { scrollingOffset.x += event->x() - scrollingFrom.x; scrollingOffset.y += event->y() - scrollingFrom.y; @@ -1010,6 +1012,9 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) return; } + if (locked) + return; + if (mouseDown) { vec2 pos = GetMouseEventPos(event);