pub trait ShellApp<D> {
// Required method
fn screen_ui(&mut self, ui: &mut Ui, screen: D, side: &mut Side);
// Provided methods
fn side_ui(&mut self, ui: &mut Ui, screen: D, side: &mut Side) { ... }
fn foot_ui(&mut self, ui: &mut Ui) -> Option<D> { ... }
fn status_ui(&mut self, ui: &mut Ui) { ... }
fn action(&mut self, id: &'static str, side: &mut Side) { ... }
}Expand description
An app as the shell draws it, each frame, with Shell::show: its screens, its side
pane, its foot and status, and what its actions do. The shell calls these in turn, each
with the app’s &mut self, so a screen and the side pane share the app’s state freely.
#[derive(Clone, Copy, PartialEq)]
enum Screen { Entries, Settings }
struct Journal { draft: Option<String> }
impl ShellApp<Screen> for Journal {
fn screen_ui(&mut self, ui: &mut egui::Ui, screen: Screen, side: &mut Side) {
egui::CentralPanel::default().show(ui, |ui| ui.label("…"));
}
fn side_ui(&mut self, ui: &mut egui::Ui, screen: Screen, side: &mut Side) {
match &mut self.draft {
Some(text) => {
ui.text_edit_multiline(text);
if ui.button("Save").clicked() {
self.draft = None;
side.close();
}
}
None => { ui.weak("Nothing selected"); }
}
}
fn action(&mut self, id: &'static str, side: &mut Side) {
if id == "new-entry" {
self.draft = Some(String::new());
side.open();
}
}
}
let mut shell = Shell::from_items(vec![
Action::new("new-entry", icons::plus(), "new-entry").into(),
Destination::new(Screen::Entries, icons::file_text(), "entries").into(),
])
.with_footer(vec![Destination::new(Screen::Settings, icons::settings(), "settings")])
.with_side_pane()
.with_status_bar();
let mut journal = Journal { draft: None };
// Every frame:
shell.show(ui, &mut journal);Required Methods§
Provided Methods§
Sourcefn side_ui(&mut self, ui: &mut Ui, screen: D, side: &mut Side)
fn side_ui(&mut self, ui: &mut Ui, screen: D, side: &mut Side)
Fill the side pane, with_side_pane (no panels of its own):
the new entry being written, else screen’s item, else a word that there is none.
Through side it closes the pane once the entry is saved or dropped.
Sourcefn foot_ui(&mut self, ui: &mut Ui) -> Option<D>
fn foot_ui(&mut self, ui: &mut Ui) -> Option<D>
Draw the foot — a status dot, say — at the rail’s foot, at the bottom bar’s end, or on the status bar; a destination it returns is opened.
Sourcefn status_ui(&mut self, ui: &mut Ui)
fn status_ui(&mut self, ui: &mut Ui)
Fill the status bar from the left, with_status_bar.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".