소스 검색

tools: only send mouse_{up/down/move} to tool when camera is idle

Daniele Bartolini 4 년 전
부모
커밋
dda2751a5a
2개의 변경된 파일12개의 추가작업 그리고 12개의 파일을 삭제
  1. 6 2
      samples/core/editors/level_editor/level_editor.lua
  2. 6 10
      tools/level_editor/editor_view.vala

+ 6 - 2
samples/core/editors/level_editor/level_editor.lua

@@ -1678,11 +1678,15 @@ function LevelEditor:mouse_wheel(delta)
 end
 
 function LevelEditor:mouse_down(x, y)
-	self.tool:mouse_down(x, y)
+	if self._camera:is_idle() then
+		self.tool:mouse_down(x, y)
+	end
 end
 
 function LevelEditor:mouse_up(x, y)
-	self.tool:mouse_up(x, y)
+	if self._camera:is_idle() then
+		self.tool:mouse_up(x, y)
+	end
 end
 
 function LevelEditor:key_down(key)

+ 6 - 10
tools/level_editor/editor_view.vala

@@ -142,16 +142,14 @@ public class EditorView : Gtk.EventBox
 			, _mouse_right
 			);
 
+		if (ev.button == Gdk.BUTTON_PRIMARY)
+			s += LevelEditorApi.mouse_up((int)ev.x, (int)ev.y);
+
 		if (camera_modifier_pressed())
 		{
 			if (!_mouse_left || !_mouse_middle || !_mouse_right)
 				s += "LevelEditor:camera_drag_start('idle')";
 		}
-		else
-		{
-			if (ev.button == Gdk.BUTTON_PRIMARY)
-				s += LevelEditorApi.mouse_up((int)ev.x, (int)ev.y);
-		}
 
 		_client.send_script(s);
 		return Gdk.EVENT_PROPAGATE;
@@ -182,11 +180,9 @@ public class EditorView : Gtk.EventBox
 			if (_mouse_right)
 				s += "LevelEditor:camera_drag_start('dolly')";
 		}
-		else
-		{
-			if (ev.button == Gdk.BUTTON_PRIMARY)
-				s += LevelEditorApi.mouse_down((int)ev.x, (int)ev.y);
-		}
+
+		if (ev.button == Gdk.BUTTON_PRIMARY)
+			s += LevelEditorApi.mouse_down((int)ev.x, (int)ev.y);
 
 		_client.send_script(s);
 		return Gdk.EVENT_PROPAGATE;