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

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

Loading…
Cancel
Save