Lines
100 %
Functions
50 %
Branches
//! Overlay stack — LIFO focus layer rendered on top of the main view.
use crate::modal::Modal;
#[cfg(test)]
mod tests;
/// LIFO stack of overlays. The topmost overlay owns keyboard focus.
#[derive(Debug, Default)]
pub struct OverlayStack {
items: Vec<Modal>,
}
impl OverlayStack {
#[must_use]
pub const fn new() -> Self {
Self { items: Vec::new() }
pub fn push(&mut self, modal: Modal) {
self.items.push(modal);
pub fn pop(&mut self) -> Option<Modal> {
self.items.pop()
pub fn top(&self) -> Option<&Modal> {
self.items.last()
pub fn top_mut(&mut self) -> Option<&mut Modal> {
self.items.last_mut()
pub fn is_empty(&self) -> bool {
self.items.is_empty()