Center a popup rectangle within `area` using percentage-based width and an absolute height (in rows).
(percent_x: u16, height: u16, area: Rect)
| 660 | /// Center a popup rectangle within `area` using percentage-based width and |
| 661 | /// an absolute height (in rows). |
| 662 | pub 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 | } |
no outgoing calls
no test coverage detected