Browse Source

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 years ago
parent
commit
cbe2abf0b1
1 changed files with 20 additions and 15 deletions
  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)
 void OBSBasicPreview::keyPressEvent(QKeyEvent *event)
 {
 {
-	if (locked ||
-	    GetScalingMode() == ScalingMode::Window ||
+	if (GetScalingMode() == ScalingMode::Window ||
 	    event->isAutoRepeat()) {
 	    event->isAutoRepeat()) {
 		OBSQTDisplay::keyPressEvent(event);
 		OBSQTDisplay::keyPressEvent(event);
 		return;
 		return;
@@ -416,6 +415,19 @@ void OBSBasicPreview::keyReleaseEvent(QKeyEvent *event)
 
 
 void OBSBasicPreview::mousePressEvent(QMouseEvent *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) {
 	if (locked) {
 		OBSQTDisplay::mousePressEvent(event);
 		OBSQTDisplay::mousePressEvent(event);
 		return;
 		return;
@@ -430,13 +442,6 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event)
 
 
 	OBSQTDisplay::mousePressEvent(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 &&
 	if (event->button() != Qt::LeftButton &&
 	    event->button() != Qt::RightButton)
 	    event->button() != Qt::RightButton)
 		return;
 		return;
@@ -500,14 +505,14 @@ void OBSBasicPreview::ProcessClick(const vec2 &pos)
 
 
 void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event)
 void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event)
 {
 {
+	if (scrollMode)
+		setCursor(Qt::OpenHandCursor);
+
 	if (locked) {
 	if (locked) {
 		OBSQTDisplay::mouseReleaseEvent(event);
 		OBSQTDisplay::mouseReleaseEvent(event);
 		return;
 		return;
 	}
 	}
 
 
-	if (scrollMode)
-		setCursor(Qt::OpenHandCursor);
-
 	if (mouseDown) {
 	if (mouseDown) {
 		vec2 pos = GetMouseEventPos(event);
 		vec2 pos = GetMouseEventPos(event);
 
 
@@ -998,9 +1003,6 @@ void OBSBasicPreview::StretchItem(const vec2 &pos)
 
 
 void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
 void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
 {
 {
-	if (locked)
-		return;
-
 	if (scrollMode && event->buttons() == Qt::LeftButton) {
 	if (scrollMode && event->buttons() == Qt::LeftButton) {
 		scrollingOffset.x += event->x() - scrollingFrom.x;
 		scrollingOffset.x += event->x() - scrollingFrom.x;
 		scrollingOffset.y += event->y() - scrollingFrom.y;
 		scrollingOffset.y += event->y() - scrollingFrom.y;
@@ -1010,6 +1012,9 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
 		return;
 		return;
 	}
 	}
 
 
+	if (locked)
+		return;
+
 	if (mouseDown) {
 	if (mouseDown) {
 		vec2 pos = GetMouseEventPos(event);
 		vec2 pos = GetMouseEventPos(event);