Salman Farooq 2025-06-14 23:57:52 +03:00 committed by GitHub
commit 4e67b99bb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -7,6 +7,8 @@ use tui::buffer::Buffer;
use crate::compositor::{Component, Context, Event, EventResult};
pub const FULL_OVERLAID_MAX_WIDTH: u16 = 240;
/// Contains a component placed in the center of the parent component
pub struct Overlay<T> {
/// Child component
@ -19,7 +21,14 @@ pub struct Overlay<T> {
pub fn overlaid<T>(content: T) -> Overlay<T> {
Overlay {
content,
calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)),
calc_child_size: Box::new(|rect: Rect| {
let percentage = if rect.width < FULL_OVERLAID_MAX_WIDTH {
100
} else {
90
};
clip_rect_relative(rect.clip_bottom(2), percentage, percentage)
}),
}
}