pub struct ScreenState { /* private fields */ }Expand description
Navigation stack state for multi-screen apps.
Tracks screen names in a push/pop stack while preserving the root screen.
Each screen gets isolated focus and hook state when used with
crate::Context::screen.
§Example
let mut screens = slt::ScreenState::new("main");
slt::run(|ui| {
let current = screens.current().to_string();
if current == "main" {
if ui.button("Settings").clicked { screens.push("settings"); }
}
if current == "settings" {
if ui.button("Back").clicked { screens.pop(); }
}
});Implementations§
Source§impl ScreenState
impl ScreenState
Sourcepub fn new(initial: impl Into<String>) -> Self
pub fn new(initial: impl Into<String>) -> Self
Create a screen stack with an initial root screen.
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Return true if name is currently present in the navigation stack.
Sourcepub fn remove_inactive(&mut self, name: &str) -> bool
pub fn remove_inactive(&mut self, name: &str) -> bool
Remove retained focus state for a screen that is no longer on the stack.
Returns false when the screen is still active or stacked, because
dropping focus for a live screen would make back navigation jumpy.
Sourcepub fn retain_inactive(&mut self, keep: impl FnMut(&str) -> bool) -> usize
pub fn retain_inactive(&mut self, keep: impl FnMut(&str) -> bool) -> usize
Retain inactive focus-state entries accepted by keep.
Screens still present in the stack are always kept. Returns the number of focus-state entries removed.
Sourcepub fn focus_state_count(&self) -> usize
pub fn focus_state_count(&self) -> usize
Number of retained per-screen focus entries.
Diagnostic helper for apps with runtime-generated screen names.
Trait Implementations§
Source§impl Clone for ScreenState
impl Clone for ScreenState
Source§fn clone(&self) -> ScreenState
fn clone(&self) -> ScreenState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more