From 213a8d8c342314e8616ba5fe999bfc2308761b62 Mon Sep 17 00:00:00 2001 From: diegostafa Date: Wed, 6 Mar 2024 15:25:44 +0100 Subject: [PATCH 1/2] render loading spinner only if there's a path --- src/ui.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 1410a20..7a398e5 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -2047,16 +2047,14 @@ pub fn main_menu(ui: &mut Ui, state: &mut OculanteState, app: &mut App, gfx: &mu .unwrap_or_default() )); } - } - if !state.is_loaded { - if let Some(p) = &state.current_path { + if !state.is_loaded { ui.horizontal(|ui| { ui.add(egui::Spinner::default()); ui.label(format!("Loading {}", p.display())); }); + app.window().request_frame(); } - app.window().request_frame(); } drag_area(ui, state, app); From be6f1921a5d535fa79862704cca6752c27d1228f Mon Sep 17 00:00:00 2001 From: diegostafa Date: Wed, 6 Mar 2024 15:28:04 +0100 Subject: [PATCH 2/2] render image update only if there's an image --- src/main.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 896e602..114eece 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) @@ -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)