From 8388fbfe3e43c41ae1bd8494e8d3604e9f476a06 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Fri, 1 Mar 2024 14:00:14 +0100 Subject: [PATCH] Better separated 3D view and graph editor navigation. --- src/main.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main.cc b/src/main.cc index bf58e20..27bb0b3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -669,6 +669,7 @@ int main() { // Graph Editor gApplicationConfig.graph_editor.config.SettingsFile = "graph_editor.json"; + gApplicationConfig.graph_editor.config.NavigateButtonIndex = 2; gApplicationConfig.graph_editor.context = ax::NodeEditor::CreateEditor(&gApplicationConfig.graph_editor.config); // draw loop @@ -711,13 +712,7 @@ int main() { // handle input handle_mouse(w, &gGuiInputState); - if (glfwGetMouseButton(w, GLFW_MOUSE_BUTTON_RIGHT)) { - if (gControlMode == ControlMode::ControlModeNone) { - gControlMode = ControlMode::ControlModeFPS; - Camera_CalcFromMatrix(&state.camera, &state.camera.mtxView[0]); - glfwSetInputMode(w, GLFW_CURSOR, GLFW_CURSOR_DISABLED); - } - } else { + if (!glfwGetMouseButton(w, GLFW_MOUSE_BUTTON_RIGHT)) { gControlMode = ControlMode::ControlModeNone; glfwSetInputMode(w, GLFW_CURSOR, GLFW_CURSOR_NORMAL); Camera_Update( @@ -761,8 +756,8 @@ int main() { Camera_Update( &state.camera, - cur_width, - cur_height, + offscreen_viewport.size[0], + offscreen_viewport.size[1], static_cast(state.time.frame), static_cast(gGuiInputState.mousedX), static_cast(gGuiInputState.mousedY), @@ -847,6 +842,14 @@ int main() { ImGui::Begin("Viewport", &gApplicationConfig.viewport_widget.visible); + if (ImGui::IsWindowHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Right)) { + if (gControlMode == ControlMode::ControlModeNone) { + gControlMode = ControlMode::ControlModeFPS; + Camera_CalcFromMatrix(&state.camera, &state.camera.mtxView[0]); + glfwSetInputMode(w, GLFW_CURSOR, GLFW_CURSOR_DISABLED); + } + } + ImVec2 viewport_widget_size = ImGui::GetWindowSize(); gApplicationConfig.viewport_widget.size[0] = static_cast(viewport_widget_size.x); gApplicationConfig.viewport_widget.size[1] = static_cast(viewport_widget_size.y);