feat: implement sound removal functionality in SequencerPage and update SequencerCanvas props
This commit is contained in:
@@ -13,6 +13,7 @@ interface SequencerCanvasProps {
|
|||||||
onScroll?: () => void
|
onScroll?: () => void
|
||||||
draggedItem?: any // Current dragged item from parent
|
draggedItem?: any // Current dragged item from parent
|
||||||
dragOverInfo?: {trackId: string, x: number} | null // Drag over position info
|
dragOverInfo?: {trackId: string, x: number} | null // Drag over position info
|
||||||
|
onRemoveSound: (soundId: string, trackId: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TrackRowProps {
|
interface TrackRowProps {
|
||||||
@@ -23,6 +24,7 @@ interface TrackRowProps {
|
|||||||
currentTime: number
|
currentTime: number
|
||||||
draggedItem?: any // Current dragged item
|
draggedItem?: any // Current dragged item
|
||||||
dragOverInfo?: {trackId: string, x: number} | null // Drag over position info
|
dragOverInfo?: {trackId: string, x: number} | null // Drag over position info
|
||||||
|
onRemoveSound: (soundId: string, trackId: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PlacedSoundItemProps {
|
interface PlacedSoundItemProps {
|
||||||
@@ -107,7 +109,7 @@ function PlacedSoundItem({ sound, zoom, trackId, onRemove }: PlacedSoundItemProp
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function TrackRow({ track, duration, zoom, isPlaying, currentTime, draggedItem, dragOverInfo }: TrackRowProps) {
|
function TrackRow({ track, duration, zoom, isPlaying, currentTime, draggedItem, dragOverInfo, onRemoveSound }: TrackRowProps) {
|
||||||
const totalWidth = duration * zoom
|
const totalWidth = duration * zoom
|
||||||
const playheadPosition = currentTime * zoom
|
const playheadPosition = currentTime * zoom
|
||||||
|
|
||||||
@@ -120,7 +122,7 @@ function TrackRow({ track, duration, zoom, isPlaying, currentTime, draggedItem,
|
|||||||
})
|
})
|
||||||
|
|
||||||
const handleRemoveSound = (soundId: string) => {
|
const handleRemoveSound = (soundId: string) => {
|
||||||
console.log('Remove sound:', soundId, 'from track:', track.id)
|
onRemoveSound(soundId, track.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -208,6 +210,7 @@ export const SequencerCanvas = forwardRef<HTMLDivElement, SequencerCanvasProps>(
|
|||||||
onScroll,
|
onScroll,
|
||||||
draggedItem,
|
draggedItem,
|
||||||
dragOverInfo,
|
dragOverInfo,
|
||||||
|
onRemoveSound,
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
const totalWidth = duration * zoom
|
const totalWidth = duration * zoom
|
||||||
const timelineRef = useRef<HTMLDivElement>(null)
|
const timelineRef = useRef<HTMLDivElement>(null)
|
||||||
@@ -292,6 +295,7 @@ export const SequencerCanvas = forwardRef<HTMLDivElement, SequencerCanvasProps>(
|
|||||||
currentTime={currentTime}
|
currentTime={currentTime}
|
||||||
draggedItem={draggedItem}
|
draggedItem={draggedItem}
|
||||||
dragOverInfo={dragOverInfo}
|
dragOverInfo={dragOverInfo}
|
||||||
|
onRemoveSound={onRemoveSound}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -258,6 +258,17 @@ export function SequencerPage() {
|
|||||||
setState(prev => ({ ...prev, duration }))
|
setState(prev => ({ ...prev, duration }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleRemoveSound = (soundId: string, trackId: string) => {
|
||||||
|
setState(prev => ({
|
||||||
|
...prev,
|
||||||
|
tracks: prev.tracks.map(track =>
|
||||||
|
track.id === trackId
|
||||||
|
? { ...track, sounds: track.sounds.filter(sound => sound.id !== soundId) }
|
||||||
|
: track
|
||||||
|
),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
const handleVerticalScroll = useCallback(() => {
|
const handleVerticalScroll = useCallback(() => {
|
||||||
if (trackControlsRef.current && sequencerCanvasRef.current) {
|
if (trackControlsRef.current && sequencerCanvasRef.current) {
|
||||||
const canvasScrollTop = sequencerCanvasRef.current.scrollTop
|
const canvasScrollTop = sequencerCanvasRef.current.scrollTop
|
||||||
@@ -346,6 +357,7 @@ export function SequencerPage() {
|
|||||||
onScroll={handleVerticalScroll}
|
onScroll={handleVerticalScroll}
|
||||||
draggedItem={draggedItem}
|
draggedItem={draggedItem}
|
||||||
dragOverInfo={dragOverInfo}
|
dragOverInfo={dragOverInfo}
|
||||||
|
onRemoveSound={handleRemoveSound}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user