From 335c63550c6594ffd7df7a8cb2d57a9a1d4762a5 Mon Sep 17 00:00:00 2001 From: Gondos Date: Sun, 21 Dec 2025 17:26:34 +0100 Subject: [PATCH 1/3] =?UTF-8?q?[ImGui]FPS=20info:=20filter=20=CE=94T/F=20a?= =?UTF-8?q?nd=20right=20align?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Orbiter/MenuInfoBar.cpp | 47 +++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/Src/Orbiter/MenuInfoBar.cpp b/Src/Orbiter/MenuInfoBar.cpp index 0594c8fdd..165e4778a 100644 --- a/Src/Orbiter/MenuInfoBar.cpp +++ b/Src/Orbiter/MenuInfoBar.cpp @@ -29,6 +29,24 @@ const ImGuiWindowFlags INFOFLAGS = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoDocking; +template +struct MovingAverage { + float buf[N]{}; + std::size_t idx = 0; + std::size_t count = 0; + float sum = 0.0; + + float add(float x) { + sum -= buf[idx]; + buf[idx] = x; + sum += x; + + idx = (idx + 1) % N; + if (count < N) ++count; + + return sum / count; + } +}; class DynamicMenuBar: public ImGuiDialog { @@ -506,6 +524,7 @@ class InfoFrameRate { float history[HISTORY_SIZE]; float fpsMax; int historyOffset; + MovingAverage<16> dtavg; public: InfoFrameRate() { for(int i = 0; i < HISTORY_SIZE; i++) { @@ -540,8 +559,32 @@ class InfoFrameRate { ImGuiContext &g = *GImGui; ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x - HISTORY_SIZE - 8.0, 0), ImGuiChildFlags_AutoResizeY); - ImGui::TextColored(white, "F/s:%.0f", g.IO.Framerate); - ImGui::TextColored(white, "ΔT/F:%0.*fs", td.SimDT < 1e-1 ? 3 : td.SimDT < 1 ? 2 : td.SimDT < 10 ? 1 : 0, td.SimDT); + + ImGui::TextColored(white, "%s", "F/s"); + char buf[64]; + snprintf(buf, 64, "%.0f", td.FPS()); + buf[63] = '\n'; + // Right align + ImGui::SameLine(); + ImGui::SetCursorPosX( + ImGui::GetCursorPosX() + + ImGui::GetContentRegionAvail().x - + ImGui::CalcTextSize(buf).x + ); + ImGui::TextColored(white, "%s", buf); + + ImGui::TextColored(white, "%s", "ΔT/F"); + float simdt = dtavg.add(td.SimDT); + snprintf(buf, 64, "%0.*fs", simdt < 1e-1 ? 3 : simdt < 1 ? 2 : simdt < 10 ? 1 : 0, simdt); + buf[63] = '\n'; + // Right align + ImGui::SameLine(); + ImGui::SetCursorPosX( + ImGui::GetCursorPosX() + + ImGui::GetContentRegionAvail().x - + ImGui::CalcTextSize(buf).x + ); + ImGui::TextColored(white, "%s", buf); ImGui::EndChild(); ImGui::SameLine(); ImGui::BeginChild("ChildR");//, ImVec2(ImGui::GetContentRegionAvail().x / 3.0f * 2.0f, 0), ImGuiChildFlags_AutoResizeY); From 6fb80c90d972b2a3c0bab60450878809d3b2720d Mon Sep 17 00:00:00 2001 From: Gondos Date: Sun, 21 Dec 2025 19:07:58 +0100 Subject: [PATCH 2/3] [ImGui]Don't show the menubar in the window list --- Src/Orbiter/MenuInfoBar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Orbiter/MenuInfoBar.cpp b/Src/Orbiter/MenuInfoBar.cpp index 165e4778a..d1f9c9385 100644 --- a/Src/Orbiter/MenuInfoBar.cpp +++ b/Src/Orbiter/MenuInfoBar.cpp @@ -118,7 +118,8 @@ class DynamicMenuBar: public ImGuiDialog ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_DockNodeHost | ImGuiWindowFlags_NoBringToFrontOnFocus | - ImGuiWindowFlags_NoDocking; + ImGuiWindowFlags_NoDocking | + ImGuiWindowFlags_NoNav; void OnDraw() {} std::vector items; float animState; From 8e717991bc202a846931171f92beeaa6da3641c6 Mon Sep 17 00:00:00 2001 From: Gondos Date: Sun, 21 Dec 2025 19:25:54 +0100 Subject: [PATCH 3/3] [ImGui]Fix target lock toggle in Camera/Ground tab --- Src/Orbiter/DlgCamera.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Src/Orbiter/DlgCamera.cpp b/Src/Orbiter/DlgCamera.cpp index 0134a6faa..30a8e0815 100644 --- a/Src/Orbiter/DlgCamera.cpp +++ b/Src/Orbiter/DlgCamera.cpp @@ -352,7 +352,9 @@ void DlgCamera::DrawGround() { ApplyObserver(); } - ImGui::Checkbox("Target lock", &m_TargetLock); + if(ImGui::Checkbox("Target lock", &m_TargetLock)) + g_camera->SetGroundObserver_TargetLock (m_TargetLock); + ImGui::EndChild(); }