Skip to main content

boxmux_lib/components/dimensions/
mod.rs

1pub mod component_dimensions;
2pub mod layout_dimensions;
3pub mod mouse_dimensions;
4pub mod progress_dimensions;
5pub mod scroll_dimensions;
6pub mod text_dimensions;
7
8pub use component_dimensions::ComponentDimensions;
9pub use layout_dimensions::LayoutDimensions;
10pub use mouse_dimensions::MouseDimensions;
11pub use progress_dimensions::ProgressDimensions;
12pub use scroll_dimensions::ScrollDimensions;
13pub use text_dimensions::TextDimensions;
14
15/// Common types used across dimension classes
16#[derive(Debug, Clone, Copy, PartialEq)]
17pub enum Orientation {
18    Horizontal,
19    Vertical,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq)]
23pub struct Padding {
24    pub top: usize,
25    pub right: usize,
26    pub bottom: usize,
27    pub left: usize,
28}
29
30impl Padding {
31    pub fn new(top: usize, right: usize, bottom: usize, left: usize) -> Self {
32        Self {
33            top,
34            right,
35            bottom,
36            left,
37        }
38    }
39
40    pub fn uniform(padding: usize) -> Self {
41        Self::new(padding, padding, padding, padding)
42    }
43
44    pub fn zero() -> Self {
45        Self::uniform(0)
46    }
47
48    pub fn horizontal_total(&self) -> usize {
49        self.left + self.right
50    }
51
52    pub fn vertical_total(&self) -> usize {
53        self.top + self.bottom
54    }
55}
56
57#[derive(Debug, Clone, Copy, PartialEq)]
58pub enum HitRegion {
59    Content,
60    Border,
61    ScrollbarVertical,
62    ScrollbarHorizontal,
63    TabBar,
64    CloseButton,
65    Outside,
66}
67
68/// Font metrics for text calculations (expandable for future use)
69#[derive(Debug, Clone, Copy, PartialEq)]
70pub struct FontMetrics {
71    pub char_width: usize,
72    pub line_height: usize,
73}
74
75impl Default for FontMetrics {
76    fn default() -> Self {
77        Self {
78            char_width: 1, // Terminal characters
79            line_height: 1,
80        }
81    }
82}