From 65a69ccbea896242a4b8e673bddc20ae89a24d73 Mon Sep 17 00:00:00 2001
From: Michel Mastriani <michel.mastriani@gmail.com>
Date: Tue, 11 Jun 2019 22:30:20 -0300
Subject: [PATCH] Fixed Grid and Solution for sensitive mouse

---
 Source/Fractorium/FractoriumMenus.cpp |  7 ++++++-
 Source/Fractorium/GLWidget.cpp        | 12 +++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/Source/Fractorium/FractoriumMenus.cpp b/Source/Fractorium/FractoriumMenus.cpp
index 96a83a5..86f19b6 100644
--- a/Source/Fractorium/FractoriumMenus.cpp
+++ b/Source/Fractorium/FractoriumMenus.cpp
@@ -261,6 +261,7 @@ void FractoriumEmberController<T>::OpenAndPrepFiles(const QStringList& filenames
 			FillLibraryTree(append ? previousSize - 1 : 0);
 
 		ClearUndo();
+        m_GLController->ClearControl();
 		SetEmber(previousSize, false);
 	}
 }
@@ -279,7 +280,7 @@ void Fractorium::OnActionOpen(bool checked) { m_Controller->OpenAndPrepFiles(Set
 template <typename T>
 void FractoriumEmberController<T>::SaveCurrentAsXml()
 {
-	QString filename;
+    QString filename;
 	auto s = m_Fractorium->m_Settings;
 
 	if (s->SaveAutoUnique() && m_LastSaveCurrent != "")
@@ -321,6 +322,8 @@ void FractoriumEmberController<T>::SaveCurrentAsXml()
 		else
 			m_Fractorium->ShowCritical("Save Failed", "Could not save file, try saving to a different folder.");
 	}
+
+    m_GLController->ClearControl();
 }
 
 void Fractorium::OnActionSaveCurrentAsXml(bool checked) { m_Controller->SaveCurrentAsXml(); }
@@ -364,6 +367,8 @@ void FractoriumEmberController<T>::SaveEntireFileAsXml()
 		else
 			m_Fractorium->ShowCritical("Save Failed", "Could not save file, try saving to a different folder.");
 	}
+
+    m_GLController->ClearControl();
 }
 
 void Fractorium::OnActionSaveEntireFileAsXml(bool checked) { m_Controller->SaveEntireFileAsXml(); }
diff --git a/Source/Fractorium/GLWidget.cpp b/Source/Fractorium/GLWidget.cpp
index 4278b1d..a37421e 100644
--- a/Source/Fractorium/GLWidget.cpp
+++ b/Source/Fractorium/GLWidget.cpp
@@ -374,7 +374,7 @@ void GLEmberControllerBase::ClearControl() { m_DragModifier &= ~et(eDragModifier
 template <typename T>
 void GLEmberController<T>::ClearWindow()
 {
-	auto ember = m_FractoriumEmberController->CurrentEmber();
+    auto ember = m_FractoriumEmberController->CurrentEmber();
 	m_GL->makeCurrent();
 	m_GL->glClearColor(ember->m_Background.r, ember->m_Background.g, ember->m_Background.b, 1.0);
 	m_GL->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -804,7 +804,7 @@ bool GLEmberControllerBase::KeyPress_(QKeyEvent* e)
 	{
 		SetControl();
 		return true;
-	}
+    }
 
 	return false;
 }
@@ -829,7 +829,7 @@ bool GLEmberControllerBase::KeyRelease_(QKeyEvent* e)
 {
 	if (e->key() == Qt::Key_Control)
 	{
-		ClearControl();
+        ClearControl();
 		return true;
 	}
 
@@ -1116,12 +1116,10 @@ void GLEmberController<T>::Wheel(QWheelEvent* e)
 	}
 	else
 	{
-		if (m_Fractorium->DrawImage())
+        if (m_Fractorium->DrawImage() && (!(e->buttons() & Qt::MiddleButton)) && (!(e->modifiers() & Qt::ShiftModifier))) //Middle button does whole image translation, so ignore the mouse wheel while panning to avoid inadvertent zooming. ShiftModifier for sensitive mouse.
 		{
 			auto ember = m_FractoriumEmberController->CurrentEmber();
-
-			if (!(e->buttons() & Qt::MiddleButton))//Middle button does whole image translation, so ignore the mouse wheel while panning to avoid inadvertent zooming.
-				m_Fractorium->SetScale(ember->m_PixelsPerUnit + (e->angleDelta().y() >= 0 ? 50 : -50));
+            m_Fractorium->SetScale(ember->m_PixelsPerUnit + (e->angleDelta().y() >= 0 ? 50 : -50));
 		}
 	}
 }