ratatui_kit/render/
layout_style.rs1use ratatui::layout::{Constraint, Direction, Flex, Layout, Margin, Offset};
2
3#[derive(Default, Clone)]
4pub struct LayoutStyle {
5 pub flex_direction: Direction,
6 pub justify_content: Flex,
7 pub gap: i32,
8 pub margin: Margin,
9 pub offset: Offset,
10 pub width: Constraint,
11 pub height: Constraint,
12}
13
14impl LayoutStyle {
15 pub fn get_layout(&self) -> Layout {
16 Layout::default()
17 .direction(self.flex_direction)
18 .flex(self.justify_content)
19 .spacing(self.gap)
20 }
21
22 pub fn get_width(&self) -> Constraint {
23 self.width
24 }
25
26 pub fn get_height(&self) -> Constraint {
27 self.height
28 }
29
30 pub fn inner_area(&self, area: ratatui::layout::Rect) -> ratatui::layout::Rect {
31 area.offset(self.offset).inner(self.margin)
32 }
33}