refactor(spectrum): decouple drawSwrSweep from m_overlayMenu pointer (#2205). Principle XIII.#3035
Conversation
…2205). Principle XIII. Introduces a private SpectrumWidget::leftOccludedRect() helper that returns the visible overlay-menu geometry (or a null QRect when the menu is hidden or absent). Both paint-path callers — drawSwrSweep() label-collision avoidance and drawOffScreenSlices() left-margin computation — now go through the helper instead of reading m_overlayMenu->geometry() / ->width() directly. Behavior-preserving: the helper preserves the existing null + isVisible guards. If the overlay menu is ever replaced, wrapped, or made optional, only leftOccludedRect() needs updating. Maintainer (KK7GWY) approved the leftOccludedRect() shape proposed in the triage analysis on issue #2205; honoring that direct steering is Principle XIII (The Operator Outranks Every Agent). Blast radius: change is purely additive at the header (new private method declaration) and internal to drawSwrSweep / drawOffScreenSlices in the cpp. Public API of SpectrumWidget is unchanged, so the codegraph high-risk callers (MainWindow::wirePanadapter, ::buildMenuBar, etc.) cannot regress on this refactor.
There was a problem hiding this comment.
Nice, focused refactor. The new leftOccludedRect() helper cleanly encapsulates the overlay-menu-as-occluder concern, and the generic name avoids leaking the specific child-widget pointer through the abstraction — exactly what #2205 asked for.
A couple of small observations, none blocking:
-
Scope creep is welcome here. The issue only called out
drawSwrSweep, but applying the same helper todrawOffScreenSlices(which had the identicalm_overlayMenu->isVisible()+width()pattern at SpectrumWidget.cpp:7505-7506) is the right call — keeps both occlusion-avoidance paths converged so they can't drift apart later. Worth mentioning in the PR body for reviewers, since the title only referencesdrawSwrSweep. -
Sentinel semantics. Returning
QRect{}and testingisNull()is fine — a default-constructedQRecthas width=0 and height=0, soisNull()is true. Just note that indrawSwrSweep, the!occluded.isNull()guard is now technically redundant with thelabelRect.intersects(...)check (intersecting against an empty rect returns false anyway), but it short-circuits cleanly and reads well, so no need to change. -
Other
m_overlayMenureferences untouched and that's correct — the remaining usages in the file (raise/stack-order management,syncDisplaySettings, etc.) are owner-style operations on the menu itself, not occlusion queries, so they don't belong behind this helper.
LGTM. Thanks @aethersdr-agent!
🤖 aethersdr-agent · cost: $2.0519 · model: claude-opus-4-7
…ethersdr#2205). Principle XIII. (aethersdr#3035) ## Summary Fixes aethersdr#2205 ### What was changed refactor(spectrum): decouple drawSwrSweep from m_overlayMenu pointer (aethersdr#2205). Principle XIII. ### Files modified - `src/gui/SpectrumWidget.cpp` - `src/gui/SpectrumWidget.h` ``` src/gui/SpectrumWidget.cpp | 19 ++++++++++++++----- src/gui/SpectrumWidget.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) ``` --- Generated by AetherClaude (automated agent for AetherSDR) --- <sub>🤖 aethersdr-agent · cost: $6.7502 · model: claude-opus-4-7</sub> Co-authored-by: aethersdr-agent[bot] <273844287+aethersdr-agent[bot]@users.noreply.github.com>
Summary
Fixes #2205
What was changed
refactor(spectrum): decouple drawSwrSweep from m_overlayMenu pointer (#2205). Principle XIII.
Files modified
src/gui/SpectrumWidget.cppsrc/gui/SpectrumWidget.hGenerated by AetherClaude (automated agent for AetherSDR)
🤖 aethersdr-agent · cost: $6.7502 · model: claude-opus-4-7