Fix dragging an existing pedal into a region lane (cross-lane move)
Drag/drop only supported add: (palette→anywhere) and same-lane reorders, so dragging a pedal from the main chain (or another lane) into a Stereo Unzip / Split / Parallel lane highlighted the lane but the drop was a no-op. - New core ShoeGaze.movePedal(from:at:to:in:) moves a pedal across lanes, preserving its PedalState (params), with destination-index correction when the removal deletes a top-level segment before the target region. - BoardFlowView routes movemain:/movebranch: payloads dropped on a lane (or the main chain, or another lane's card) through it via moveAcross(_:toLane:). Tests: move a main pedal into an unzip lane (params preserved); move a pedal that sits before the region (index-adjust path). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -582,4 +582,54 @@ struct BoardEditAPITests {
|
||||
let samples: [Float] = try render(engine2, url2)
|
||||
#expect(hasNonSilentOutput(samples), "loaded edited rig should render audio")
|
||||
}
|
||||
|
||||
// MARK: - Cross-lane move (drag a pedal into a region lane)
|
||||
|
||||
@Test func moveMainPedalIntoStereoUnzipLanePreservingParams() throws {
|
||||
// Ping-Pong (stereo) then Overdrive on the main chain; unzip after Ping-Pong.
|
||||
let (sg, engine, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Ping-Pong", "Overdrive"])
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
|
||||
// Tweak the live Overdrive so we can verify its params survive the move.
|
||||
let overdrive: OverdrivePedal? = live.pedals.compactMap { $0 as? OverdrivePedal }.first
|
||||
overdrive?.drive = 11.0
|
||||
|
||||
// Move the Overdrive (main linear index 1) into the unzip's left lane (region segment 1).
|
||||
live = try sg.movePedal(from: .main, at: 1, to: .left(region: 1), in: live)
|
||||
|
||||
#expect(names(live) == ["Ping-Pong"], "Overdrive should leave the main chain")
|
||||
guard let state: StereoUnzipState = unzipState(live) else {
|
||||
Issue.record("No stereo unzip segment")
|
||||
return
|
||||
}
|
||||
#expect(state.left.map { $0.type } == ["Overdrive"], "Overdrive should land in the left lane")
|
||||
#expect(state.left.first?.knobValues.first == 11.0, "Drive param should survive the move")
|
||||
|
||||
let samples: [Float] = try render(engine, url)
|
||||
#expect(hasNonSilentOutput(samples), "board renders after the cross-lane move")
|
||||
}
|
||||
|
||||
@Test func moveMainPedalBeforeUnzipRegionAdjustsIndex() throws {
|
||||
// Overdrive (mono) then Ping-Pong (stereo); unzip after Ping-Pong. Moving the Overdrive —
|
||||
// which sits BEFORE the unzip region — exercises the destination-index adjustment.
|
||||
let (sg, engine, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Overdrive", "Ping-Pong"])
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 1, in: board)
|
||||
// Unzip is top-level segment 2; Overdrive is main linear index 0 (top-level segment 0).
|
||||
live = try sg.movePedal(from: .main, at: 0, to: .left(region: 2), in: live)
|
||||
|
||||
#expect(names(live) == ["Ping-Pong"], "Overdrive should leave the main chain")
|
||||
guard let state: StereoUnzipState = unzipState(live) else {
|
||||
Issue.record("No stereo unzip segment")
|
||||
return
|
||||
}
|
||||
#expect(state.left.map { $0.type } == ["Overdrive"], "Overdrive should land in the left lane")
|
||||
|
||||
let samples: [Float] = try render(engine, url)
|
||||
#expect(hasNonSilentOutput(samples), "board renders after the index-adjusted move")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user