1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::class::{styles::StyleClass, ApplyClass};
use bevy::ui::{Style, Val};

pub fn gap(px: f32) -> StyleClass {
    StyleClass::Gap(Gap(Val::Px(px)))
}

pub fn gap_x(px: f32) -> StyleClass {
    StyleClass::ColGap(ColGap(Val::Px(px)))
}

pub fn gap_y(px: f32) -> StyleClass {
    StyleClass::RowGap(RowGap(Val::Px(px)))
}

#[derive(Debug, Clone)]
pub struct Gap(Val);

impl ApplyClass for Gap {
    type Component = Style;

    fn apply_class(&self, component: &mut Self::Component) {
        component.row_gap = self.0;
        component.column_gap = self.0;
    }
}

#[derive(Debug, Clone)]
pub struct RowGap(Val);

impl ApplyClass for RowGap {
    type Component = Style;

    fn apply_class(&self, component: &mut Self::Component) {
        component.row_gap = self.0;
    }
}

#[derive(Debug, Clone)]
pub struct ColGap(Val);

impl ApplyClass for ColGap {
    type Component = Style;

    fn apply_class(&self, component: &mut Self::Component) {
        component.column_gap = self.0;
    }
}