dais_ui/presenter/
layout.rs1pub struct PresenterLayout {
11 pub current_slide: egui::Rect,
13 pub next_preview: egui::Rect,
15 pub notes_panel: egui::Rect,
17 pub status_bar: egui::Rect,
19 pub vertical_splitter: egui::Rect,
21 pub horizontal_splitter: egui::Rect,
23}
24
25const STATUS_BAR_HEIGHT: f32 = 40.0;
27const SPLITTER_SIZE: f32 = 8.0;
29
30impl PresenterLayout {
31 pub fn compute(available: egui::Rect, left_fraction: f32, top_fraction: f32) -> Self {
33 let total_w = available.width();
34 let total_h = available.height();
35
36 let status_bar = egui::Rect::from_min_size(
37 egui::pos2(available.min.x, available.max.y - STATUS_BAR_HEIGHT),
38 egui::vec2(total_w, STATUS_BAR_HEIGHT),
39 );
40
41 let content_h = (total_h - STATUS_BAR_HEIGHT).max(0.0);
42 let splitter_half = SPLITTER_SIZE * 0.5;
43 let left_w = (total_w * left_fraction - splitter_half).max(0.0);
44 let right_w = (total_w - left_w - SPLITTER_SIZE).max(0.0);
45
46 let current_slide = egui::Rect::from_min_size(available.min, egui::vec2(left_w, content_h));
47 let vertical_splitter = egui::Rect::from_min_max(
48 egui::pos2(current_slide.max.x, available.min.y),
49 egui::pos2(current_slide.max.x + SPLITTER_SIZE, available.min.y + content_h),
50 );
51
52 let right_top = egui::pos2(vertical_splitter.max.x, available.min.y);
53 let top_h = (content_h * top_fraction - splitter_half).max(0.0);
54 let bottom_h = (content_h - top_h - SPLITTER_SIZE).max(0.0);
55
56 let next_preview = egui::Rect::from_min_size(right_top, egui::vec2(right_w, top_h));
57 let horizontal_splitter = egui::Rect::from_min_max(
58 egui::pos2(right_top.x, next_preview.max.y),
59 egui::pos2(right_top.x + right_w, next_preview.max.y + SPLITTER_SIZE),
60 );
61
62 let notes_panel = egui::Rect::from_min_size(
63 egui::pos2(right_top.x, horizontal_splitter.max.y),
64 egui::vec2(right_w, bottom_h),
65 );
66
67 Self {
68 current_slide,
69 next_preview,
70 notes_panel,
71 status_bar,
72 vertical_splitter,
73 horizontal_splitter,
74 }
75 }
76}