From a149b184352a0c5f81e47fdcdb1c068af5112503 Mon Sep 17 00:00:00 2001 From: Uladzimir Karpenka Date: Mon, 27 Apr 2026 18:37:02 +0300 Subject: [PATCH] Fix ruler not updating on sample rate change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add FRulerLastSpan to ruler cache — previously only FCenterFreq and ActiveVfoFreq were tracked, so span changes left the ruler showing stale frequency step marks. Co-Authored-By: Claude Sonnet 4.6 --- SpectrumView.pas | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/SpectrumView.pas b/SpectrumView.pas index b435d35..eb2e084 100644 --- a/SpectrumView.pas +++ b/SpectrumView.pas @@ -48,6 +48,7 @@ type FSmBitmap: TBitmap; FRulerLastFreq: Double; FRulerLastVfo: Double; + FRulerLastSpan: Double; // ── Radio state ─────────────────────────────────────────────────────────── FVfoA: Double; @@ -513,7 +514,7 @@ procedure TSpectrumView.SetRulerSize(W, H: Integer); begin if (W <= 0) or (H <= 0) then Exit; FRulerBitmap.SetSize(W, H); - FRulerLastFreq := -1.0; FRulerLastVfo := -1.0; + FRulerLastFreq := -1.0; FRulerLastVfo := -1.0; FRulerLastSpan := -1.0; end; function TSpectrumView.SpectrumBitmapWidth: Integer; @@ -533,7 +534,7 @@ end; procedure TSpectrumView.InvalidateRulerCache; begin - FRulerLastFreq := -1.0; FRulerLastVfo := -1.0; + FRulerLastFreq := -1.0; FRulerLastVfo := -1.0; FRulerLastSpan := -1.0; end; procedure TSpectrumView.ResetSpectrumBuf; @@ -570,7 +571,8 @@ end; function TSpectrumView.NeedsRulerRedraw: Boolean; begin Result := (Abs(FCenterFreq - FRulerLastFreq) >= 0.5) or - (Abs(ActiveVfoFreq - FRulerLastVfo) >= 0.5); + (Abs(ActiveVfoFreq - FRulerLastVfo) >= 0.5) or + (Abs(FSpanHz - FRulerLastSpan) >= 1.0); end; // ──────────────────────────────────────────────────────────────────────────── @@ -854,8 +856,9 @@ begin W := FPbRuler.Width; H := FPbRuler.Height; if (W <= 0) or (H <= 0) then Exit; if (Abs(FCenterFreq - FRulerLastFreq) < 0.5) and - (Abs(ActiveVfoFreq - FRulerLastVfo) < 0.5) then Exit; - FRulerLastFreq := FCenterFreq; FRulerLastVfo := ActiveVfoFreq; + (Abs(ActiveVfoFreq - FRulerLastVfo) < 0.5) and + (Abs(FSpanHz - FRulerLastSpan) < 1.0) then Exit; + FRulerLastFreq := FCenterFreq; FRulerLastVfo := ActiveVfoFreq; FRulerLastSpan := FSpanHz; if (FRulerBitmap.Width <> W) or (FRulerBitmap.Height <> H) then FRulerBitmap.SetSize(W, H); C := FRulerBitmap.Canvas;