From bbc1ef66233b79fe9a61ce6109aed9d2d7061ea9 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Fri, 27 Jun 2025 10:55:35 -0400 Subject: [PATCH] testing imgui tabs and combobox --- src/gooey.cpp | 70 +++++++++++++++++++++++++++++++++------------------ src/main.cpp | 3 ++- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/gooey.cpp b/src/gooey.cpp index 901af82..ef25872 100644 --- a/src/gooey.cpp +++ b/src/gooey.cpp @@ -76,26 +76,40 @@ gooDraw(SDL_Window* window, GameState* gs, RenderState* rs) Begin("Gooey"); drawSimulationWindow(gs->running, gs->sim_time_ms, gs->sim_speed); - drawMemoryWindow(gs->arena, rs); Separator(); - drawOrbitSelectionWindow(gs); - GameOrbit* orbit = getSelectedOrbit(gs); + // FIXME: testing tabs + if (BeginTabBar("tabbar_01")) { + if (BeginTabItem("orbits")) { + drawOrbitSelectionWindow(gs); + GameOrbit* orbit = getSelectedOrbit(gs); + + if (orbit) { + TwoBodySystem& sys = orbit->system; + BeginChild("orbit details", ImVec2(G_WIDTH - 20, 450), true); + drawSystemWindow(sys); + Separator(); + drawSatelliteWindow(sys.sat); + Separator(); + drawOrbitalElements(sys.elements); + EndChild(); + + BeginChild("impulsive maneuver", ImVec2(G_WIDTH - 20, 125), true); + drawManeuverWindow(gs); + EndChild(); + } - if (orbit) { - TwoBodySystem& sys = orbit->system; - BeginChild("orbit details", ImVec2(G_WIDTH - 20, 450), true); - drawSystemWindow(sys); - Separator(); - drawSatelliteWindow(sys.sat); - Separator(); - drawOrbitalElements(sys.elements); - EndChild(); - } + EndTabItem(); + } - BeginChild("impulsive maneuver", ImVec2(G_WIDTH - 20, 125), true); - drawManeuverWindow(gs); - EndChild(); + if (BeginTabItem("resources")) { + drawMemoryWindow(gs->arena, rs); + EndTabItem(); + } + + EndTabBar(); + } + // FIXME: end testing tabs End(); Render(); @@ -162,17 +176,25 @@ void drawOrbitSelectionWindow(GameState* gs) BeginChild("orbit selection", ImVec2(G_WIDTH - 20, 55), true); - for (u32 i = 0; i < gs->num_orbits; i++) { - GameOrbit& orbit = gs->orbits[i]; + const u32 label_len = 32; + static char label[label_len]; + static char selected_label[label_len]; + + if (BeginCombo("select orbit", selected_label)) { + for (u32 i = 0; i < gs->num_orbits; i++) { + GameOrbit& orbit = gs->orbits[i]; - if (orbit.in_use) { - const u32 label_len = 32; - static char label[label_len]; - snprintf(label, label_len, "Orbit %d", i); + if (orbit.in_use) { + snprintf(label, label_len, "Orbit %d", i); - if (Selectable(label, orbit.selected)) - selectOrbit(gs, &orbit); + if (Selectable(label, orbit.selected)) { + selectOrbit(gs, &orbit); + snprintf(selected_label, label_len, "Orbit %d", i); + } + } } + + EndCombo(); } EndChild(); diff --git a/src/main.cpp b/src/main.cpp index f727055..653ce78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -303,7 +303,8 @@ loadScene(GameState* gs, RenderState* rs) addManeuver(gs, go_2, ImpulseType::CIRCULARIZE_LOWERING); // NOTE: pre-select an orbit for testing - selectOrbit(gs, go_2); + // NOTE: doesn't work the same with the Combo Selection + //selectOrbit(gs, go_2); #if DEBUG_ORBITS // NOTE: add more orbits with maneuvers to try and provoke a failure