From 0c7ff4063850ecbb8ccaeab51fe402b273b03fad Mon Sep 17 00:00:00 2001 From: ericek111 Date: Wed, 25 Mar 2026 19:47:26 +0100 Subject: [PATCH] commit no. 4 --- src/ui/Application.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/ui/Application.cpp b/src/ui/Application.cpp index 352bbe5..558d4a8 100644 --- a/src/ui/Application.cpp +++ b/src/ui/Application.cpp @@ -649,14 +649,12 @@ void Application::renderWaterfallPanel() { float availW = ImGui::GetContentRegionAvail().x; float availH = ImGui::GetContentRegionAvail().y; - // Fixed history depth — independent of screen height, so resizing the - // splitter doesn't recreate the texture every frame. - constexpr int kHistoryRows = 1024; - - // Only recreate when the bin count (FFT size) changes. + // History depth must be >= panel height for 1:1 pixel mapping. + // Only recreate when bin count or needed height actually changes. + int neededH = std::max(1024, static_cast(availH) + 1); int binCount = std::max(1, analyzer_.spectrumSize()); - if (binCount != waterfall_.width() || waterfall_.height() != kHistoryRows) { - waterfall_.resize(binCount, kHistoryRows); + if (binCount != waterfall_.width() || waterfall_.height() < neededH) { + waterfall_.resize(binCount, neededH); waterfall_.setColorMap(colorMap_); } @@ -718,19 +716,19 @@ void Application::renderWaterfallPanel() { // From newestRow, walk forward (increasing index mod h) for // screenRows steps to cover newest→oldest. + // Use availH for the screen extent so there's no fractional pixel gap. + float pxPerRow = availH / static_cast(screenRows); + if (newestRow + screenRows <= h) { - // No wrap: rows [newestRow .. newestRow+screenRows) - drawSpan(newestRow, screenRows, screenY, static_cast(screenRows)); + drawSpan(newestRow, screenRows, screenY, availH); } else { - // Wraps: [newestRow .. h), then [0 .. remainder) int firstCount = h - newestRow; - float firstH = static_cast(firstCount); + float firstH = firstCount * pxPerRow; drawSpan(newestRow, firstCount, screenY, firstH); int secondCount = screenRows - firstCount; - float secondH = static_cast(secondCount); if (secondCount > 0) - drawSpan(0, secondCount, screenY + firstH, secondH); + drawSpan(0, secondCount, screenY + firstH, availH - firstH); } // ── Frequency axis labels ── @@ -1011,9 +1009,9 @@ void Application::updateAnalyzerSettings() { // Re-init waterfall texture so the old image from a different FFT // size doesn't persist. - constexpr int kHistoryRows = 1024; + int reinitH = std::max(1024, waterfall_.height()); int binCount2 = std::max(1, analyzer_.spectrumSize()); - waterfall_.init(binCount2, kHistoryRows); + waterfall_.init(binCount2, reinitH); } }