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
49
50
51
52
53
54
55
56
57
58
59
60
//! The status bar: the components of [`crate::status_bar`]'s items. What holds them to the bar's
//! width is [`crate::fit_bars`]; their look is [`crate::apply_skin`]'s.
use bevy::prelude::*;
/// A [`crate::status_bar`]'s root. Query for it to find the bar.
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Eq, Reflect)]
#[reflect(Component, Default, Debug, PartialEq, Clone)]
pub struct StatusBar;
/// A [`crate::status_item`]. It **requires** [`StatusKind`], so a `StatusKind` of your own in the
/// same tuple is the one the item has: `(status_item("2 problems"), StatusKind::Warning)`.
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Eq, Reflect)]
#[reflect(Component, Default, Debug, PartialEq, Clone)]
#[require(StatusKind)]
pub struct StatusItem;
/// One side of a [`crate::status_bar`]: the left group (the workspace's state) grows to fill the
/// bar; the right group (the context's) is pushed to its end.
#[derive(Component, Clone, Copy, Debug, PartialEq, Eq)]
pub struct StatusGroup {
pub(crate) left: bool,
}
/// How much a [`crate::status_item`] means, shown as a mark at its start: [`StatusKind::Info`]
/// draws none; a warning's is [`crate::GooeySkin::accent`] and an error's
/// [`crate::GooeySkin::danger`]. The words never change colour (4.5:1 against the bar in every
/// kind, and the mark is a shape, not only a hue). Change it to change the mark in the same frame.
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Eq, Reflect)]
#[reflect(Component, Default, Debug, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum StatusKind {
/// Plain state.
#[default]
Info,
/// Something to look at.
Warning,
/// Something is wrong.
Error,
}
/// Which items of a narrow [`crate::status_bar`] stay: the **lowest** priority hides first, and an
/// item of the right group before any of the left's. Higher is kept longer; the default is 128.
///
/// ```
/// # use bevy::prelude::*;
/// # use bevy_gooey::*;
/// # fn ui(mut commands: Commands) {
/// commands.spawn((status_item("main"), StatusPriority(200)));
/// # }
/// ```
#[derive(Component, Clone, Copy, Debug, PartialEq, Eq, Reflect)]
#[reflect(Component, Default, Debug, PartialEq, Clone)]
pub struct StatusPriority(pub u8);
impl Default for StatusPriority {
fn default() -> Self {
Self(128)
}
}