Skip to content

Commit

Permalink
don't scale time at initial tap
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Nov 15, 2024
1 parent 9833937 commit 87ce3f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ impl View for DelayGraph {
fn draw(&self, draw_context: &mut DrawContext, canvas: &mut Canvas) {
// let params = self.params.clone();

let params = self.params.clone();
let bounds = draw_context.bounds();

let background_color: vg::Color = draw_context.background_color().into();
Expand All @@ -396,34 +397,35 @@ impl View for DelayGraph {

// Compute the time scaling factor
let target_time_scaling_factor = Self::compute_time_scaling_factor(
self.params.clone(),
params.clone(),
bounds.w,
border_width,
outline_width,
);

let time_scaling_factor = (self
.params
.previous_time_scaling_factor
.load(Ordering::SeqCst)
if params.previous_time_scaling_factor.load(Ordering::SeqCst) == 0.0 {
params
.previous_time_scaling_factor
.store(target_time_scaling_factor, Ordering::SeqCst);
}
let time_scaling_factor = (params.previous_time_scaling_factor.load(Ordering::SeqCst)
* ZOOM_SMOOTH_POLE)
+ (target_time_scaling_factor * (1.0 - ZOOM_SMOOTH_POLE));
self.params
params
.previous_time_scaling_factor
.store(time_scaling_factor, Ordering::SeqCst);
// Draw components
Self::draw_background(canvas, bounds, background_color);
Self::draw_delay_times_as_lines(
canvas,
self.params.clone(),
params.clone(),
bounds,
border_color,
border_width,
time_scaling_factor,
);
Self::draw_time_line(
canvas,
self.params.clone(),
params.clone(),
bounds,
selection_color,
outline_width,
Expand All @@ -432,7 +434,7 @@ impl View for DelayGraph {
);
Self::draw_tap_velocities(
canvas,
self.params.clone(),
params.clone(),
bounds,
outline_color,
outline_width,
Expand All @@ -441,7 +443,7 @@ impl View for DelayGraph {
);
Self::draw_tap_notes_and_pans(
canvas,
self.params.clone(),
params.clone(),
bounds,
selection_color,
outline_width,
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,9 @@ impl Del2 {
self.enabled_actions.store(LOCK_TAPS, false);
self.params.current_tap.store(0, Ordering::SeqCst);

self.params
.previous_time_scaling_factor
.store(0.0, Ordering::SeqCst);
self.params
.previous_first_note_height
.store(0.0, Ordering::SeqCst);
Expand Down

0 comments on commit 87ce3f5

Please sign in to comment.