2021-08-16 19:32:44 +00:00
|
|
|
#[derive(Clone, PartialEq, Default)]
|
|
|
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
|
|
|
pub struct WindowWithPanels {}
|
|
|
|
|
|
|
|
impl super::Demo for WindowWithPanels {
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
"🗖 Window With Panels"
|
|
|
|
}
|
2021-08-19 22:10:06 +00:00
|
|
|
|
2021-08-16 19:32:44 +00:00
|
|
|
fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) {
|
|
|
|
use super::View;
|
|
|
|
let window = egui::Window::new("Window with Panels")
|
2021-08-23 20:28:42 +00:00
|
|
|
.default_width(600.0)
|
|
|
|
.default_height(400.0)
|
2021-08-28 11:18:21 +00:00
|
|
|
.vscroll(false)
|
2021-08-16 19:32:44 +00:00
|
|
|
.open(open);
|
|
|
|
window.show(ctx, |ui| self.ui(ui));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl super::View for WindowWithPanels {
|
|
|
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
2021-08-27 18:08:01 +00:00
|
|
|
// Note that the order we add the panels is very important!
|
|
|
|
|
2021-08-19 22:10:06 +00:00
|
|
|
egui::TopBottomPanel::top("top_panel")
|
2021-08-27 18:08:01 +00:00
|
|
|
.resizable(true)
|
|
|
|
.min_height(32.0)
|
2021-08-19 22:10:06 +00:00
|
|
|
.show_inside(ui, |ui| {
|
2021-08-28 11:18:21 +00:00
|
|
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
2021-08-27 18:08:01 +00:00
|
|
|
ui.vertical_centered(|ui| {
|
|
|
|
ui.heading("Expandable Upper Panel");
|
2021-08-16 19:32:44 +00:00
|
|
|
});
|
2021-08-27 18:08:01 +00:00
|
|
|
ui.add(egui::Label::new(crate::LOREM_IPSUM_LONG).small().weak());
|
2021-08-23 20:28:42 +00:00
|
|
|
});
|
2021-08-19 22:10:06 +00:00
|
|
|
});
|
2021-08-16 19:32:44 +00:00
|
|
|
|
2021-08-19 22:10:06 +00:00
|
|
|
egui::SidePanel::left("left_panel")
|
2021-08-16 19:32:44 +00:00
|
|
|
.resizable(true)
|
2021-08-23 20:28:42 +00:00
|
|
|
.default_width(150.0)
|
|
|
|
.width_range(80.0..=200.0)
|
2021-08-19 22:10:06 +00:00
|
|
|
.show_inside(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.vertical_centered(|ui| {
|
|
|
|
ui.heading("Left Panel");
|
|
|
|
});
|
2021-08-28 11:18:21 +00:00
|
|
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.add(egui::Label::new(crate::LOREM_IPSUM_LONG).small().weak());
|
2021-08-19 22:10:06 +00:00
|
|
|
});
|
2021-08-16 19:32:44 +00:00
|
|
|
});
|
|
|
|
|
2021-08-19 22:10:06 +00:00
|
|
|
egui::SidePanel::right("right_panel")
|
|
|
|
.resizable(true)
|
2021-08-23 20:28:42 +00:00
|
|
|
.default_width(150.0)
|
|
|
|
.width_range(80.0..=200.0)
|
2021-08-19 22:10:06 +00:00
|
|
|
.show_inside(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.vertical_centered(|ui| {
|
|
|
|
ui.heading("Right Panel");
|
|
|
|
});
|
2021-08-28 11:18:21 +00:00
|
|
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.add(egui::Label::new(crate::LOREM_IPSUM_LONG).small().weak());
|
2021-08-19 22:10:06 +00:00
|
|
|
});
|
|
|
|
});
|
2021-08-16 19:32:44 +00:00
|
|
|
|
2021-08-27 18:08:01 +00:00
|
|
|
egui::TopBottomPanel::bottom("bottom_panel")
|
2021-08-19 22:10:06 +00:00
|
|
|
.resizable(false)
|
|
|
|
.min_height(0.0)
|
|
|
|
.show_inside(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.vertical_centered(|ui| {
|
2021-08-27 18:08:01 +00:00
|
|
|
ui.heading("Bottom Panel");
|
2021-08-23 20:28:42 +00:00
|
|
|
});
|
2021-08-19 22:10:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
egui::CentralPanel::default().show_inside(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.vertical_centered(|ui| {
|
|
|
|
ui.heading("Central Panel");
|
|
|
|
});
|
2021-08-28 11:18:21 +00:00
|
|
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
2021-08-23 20:28:42 +00:00
|
|
|
ui.add(egui::Label::new(crate::LOREM_IPSUM_LONG).small().weak());
|
2021-08-16 19:32:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|