Skip to main content

oxicode_vtui/design/layout/
config.rs

1//! Layout configuration — appearance settings that drive the pane geometry.
2//!
3//! Pure data — the actual geometry computation lives in
4//! [`super::agent::AgentViewLayout::compute`].
5
6/// Horizontal + vertical padding configuration for the agent view.
7///
8/// All values are in terminal cells.  The `eff_*` methods fold in the compact
9/// flag so callers pass one boolean instead of replicating the conditional
10/// everywhere.
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub struct LayoutConfig {
13    /// Left horizontal padding (normal mode).
14    pub hpad_left: u16,
15    /// Right horizontal padding (normal mode).
16    pub hpad_right: u16,
17    /// Left horizontal padding (compact mode).
18    pub hpad_left_compact: u16,
19    /// Right horizontal padding (compact mode).
20    pub hpad_right_compact: u16,
21    /// Outer vertical padding (normal mode).
22    pub outer_vpad: u16,
23    /// Outer vertical padding (compact mode — usually 0).
24    pub outer_vpad_compact: u16,
25}
26
27impl Default for LayoutConfig {
28    fn default() -> Self {
29        Self {
30            hpad_left: 2,
31            hpad_right: 2,
32            hpad_left_compact: 1,
33            hpad_right_compact: 1,
34            outer_vpad: 1,
35            outer_vpad_compact: 0,
36        }
37    }
38}
39
40impl LayoutConfig {
41    /// Effective left horizontal padding given the compact flag.
42    #[must_use]
43    pub fn eff_hpad_left(&self, compact: bool) -> u16 {
44        if compact {
45            self.hpad_left_compact
46        } else {
47            self.hpad_left
48        }
49    }
50
51    /// Effective right horizontal padding given the compact flag.
52    #[must_use]
53    pub fn eff_hpad_right(&self, compact: bool) -> u16 {
54        if compact {
55            self.hpad_right_compact
56        } else {
57            self.hpad_right
58        }
59    }
60
61    /// Effective outer vertical padding given the compact flag.
62    #[must_use]
63    pub fn eff_outer_vpad(&self, compact: bool) -> u16 {
64        if compact {
65            self.outer_vpad_compact
66        } else {
67            self.outer_vpad
68        }
69    }
70}
71
72/// Scrollbar appearance configuration.
73#[derive(Debug, Clone, Copy, PartialEq, Eq)]
74pub struct ScrollbarConfig {
75    /// Whether the scrollbar is enabled.
76    pub enabled: bool,
77    /// Columns of gap between the scrollbar and content (left side).
78    pub gap_left: u16,
79    /// Columns of gap between the scrollbar and the screen edge (right side).
80    pub gap_right: u16,
81}
82
83impl Default for ScrollbarConfig {
84    fn default() -> Self {
85        Self {
86            enabled: true,
87            gap_left: 1,
88            gap_right: 1,
89        }
90    }
91}