Skip to content

Commit

Permalink
make-overlaid-content-conditionally-take-all-the-space
Browse files Browse the repository at this point in the history
  • Loading branch information
salman-farooq-sh committed Jan 1, 2025
1 parent d24eaa1 commit 09685a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion helix-term/src/ui/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}),
}
}

Expand Down

0 comments on commit 09685a0

Please sign in to comment.