From ff1e270f0b87ecf9b5efd8d083e67fe24ee66b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0toura=C4=8D?= <525032@mail.muni.cz> Date: Sat, 18 May 2024 23:19:16 +0200 Subject: [PATCH] fix ui drag when step set to 0 --- src/edit/src/editor.cpp | 3 ++- src/gui/src/ui.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/edit/src/editor.cpp b/src/edit/src/editor.cpp index 9388074..4618254 100644 --- a/src/edit/src/editor.cpp +++ b/src/edit/src/editor.cpp @@ -2282,6 +2282,7 @@ void Editor::exitManipulateModule() void Editor::exitRotateComponent() { scene->manageSelection(nullptr); + selected_module = nullptr; prev_rebuild_node = nullptr; can_rotate_component = true; is_rotating_component = false; @@ -2680,7 +2681,7 @@ void Editor::teleportModulesByConnectors(const connector_ptr source_connector, c const auto oriented_angle = glm::orientedAngle(source_north, destination_north, destination_facing); source_parent->rotateRotationQuat(glm::angleAxis(oriented_angle, destination_facing)); - + // Rotate to selected cardinality auto orientation = glm::radians(rofi::cardinal_to_degree(selected_cardinality)); diff --git a/src/gui/src/ui.cpp b/src/gui/src/ui.cpp index ee8affd..5f95fe8 100644 --- a/src/gui/src/ui.cpp +++ b/src/gui/src/ui.cpp @@ -736,6 +736,10 @@ void module_rotation_ui(const osi::Window &window, edit::UIData &data) ImGui::End(); + // DragFloat still changes value when step is set to 0 + if (data.module_rotation_step == 0) + euler_angles = prev_euler_angles; + data.module_rotation_angles = euler_angles - prev_euler_angles; data.is_rotating_module = data.module_rotation_angles != glm::vec3(0.0f, 0.0f, 0.0f); } @@ -827,6 +831,10 @@ void component_rotation_ui(const osi::Window &window, edit::UIData &data) ImGui::End(); + // DragFloat still changes value when step is set to 0 + if (data.component_rotation_step == 0) + current_rotation = prev_rotation; + data.component_rotation_angle = component_info == "Body A" ? prev_rotation - current_rotation : current_rotation - prev_rotation; data.is_rotating_component = data.component_rotation_angle != 0; } -- GitLab