Skip to content

Commit

Permalink
wave viewer: fix offset calculation for marker
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Dec 22, 2023
1 parent c743c03 commit 87c2836
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/widget/waveform_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,18 +393,18 @@ where
);

if let Some(peaks) = self.get_wave(state) {
let zoom = match state.interpolated.is_none() {
true => state.zoom,
false => 1.0,
};

let waveform = state
.canvas_cache
.draw(renderer, layout.bounds().size(), |frame| {
// Get generated waveform
let path = state.waveform.as_ref().expect("wave should be generated");

// Scale and stretch waveform
let zoom = match state.interpolated.is_none() {
true => state.zoom,
false => 1.0,
};

frame.scale_nonuniform([zoom, layout_height]);

// TODO: horizontally transform waveform
Expand All @@ -423,7 +423,7 @@ where

// Draw markers - only do so if we're rendering the waveform
if let Some(markers) = &self.markers {
let wave_width = peaks.peaks()[0].len() as f32 * state.zoom;
let wave_width = peaks.peaks()[0].len() as f32 * zoom;

for marker in markers {
let x = layout.bounds().x + wave_width * marker.0 - state.wave_offset as f32;
Expand Down

0 comments on commit 87c2836

Please sign in to comment.