settings up repo
This commit is contained in:
commit
47a7e3331d
5 changed files with 3766 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
3653
Cargo.lock
generated
Normal file
3653
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "shape_maker"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = "0.7.0"
|
||||||
|
bevy_egui = { version = "0.14.0", features = ["manage_clipboard"] }
|
||||||
|
bevy_prototype_lyon = "0.5.0"
|
28
src/lib.rs
Normal file
28
src/lib.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
use bevy_egui::egui;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Action {
|
||||||
|
Create, Modify, Delete
|
||||||
|
}
|
||||||
|
pub struct UiState {
|
||||||
|
pub current_action: Action,
|
||||||
|
|
||||||
|
}
|
||||||
|
impl Default for UiState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self { current_action: Action::Modify }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
73
src/main.rs
Normal file
73
src/main.rs
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
use bevy::{prelude::*, window::PresentMode, winit::WinitSettings};
|
||||||
|
use bevy_egui::{egui, EguiContext, EguiPlugin};
|
||||||
|
use bevy_prototype_lyon::prelude::*;
|
||||||
|
|
||||||
|
use shape_maker::*;
|
||||||
|
|
||||||
|
|
||||||
|
/// This example demonstrates the following functionality and use-cases of bevy_egui:
|
||||||
|
/// - rendering loaded assets;
|
||||||
|
/// - toggling hidpi scaling (by pressing '/' button);
|
||||||
|
/// - configuring egui contexts during the startup.
|
||||||
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.insert_resource(ClearColor(Color::rgb(0.1, 0.1, 0.12)))
|
||||||
|
.insert_resource(Msaa { samples: 4 })
|
||||||
|
// Optimal power saving and present mode settings for desktop apps.
|
||||||
|
.insert_resource(WinitSettings::desktop_app())
|
||||||
|
.insert_resource(WindowDescriptor {
|
||||||
|
present_mode: PresentMode::Mailbox,
|
||||||
|
title: "Shape Maker".to_string(),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.insert_resource(ButtonsColors::default())
|
||||||
|
.insert_resource(UiState::default())
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugin(EguiPlugin)
|
||||||
|
.add_plugin(ShapePlugin)
|
||||||
|
.add_startup_system(configure_visuals)
|
||||||
|
.add_system(action_bar_sys)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn configure_visuals(mut egui_ctx: ResMut<EguiContext>) {
|
||||||
|
egui_ctx.ctx_mut().set_visuals(egui::Visuals {
|
||||||
|
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 modify_color = if let Action::Modify = state.current_action { colors.clicked } else { colors.regular };
|
||||||
|
let create_color = if let Action::Create = state.current_action { colors.clicked } else { colors.regular };
|
||||||
|
let delete_color = if let Action::Delete = state.current_action { colors.clicked } else { colors.regular };
|
||||||
|
|
||||||
|
if hui.button(egui::RichText::new("M").color(modify_color)).clicked() {
|
||||||
|
state.current_action = Action::Modify;
|
||||||
|
}
|
||||||
|
if hui.button(egui::RichText::new("C").color(create_color)).clicked() {
|
||||||
|
state.current_action = Action::Create;
|
||||||
|
}
|
||||||
|
if hui.button(egui::RichText::new("D").color(delete_color)).clicked() {
|
||||||
|
state.current_action = Action::Delete;
|
||||||
|
}
|
||||||
|
hui.label(" | ");
|
||||||
|
|
||||||
|
if hui.button(" I ").clicked() {
|
||||||
|
println!("Image loading is still not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
hui.label(": :");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue