Browse Source

Added togglable setting for changing the behavior of the MMB, allows panning by default instead of rotation/orbit

julyfortoday 10 years ago
parent
commit
6d8e057a7e

+ 11 - 0
bin/Data/Scripts/Editor/EditorPreferences.as

@@ -91,6 +91,10 @@ void UpdateEditorPreferencesDialog()
     LineEdit@ uiMaxOpacityEdit = preferencesDialog.GetChild("UIMaxOpacity", true);
     LineEdit@ uiMaxOpacityEdit = preferencesDialog.GetChild("UIMaxOpacity", true);
     uiMaxOpacityEdit.text = String(uiMaxOpacity);
     uiMaxOpacityEdit.text = String(uiMaxOpacity);
 
 
+	CheckBox@ middleMousePanToggle = preferencesDialog.GetChild("UIMiddleMousePan", true);
+    middleMousePanToggle.checked = mmbPan;
+	
+	
     CheckBox@ showInternalUIElementToggle = preferencesDialog.GetChild("ShowInternalUIElement", true);
     CheckBox@ showInternalUIElementToggle = preferencesDialog.GetChild("ShowInternalUIElement", true);
     showInternalUIElementToggle.checked = showInternalUIElement;
     showInternalUIElementToggle.checked = showInternalUIElement;
 
 
@@ -159,6 +163,7 @@ void UpdateEditorPreferencesDialog()
     {
     {
         SubscribeToEvent(uiMinOpacityEdit, "TextFinished", "EditUIMinOpacity");
         SubscribeToEvent(uiMinOpacityEdit, "TextFinished", "EditUIMinOpacity");
         SubscribeToEvent(uiMaxOpacityEdit, "TextFinished", "EditUIMaxOpacity");
         SubscribeToEvent(uiMaxOpacityEdit, "TextFinished", "EditUIMaxOpacity");
+		SubscribeToEvent(middleMousePanToggle, "Toggled", "ToggleMiddleMousePan");
         SubscribeToEvent(showInternalUIElementToggle, "Toggled", "ToggleShowInternalUIElement");
         SubscribeToEvent(showInternalUIElementToggle, "Toggled", "ToggleShowInternalUIElement");
         SubscribeToEvent(showTemporaryObjectToggle, "Toggled", "ToggleShowTemporaryObject");
         SubscribeToEvent(showTemporaryObjectToggle, "Toggled", "ToggleShowTemporaryObject");
         SubscribeToEvent(nodeItemTextColorEditR, "TextFinished", "EditNodeTextColor");
         SubscribeToEvent(nodeItemTextColorEditR, "TextFinished", "EditNodeTextColor");
@@ -232,6 +237,12 @@ void EditUIMaxOpacity(StringHash eventType, VariantMap& eventData)
     UnfadeUI();
     UnfadeUI();
 }
 }
 
 
+void ToggleMiddleMousePan(StringHash eventType, VariantMap& eventData)
+{
+    bool mmbPanEnabled = cast<CheckBox>(eventData["Element"].GetPtr()).checked;
+    SetMMBPan(mmbPanEnabled);
+}
+
 void ToggleShowInternalUIElement(StringHash eventType, VariantMap& eventData)
 void ToggleShowInternalUIElement(StringHash eventType, VariantMap& eventData)
 {
 {
     showInternalUIElement = cast<CheckBox>(eventData["Element"].GetPtr()).checked;
     showInternalUIElement = cast<CheckBox>(eventData["Element"].GetPtr()).checked;

+ 17 - 3
bin/Data/Scripts/Editor/EditorView.as

@@ -6,6 +6,7 @@ Camera@ camera;
 
 
 Node@ gridNode;
 Node@ gridNode;
 CustomGeometry@ grid;
 CustomGeometry@ grid;
+bool mmbPan = false;
 
 
 UIElement@ viewportUI; // holds the viewport ui, convienent for clearing and hiding
 UIElement@ viewportUI; // holds the viewport ui, convienent for clearing and hiding
 uint setViewportCursor = 0; // used to set cursor in post update
 uint setViewportCursor = 0; // used to set cursor in post update
@@ -999,6 +1000,11 @@ void UpdateViewParameters()
     }
     }
 }
 }
 
 
+void SetMMBPan(bool enableMMBPan)
+{
+	mmbPan = enableMMBPan;
+}
+
 void CreateGrid()
 void CreateGrid()
 {
 {
     if (gridNode !is null)
     if (gridNode !is null)
@@ -1255,16 +1261,23 @@ void UpdateView(float timeStep)
 			cameraNode.worldPosition = centerPoint - q * Vector3(0.0, 0.0,10);
 			cameraNode.worldPosition = centerPoint - q * Vector3(0.0, 0.0,10);
 		}
 		}
 	}
 	}
-	
+
     // Rotate/orbit/pan camera
     // Rotate/orbit/pan camera
-    if (input.mouseButtonDown[MOUSEB_RIGHT] || input.mouseButtonDown[MOUSEB_MIDDLE])
+	bool changeCamViewButton = input.mouseButtonDown[MOUSEB_RIGHT] || input.mouseButtonDown[MOUSEB_MIDDLE];
+    if (changeCamViewButton)
     {
     {
         SetMouseLock();
         SetMouseLock();
 
 
         IntVector2 mouseMove = input.mouseMove;
         IntVector2 mouseMove = input.mouseMove;
         if (mouseMove.x != 0 || mouseMove.y != 0)
         if (mouseMove.x != 0 || mouseMove.y != 0)
         {
         {
-            if (input.keyDown[KEY_LSHIFT] && input.mouseButtonDown[MOUSEB_MIDDLE])
+			bool panTheCamera = false;
+			if(mmbPan)
+				panTheCamera = !(changeCamViewButton && input.keyDown[KEY_LSHIFT]);
+			else
+				panTheCamera = (changeCamViewButton && input.keyDown[KEY_LSHIFT]);
+			
+            if (panTheCamera)
             {
             {
                 cameraNode.Translate(Vector3(-mouseMove.x, mouseMove.y, 0) * timeStep * cameraBaseSpeed * 0.5);
                 cameraNode.Translate(Vector3(-mouseMove.x, mouseMove.y, 0) * timeStep * cameraBaseSpeed * 0.5);
             }
             }
@@ -1278,6 +1291,7 @@ void UpdateView(float timeStep)
 
 
                 Quaternion q = Quaternion(activeViewport.cameraPitch, activeViewport.cameraYaw, 0);
                 Quaternion q = Quaternion(activeViewport.cameraPitch, activeViewport.cameraYaw, 0);
                 cameraNode.rotation = q;
                 cameraNode.rotation = q;
+						
                 if (input.mouseButtonDown[MOUSEB_MIDDLE] && (selectedNodes.length > 0 || selectedComponents.length > 0))
                 if (input.mouseButtonDown[MOUSEB_MIDDLE] && (selectedNodes.length > 0 || selectedComponents.length > 0))
                 {
                 {
                     Vector3 centerPoint = SelectedNodesCenterPoint();
                     Vector3 centerPoint = SelectedNodesCenterPoint();

+ 10 - 0
bin/Data/UI/EditorPreferencesDialog.xml

@@ -50,6 +50,16 @@
                         <attribute name="Min Size" value="50 0" />
                         <attribute name="Min Size" value="50 0" />
                         <attribute name="Max Size" value="50 2147483647" />
                         <attribute name="Max Size" value="50 2147483647" />
                     </element>
                     </element>
+                </element>
+				<element style="ListRow">
+                    <attribute name="Layout Border" value="20 0 0 0" />
+                    <attribute name="Layout Spacing" value="8" />
+                    <element type="CheckBox">
+                        <attribute name="Name" value="UIMiddleMousePan" />
+                    </element>
+                    <element type="Text">
+                        <attribute name="Text" value="Pan using MiddleMouseButton" />
+                    </element>
                 </element>
                 </element>
                 <element type="BorderImage" style="EditorDivider" />
                 <element type="BorderImage" style="EditorDivider" />
                 <element style="ListRow">
                 <element style="ListRow">