rotate + shape_tree start
This commit is contained in:
parent
f52c7b9057
commit
7a3d51a626
6 changed files with 175 additions and 75 deletions
75
src/main.rs
75
src/main.rs
|
@ -1,5 +1,4 @@
|
|||
use bevy::ecs::schedule::ShouldRun;
|
||||
use bevy::math::Vec3Swizzles;
|
||||
use bevy::{prelude::*, window::PresentMode, winit::WinitSettings};
|
||||
use bevy_egui::{egui, EguiContext, EguiPlugin};
|
||||
use bevy_prototype_lyon::prelude::*;
|
||||
|
@ -38,7 +37,11 @@ fn main() {
|
|||
.add_system(modify_sys.with_run_criteria(|state: Res<UiState>, mut ec: ResMut<EguiContext>|
|
||||
if !ec.ctx_mut().is_pointer_over_area() && state.current_action == Action::Modify { ShouldRun::Yes } else { ShouldRun::No }
|
||||
))
|
||||
.add_system(rotate_sys.with_run_criteria(|state: Res<UiState>, mut ec: ResMut<EguiContext>|
|
||||
if !ec.ctx_mut().is_pointer_over_area() && state.current_action == Action::Rotate { ShouldRun::Yes } else { ShouldRun::No }
|
||||
))
|
||||
.add_system(action_bar_sys)
|
||||
.add_system(shape_tree_sys)
|
||||
;
|
||||
|
||||
app.run();
|
||||
|
@ -56,72 +59,4 @@ fn configure_visuals(mut egui_ctx: ResMut<EguiContext>) {
|
|||
window_rounding: 0.0.into(),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
fn action_bar_sys(
|
||||
mut egui_ctx: ResMut<EguiContext>,
|
||||
mut state: ResMut<UiState>,
|
||||
colors: Res<ButtonsColors>,
|
||||
) {
|
||||
egui::Window::new("buttons_float")
|
||||
.default_pos((50.0, 20.0))
|
||||
.title_bar(false)
|
||||
.resizable(false)
|
||||
.show(egui_ctx.ctx_mut(), |ui| {
|
||||
ui.horizontal(|hui| {
|
||||
let m = hui.button(egui::RichText::new("M").color(state.current_action_color(&colors, Action::Modify)))
|
||||
.on_hover_text("Modify");
|
||||
if m.clicked() {
|
||||
state.current_action = Action::Modify;
|
||||
}
|
||||
let r = hui.button(egui::RichText::new("R").color(state.current_action_color(&colors, Action::Rotate)))
|
||||
.on_hover_text("Rotate");
|
||||
if r.clicked() {
|
||||
state.current_action = Action::Rotate;
|
||||
}
|
||||
let c = hui.button(egui::RichText::new("C").color(state.current_action_color(&colors, Action::Create)))
|
||||
.on_hover_text("Create");
|
||||
if c.clicked() {
|
||||
state.current_action = Action::Create;
|
||||
}
|
||||
let d = hui.button(egui::RichText::new("D").color(state.current_action_color(&colors, Action::Delete)))
|
||||
.on_hover_text("Delete");
|
||||
if d.clicked() {
|
||||
state.current_action = Action::Delete;
|
||||
}
|
||||
hui.label(" | ");
|
||||
|
||||
if hui.button(" I ").on_hover_text("Import Image").clicked() {
|
||||
println!("Importing Images is still not supported!");
|
||||
}
|
||||
|
||||
hui.label(": :");
|
||||
});
|
||||
|
||||
if state.current_action == Action::Create {
|
||||
ui.horizontal(|hui| {
|
||||
let tri = hui.button(egui::RichText::new("Tri").color(state.create_shape_color(&colors, CreateShape::Triangle)))
|
||||
.on_hover_text("Triangle - from 3 edges");
|
||||
if tri.clicked() {
|
||||
state.create_shape = CreateShape::Triangle;
|
||||
}
|
||||
let squ = hui.button(egui::RichText::new("Squ").color(state.create_shape_color(&colors, CreateShape::Square)))
|
||||
.on_hover_text("Square - from 2 opposing edges");
|
||||
if squ.clicked() {
|
||||
state.create_shape = CreateShape::Square;
|
||||
}
|
||||
let cir = hui.button(egui::RichText::new("Cir").color(state.create_shape_color(&colors, CreateShape::Circle)))
|
||||
.on_hover_text("Circle - center point and radius");
|
||||
if cir.clicked() {
|
||||
state.create_shape = CreateShape::Circle;
|
||||
}
|
||||
// let cap = hui.button(egui::RichText::new("Cap").color(state.create_shape_color(&colors, CreateShape::Capsule)))
|
||||
// .on_hover_text("Capsule - from 2 center points and a radius");
|
||||
// if cap.clicked() {
|
||||
// state.create_shape = CreateShape::Capsule;
|
||||
// }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue