Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_feathers/src/display/label.rs
30636 views
1
//! BSN scene function for displaying a plain text string in the correct font.
2
use bevy_app::PropagateOver;
3
use bevy_scene::{bsn, Scene};
4
use bevy_text::{FontSourceTemplate, FontWeight, TextFont};
5
use bevy_ui::widget::Text;
6
7
use crate::{
8
constants::{fonts, size},
9
theme::ThemeTextColor,
10
tokens,
11
};
12
13
/// A text label.
14
pub fn label(text: impl Into<String>) -> impl Scene {
15
bsn! {
16
Text(text)
17
TextFont {
18
font: FontSourceTemplate::Handle(fonts::REGULAR),
19
font_size: size::MEDIUM_FONT,
20
weight: FontWeight::NORMAL,
21
}
22
PropagateOver<TextFont>
23
ThemeTextColor(tokens::TEXT_MAIN)
24
}
25
}
26
27
/// A text label with a dimmed color.
28
pub fn label_dim(text: impl Into<String>) -> impl Scene {
29
bsn! {
30
Text(text)
31
TextFont {
32
font: FontSourceTemplate::Handle(fonts::REGULAR),
33
font_size: size::MEDIUM_FONT,
34
weight: FontWeight::NORMAL,
35
}
36
PropagateOver<TextFont>
37
ThemeTextColor(tokens::TEXT_DIM)
38
}
39
}
40
41
/// A small text label, used for field captions.
42
pub fn label_small(text: impl Into<String>) -> impl Scene {
43
bsn! {
44
Text(text)
45
TextFont {
46
font: FontSourceTemplate::Handle(fonts::REGULAR),
47
font_size: size::EXTRA_SMALL_FONT,
48
weight: FontWeight::NORMAL,
49
}
50
PropagateOver<TextFont>
51
ThemeTextColor(tokens::TEXT_MAIN)
52
}
53
}
54
55