can now change colors!
This commit is contained in:
parent
a6452fcfbf
commit
91e31fed7e
1 changed files with 28 additions and 5 deletions
33
src/ui.rs
33
src/ui.rs
|
@ -116,8 +116,9 @@ pub fn items_tree_sys(
|
|||
mut selected: ResMut<SelectedItem>,
|
||||
mut egui_ctx: ResMut<EguiContext>,
|
||||
shapes:Query<(Entity, &ShapeData)>,
|
||||
mut visible: Query<&mut Visibility, Or<(With<Path>, With<Sprite>)>>,
|
||||
images: Query<(Entity, &ImageName), With<Sprite>>,
|
||||
mut draw_modes: Query<&mut DrawMode, With<ShapeData>>,
|
||||
mut visible: Query<&mut Visibility, Or<(With<Path>, With<Sprite>)>>,
|
||||
) {
|
||||
egui::Window::new("Items")
|
||||
.default_pos((10.0,100.0))
|
||||
|
@ -125,11 +126,12 @@ pub fn items_tree_sys(
|
|||
.resizable(false)
|
||||
.show(egui_ctx.ctx_mut(), |ui| {
|
||||
for (e, sd) in shapes.iter() {
|
||||
let entity_selected = if let Some(se) = **selected && se == e { true } else { false };
|
||||
ui.horizontal(|hui| {
|
||||
let color = if let Some(se) = **selected && se == e { egui::Color32::GOLD } else { egui::Color32::WHITE };
|
||||
let color = if entity_selected { egui::Color32::GOLD } else { egui::Color32::WHITE };
|
||||
let label = egui::Label::new(egui::RichText::new(&sd.name).color(color)).sense(egui::Sense::click());
|
||||
if hui.add(label).clicked() {
|
||||
if color == egui::Color32::GOLD {
|
||||
if entity_selected {
|
||||
**selected = None;
|
||||
}
|
||||
else {
|
||||
|
@ -144,13 +146,21 @@ pub fn items_tree_sys(
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
if let Ok(mut dm) = draw_modes.get_mut(e) {
|
||||
if let DrawMode::Outlined { fill_mode: _ , outline_mode: o } = &mut *dm {
|
||||
o.color = if entity_selected { Color::GOLD } else { Color::rgba(0.0, 0.5, 0.5, 0.6) };
|
||||
}
|
||||
}
|
||||
}
|
||||
for (e, n) in images.iter() {
|
||||
let entity_selected = if let Some(se) = **selected && se == e { true } else { false };
|
||||
|
||||
ui.horizontal(|hui| {
|
||||
let color = if let Some(se) = **selected && se == e { egui::Color32::GOLD } else { egui::Color32::WHITE };
|
||||
let color = if entity_selected { egui::Color32::GOLD } else { egui::Color32::WHITE };
|
||||
let label = egui::Label::new(egui::RichText::new(&**n).color(color)).sense(egui::Sense::click());
|
||||
if hui.add(label).clicked() {
|
||||
if color == egui::Color32::GOLD {
|
||||
if entity_selected {
|
||||
**selected = None;
|
||||
}
|
||||
else {
|
||||
|
@ -254,6 +264,19 @@ pub fn inspector_sys(
|
|||
if let Ok(mut v) = visible.get_mut(e) {
|
||||
ui.checkbox(&mut v.is_visible, "Visible");
|
||||
}
|
||||
if let Ok(mut dm) = draw_modes.get_mut(e) {
|
||||
ui.separator();
|
||||
if let DrawMode::Outlined { fill_mode: f, outline_mode: _ } = &mut *dm {
|
||||
ui.horizontal(|hui| {
|
||||
hui.label("Color: ");
|
||||
let mut color = [f.color.r(), f.color.g(), f.color.b(), f.color.a()];
|
||||
if hui.color_edit_button_rgba_unmultiplied(&mut color).changed() {
|
||||
f.color = Color::from(color);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ui.separator();
|
||||
if ui.button("Delete").clicked() {
|
||||
|
|
Loading…
Reference in a new issue