From 337b526ef3ea0a6fb806a823c6d408ec0f134104 Mon Sep 17 00:00:00 2001 From: Hugo Lindsay <8341280+ashneverdawn@users.noreply.github.com> Date: Sat, 29 Aug 2020 19:49:39 -0400 Subject: [PATCH] UI component bundles derive clone (#390) make Draw, TextStyle, and the rest of the ui components derive clone --- crates/bevy_render/src/draw.rs | 2 +- crates/bevy_render/src/pipeline/render_pipelines.rs | 2 +- crates/bevy_text/src/draw.rs | 1 + crates/bevy_ui/src/entity.rs | 8 ++++---- crates/bevy_ui/src/widget/button.rs | 1 + crates/bevy_ui/src/widget/image.rs | 1 + crates/bevy_ui/src/widget/text.rs | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/bevy_render/src/draw.rs b/crates/bevy_render/src/draw.rs index 4c27e055a95bc..42bfd7d9615b4 100644 --- a/crates/bevy_render/src/draw.rs +++ b/crates/bevy_render/src/draw.rs @@ -50,7 +50,7 @@ pub enum RenderCommand { } /// A component that indicates how to draw an entity. -#[derive(Properties)] +#[derive(Properties, Clone)] pub struct Draw { pub is_visible: bool, pub is_transparent: bool, diff --git a/crates/bevy_render/src/pipeline/render_pipelines.rs b/crates/bevy_render/src/pipeline/render_pipelines.rs index b3649cd9b693b..24b53985ab4c4 100644 --- a/crates/bevy_render/src/pipeline/render_pipelines.rs +++ b/crates/bevy_render/src/pipeline/render_pipelines.rs @@ -34,7 +34,7 @@ impl RenderPipeline { } } -#[derive(Properties)] +#[derive(Properties, Clone)] pub struct RenderPipelines { pub pipelines: Vec, #[property(ignore)] diff --git a/crates/bevy_text/src/draw.rs b/crates/bevy_text/src/draw.rs index b47c6e4dd543a..bb73d285e3111 100644 --- a/crates/bevy_text/src/draw.rs +++ b/crates/bevy_text/src/draw.rs @@ -15,6 +15,7 @@ use bevy_render::{ }; use bevy_sprite::{TextureAtlas, TextureAtlasSprite}; +#[derive(Clone)] pub struct TextStyle { pub font_size: f32, pub color: Color, diff --git a/crates/bevy_ui/src/entity.rs b/crates/bevy_ui/src/entity.rs index 6c857f339d241..c92177292391c 100644 --- a/crates/bevy_ui/src/entity.rs +++ b/crates/bevy_ui/src/entity.rs @@ -18,7 +18,7 @@ use bevy_transform::{ prelude::{Rotation, Scale, Transform, Translation}, }; -#[derive(Bundle)] +#[derive(Bundle, Clone)] pub struct NodeComponents { pub node: Node, pub style: Style, @@ -62,7 +62,7 @@ impl Default for NodeComponents { } } -#[derive(Bundle)] +#[derive(Bundle, Clone)] pub struct ImageComponents { pub node: Node, pub style: Style, @@ -110,7 +110,7 @@ impl Default for ImageComponents { } } -#[derive(Bundle)] +#[derive(Bundle, Clone)] pub struct TextComponents { pub node: Node, pub style: Style, @@ -140,7 +140,7 @@ impl Default for TextComponents { } } -#[derive(Bundle)] +#[derive(Bundle, Clone)] pub struct ButtonComponents { pub node: Node, pub button: Button, diff --git a/crates/bevy_ui/src/widget/button.rs b/crates/bevy_ui/src/widget/button.rs index fef7c51320b03..8201482dc3bb4 100644 --- a/crates/bevy_ui/src/widget/button.rs +++ b/crates/bevy_ui/src/widget/button.rs @@ -1 +1,2 @@ +#[derive(Clone)] pub struct Button; diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index d4697603898c4..51e800657d748 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -5,6 +5,7 @@ use bevy_math::Size; use bevy_render::texture::Texture; use bevy_sprite::ColorMaterial; +#[derive(Clone)] pub enum Image { KeepAspect, } diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index f631e82d1ec39..5ad87c66224d3 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -12,7 +12,7 @@ use bevy_sprite::TextureAtlas; use bevy_text::{DrawableText, Font, FontAtlasSet, TextStyle}; use bevy_transform::prelude::Transform; -#[derive(Default)] +#[derive(Default, Clone)] pub struct Text { pub value: String, pub font: Handle,