Skip to content

Commit

Permalink
Ensure all images are displayed in file browser, secure range
Browse files Browse the repository at this point in the history
  • Loading branch information
woelper committed Dec 30, 2024
1 parent bc49702 commit cee83e7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/filebrowser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,11 @@ pub fn browse<F: FnMut(&PathBuf)>(

let r = ui.available_rect_before_wrap();

// ui.painter().debug_rect(r, Color32::LIGHT_RED, format!("{:?}", r));
let spacing = ui.style().spacing.item_spacing.x;
let w = r.width() - spacing * 3.;

let thumbs_per_row = (w / (THUMB_SIZE[0] as f32 + spacing)).floor().max(1.).min(entries.len() as f32);
let num_rows = entries.len() / (thumbs_per_row as usize).max(1);

// debug!("tpr {thumbs_per_row} {w}, rows: {num_rows}");
let num_rows = (entries.len() as f32 / (thumbs_per_row).max(1.)).ceil() as usize;

egui::Frame::none()
.fill(panel_bg_color)
Expand All @@ -408,7 +405,7 @@ pub fn browse<F: FnMut(&PathBuf)>(
.clone()
.drain(
(row_range.start * thumbs_per_row as usize)
..(row_range.end * thumbs_per_row as usize),
..(row_range.end * thumbs_per_row as usize).min(entries.len()),
)
.collect::<Vec<_>>();

Expand Down

0 comments on commit cee83e7

Please sign in to comment.