Type-enforce the waveform overlay contract, narrow waveformLanes to LaneSplit, fix laneCount/cache/path-fallback bugs
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
// start/loop marker, and resolving both drags live against the pure inverse maps
|
||||
// (envelope_edit, waveform_view). Windows-only.
|
||||
//
|
||||
// Hit-test and drag both resolve against WaveformSurface::overlay — the same full-band rect
|
||||
// the overlays draw into — so a grab in the lower stereo lane reaches them.
|
||||
// Overlay contract: see waveform_view.h's WaveformSurface.
|
||||
|
||||
#include "shell/instrument/reasampler_editor.h"
|
||||
|
||||
@@ -27,7 +26,7 @@ bool ReaSamplerEditor::mouseDownWaveform(const FaceLayout& fl, int x, int y) {
|
||||
const std::vector<AudioSample>& pcm = monoPcmFor(selectedId_);
|
||||
const std::int64_t frames = static_cast<std::int64_t>(pcm.size());
|
||||
if (frames <= 0) return false;
|
||||
const Rect overlay = waveformOverlayArea(fl.bands.waveform);
|
||||
const OverlayArea overlay = waveformOverlayArea(fl.bands.waveform);
|
||||
|
||||
// Envelope nodes first (they sit on top of the markers), then the wave markers.
|
||||
const double rate = liveSampleRate();
|
||||
@@ -64,7 +63,7 @@ bool ReaSamplerEditor::mouseDownWaveform(const FaceLayout& fl, int x, int y) {
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::dragWaveform(const FaceLayout& fl, int x, int y) {
|
||||
const Rect overlay = waveformOverlayArea(fl.bands.waveform);
|
||||
const OverlayArea overlay = waveformOverlayArea(fl.bands.waveform);
|
||||
const int dx = x - dragStartX_;
|
||||
|
||||
if (drag_ == DragKind::kEnvNode) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// editor_paint_waveform.cpp — the WAVEFORM band's painter: the channel lane(s), the loop
|
||||
// span + start/loop markers, and the amp-envelope overlay. Windows-only.
|
||||
//
|
||||
// Overlays that ride the waveform (the envelope trace, its node handles, the markers) draw
|
||||
// ONCE into WaveformSurface::overlay — the full band, spanning both stacked lanes in
|
||||
// stereo. Never per lane; see waveform_view.h's overlay contract.
|
||||
// Overlay contract: see waveform_view.h's WaveformSurface.
|
||||
|
||||
#include "shell/instrument/reasampler_editor.h"
|
||||
|
||||
@@ -76,13 +74,14 @@ void ReaSamplerEditor::paintWaveform(LICE_IBitmap* bmp, const Rect& band) {
|
||||
|
||||
// Markers and the loop span are overlays: ONE draw across the full stacked height, so a
|
||||
// stereo view reads one loop region rather than two.
|
||||
const Rect& overlay = surface.overlay;
|
||||
const OverlayArea& overlay = surface.overlay;
|
||||
const Rect& overlayRect = overlay.rect;
|
||||
const SetupMarkers m = pickedMarkers(frames);
|
||||
if (m.hasLoop && m.loopEnd > m.loopStart) {
|
||||
const int lx = frameToX(overlay, frames, m.loopStart);
|
||||
const int rx = frameToX(overlay, frames, m.loopEnd);
|
||||
if (rx > lx) {
|
||||
LICE_FillRect(bmp, lx, overlay.y, rx - lx, overlay.height,
|
||||
LICE_FillRect(bmp, lx, overlayRect.y, rx - lx, overlayRect.height,
|
||||
toLice(roleColor(kRoleLoopMarker)), 0.20f, 0);
|
||||
}
|
||||
}
|
||||
@@ -92,16 +91,17 @@ void ReaSamplerEditor::paintWaveform(LICE_IBitmap* bmp, const Rect& band) {
|
||||
const int mx = frameToX(overlay, frames, markerFrames[i]);
|
||||
const bool loopMarker = (i != 0);
|
||||
const float alpha = (loopMarker && !m.hasLoop) ? 0.4f : 1.0f;
|
||||
LICE_FillRect(bmp, mx - 1, overlay.y, 2, overlay.height,
|
||||
LICE_FillRect(bmp, mx - 1, overlayRect.y, 2, overlayRect.height,
|
||||
toLice(roleColor(markerRoles[i])), alpha, 0);
|
||||
}
|
||||
|
||||
paintEnvelopeOverlay(bmp, overlay, frames);
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::paintEnvelopeOverlay(LICE_IBitmap* bmp, const Rect& waveArea,
|
||||
void ReaSamplerEditor::paintEnvelopeOverlay(LICE_IBitmap* bmp, const OverlayArea& waveArea,
|
||||
std::int64_t frames) {
|
||||
if (frames <= 0 || waveArea.width <= 0 || waveArea.height <= 0) return;
|
||||
const Rect& area = waveArea.rect;
|
||||
if (frames <= 0 || area.width <= 0 || area.height <= 0) return;
|
||||
const double rate = liveSampleRate();
|
||||
if (rate <= 0.0) return;
|
||||
const double totalSeconds = static_cast<double>(frames) / rate;
|
||||
@@ -113,8 +113,8 @@ void ReaSamplerEditor::paintEnvelopeOverlay(LICE_IBitmap* bmp, const Rect& waveA
|
||||
// curve over the waveform. Clip x to the wave rect (a Gate release tail maps past the right).
|
||||
const LICE_pixel line = toLice(roleColor(Role::AccentSecondary));
|
||||
for (std::size_t i = 1; i < poly.size(); ++i) {
|
||||
const int x0 = (std::max)(waveArea.x, (std::min)(waveArea.right() - 1, poly[i - 1].x));
|
||||
const int x1 = (std::max)(waveArea.x, (std::min)(waveArea.right() - 1, poly[i].x));
|
||||
const int x0 = (std::max)(area.x, (std::min)(area.right() - 1, poly[i - 1].x));
|
||||
const int x1 = (std::max)(area.x, (std::min)(area.right() - 1, poly[i].x));
|
||||
LICE_Line(bmp, x0, poly[i - 1].y, x1, poly[i].y, line, 1.0f, 0, true);
|
||||
}
|
||||
// Draggable node handles: a small square per draggable node (Origin + ReleaseStart are
|
||||
@@ -128,8 +128,8 @@ void ReaSamplerEditor::paintEnvelopeOverlay(LICE_IBitmap* bmp, const Rect& waveA
|
||||
if (v.node == EnvNode::Origin || v.node == EnvNode::ReleaseStart) continue;
|
||||
const bool grabbed = (drag_ == DragKind::kEnvNode && envNode_ == v.node);
|
||||
const int r = 3;
|
||||
const int hx = (std::max)(waveArea.x + r, (std::min)(waveArea.right() - 1 - r, v.x));
|
||||
const int hy = (std::max)(waveArea.y + r, (std::min)(waveArea.bottom() - 1 - r, v.y));
|
||||
const int hx = (std::max)(area.x + r, (std::min)(area.right() - 1 - r, v.x));
|
||||
const int hy = (std::max)(area.y + r, (std::min)(area.bottom() - 1 - r, v.y));
|
||||
LICE_FillRect(bmp, hx - r, hy - r, 2 * r, 2 * r, grabbed ? handleHot : handle, 1.0f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,11 @@ std::string ReaSamplerEditor::samplePathFor(const std::string& sampleId) const {
|
||||
if (!processor_) return {};
|
||||
auto banksJson = processor_->bridge().readReasamplerExtState(reasampler::kProjExtBanksKey);
|
||||
if (banksJson) {
|
||||
if (auto sel = selectSample(*banksJson, sampleId)) return sel->relativePath;
|
||||
// An empty relativePath (found the entry, but it carries no path) falls through to
|
||||
// the refs fallback below rather than short-circuiting on it.
|
||||
if (auto sel = selectSample(*banksJson, sampleId); sel && !sel->relativePath.empty()) {
|
||||
return sel->relativePath;
|
||||
}
|
||||
}
|
||||
// Fallback: the bank blob is not readable (extension absent / not yet parsed) or the id
|
||||
// went stale there — the instance-owned ref still carries the path, so a self-contained
|
||||
@@ -222,7 +226,7 @@ std::string ReaSamplerEditor::samplePathFor(const std::string& sampleId) const {
|
||||
|
||||
const ReaSamplerEditor::ChannelPcm& ReaSamplerEditor::channelPcmFor(
|
||||
const std::string& sampleId) {
|
||||
if (channelPcmId_ == sampleId && !sampleId.empty()) return channelPcm_;
|
||||
if (channelPcmId_ == sampleId) return channelPcm_;
|
||||
|
||||
// A failed decode is still cached (channelCount stays 0) so a broken/missing file is not
|
||||
// re-read on every paint.
|
||||
|
||||
@@ -45,6 +45,7 @@ using instrument::ui::ChromeRects;
|
||||
using instrument::ui::DeckGroupDesc;
|
||||
using instrument::ui::EnvClampBounds;
|
||||
using instrument::ui::EnvNode;
|
||||
using instrument::ui::OverlayArea;
|
||||
using instrument::ui::Rect;
|
||||
using instrument::ui::SampleBands;
|
||||
|
||||
@@ -173,7 +174,7 @@ private:
|
||||
void paintVelocityCurve(LICE_IBitmap* bmp, const Rect& r);
|
||||
// Traces the amp-envelope overlay + its draggable node handles over `waveArea`, ONCE at
|
||||
// full band height (never per lane).
|
||||
void paintEnvelopeOverlay(LICE_IBitmap* bmp, const Rect& waveArea, std::int64_t frames);
|
||||
void paintEnvelopeOverlay(LICE_IBitmap* bmp, const OverlayArea& waveArea, std::int64_t frames);
|
||||
|
||||
// --- Input: the mouse-down dispatch and its per-band branches ---
|
||||
void onMouseDown(int x, int y);
|
||||
|
||||
Reference in New Issue
Block a user