瀏覽代碼

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.
Joseph El-Khouri 9 年之前
父節點
當前提交
cbe2abf0b1
共有 1 個文件被更改,包括 20 次插入15 次删除
  1. 20 15
      UI/window-basic-preview.cpp

+ 20 - 15
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);