Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_feathers/src/containers/pane.rs
30636 views
1
use bevy_ecs::hierarchy::Children;
2
use bevy_scene::{bsn, Scene};
3
use bevy_text::FontWeight;
4
use bevy_ui::{
5
px, AlignItems, AlignSelf, Display, FlexDirection, JustifyContent, Node, PositionType, UiRect,
6
};
7
8
use crate::{
9
constants::{fonts, size},
10
font_styles::InheritableFont,
11
rounded_corners::RoundedCorners,
12
theme::{InheritableThemeTextColor, ThemeBackgroundColor, ThemeBorderColor},
13
tokens,
14
};
15
16
/// A standard pane
17
pub fn pane() -> impl Scene {
18
bsn! {
19
Node {
20
display: Display::Flex,
21
flex_direction: FlexDirection::Column,
22
align_items: AlignItems::Stretch,
23
}
24
}
25
}
26
27
/// Pane header
28
pub fn pane_header() -> impl Scene {
29
bsn! {
30
Node {
31
display: Display::Flex,
32
flex_direction: FlexDirection::Row,
33
align_items: AlignItems::Center,
34
justify_content: JustifyContent::SpaceBetween,
35
padding: px(6),
36
border: UiRect {
37
left: px(1),
38
top: px(1),
39
right: px(1),
40
},
41
min_height: size::HEADER_HEIGHT,
42
column_gap: px(6),
43
border_radius: {RoundedCorners::Top.to_border_radius(4.0)},
44
}
45
ThemeBackgroundColor(tokens::PANE_HEADER_BG)
46
ThemeBorderColor(tokens::PANE_HEADER_BORDER)
47
InheritableThemeTextColor(tokens::PANE_HEADER_TEXT)
48
InheritableFont {
49
font: fonts::REGULAR,
50
font_size: size::MEDIUM_FONT,
51
weight: FontWeight::NORMAL,
52
}
53
}
54
}
55
56
/// Vertical divider between groups of widgets in pane headers
57
pub fn pane_header_divider() -> impl Scene {
58
bsn! {
59
Node {
60
width: px(1),
61
align_self: AlignSelf::Stretch,
62
}
63
Children [(
64
// Because we want to extend the divider into the header padding area, we'll use
65
// an absolutely-positioned child.
66
Node {
67
position_type: PositionType::Absolute,
68
left: px(0),
69
right: px(0),
70
top: px(-6),
71
bottom: px(-6),
72
}
73
ThemeBackgroundColor(tokens::PANE_HEADER_DIVIDER)
74
)]
75
}
76
}
77
78
/// Pane body
79
pub fn pane_body() -> impl Scene {
80
bsn! {
81
Node {
82
display: Display::Flex,
83
flex_direction: FlexDirection::Column,
84
row_gap: px(4),
85
padding: px(6),
86
border_radius: {RoundedCorners::Bottom.to_border_radius(4.0)}
87
}
88
ThemeBackgroundColor(tokens::PANE_BODY_BG)
89
}
90
}
91
92