Skip to content

Commit

Permalink
render image update only if there's an image
Browse files Browse the repository at this point in the history
  • Loading branch information
diegostafa committed Mar 6, 2024
1 parent 213a8d8 commit be6f192
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,13 +1011,12 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
}

if state.reset_image {
let draw_area = ctx.available_rect();
let window_size = nalgebra::Vector2::new(
draw_area.width().min(app.window().width() as f32),
draw_area.height().min(app.window().height() as f32),
);

if let Some(current_image) = &state.current_image {
let draw_area = ctx.available_rect();
let window_size = nalgebra::Vector2::new(
draw_area.width().min(app.window().width() as f32),
draw_area.height().min(app.window().height() as f32),
);
let img_size = current_image.size_vec();
state.image_geometry.scale = (window_size.x / img_size.x)
.min(window_size.y / img_size.y)
Expand All @@ -1030,8 +1029,8 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
state.image_geometry.offset.y += draw_area.top();
debug!("Image has been reset.");
state.reset_image = false;
app.window().request_frame();
}
app.window().request_frame();
}

// Settings come last, as they block keyboard grab (for hotkey assigment)
Expand Down

0 comments on commit be6f192

Please sign in to comment.