default color for making shapes
This commit is contained in:
parent
a7eb757a8f
commit
0ddb8bdba4
5 changed files with 18 additions and 4 deletions
|
@ -12,7 +12,7 @@ When an item is selected in the items tree window(will be written in gold), clic
|
|||
|
||||
## TODO
|
||||
|
||||
- [ ] Pick default color for shapes
|
||||
- [x] Pick default color for shapes
|
||||
- [ ] Undo/Redo history
|
||||
- [ ] Select item by clicking/double clicking on the relevant shape/image
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use bevy_prototype_lyon::prelude::*;
|
|||
pub fn create_sys(
|
||||
mut coms: Commands,
|
||||
p_size: Res<PointSize>,
|
||||
default_color: Res<DefaultColor>,
|
||||
state: Res<UiState>,
|
||||
mouse: Res<Input<MouseButton>>,
|
||||
wnds: Res<Windows>,
|
||||
|
@ -76,7 +77,7 @@ pub fn create_sys(
|
|||
else if mouse.just_released(MouseButton::Left) {
|
||||
// We can now spawn a shape in the current mouse position...
|
||||
// Spawn the first point
|
||||
*shape = Some(create_new_shape(&mut coms, mouse_pos, state.create_shape, p_size.0));
|
||||
*shape = Some(create_new_shape(&mut coms, mouse_pos, state.create_shape, p_size.0, **default_color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,10 +276,10 @@ fn update_main_shape_creation(
|
|||
}
|
||||
}
|
||||
|
||||
fn create_new_shape(coms: &mut Commands, pos: Vec2, create_shape: CreateShape, p_size: f32) -> ShapeData {
|
||||
fn create_new_shape(coms: &mut Commands, pos: Vec2, create_shape: CreateShape, p_size: f32, color: Color) -> ShapeData {
|
||||
// Shape draw mode...
|
||||
let draw_mode = DrawMode::Outlined {
|
||||
fill_mode: FillMode::color(Color::rgba(0.0, 0.5, 0.5, 0.4)),
|
||||
fill_mode: FillMode::color(color),
|
||||
outline_mode: StrokeMode::new(Color::rgba(0.0, 0.5, 0.5, 0.6), 3.0),
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ pub use modify::modify_sys;
|
|||
pub use create::create_sys;
|
||||
pub use helpers::*;
|
||||
|
||||
#[derive(Debug, Clone, Deref, DerefMut)]
|
||||
pub struct DefaultColor(pub Color);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SnapGrid {
|
||||
pub width: f32,
|
||||
|
|
|
@ -28,6 +28,7 @@ fn main() {
|
|||
.insert_resource(SnapGrid::default())
|
||||
.insert_resource(ui::SelectedItem::default())
|
||||
.insert_resource(ShouldImportExport::default())
|
||||
.insert_resource(DefaultColor(Color::rgba(0.0, 0.5, 0.5, 0.4)))
|
||||
;
|
||||
|
||||
app
|
||||
|
|
|
@ -12,6 +12,7 @@ pub fn action_bar_sys(
|
|||
assets: Res<AssetServer>,
|
||||
mut egui_ctx: ResMut<EguiContext>,
|
||||
mut state: ResMut<UiState>,
|
||||
mut default_color: ResMut<DefaultColor>,
|
||||
colors: Res<ButtonsColors>,
|
||||
) {
|
||||
egui::Window::new("buttons_float")
|
||||
|
@ -76,6 +77,14 @@ pub fn action_bar_sys(
|
|||
// state.create_shape = CreateShape::Capsule;
|
||||
// }
|
||||
});
|
||||
ui.horizontal(|hui| {
|
||||
hui.label("Color: ");
|
||||
let c = **default_color;
|
||||
let mut color = [c.r(), c.g(), c.b(), c.a()];
|
||||
if hui.color_edit_button_rgba_unmultiplied(&mut color).changed() {
|
||||
**default_color = Color::from(color);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue