dais_ui/presenter/
next_preview.rs1use crate::widgets::SlideThumbnail;
6use dais_document::page::RenderedPage;
7
8pub struct NextPreviewPanel {
10 thumbnail: SlideThumbnail,
11}
12
13impl NextPreviewPanel {
14 pub fn new() -> Self {
15 Self { thumbnail: SlideThumbnail::new() }
16 }
17
18 pub fn update(&mut self, ctx: &egui::Context, page: &RenderedPage, page_index: usize) {
20 self.thumbnail.update(ctx, page, page_index);
21 }
22
23 pub fn show(&self, ui: &mut egui::Ui, area: egui::Rect) {
25 let mut child_ui = ui.new_child(
26 egui::UiBuilder::new()
27 .max_rect(area)
28 .layout(egui::Layout::centered_and_justified(egui::Direction::TopDown)),
29 );
30
31 child_ui.scope_builder(
33 egui::UiBuilder::new()
34 .max_rect(egui::Rect::from_min_size(area.min, egui::vec2(area.width(), 20.0))),
35 |ui| {
36 ui.colored_label(egui::Color32::GRAY, "Next");
37 },
38 );
39
40 let content_area = egui::Rect::from_min_size(
41 area.min + egui::vec2(0.0, 20.0),
42 egui::vec2(area.width(), (area.height() - 20.0).max(1.0)),
43 );
44
45 let padding = egui::vec2(8.0, 4.0);
46 let available = egui::vec2(
47 (content_area.width() - padding.x * 2.0).max(1.0),
48 (content_area.height() - padding.y * 2.0).max(1.0),
49 );
50
51 let mut inner = child_ui.new_child(
52 egui::UiBuilder::new()
53 .max_rect(content_area)
54 .layout(egui::Layout::centered_and_justified(egui::Direction::TopDown)),
55 );
56 self.thumbnail.show(&mut inner, available);
57 }
58
59 pub fn show_empty(&self, ui: &mut egui::Ui, area: egui::Rect) {
61 let mut child_ui = ui.new_child(
62 egui::UiBuilder::new()
63 .max_rect(area)
64 .layout(egui::Layout::centered_and_justified(egui::Direction::TopDown)),
65 );
66 child_ui.colored_label(egui::Color32::from_gray(100), "End of presentation");
67 }
68}
69
70impl Default for NextPreviewPanel {
71 fn default() -> Self {
72 Self::new()
73 }
74}