Skip to main content

zest_theme/
spacing.rs

1//! [`Spacing`]: design-system spacing scale in pixels.
2
3/// Design-system spacing scale, in pixels.
4///
5/// Mirrors libcosmic's `space_xxxs` through `space_xxxl` scale. Widgets
6/// reference these values rather than hard-coding pixel counts, so the
7/// entire UI scales coherently when a theme is swapped.
8///
9/// Default values are tuned for a 320×240 display at 1× density. For
10/// larger displays consider scaling proportionally.
11#[derive(Copy, Clone, Debug, PartialEq, Eq)]
12pub struct Spacing {
13    /// 0 px — for explicit "no gap" placement.
14    pub space_none: u16,
15    /// Extra-extra-extra-small (1 px).
16    pub space_xxxs: u16,
17    /// Extra-extra-small (2 px).
18    pub space_xxs: u16,
19    /// Extra-small (4 px).
20    pub space_xs: u16,
21    /// Small (8 px).
22    pub space_s: u16,
23    /// Medium (12 px).
24    pub space_m: u16,
25    /// Large (16 px).
26    pub space_l: u16,
27    /// Extra-large (24 px).
28    pub space_xl: u16,
29    /// Extra-extra-large (32 px).
30    pub space_xxl: u16,
31    /// Extra-extra-extra-large (48 px).
32    pub space_xxxl: u16,
33}
34
35impl Spacing {
36    /// Default scale tuned for 320×240 displays.
37    pub const fn default_small() -> Self {
38        Self {
39            space_none: 0,
40            space_xxxs: 1,
41            space_xxs: 2,
42            space_xs: 4,
43            space_s: 8,
44            space_m: 12,
45            space_l: 16,
46            space_xl: 24,
47            space_xxl: 32,
48            space_xxxl: 48,
49        }
50    }
51}
52
53impl Default for Spacing {
54    fn default() -> Self {
55        Self::default_small()
56    }
57}