Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Dec 6, 2024
1 parent 04abc17 commit 04021eb
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,40 +338,38 @@ impl View for DelayGraph {

fn draw(&self, draw_context: &mut DrawContext, canvas: &mut Canvas) {
let params = self.params.clone();

let tap_counter = params.tap_counter.load(Ordering::SeqCst);
let input_meter = self.input_meter.clone();
let output_meter = self.output_meter.clone();
let tap_meters = self.tap_meters.clone();
let meter_indexes = self.meter_indexes.clone();

let input_meter = &self.input_meter;
let output_meter = &self.output_meter;

let bounds = draw_context.bounds();
let border_color: vg::Color = draw_context.border_color().into();
let outline_width = draw_context.outline_width();
let border_width = draw_context.border_width();
let background_color: vg::Color = draw_context.background_color().into();
let first_note = params.first_note.load(Ordering::SeqCst);

// Draw components
Self::draw_background(canvas, bounds, background_color);

let outline_color: vg::Color = draw_context.outline_color().into();
let selection_color: vg::Color = draw_context.selection_color().into();
let font_color: vg::Color = draw_context.font_color().into();
let tap_meters = self.tap_meters.clone();
let meter_indexes = self.meter_indexes.clone();

let first_note = params.first_note.load(Ordering::SeqCst);
let current_time = params.current_time.load(Ordering::SeqCst);
// Compute the time scaling factor
let target_time_scaling_factor = Self::compute_time_scaling_factor(&params);

let target_time_scaling_factor = Self::compute_time_scaling_factor(&params);
let gui_decay_weight = Self::calculate_gui_decay_weight(&params);

let available_width = outline_width.mul_add(-0.5, bounds.w - border_width);

let time_scaling_factor = (Self::gui_smooth(
target_time_scaling_factor,
&params.previous_time_scaling_factor,
gui_decay_weight,
) / available_width)
.recip();

// Start drawing
Self::draw_background(canvas, bounds, background_color);

if tap_counter > 0 {
Self::draw_delay_times_as_lines(
canvas,
Expand All @@ -381,6 +379,7 @@ impl View for DelayGraph {
border_width,
time_scaling_factor,
);

Self::draw_tap_velocities_and_meters(
canvas,
&params,
Expand All @@ -397,8 +396,8 @@ impl View for DelayGraph {

Self::draw_in_out_meters(
canvas,
&input_meter,
&output_meter,
input_meter,
output_meter,
bounds,
border_color,
outline_width,
Expand Down

0 comments on commit 04021eb

Please sign in to comment.