ratatui_toolkit/primitives/resizable_split/constructors/
mod.rs

1use crate::primitives::resizable_split::{ResizableSplit, SplitDirection};
2
3impl ResizableSplit {
4    pub fn new(initial_percent: u16) -> Self {
5        Self::new_with_direction(initial_percent, SplitDirection::Vertical)
6    }
7
8    pub fn new_with_direction(initial_percent: u16, direction: SplitDirection) -> Self {
9        Self {
10            split_percent: initial_percent.clamp(5, 95),
11            min_percent: 10,
12            max_percent: 90,
13            is_dragging: false,
14            is_hovering: false,
15            direction,
16            divider_pos: 0,
17        }
18    }
19
20    pub fn start_drag(&mut self) {
21        self.is_dragging = true;
22    }
23
24    pub fn stop_drag(&mut self) {
25        self.is_dragging = false;
26    }
27
28    pub fn right_percent(&self) -> u16 {
29        100 - self.split_percent
30    }
31
32    pub fn bottom_percent(&self) -> u16 {
33        self.right_percent()
34    }
35}