MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / centered_popup

Function centered_popup

crates/openshell-tui/src/ui/mod.rs:662–679  ·  view source on GitHub ↗

Center a popup rectangle within `area` using percentage-based width and an absolute height (in rows).

(percent_x: u16, height: u16, area: Rect)

Source from the content-addressed store, hash-verified

660/// Center a popup rectangle within `area` using percentage-based width and
661/// an absolute height (in rows).
662pub fn centered_popup(percent_x: u16, height: u16, area: Rect) -> Rect {
663 let vert = Layout::default()
664 .direction(Direction::Vertical)
665 .constraints([
666 Constraint::Percentage((100 - height.min(100)) / 2),
667 Constraint::Length(height),
668 Constraint::Percentage((100 - height.min(100)) / 2),
669 ])
670 .split(area);
671 Layout::default()
672 .direction(Direction::Horizontal)
673 .constraints([
674 Constraint::Percentage((100 - percent_x) / 2),
675 Constraint::Percentage(percent_x),
676 Constraint::Percentage((100 - percent_x) / 2),
677 ])
678 .split(vert[1])[1]
679}

Callers 2

draw_confirm_popupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected