Q-W2 review follow-ups: anon-namespace TU-private panel helpers, fix stale bank_panel.cpp comments, correct shim-transitivity claim

Wraps ~50 file-local helpers across all eight panel TUs in namespace{} (dissolves the menuAppend default-arg ODR trap); zero behavior change, 60/60 green.
This commit is contained in:
2026-07-29 11:28:48 -04:00
parent 30a4ffd01b
commit 19b12186ac
8 changed files with 64 additions and 6 deletions
+12
View File
@@ -87,6 +87,8 @@ std::vector<const Bank*> namedBanks() {
// unsaved project the empty-close discard in persistBankOp ensures no stale state
// survives (matches the capture/B3 quiet-persist idiom).
namespace {
// REAPER's stock single-line input (comma-safe via the \x1f return separator, as B3).
bool promptText(const char* title, const char* caption, const std::string& initial,
std::string& out) {
@@ -111,6 +113,8 @@ std::string mintBankId() {
return std::string(buf);
}
} // namespace
void doCreateBank() {
if (!book()) return;
std::string name;
@@ -127,6 +131,8 @@ void doCreateBank() {
invalidatePanel();
}
namespace {
void doRenameBank(const std::string& bankId) {
if (!book()) return;
const Bank* bk = book()->bank(bankId);
@@ -198,6 +204,8 @@ void doActivateBank(const std::string& bankId) {
invalidatePanel();
}
} // namespace
// Move or copy `sampleIds` from `srcBankId` to `destBankId` (index-only). Both pass
// ids straight to the model op (no BankModel& cached across the loop's mutations).
//
@@ -312,6 +320,8 @@ std::vector<std::string> resolveDragPathsForOs() {
// Menu command ids are LOCAL to the popup (not REAPER action ids) — TPM_RETURNCMD
// hands the chosen id straight back, so no hookcommand routing is involved.
namespace {
// Appends a string item (id) to `menu` at its end. Portable over Win32/SWELL: both
// accept InsertMenu(menu, pos, MF_BYPOSITION|MF_STRING, id, text) with a negative
// position appending. Win32 and SWELL both treat pos < 0 as an append.
@@ -337,6 +347,8 @@ enum : unsigned int {
kMenuCopyBase = 2000, // copy-to-bank: kMenuCopyBase + destination index
};
} // namespace
// Shows the right-click context menu for a named-bank TAB: activate / rename / delete
// / evacuate that bank, plus a create entry. Drives the id-keyed ops.
void showTabMenu(int screenX, int screenY, const std::string& bankId) {
+8
View File
@@ -30,6 +30,8 @@ namespace reasampler::panel {
constexpr int kDragThreshold = 5; // px the pointer must move to begin a drag
namespace {
// Resolves the drop target under client (x, y) during a drag, updating dropKind /
// dropBankId. A drop onto the pool region -> the pool; onto a named tab -> that bank;
// anywhere else -> none.
@@ -234,6 +236,8 @@ void updateHover(int x, int y) {
}
}
} // namespace
// Applies the tooltip hover-delay: if a tooltip-bearing element has been hovered past
// kTooltipDelayMs and the tooltip is not yet shown, latch it and repaint once. Driven from the
// OnTimer poll (bankPanelRefresh) so the tooltip appears after a rest with no dedicated timer;
@@ -365,6 +369,8 @@ void onMouseMove(int x, int y) {
// batched undo point + saves). A no-op reorder (already at the target, model returns false)
// opens no undo point. Selection reasons over slot order, so it is cleared after — the
// fingerprint pass rebuilds it against the new order.
namespace {
void doReorderDrop(const std::string& id, const std::string& bankId, int targetSlot) {
if (!book() || id.empty() || bankId.empty() || targetSlot < 0) return;
if (!book()->reorderSample(id, bankId, targetSlot)) return; // rejected/no-op: no undo point
@@ -386,6 +392,8 @@ void doReplaceDrop(const std::string& newId, const std::string& oldId,
invalidatePanel();
}
} // namespace
// Clears all drag-state fields to their resting values. Called from every exit path
// (button-up, WM_CAPTURECHANGED, WM_DESTROY, closePanel) so the set of cleared fields
// stays consistent across all four sites.
+10 -2
View File
@@ -48,6 +48,8 @@ TailSetting currentTail() {
return g_panel.session ? g_panel.session->tail() : TailSetting{};
}
namespace {
// Commits the current tail setting to ext state and marks the active project dirty
// so the change travels inside the .rpp on Ctrl+S. saveToActiveProject() is the only
// path that calls SetProjExtState for the tail key — calling it here closes the gap
@@ -96,7 +98,7 @@ bool handleToolbarClick(int x, int y, const ActionBarRect& bar,
// True iff `tr` has I_FREEMODE==2 (fixed lanes enabled). The SDK value is verified
// in view.cpp (kFreeModeFixedLanes=2); reproduced here as a local constant so
// bank_panel.cpp stays self-contained without pulling in view.cpp's private namespace.
// panel_input.cpp stays self-contained without pulling in view.cpp's private namespace.
constexpr int kFreeModeFixedLanes = 2;
bool isFixedLaneTrack(MediaTrack* tr) {
@@ -104,7 +106,7 @@ bool isFixedLaneTrack(MediaTrack* tr) {
}
// Item GUID + fixed-lane name reads come from the shared item_read seam (item_read.h):
// itemGuid(it) and itemLaneName(tr, it). bank_panel.cpp no longer carries its own copies.
// itemGuid(it) and itemLaneName(tr, it). panel_input.cpp no longer carries its own copies.
// Enumerates the live project's track + item GUIDs. Fills `allGuids` (the full live set,
// baseline input) and, for each item, records whether it sits on a manual lane so a
@@ -319,6 +321,8 @@ bool handlePoolChromeClick(int x, int y, const RECT& region) {
return false;
}
} // namespace
// Applies a left-click at (x, y): route to top toolbar / footer (toggle / Tail / Prune) /
// bottom toolbar / region chrome / grid selection, and arm a potential drag when the click
// lands on a selected cell. L4 order mirrors the three-zone layout top-to-bottom.
@@ -500,6 +504,8 @@ bool handleWheel(int x, int y, int delta) {
return true;
}
namespace {
bool isOurWindow(HWND hwnd) {
for (HWND w = hwnd; w; w = GetParent(w))
if (w == g_panel.hwnd) return true;
@@ -557,6 +563,8 @@ int translateAccel(MSG* msg, accelerator_register_t* /*ctx*/) {
accelerator_register_t g_accel{translateAccel, true, nullptr};
bool g_accelRegistered = false;
} // namespace
void registerAccel() {
if (g_accelRegistered || !g_rec) return;
g_rec->Register("accelerator", &g_accel);
+12
View File
@@ -49,6 +49,8 @@ int modeCount() {
// buttons tile into the band MINUS the menu reserve (topToolbarActionRect), so they never run
// under the menu button (L5 refinement 1).
namespace {
ActionBarRect topToolbarRect(int w) {
ActionBarRect s;
s.x = 0;
@@ -67,6 +69,8 @@ MenuBarRect topMenuBarRect(int w) {
// The More button's rect (right-anchored in the top band). Empty when the band is too narrow
// to place it clear of its left inset — the three variants stay reachable via their bindable
// commands (graceful suppression).
} // namespace
MenuButtonRect topMenuButtonRect(int w) {
return computeMenuButton(topMenuBarRect(w), kMenuBtnSpec);
}
@@ -200,6 +204,8 @@ std::vector<ActionBarRow> overflowMenuRows() {
};
}
namespace {
// The active mode id the opposite-mode gate + footer toggle both read (ONE source of truth for
// "which mode is active"). Empty when no session (every button then falls to fail-open live).
std::string activeModeIdOrEmpty() {
@@ -207,6 +213,8 @@ std::string activeModeIdOrEmpty() {
return g_panel.session->view().activeModeId();
}
} // namespace
// The BOTTOM toolbar inventory (L5 refinement 3): FOUR Item/Track x Arrange/Design tag buttons
// then a set-apart Show Both. The suffixes are the ACTUAL registered command-id strings from
// actions.cpp (VIEW_MOVE_ITEMS_ARRANGE / VIEW_MOVE_ITEMS_DESIGN for the item moves;
@@ -290,6 +298,8 @@ int resolveBarCommandId(const ActionBarRow& row) {
return NamedCommandLookup(named.c_str());
}
namespace {
// The current key binding string for a command in the MAIN section, or "" (unbound / not
// registered). Queried via kbd_getTextFromCmd (SectionFromUniqueID(0)).
std::string barBindingText(int cmd) {
@@ -300,6 +310,8 @@ std::string barBindingText(int cmd) {
return {};
}
} // namespace
// The flat action index under (x, y) in `bar` for the given row set, or -1 (miss). Pure hit-test.
int toolbarHit(int x, int y, const ActionBarRect& bar, const std::vector<ActionBarRow>& rows) {
if (bar.height <= 0) return -1;
+4
View File
@@ -23,6 +23,8 @@
namespace reasampler::panel {
namespace {
// --- Drawing: thumbnails (via the kit's shared drawWaveform since FA3) ---------
// Draws the L7 decorative metadata overlay on a card: bars.beats.subdivisions bottom-LEFT
@@ -506,6 +508,8 @@ std::string activeBankName() {
return bk ? bk->displayName : std::string(kPoolBankName);
}
} // namespace
// --- Full paint ---------------------------------------------------------------
void paintPanel(HWND hwnd, HDC hdc) {
+6 -4
View File
@@ -14,10 +14,12 @@
// plain free function — direct call-through, no interface, no virtual dispatch
// (T4-28: the audition path and the per-mouse-move path must stay direct calls).
// * Explicit using-declarations pulling the pure modules' symbols into
// reasampler::panel from their REAL namespace homes (Q-W1 sub-namespaces) — the
// panel TUs do NOT include the interim core/namespaces.h shim (Q-W2 retires it
// for this module; some still-unsplit shell headers carry it transitively until
// their own waves, but nothing here depends on it).
// reasampler::panel from their REAL namespace homes (Q-W1 sub-namespaces) — this
// header itself does not directly include the interim core/namespaces.h shim
// (Q-W2 retires that direct dependency for this module). Six of the eight panel
// TUs still pull the shim in TRANSITIVELY via actions.h/persist.h/ingest.h/
// draw_kit.h/view.h; only panel_thumbnails.cpp and panel_audition.cpp are
// shim-free end to end. Nothing HERE depends on it either way.
//
// REFERENCE-INVALIDATION GUARDRAIL (CONTEXT.md §Multi-bank): a bank-structural
// mutation (create/delete/evacuate/activate/move) can reallocate the book's vector,
+8
View File
@@ -25,6 +25,8 @@
namespace reasampler::panel {
namespace {
constexpr int kMaxThumbnailFrames = 1 << 20; // ~1M frames (~22s @ 48k)
// --- Thumbnail computation (M5; `width` is a BIN count since FA3 oversampling) --
@@ -78,6 +80,8 @@ Envelope computeThumbnail(const std::string& absPath, int width) {
static_cast<std::size_t>(binCount));
}
} // namespace
const Envelope& thumbnailFor(const Sample& sample, int width,
const std::string& projectDir) {
ThumbnailKey key{sample.id, width, g_panel.generation};
@@ -96,6 +100,8 @@ const Envelope& thumbnailFor(const Sample& sample, int width,
// --- Bank-change detection ----------------------------------------------------
namespace {
// A fingerprint of the WHOLE BOOK: for each bank, its id + display name + active flag
// + per-sample id/path. Catches every mutation the panel must redraw for: capture,
// project load, and B4's own create/rename/delete/move/activate.
@@ -119,6 +125,8 @@ std::string bookFingerprint() {
return fp;
}
} // namespace
// Reconciles shownBankId against the live named banks: keep it if it still names a
// named bank; otherwise fall to the first named bank (or empty when none). Keeps the
// banks region always showing a valid tab. Never touches the ACTIVE bank.
+4
View File
@@ -46,6 +46,8 @@ PanelState g_panel;
// --- Dialog proc + docking ----------------------------------------------------
namespace {
// Decodes a WM_DROPFILES HDROP into the dropped file paths (absolute, OS-native) and hands
// them to the S8 ingest path. Multi-file drop: ingestDroppedFiles imports all into the active
// bank (bank-fill only — no assignment to any live instance). Always DragFinish's the HDROP
@@ -193,6 +195,8 @@ void closePanel() {
g_panel.open = false;
}
} // namespace
} // namespace reasampler::panel
// --- Public API (the lifecycle seam — panel_window.h) --------------------------