Font buttons use their font for preview

main
Elijah Voigt 2 years ago
parent cc05c7c434
commit fa7b52e8ce

@ -242,7 +242,10 @@ fn initialize_ui(mut commands: Commands) {
content_containers.iter().for_each(|(name, target)| { content_containers.iter().for_each(|(name, target)| {
parent.spawn(( parent.spawn((
b.clone(), b.clone(),
ui::Title { text: name.clone() }, ui::Title {
text: name.clone(),
..default()
},
ui::Collapse { target: *target }, ui::Collapse { target: *target },
)); ));
}); });
@ -268,6 +271,7 @@ fn initialize_ui(mut commands: Commands) {
}, },
ui::Title { ui::Title {
text: "Assets".into(), text: "Assets".into(),
..default()
}, },
ui::Minimize { target: container }, ui::Minimize { target: container },
ui::Sorting(0), ui::Sorting(0),
@ -380,6 +384,7 @@ mod audio {
handle: handle.clone(), handle: handle.clone(),
}, },
get_asset_name(&server, handle.clone()), get_asset_name(&server, handle.clone()),
None,
); );
commands.entity(id).insert(AudioSourceBundle { commands.entity(id).insert(AudioSourceBundle {
source: handle.clone(), source: handle.clone(),
@ -416,6 +421,7 @@ mod audio {
handle: handle.clone(), handle: handle.clone(),
}, },
get_asset_name(&server, handle.clone()), get_asset_name(&server, handle.clone()),
None,
); );
commands.entity(id).insert(AudioSourceBundle { commands.entity(id).insert(AudioSourceBundle {
source: handle.clone(), source: handle.clone(),
@ -473,6 +479,7 @@ mod assets {
commands: &mut Commands, commands: &mut Commands,
target: ui::TargetAsset<A>, target: ui::TargetAsset<A>,
name: String, name: String,
font: Option<Handle<Font>>,
) -> Entity { ) -> Entity {
commands commands
.spawn(( .spawn((
@ -487,7 +494,10 @@ mod assets {
border_color: Color::BLACK.into(), border_color: Color::BLACK.into(),
..default() ..default()
}, },
ui::Title { text: name }, ui::Title {
text: name,
font: font.clone(),
},
)) ))
.set_parent(root.single()) .set_parent(root.single())
.id() .id()
@ -512,7 +522,10 @@ mod assets {
border_color: Color::BLACK.into(), border_color: Color::BLACK.into(),
..default() ..default()
}, },
ui::Title { text: name }, ui::Title {
text: name,
..default()
},
)) ))
.set_parent(root.single()) .set_parent(root.single())
.id() .id()
@ -585,6 +598,7 @@ mod gltf {
handle: handle.clone(), handle: handle.clone(),
}, },
get_asset_name(&server, handle.clone()), get_asset_name(&server, handle.clone()),
None,
); );
} }
AssetEvent::Removed { handle } => { AssetEvent::Removed { handle } => {
@ -613,6 +627,7 @@ mod gltf {
handle: handle.clone(), handle: handle.clone(),
}, },
get_asset_name(&server, handle.clone()), get_asset_name(&server, handle.clone()),
None,
); );
} }
}); });
@ -762,6 +777,7 @@ mod scenes {
handle: handle.clone(), handle: handle.clone(),
}, },
name.clone(), name.clone(),
None,
); );
} }
CustomAssetEvent::Remove { handle } => { CustomAssetEvent::Remove { handle } => {
@ -829,6 +845,7 @@ mod animations {
handle: handle.clone(), handle: handle.clone(),
}, },
name.clone(), name.clone(),
None,
); );
} }
CustomAssetEvent::Remove { handle } => { CustomAssetEvent::Remove { handle } => {
@ -904,6 +921,7 @@ mod fonts {
handle: handle.clone(), handle: handle.clone(),
}, },
get_asset_name(&server, handle.clone()), get_asset_name(&server, handle.clone()),
Some(handle.clone()),
); );
} }
AssetEvent::Removed { handle } => { AssetEvent::Removed { handle } => {
@ -932,6 +950,7 @@ mod fonts {
handle: handle.clone(), handle: handle.clone(),
}, },
get_asset_name(&server, handle.clone()), get_asset_name(&server, handle.clone()),
Some(handle.clone()),
); );
} }
}); });

@ -55,9 +55,10 @@ pub use title::*;
mod title { mod title {
use super::*; use super::*;
#[derive(Debug, Component)] #[derive(Debug, Component, Default)]
pub struct Title { pub struct Title {
pub text: String, pub text: String,
pub font: Option<Handle<Font>>,
} }
#[derive(Debug, Component)] #[derive(Debug, Component)]
@ -93,16 +94,24 @@ mod title {
) { ) {
events.for_each(|(entity, title, note, minimize, close)| { events.for_each(|(entity, title, note, minimize, close)| {
commands.entity(entity).with_children(|parent| { commands.entity(entity).with_children(|parent| {
let style = match &title.font {
Some(handle) => TextStyle {
color: Color::BLACK,
font: handle.clone(),
..default()
},
None => TextStyle {
color: Color::BLACK,
..default()
},
};
parent.spawn(( parent.spawn((
TextBundle { TextBundle {
text: Text { text: Text {
sections: vec![ sections: vec![
TextSection { TextSection {
value: title.text.clone(), value: title.text.clone(),
style: TextStyle { style,
color: Color::BLACK,
..default()
},
}, },
TextSection { TextSection {
value: note value: note
@ -591,6 +600,7 @@ pub mod alert {
}, },
Title { Title {
text: "Alert".into(), text: "Alert".into(),
..default()
}, },
Close { Close {
target: parent.parent_entity(), target: parent.parent_entity(),

Loading…
Cancel
Save