Skip to content

Commit ae4a7ea

Browse files
committed
refactor: extract view direction menu
1 parent c874255 commit ae4a7ea

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

include/MeshCraft/Application/UI/MenuBar.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class MenuBar final {
66
public:
77
static void drawPanelToggles(bool& timeline, bool& registry, bool& ai, bool& validation);
88
static void drawOverlays(bool& edges, bool& wireframe, bool& stats, bool& shadowDebug, bool& snap);
9+
static void drawViewDirections(float& yaw, float& pitch);
910
};
1011

1112
} // namespace MeshCraft::Application::UI

src/MeshCraft/Application/UI/MenuBar.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,7 @@ float MeshCraftApplication::drawMenuBar()
511511
ImGui::EndMenu();
512512
}
513513
if (ImGui::BeginMenu("View")) {
514-
if (ImGui::MenuItem("Front", "Num1")) { camera_.yaw = 0.0f; camera_.pitch = 0.0f; }
515-
if (ImGui::MenuItem("Right", "Num3")) { camera_.yaw = std::numbers::pi_v<float> * 0.5f; camera_.pitch = 0.0f; }
516-
if (ImGui::MenuItem("Back", "Num5")) { camera_.yaw = std::numbers::pi_v<float>; camera_.pitch = 0.0f; }
517-
if (ImGui::MenuItem("Top", "Num7")) { camera_.yaw = 0.0f; camera_.pitch = 1.47f; }
518-
if (ImGui::MenuItem("Bottom", "Num9")) { camera_.yaw = 0.0f; camera_.pitch =-1.47f; }
514+
UI::MenuBar::drawViewDirections(camera_.yaw, camera_.pitch);
519515
ImGui::Separator();
520516
if (ImGui::MenuItem("Focus on selection", "F")) {
521517
if (selection_.hasSelection()) {
@@ -616,4 +612,12 @@ void MenuBar::drawOverlays(bool& edges, bool& wireframe, bool& stats, bool& shad
616612
ImGui::MenuItem("Snap to Grid", nullptr, &snap);
617613
}
618614

615+
void MenuBar::drawViewDirections(float& yaw, float& pitch) {
616+
if (ImGui::MenuItem("Front", "Num1")) { yaw = 0.0f; pitch = 0.0f; }
617+
if (ImGui::MenuItem("Right", "Num3")) { yaw = std::numbers::pi_v<float> * 0.5f; pitch = 0.0f; }
618+
if (ImGui::MenuItem("Back", "Num5")) { yaw = std::numbers::pi_v<float>; pitch = 0.0f; }
619+
if (ImGui::MenuItem("Top", "Num7")) { yaw = 0.0f; pitch = 1.47f; }
620+
if (ImGui::MenuItem("Bottom", "Num9")) { yaw = 0.0f; pitch = -1.47f; }
621+
}
622+
619623
} // namespace MeshCraft::Application::UI

0 commit comments

Comments
 (0)