Cut shell/instrument comment bloat ~34% (comments only, zero code change)
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
// editor_platform.cpp — the ReaSamplerEditor's IPlugView + Win32 window plumbing (Q-W2v
|
||||
// split of reasampler_editor.cpp, T4-11): platform-type/resize negotiation, the child
|
||||
// window class + creation/destruction, the S9/S8 sync timer lifetime, the WM_* dispatch
|
||||
// (wndProc — paint, mouse, keyboard, capture-loss rollback, drop-accept, timer), and the
|
||||
// non-Windows stubs (D5 makes Windows the only build target; the TU still compiles
|
||||
// elsewhere).
|
||||
// editor_platform.cpp — the ReaSamplerEditor's IPlugView + Win32 window plumbing:
|
||||
// platform-type/resize negotiation, the child window class + creation/destruction, the
|
||||
// sync timer lifetime, the WM_* dispatch (wndProc — paint, mouse, keyboard, capture-loss
|
||||
// rollback, drop-accept, timer), and the non-Windows stubs (Windows is the only build
|
||||
// target; the TU still compiles elsewhere).
|
||||
|
||||
#include "shell/instrument/reasampler_editor.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windowsx.h> // GET_X_LPARAM / GET_Y_LPARAM
|
||||
#include <shellapi.h> // DragAcceptFiles / DragQueryFile / DragFinish — S13 drop-accept
|
||||
#include <shellapi.h> // DragAcceptFiles / DragQueryFile / DragFinish — drop-accept
|
||||
#endif
|
||||
|
||||
#include "shell/instrument/editor_internal.h" // (transitively: lice + the kit, Windows only)
|
||||
@@ -23,11 +22,11 @@ namespace reasampler::vst {
|
||||
namespace {
|
||||
constexpr const wchar_t* kChildClassName = L"ReaSampler9000VstEditor";
|
||||
|
||||
// The S9/S8 change-detection poll (WM_TIMER on the child window). A low-frequency
|
||||
// UI-thread timer: responsive enough that a recapture/ingest/assign refreshes "within a
|
||||
// bounded cadence" (the S9 verify criterion) yet cheap — three small ext-state reads per
|
||||
// tick, coalescing many bumps between ticks into one reload. 500 ms is a deliberate
|
||||
// build-time residual. The id is a per-window SetTimer id (any nonzero).
|
||||
// The change-detection poll (WM_TIMER on the child window). A low-frequency UI-thread
|
||||
// timer: responsive enough that a recapture/ingest/assign refreshes within a bounded
|
||||
// cadence, yet cheap — three small ext-state reads per tick, coalescing many bumps
|
||||
// between ticks into one reload. 500 ms is a deliberate build-time residual. The id is a
|
||||
// per-window SetTimer id (any nonzero).
|
||||
constexpr UINT_PTR kSyncTimerId = 1;
|
||||
constexpr UINT kSyncTimerIntervalMs = 500;
|
||||
} // namespace
|
||||
@@ -45,12 +44,12 @@ tresult PLUGIN_API ReaSamplerEditor::canResize() {
|
||||
}
|
||||
|
||||
tresult PLUGIN_API ReaSamplerEditor::checkSizeConstraint(ViewRect* rect) {
|
||||
// Enforce a minimum usable floor: at least 560 wide and 460 tall. The host calls this before
|
||||
// every resize; clamp the proposed rect in place and return kResultTrue so the host applies the
|
||||
// (possibly adjusted) rect rather than the raw user drag. 560×460 keeps the Sample face's title
|
||||
// + hero waveform + cluster + a few control rows visible (the control strip clips gracefully
|
||||
// below the panel bottom); anything smaller would clip essential UI. The default 840×620 is
|
||||
// above this floor.
|
||||
// Enforce a minimum usable floor: at least 560 wide and 460 tall. The host calls this
|
||||
// before every resize; clamp the proposed rect in place and return kResultTrue so the host
|
||||
// applies the (possibly adjusted) rect rather than the raw user drag. 560x460 keeps the
|
||||
// Sample face's title + hero waveform + cluster + a few control rows visible (the control
|
||||
// strip clips gracefully below the panel bottom); anything smaller would clip essential UI.
|
||||
// The default 840x620 is above this floor.
|
||||
constexpr int kMinW = 560;
|
||||
constexpr int kMinH = 460;
|
||||
if (!rect) return kResultFalse;
|
||||
@@ -85,11 +84,11 @@ void ReaSamplerEditor::attachedToParent() {
|
||||
classRegistered = true;
|
||||
}
|
||||
|
||||
// Create the kit's cached AA fonts before the first paint (Phase L, L3). Idempotent, so a
|
||||
// reopen (or a co-resident embed strip that also inits) is a cheap no-op. NOT torn down on
|
||||
// editor close: the embed strip in the SAME binary shares the kit's process-global font
|
||||
// set, so a per-view shutdown could free fonts still in use by the other view. The tiny
|
||||
// static HFONT set is reclaimed by the OS at module unload. See the L3 handoff note.
|
||||
// Create the kit's cached AA fonts before the first paint. Idempotent, so a reopen (or a
|
||||
// co-resident embed strip that also inits) is a cheap no-op. Not torn down on editor close:
|
||||
// the embed strip in the same binary shares the kit's process-global font set, so a
|
||||
// per-view shutdown could free fonts still in use by the other view. The tiny static HFONT
|
||||
// set is reclaimed by the OS at module unload.
|
||||
kitFontsInit();
|
||||
|
||||
refreshFromBank();
|
||||
@@ -99,17 +98,17 @@ void ReaSamplerEditor::attachedToParent() {
|
||||
r.getWidth(), r.getHeight(), parent, nullptr, hInst, nullptr);
|
||||
if (childHwnd_) {
|
||||
SetWindowLongPtr(childHwnd_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
|
||||
// S13: accept OS file drops on the editor window (WM_DROPFILES). The drop is NOT
|
||||
// ingested here (the relay is degraded — see onFilesDropped); accepting it lets us show
|
||||
// the "drop on the panel" affordance instead of the OS bouncing the drop silently.
|
||||
// Accept OS file drops on the editor window (WM_DROPFILES). The drop is not ingested
|
||||
// here (the relay is degraded — see onFilesDropped); accepting it lets us show the
|
||||
// "drop on the panel" affordance instead of the OS bouncing the drop silently.
|
||||
DragAcceptFiles(childHwnd_, TRUE);
|
||||
// Start the S9/S8 change-detection poll (UI thread). Tied to the child window's
|
||||
// lifetime — created here, killed in removedFromParent — so an instance whose editor
|
||||
// is closed does NOT poll (the editor-open-only cadence; see the handoff limitation).
|
||||
// Start the change-detection poll (UI thread). Tied to the child window's lifetime —
|
||||
// created here, killed in removedFromParent — so an instance whose editor is closed
|
||||
// does not poll.
|
||||
SetTimer(childHwnd_, kSyncTimerId, kSyncTimerIntervalMs, nullptr);
|
||||
// Poll ONCE immediately so a pending assignment (an S8 ingest fired while this editor
|
||||
// was closed) or a bank change applies the instant the editor opens, rather than waiting
|
||||
// up to one timer interval. refreshFromBank above already primed the view; this folds in
|
||||
// Poll once immediately so a pending assignment (an ingest fired while this editor was
|
||||
// closed) or a bank change applies the instant the editor opens, rather than waiting up
|
||||
// to one timer interval. refreshFromBank above already primed the view; this folds in
|
||||
// any pending assign/generation so the just-opened editor shows the assigned capture.
|
||||
onSyncTimer();
|
||||
}
|
||||
@@ -147,7 +146,7 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
case WM_LBUTTONDOWN:
|
||||
if (self) {
|
||||
SetCapture(hwnd); // keep receiving moves/up if the cursor leaves the child
|
||||
SetFocus(hwnd); // take keyboard focus so WM_CHAR reaches the search box (S12)
|
||||
SetFocus(hwnd); // take keyboard focus so WM_CHAR reaches the search box
|
||||
self->onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
}
|
||||
return 0;
|
||||
@@ -155,9 +154,9 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
if (self) {
|
||||
const int mx = GET_X_LPARAM(lParam);
|
||||
const int my = GET_Y_LPARAM(lParam);
|
||||
// Hover feedback (Phase L, L3): resolve the element under the pointer and
|
||||
// repaint on change. Arm WM_MOUSELEAVE once per "over" cycle so the hover
|
||||
// clears when the pointer leaves the child (TrackMouseEvent is one-shot).
|
||||
// Hover feedback: resolve the element under the pointer and repaint on change.
|
||||
// Arm WM_MOUSELEAVE once per "over" cycle so the hover clears when the pointer
|
||||
// leaves the child (TrackMouseEvent is one-shot).
|
||||
if (!self->mouseTracking_) {
|
||||
TRACKMOUSEEVENT tme{};
|
||||
tme.cbSize = sizeof(tme);
|
||||
@@ -182,15 +181,15 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
}
|
||||
return 0;
|
||||
case WM_MOUSEWHEEL:
|
||||
// S12 browser scroll. GET_WHEEL_DELTA_WPARAM is signed; positive == wheel up.
|
||||
// Browser scroll. GET_WHEEL_DELTA_WPARAM is signed; positive == wheel up.
|
||||
if (self) self->onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
|
||||
return 0;
|
||||
case WM_CHAR:
|
||||
// S12 type-to-filter search keystrokes (only acted on when the search box is focused).
|
||||
// Type-to-filter search keystrokes (only acted on when the search box is focused).
|
||||
if (self) self->onSearchChar(static_cast<unsigned int>(wParam));
|
||||
return 0;
|
||||
case WM_GETDLGCODE:
|
||||
// Claim all keys (incl. chars) so the host doesn't eat them before WM_CHAR (S12 search).
|
||||
// Claim all keys (incl. chars) so the host doesn't eat them before WM_CHAR (search).
|
||||
return DLGC_WANTCHARS | DLGC_WANTARROWS;
|
||||
case WM_LBUTTONUP:
|
||||
if (self) {
|
||||
@@ -199,8 +198,8 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
}
|
||||
return 0;
|
||||
case WM_RBUTTONDOWN:
|
||||
// r11: right-click — the curve popup's primary node-delete affordance (issue 3c).
|
||||
// Routed explicitly (the child wndproc historically handled only left-button).
|
||||
// Right-click — the curve popup's primary node-delete affordance. Routed
|
||||
// explicitly (the child wndproc historically handled only left-button).
|
||||
if (self) self->onMouseRDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
return 0;
|
||||
case WM_RBUTTONUP:
|
||||
@@ -232,16 +231,16 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
self->drag_ = DragKind::kNone;
|
||||
self->dragParamId_ = -1;
|
||||
self->dragParamZone_ = -1;
|
||||
self->curvePointIndex_ = -1; // S-VIEW-10 curve-node drag state (peer reset)
|
||||
self->curvePointIndex_ = -1; // curve-node drag state (peer reset)
|
||||
self->dragCurveZone_ = -1;
|
||||
self->invalidate();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_DROPFILES: {
|
||||
// S13 (relay degraded): count the dropped files and flash the affordance. We do NOT
|
||||
// read/ingest the paths (the instrument never ingests — the relay to the extension is
|
||||
// unshipped); DragQueryFile with 0xFFFFFFFF just returns the count for the banner.
|
||||
// Count the dropped files and flash the affordance. We do not read/ingest the paths
|
||||
// (the instrument never ingests — the relay to the extension is unshipped);
|
||||
// DragQueryFile with 0xFFFFFFFF just returns the count for the banner.
|
||||
HDROP drop = reinterpret_cast<HDROP>(wParam);
|
||||
const UINT count = DragQueryFileW(drop, 0xFFFFFFFF, nullptr, 0);
|
||||
DragFinish(drop);
|
||||
@@ -258,7 +257,7 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
}
|
||||
}
|
||||
|
||||
#else // non-Windows: not a build target (D5), but keep the TU compilable.
|
||||
#else // non-Windows: not a build target, but keep the TU compilable.
|
||||
|
||||
void ReaSamplerEditor::attachedToParent() {}
|
||||
void ReaSamplerEditor::removedFromParent() {}
|
||||
|
||||
Reference in New Issue
Block a user