diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a66498d1e52bea0919a9d5e4b34ff1838d3db841..c79f84f007f0b93abecdcb25de5cfa94c8278499 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,15 +11,28 @@ env: jobs: build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }} - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + if: runner.os == 'linux' - name: Build - run: cargo build --verbose --workspace + run: cargo build --verbose --workspace --features "bevy/x11" # - name: Run tests # run: cargo test --verbose --workspace - name: Run fmt check diff --git a/bevy_kayak_ui/src/render/mod.rs b/bevy_kayak_ui/src/render/mod.rs index efdfcd5ce898e925e8b38f42d966806f79240d9b..f25188a6957f5f195b3cb5433fc9c923e6516dd2 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 efe552e9d5dc4848df4f4de3b0e5ef4ba71c792d..4aebae932a11500664e06d6e5351ccfaef65d22e 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 11a589ce77a2018e485c9c46bbef2004398a5e83..51e743171873a2d6aa6518c0b6370eb9ba5e7bdb 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 84d928830837d1806aa7e07436873a0b959ba775..1aecd64678fae7e059566ab41579123b8bc32310 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/examples/renderer/extract.rs b/kayak_font/examples/renderer/extract.rs index 0c90bdb96b4592ee1ca552c9ee9de046ad0446df..923923c33fcf0c3c859da2b05155cecda4b6f471 100644 --- a/kayak_font/examples/renderer/extract.rs +++ b/kayak_font/examples/renderer/extract.rs @@ -1,7 +1,8 @@ use bevy::{ math::Vec2, prelude::{Assets, Commands, Handle, Query, Res}, - sprite::Rect, render::Extract, + render::Extract, + sprite::Rect, }; use kayak_font::{KayakFont, TextProperties}; diff --git a/kayak_font/src/bevy/renderer/font_texture_cache.rs b/kayak_font/src/bevy/renderer/font_texture_cache.rs index 3d105f5731a424c271551ebb1ca82299553ab69c..8f4acdcc42a4bf31ec522b1fde75eec60a226a85 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 e4915a51a1ae10c1ba8ecbae27892dd1695983df..800db815076163a57f0559f3c5fdd9891eabf5da 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::*;