From ccc7657e7ef7c016dcd58c47186e25d75f47f19c Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Sun, 13 Nov 2022 10:03:35 +0100 Subject: [PATCH 1/6] Bump bevy to 0.9 disable not-yet-ported dependencies --- Cargo.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d08045c..26e4df0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,20 +15,21 @@ bevy_egui = ["dep:bevy_egui"] bevy-inspector-egui = ["dep:bevy-inspector-egui"] [dependencies] -bevy = {version = "0.8", features = ["render"], default-features = false} +bevy = {version = "0.9", features = ["render"], default-features = false} bevy_egui = {version = "0.16", optional = true, default-features = false} bevy-inspector-egui = { version = "0.13", optional = true, default-features = false } [dev-dependencies] -bevy = {version = "0.8", default-features = false, features = [ +bevy = {version = "0.9", default-features = false, features = [ "render", "bevy_asset", "bevy_winit", "x11", # github actions runners don't have libxkbcommon installed, so can't use wayland ]} rand = "0.8" -bevy_egui = {version = "0.16", default-features = false, features = ["default_fonts"]} -bevy-inspector-egui = {version = "0.13", default-features = false} +# https://github.com/mvlabat/bevy_egui/pull/127 +#bevy_egui = {version = "0.16", default-features = false, features = ["default_fonts"]} +#bevy-inspector-egui = {version = "0.13", default-features = false} [[example]] name = "egui" From e3dc974a3ce9265ef3aab9f796c0c9115c4ab9ec Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Sun, 13 Nov 2022 10:08:57 +0100 Subject: [PATCH 2/6] refactor: Stop using deprecated Commands::spawn_bundle --- examples/camera_scaling_mode.rs | 4 ++-- examples/clamped_borders.rs | 38 ++++++++++++++++----------------- examples/egui.rs | 4 ++-- examples/inspector.rs | 4 ++-- examples/limits.rs | 18 +++++++--------- examples/simple.rs | 4 ++-- examples/toggle.rs | 4 ++-- readme.md | 4 ++-- 8 files changed, 38 insertions(+), 42 deletions(-) diff --git a/examples/camera_scaling_mode.rs b/examples/camera_scaling_mode.rs index 4b2d41a..e9b74d7 100644 --- a/examples/camera_scaling_mode.rs +++ b/examples/camera_scaling_mode.rs @@ -14,7 +14,7 @@ fn setup(mut commands: Commands) { let mut cam = Camera2dBundle::default(); cam.projection.scaling_mode = ScalingMode::FixedVertical(10.0); - commands.spawn_bundle(cam).insert(PanCam { + commands.spawn(cam).insert(PanCam { min_x: Some(-10.), max_x: Some(10.), min_y: Some(-10.), @@ -31,7 +31,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing + offset; let y = y as f32 * spacing + offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/examples/clamped_borders.rs b/examples/clamped_borders.rs index 8d0ad6d..5471aa0 100644 --- a/examples/clamped_borders.rs +++ b/examples/clamped_borders.rs @@ -11,25 +11,23 @@ fn main() { } fn setup(mut commands: Commands) { - commands - .spawn_bundle(Camera2dBundle::default()) - .insert(PanCam { - // prevent the camera from zooming too far out - max_scale: Some(40.), - // prevent the camera from zooming too far in - min_scale: 0.5, - // prevent the camera from panning or zooming past x -750. -750 was chosen to display both the edges of the - // sample image and some boundary space beyond it - min_x: Some(-750.), - // prevent the camera from panning or zooming past x 1750. 1750 was chosen to show an asymmetric boundary - // window with more space on the right than the left - max_x: Some(1750.), - // prevent the camera from panning or zooming past y -750. value chosen for same reason as above - min_y: Some(-750.), - // prevent the camera from panning or zooming past y 1750. value chosen for same reason as above - max_y: Some(1750.), - ..default() - }); + commands.spawn(Camera2dBundle::default()).insert(PanCam { + // prevent the camera from zooming too far out + max_scale: Some(40.), + // prevent the camera from zooming too far in + min_scale: 0.5, + // prevent the camera from panning or zooming past x -750. -750 was chosen to display both the edges of the + // sample image and some boundary space beyond it + min_x: Some(-750.), + // prevent the camera from panning or zooming past x 1750. 1750 was chosen to show an asymmetric boundary + // window with more space on the right than the left + max_x: Some(1750.), + // prevent the camera from panning or zooming past y -750. value chosen for same reason as above + min_y: Some(-750.), + // prevent the camera from panning or zooming past y 1750. value chosen for same reason as above + max_y: Some(1750.), + ..default() + }); let n = 20; let spacing = 50.; @@ -40,7 +38,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/examples/egui.rs b/examples/egui.rs index d161b63..179541c 100644 --- a/examples/egui.rs +++ b/examples/egui.rs @@ -36,7 +36,7 @@ fn egui_setup(mut egui_context: ResMut) { fn setup(mut commands: Commands) { commands - .spawn_bundle(Camera2dBundle::default()) + .spawn(Camera2dBundle::default()) .insert(PanCam::default()); let n = 20; @@ -48,7 +48,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/examples/inspector.rs b/examples/inspector.rs index dbc22f5..7c06350 100644 --- a/examples/inspector.rs +++ b/examples/inspector.rs @@ -14,7 +14,7 @@ fn main() { fn setup(mut commands: Commands) { commands - .spawn_bundle(Camera2dBundle::default()) + .spawn(Camera2dBundle::default()) .insert(PanCam::default()); let n = 20; @@ -26,7 +26,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/examples/limits.rs b/examples/limits.rs index c2810c2..2751d8a 100644 --- a/examples/limits.rs +++ b/examples/limits.rs @@ -11,15 +11,13 @@ fn main() { } fn setup(mut commands: Commands) { - commands - .spawn_bundle(Camera2dBundle::default()) - .insert(PanCam { - // Set max scale in order to prevent the camera from zooming too far out - max_scale: Some(40.), - // Set min scale in order to prevent the camera from zooming too far in - min_scale: 1., - ..default() - }); + commands.spawn(Camera2dBundle::default()).insert(PanCam { + // Set max scale in order to prevent the camera from zooming too far out + max_scale: Some(40.), + // Set min scale in order to prevent the camera from zooming too far in + min_scale: 1., + ..default() + }); let n = 20; let spacing = 50.; @@ -30,7 +28,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/examples/simple.rs b/examples/simple.rs index aed4897..8290004 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -12,7 +12,7 @@ fn main() { fn setup(mut commands: Commands) { commands - .spawn_bundle(Camera2dBundle::default()) + .spawn(Camera2dBundle::default()) .insert(PanCam::default()); let n = 20; @@ -24,7 +24,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/examples/toggle.rs b/examples/toggle.rs index 67147b1..fe8fb68 100644 --- a/examples/toggle.rs +++ b/examples/toggle.rs @@ -13,7 +13,7 @@ fn main() { fn setup(mut commands: Commands) { commands - .spawn_bundle(Camera2dBundle::default()) + .spawn(Camera2dBundle::default()) .insert(PanCam::default()); let n = 20; @@ -25,7 +25,7 @@ fn setup(mut commands: Commands) { let x = x as f32 * spacing - offset; let y = y as f32 * spacing - offset; let color = Color::hsl(240., random::() * 0.3, random::() * 0.3); - commands.spawn_bundle(SpriteBundle { + commands.spawn(SpriteBundle { sprite: Sprite { color, custom_size, diff --git a/readme.md b/readme.md index af1fcfd..0e5b831 100644 --- a/readme.md +++ b/readme.md @@ -30,7 +30,7 @@ App::new() Add the component to an orthographic camera: ```rust ignore -commands.spawn_bundle(Camera2dBundle::default()) +commands.spawn(Camera2dBundle::default()) .insert(PanCam::default()); ``` @@ -39,7 +39,7 @@ This is enough to get going with sensible defaults. Alternatively, set the fields of the `PanCam` component to customize behavior: ```rust ignore -commands.spawn_bundle(Camera2dBundle::default()) +commands.spawn(Camera2dBundle::default()) .insert(PanCam { grab_buttons: vec![MouseButton::Left, MouseButton::Middle], // which buttons should drag the camera enabled: true, // when false, controls are disabled. See toggle example. From 49ac88f6b92b25cb87ad1bda70ca9f88a237b9a9 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Sun, 13 Nov 2022 10:14:41 +0100 Subject: [PATCH 3/6] refactor: Use new (bundle, component) tuple spawning API --- examples/camera_scaling_mode.rs | 17 ++++++++------- examples/clamped_borders.rs | 37 ++++++++++++++++++--------------- examples/egui.rs | 4 +--- examples/inspector.rs | 4 +--- examples/limits.rs | 17 ++++++++------- examples/simple.rs | 4 +--- examples/toggle.rs | 4 +--- 7 files changed, 44 insertions(+), 43 deletions(-) diff --git a/examples/camera_scaling_mode.rs b/examples/camera_scaling_mode.rs index e9b74d7..d96b56b 100644 --- a/examples/camera_scaling_mode.rs +++ b/examples/camera_scaling_mode.rs @@ -14,13 +14,16 @@ fn setup(mut commands: Commands) { let mut cam = Camera2dBundle::default(); cam.projection.scaling_mode = ScalingMode::FixedVertical(10.0); - commands.spawn(cam).insert(PanCam { - min_x: Some(-10.), - max_x: Some(10.), - min_y: Some(-10.), - max_y: Some(10.0), - ..default() - }); + commands.spawn(( + cam, + PanCam { + min_x: Some(-10.), + max_x: Some(10.), + min_y: Some(-10.), + max_y: Some(10.0), + ..default() + }, + )); let n = 20; let spacing = 1.; diff --git a/examples/clamped_borders.rs b/examples/clamped_borders.rs index 5471aa0..d964355 100644 --- a/examples/clamped_borders.rs +++ b/examples/clamped_borders.rs @@ -11,23 +11,26 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()).insert(PanCam { - // prevent the camera from zooming too far out - max_scale: Some(40.), - // prevent the camera from zooming too far in - min_scale: 0.5, - // prevent the camera from panning or zooming past x -750. -750 was chosen to display both the edges of the - // sample image and some boundary space beyond it - min_x: Some(-750.), - // prevent the camera from panning or zooming past x 1750. 1750 was chosen to show an asymmetric boundary - // window with more space on the right than the left - max_x: Some(1750.), - // prevent the camera from panning or zooming past y -750. value chosen for same reason as above - min_y: Some(-750.), - // prevent the camera from panning or zooming past y 1750. value chosen for same reason as above - max_y: Some(1750.), - ..default() - }); + commands.spawn(( + Camera2dBundle::default(), + PanCam { + // prevent the camera from zooming too far out + max_scale: Some(40.), + // prevent the camera from zooming too far in + min_scale: 0.5, + // prevent the camera from panning or zooming past x -750. -750 was chosen to display both the edges of the + // sample image and some boundary space beyond it + min_x: Some(-750.), + // prevent the camera from panning or zooming past x 1750. 1750 was chosen to show an asymmetric boundary + // window with more space on the right than the left + max_x: Some(1750.), + // prevent the camera from panning or zooming past y -750. value chosen for same reason as above + min_y: Some(-750.), + // prevent the camera from panning or zooming past y 1750. value chosen for same reason as above + max_y: Some(1750.), + ..default() + }, + )); let n = 20; let spacing = 50.; diff --git a/examples/egui.rs b/examples/egui.rs index 179541c..3d1713a 100644 --- a/examples/egui.rs +++ b/examples/egui.rs @@ -35,9 +35,7 @@ fn egui_setup(mut egui_context: ResMut) { } fn setup(mut commands: Commands) { - commands - .spawn(Camera2dBundle::default()) - .insert(PanCam::default()); + commands.spawn((Camera2dBundle::default(), PanCam::default())); let n = 20; let spacing = 50.; diff --git a/examples/inspector.rs b/examples/inspector.rs index 7c06350..177c6b8 100644 --- a/examples/inspector.rs +++ b/examples/inspector.rs @@ -13,9 +13,7 @@ fn main() { } fn setup(mut commands: Commands) { - commands - .spawn(Camera2dBundle::default()) - .insert(PanCam::default()); + commands.spawn((Camera2dBundle::default(), PanCam::default())); let n = 20; let spacing = 50.; diff --git a/examples/limits.rs b/examples/limits.rs index 2751d8a..d64bf0a 100644 --- a/examples/limits.rs +++ b/examples/limits.rs @@ -11,13 +11,16 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()).insert(PanCam { - // Set max scale in order to prevent the camera from zooming too far out - max_scale: Some(40.), - // Set min scale in order to prevent the camera from zooming too far in - min_scale: 1., - ..default() - }); + commands.spawn(( + Camera2dBundle::default(), + PanCam { + // Set max scale in order to prevent the camera from zooming too far out + max_scale: Some(40.), + // Set min scale in order to prevent the camera from zooming too far in + min_scale: 1., + ..default() + }, + )); let n = 20; let spacing = 50.; diff --git a/examples/simple.rs b/examples/simple.rs index 8290004..22f1e55 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -11,9 +11,7 @@ fn main() { } fn setup(mut commands: Commands) { - commands - .spawn(Camera2dBundle::default()) - .insert(PanCam::default()); + commands.spawn((Camera2dBundle::default(), PanCam::default())); let n = 20; let spacing = 50.; diff --git a/examples/toggle.rs b/examples/toggle.rs index fe8fb68..834e786 100644 --- a/examples/toggle.rs +++ b/examples/toggle.rs @@ -12,9 +12,7 @@ fn main() { } fn setup(mut commands: Commands) { - commands - .spawn(Camera2dBundle::default()) - .insert(PanCam::default()); + commands.spawn((Camera2dBundle::default(), PanCam::default())); let n = 20; let spacing = 50.; From 37755009aaa7a0460899bd624f5f5b87fd1f7e1b Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 14 Nov 2022 08:14:57 +0100 Subject: [PATCH 4/6] Update to bevy_egui 0.17 --- Cargo.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 26e4df0..6e4c0b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ bevy-inspector-egui = ["dep:bevy-inspector-egui"] [dependencies] bevy = {version = "0.9", features = ["render"], default-features = false} -bevy_egui = {version = "0.16", optional = true, default-features = false} +bevy_egui = {version = "0.17", optional = true, default-features = false} bevy-inspector-egui = { version = "0.13", optional = true, default-features = false } [dev-dependencies] @@ -27,8 +27,7 @@ bevy = {version = "0.9", default-features = false, features = [ "x11", # github actions runners don't have libxkbcommon installed, so can't use wayland ]} rand = "0.8" -# https://github.com/mvlabat/bevy_egui/pull/127 -#bevy_egui = {version = "0.16", default-features = false, features = ["default_fonts"]} +bevy_egui = {version = "0.17", default-features = false, features = ["default_fonts"]} #bevy-inspector-egui = {version = "0.13", default-features = false} [[example]] From c7d81ca830ed9d1121e024215e702023a1397f26 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 14 Nov 2022 08:18:37 +0100 Subject: [PATCH 5/6] Update to bevy-inspector-egui 0.14 --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6e4c0b1..c21ce11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ bevy-inspector-egui = ["dep:bevy-inspector-egui"] [dependencies] bevy = {version = "0.9", features = ["render"], default-features = false} bevy_egui = {version = "0.17", optional = true, default-features = false} -bevy-inspector-egui = { version = "0.13", optional = true, default-features = false } +bevy-inspector-egui = { version = "0.14", optional = true, default-features = false } [dev-dependencies] bevy = {version = "0.9", default-features = false, features = [ @@ -28,7 +28,7 @@ bevy = {version = "0.9", default-features = false, features = [ ]} rand = "0.8" bevy_egui = {version = "0.17", default-features = false, features = ["default_fonts"]} -#bevy-inspector-egui = {version = "0.13", default-features = false} +bevy-inspector-egui = {version = "0.14", default-features = false} [[example]] name = "egui" From 6bfbfd8a88a04c4c863bbde08f82ddfd13829ac3 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 14 Nov 2022 08:23:37 +0100 Subject: [PATCH 6/6] chore: Bump version to 0.7.0 --- Cargo.toml | 2 +- readme.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c21ce11..5df42be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" name = "bevy_pancam" readme = "readme.md" repository = "https://github.com/johanhelsing/bevy_pancam" -version = "0.6.1" +version = "0.7.0" [features] bevy_egui = ["dep:bevy_egui"] diff --git a/readme.md b/readme.md index 0e5b831..cb0257d 100644 --- a/readme.md +++ b/readme.md @@ -64,7 +64,8 @@ I intend to support the `main` branch of Bevy in the `bevy-main` branch. |bevy|bevy_pancam| |---|---| -|0.8|0.5, 0.6, main| +|0.9|0.7, main| +|0.8|0.5, 0.6| |0.7|0.3, 0.4| |0.6|0.2| |0.5|0.1|