shape_maker/src/lib.rs

84 lines
No EOL
1.8 KiB
Rust

#![feature(let_chains)]
use bevy::prelude::*;
use bevy_egui::egui;
mod create;
mod helpers;
mod modify;
mod rotate;
mod ui;
pub use ui::{action_bar_sys, shape_tree_sys};
pub use modify::modify_sys;
pub use create::create_sys;
pub use rotate::rotate_sys;
pub use helpers::*;
#[derive(Clone, Debug)]
pub struct PointSize(pub f32);
#[derive(Component, Debug)]
pub struct ShapeData {
pub shape: CreateShape,
pub main_shape: Entity,
pub edges: Vec<Entity>,
pub center: Option<Entity>,
}
#[derive(Component)]
pub struct MainCamera;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum CreateShape {
Triangle, Square, Circle, Capsule
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Action {
Create, Modify, Delete, Rotate
}
pub struct UiState {
pub current_action: Action,
pub create_shape: CreateShape,
}
impl Default for UiState {
fn default() -> Self {
Self {
current_action: Action::Modify,
create_shape: CreateShape::Square,
}
}
}
impl UiState {
pub fn create_shape_color(&self, colors: &ButtonsColors, shape: CreateShape) -> egui::Rgba {
if self.create_shape == shape {
colors.clicked
}
else {
colors.regular
}
}
pub fn current_action_color(&self, colors: &ButtonsColors, action: Action) -> egui::Rgba {
if self.current_action == action {
colors.clicked
}
else {
colors.regular
}
}
}
#[derive(Debug)]
pub struct ButtonsColors {
pub regular: egui::Rgba,
pub clicked: egui::Rgba,
}
impl Default for ButtonsColors {
fn default() -> Self {
Self {
regular: egui::Rgba::from_rgb(0.3, 0.3, 0.3),
clicked: egui::Rgba::from_rgb(1.0, 1.0, 1.0)
}
}
}