From 9ca2b0079f1e8b08bc4eeddb8f9c56b121dafdd3 Mon Sep 17 00:00:00 2001 From: StarToaster <startoaster23@gmail.com> Date: Thu, 18 Aug 2022 14:07:50 -0400 Subject: [PATCH] Fix formatting issues. --- bevy_kayak_ui/src/render/mod.rs | 10 +++++--- .../src/render/texture_atlas/extract.rs | 24 +++++++++---------- kayak_core/src/render_primitive.rs | 6 ++++- kayak_core/src/styles/mod.rs | 2 +- .../src/bevy/renderer/font_texture_cache.rs | 5 +--- src/widgets/mod.rs | 4 ++-- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/bevy_kayak_ui/src/render/mod.rs b/bevy_kayak_ui/src/render/mod.rs index efdfcd5..f25188a 100644 --- a/bevy_kayak_ui/src/render/mod.rs +++ b/bevy_kayak_ui/src/render/mod.rs @@ -16,8 +16,8 @@ use kayak_font::KayakFont; pub mod font; pub mod image; mod nine_patch; -mod texture_atlas; mod quad; +mod texture_atlas; pub struct BevyKayakUIExtractPlugin; @@ -81,8 +81,12 @@ pub fn extract( extracted_quads.extend(nine_patch_quads); } RenderPrimitive::TextureAtlas { .. } => { - let texture_atlas_quads = - texture_atlas::extract_texture_atlas(&render_primitive, &image_manager, &images, dpi); + let texture_atlas_quads = texture_atlas::extract_texture_atlas( + &render_primitive, + &image_manager, + &images, + dpi, + ); extracted_quads.extend(texture_atlas_quads); } RenderPrimitive::Clip { layout } => { diff --git a/bevy_kayak_ui/src/render/texture_atlas/extract.rs b/bevy_kayak_ui/src/render/texture_atlas/extract.rs index efe552e..4aebae9 100644 --- a/bevy_kayak_ui/src/render/texture_atlas/extract.rs +++ b/bevy_kayak_ui/src/render/texture_atlas/extract.rs @@ -21,8 +21,8 @@ pub fn extract_texture_atlas( let (size, position, layout, handle) = match render_primitive { RenderPrimitive::TextureAtlas { - size, - position, + size, + position, layout, handle, } => (size, position, layout, handle), @@ -57,21 +57,21 @@ pub fn extract_texture_atlas( }, uv_min: Some(Vec2::new( position.0 / image_size.x, - 1.0 - ((position.1 + size.1) / image_size.y) + 1.0 - ((position.1 + size.1) / image_size.y), )), uv_max: Some(Vec2::new( (position.0 + size.0) / image_size.x, 1.0 - (position.1 / image_size.y), )), - color: Color::WHITE, - vertex_index: 0, - char_id: 0, - z_index: layout.z_index, - font_handle: None, - quad_type: UIQuadType::Image, - type_index: 0, - border_radius: Corner::default(), - image: image_handle, + color: Color::WHITE, + vertex_index: 0, + char_id: 0, + z_index: layout.z_index, + font_handle: None, + quad_type: UIQuadType::Image, + type_index: 0, + border_radius: Corner::default(), + image: image_handle, }, }; extracted_quads.push(quad); diff --git a/kayak_core/src/render_primitive.rs b/kayak_core/src/render_primitive.rs index 11a589c..51e7431 100644 --- a/kayak_core/src/render_primitive.rs +++ b/kayak_core/src/render_primitive.rs @@ -105,7 +105,11 @@ impl From<&Style> for RenderPrimitive { layout: Rect::default(), handle, }, - RenderCommand::TextureAtlas { handle, size, position, } => Self::TextureAtlas { + RenderCommand::TextureAtlas { + handle, + size, + position, + } => Self::TextureAtlas { handle, layout: Rect::default(), size, diff --git a/kayak_core/src/styles/mod.rs b/kayak_core/src/styles/mod.rs index 84d9288..1aecd64 100644 --- a/kayak_core/src/styles/mod.rs +++ b/kayak_core/src/styles/mod.rs @@ -399,7 +399,7 @@ impl Style { impl Add for Style { type Output = Style; - /// Defines the `+` operator for [`Style`]. This is a convenience wrapper of the `self.with_style()` method and useful for concatenating many small `Style` variables. + /// Defines the `+` operator for [`Style`]. This is a convenience wrapper of the `self.with_style()` method and useful for concatenating many small `Style` variables. /// Similar to `with_style()` In a `StyleA + StyleB` operation, values from `StyleB` are applied to any field of StyleA that are marked as [`StyleProp::Unset`]. /// /// Note: since the changes are applied only to unset fields, addition is *not* commutative. This means StyleA + StyleB != StyleB + StyleA for most cases. diff --git a/kayak_font/src/bevy/renderer/font_texture_cache.rs b/kayak_font/src/bevy/renderer/font_texture_cache.rs index 3d105f5..8f4acdc 100644 --- a/kayak_font/src/bevy/renderer/font_texture_cache.rs +++ b/kayak_font/src/bevy/renderer/font_texture_cache.rs @@ -195,10 +195,7 @@ impl FontTextureCache { texture, sampler, texture_view, - size: Vec2 { - x: 1.0, - y: 1.0, - }, + size: Vec2 { x: 1.0, y: 1.0 }, texture_format: TextureFormat::Rgba8Unorm, }; diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs index e4915a5..800db81 100644 --- a/src/widgets/mod.rs +++ b/src/widgets/mod.rs @@ -8,12 +8,12 @@ mod if_element; mod image; mod inspector; mod nine_patch; -mod texture_atlas; mod on_change; mod scroll; mod spin_box; mod text; mod text_box; +mod texture_atlas; mod tooltip; mod window; @@ -27,11 +27,11 @@ pub use if_element::*; pub use image::*; pub use inspector::*; pub use nine_patch::*; -pub use texture_atlas::*; pub use on_change::*; pub use scroll::*; pub use spin_box::*; pub use text::*; pub use text_box::*; +pub use texture_atlas::*; pub use tooltip::*; pub use window::*; -- GitLab