termcinema_engine/core/layout.rs
1/// Layout configuration for the rendering canvas.
2///
3/// Defines the overall size, spacing, and alignment of the output area.
4/// All fields are optional and will fall back to theme or default values.
5pub struct LayoutSpec {
6 /// Canvas width in **pixels**.
7 /// Determines maximum horizontal space for line wrapping and positioning.
8 pub width: Option<u32>,
9
10 /// Canvas height in **pixels**.
11 /// Determines maximum vertical space for rendering content blocks.
12 pub height: Option<u32>,
13
14 /// Optional padding (in pixels) applied to all sides.
15 /// Creates spacing between the border and inner content.
16 pub padding: Option<u32>,
17
18 /// Optional line spacing between text lines (in pixels).
19 /// Affects vertical rhythm and visual readability.
20 pub line_spacing: Option<u32>,
21
22 /// Horizontal text alignment:
23 /// [`Left`] | [`Center`] | [`Right`].
24 /// Applies to each line or block within the canvas.
25 pub align: Option<TextAlign>,
26
27 /// Vertical alignment of the entire content block:
28 /// [`Top`] | [`Middle`] | [`Bottom`].
29 /// Controls placement within the total canvas height.
30 pub v_align: Option<VerticalAlign>,
31}
32
33/// Horizontal text alignment options.
34///
35/// Affects how each line of text is positioned within the available width.
36#[derive(Clone, Copy)]
37pub enum TextAlign {
38 /// Align to the left edge (default for most terminals).
39 Left,
40
41 /// Centered horizontally.
42 Center,
43
44 /// Align to the right edge.
45 Right,
46}
47
48/// Vertical alignment options for block positioning.
49///
50/// Determines how the content is placed relative to the canvas height.
51#[derive(Debug, Clone)]
52pub enum VerticalAlign {
53 /// Align to the top (default behavior).
54 Top,
55
56 /// Vertically centered.
57 Middle,
58
59 /// Align to the bottom.
60 Bottom,
61}