Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,40 @@ impl Interface {
);
ui.label(format!("Window width: {}", self.window_width));
ui.label(format!("Window height: {}", self.window_height));
}

if self.images.len() > 1 {
ui.add(
Slider::new(
&mut self.displayed_image_idx,
0..=self.images.len() as u32 - 1,
)
.text("image")
.clamp_to_range(true)
.prefix("#"),
);
}
if let Some(img) = self.images.get(self.displayed_image_idx as usize) {
let width = 360f32;
let height = img.size.y * (width / img.size.x);
ui.image(img.texture_id, (width, height));
pub fn images_ui(&mut self, ctx: &egui::CtxRef) {
if self.images.is_empty() {
return;
}

egui::Area::new("images").show(ctx, |ui| {
Frame::popup(ui.style())
.stroke(Stroke::none())
.show(ui, |ui| {
ui.set_max_width(ui.available_width() * 0.20);
CollapsingHeader::new("Images")
.default_open(true)
.show(ui, |ui| {
if self.images.len() > 1 {
ui.add(
Slider::new(
&mut self.displayed_image_idx,
0..=self.images.len() as u32 - 1,
)
.text("image")
.clamp_to_range(true)
.prefix("#"),
);
}
if let Some(img) = self.images.get(self.displayed_image_idx as usize) {
let width = 360f32;
let height = img.size.y * (width / img.size.x);
ui.image(img.texture_id, (width, height));
}
});
});
});
}

pub fn input(&mut self, event: &Event<'_, ()>, window: &Window) -> bool {
Expand Down Expand Up @@ -161,5 +178,6 @@ impl epi::App for Interface {
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::CtxRef, _frame: &mut epi::Frame<'_>) {
egui::Area::new("settings").show(ctx, |ui| self.ui(ui));
self.images_ui(ctx);
}
}