diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e41c331eb87fc378a18502b4547abf2faa4ebef8..a9620468b63d59f2997518b1470b4272c0e66b1d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,6 +56,10 @@ jobs: run: cargo test --no-default-features --features="bevy_sprite" env: CARGO_INCREMENTAL: 1 + - name: Build & run tests (text) + run: cargo test --no-default-features --features="bevy_text" + env: + CARGO_INCREMENTAL: 1 - name: Build & run tests (asset) run: cargo test --no-default-features --features="bevy_asset" env: diff --git a/CHANGELOG.md b/CHANGELOG.md index a81452e098ae1ee7cf4ab709f84cb763287085cf..46a96d910a1f1efb4158b171f01b1cd1f95a1a1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `with_repeat_count()` and `with_repeat_strategy()` builder methods to `Tween<T>`. - Added a `speed()` getter on `Animator<T>` and `AssetAnimator<T>`. - Added `set_elapsed(Duration)` and `elapsed() -> Duration` to the `Tweenable<T>` trait. Those methods are preferable over `set_progress()` and `progress()` as they avoid the conversion to floating-point values and any rounding errors. +- Added a new `bevy_text` feature for `Text`-related built-in lenses. ### Changed @@ -18,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Animators now always have a tween (instead of it being optional). This means the default animator implementation was removed. - `Delay::new()` now panics if the `duration` is zero. This prevents creating no-op `Delay` objects, and avoids an internal edge case producing wrong results. - Tweens moving to `TweenState::Completed` are now guaranteed to freeze their state. In particular, this means that their direction will not flip at the end of the last loop if their repeat strategy is `RepeatStrategy::MirroredRepeat`. +- Moved the `TextColorLens` lens from the `bevy_ui` feature to the new `bevy_text` one, to allow using it without the Bevy UI crate. ### Removed diff --git a/Cargo.toml b/Cargo.toml index e71e4411a2a09e9ab4eb39a47af25a707d998b74..af36c3a3eeafa210836f85336fc398b5161d694b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_tweening" -version = "0.5.0" +version = "0.5.1" authors = ["François Mockers <mockersf@gmail.com>", "Jerome Humbert <djeedai@gmail.com>"] edition = "2021" description = "Tweening animation plugin for the Bevy game engine" @@ -13,13 +13,15 @@ readme = "README.md" exclude = ["examples/*.gif", ".github", "release.md"] [features] -default = ["bevy_sprite", "bevy_ui", "bevy_asset"] +default = ["bevy_sprite", "bevy_ui", "bevy_asset", "bevy_text"] # Enable support for Asset animation bevy_asset = ["bevy/bevy_asset"] # Enable built-in lenses for Bevy sprites bevy_sprite = ["bevy/bevy_sprite", "bevy/bevy_render"] # Enable built-in lenses for Bevy UI -bevy_ui = ["bevy/bevy_ui", "bevy/bevy_text", "bevy/bevy_render"] +bevy_ui = ["bevy/bevy_ui", "bevy/bevy_render"] +# Enable built-in lenses for Bevy Text +bevy_text = ["bevy/bevy_text", "bevy/bevy_render"] [dependencies] interpolation = "0.2" @@ -54,7 +56,7 @@ required-features = [ "bevy_ui", "bevy/bevy_winit" ] [[example]] name = "text_color" -required-features = [ "bevy_ui", "bevy/bevy_winit" ] +required-features = [ "bevy_text", "bevy/bevy_winit" ] [[example]] name = "sequence" diff --git a/README.md b/README.md index 02352f0b31bbb1d82744aa77eabafecf61e52e3e..206cf3a13a63b7258107e0fe9a91553de498fa01 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ This crate supports the following features: | `bevy_asset` | Yes | Enable animating Bevy assets (`Asset`) in addition of components. | | `bevy_sprite` | Yes | Includes built-in lenses for some `Sprite`-related components. | | `bevy_ui` | Yes | Includes built-in lenses for some UI-related components. | +| `bevy_text` | Yes | Includes built-in lenses for some `Text`-related components. | ### System setup @@ -121,7 +122,7 @@ The naming scheme for predefined lenses is `"<TargetName><FieldName>Lens"`, wher | | [`scale`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformScaleLens.html) | | | [`Sprite`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.SpriteColorLens.html) | `bevy_sprite` | | [`Style`](https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.UiPositionLens.html) | `bevy_ui` | -| [`Text`](https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TextColorLens.html) | `bevy_ui` | +| [`Text`](https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TextColorLens.html) | `bevy_text` | ¹ Shortest-path interpolation between two rotations, using `Quat::slerp()`. diff --git a/src/lens.rs b/src/lens.rs index 8a8eec8f1e79985e9cae5e299984253918aad0d7..016b03f9f490290811de9f1f763756a5732b03de 100644 --- a/src/lens.rs +++ b/src/lens.rs @@ -79,7 +79,7 @@ pub trait Lens<T> { /// /// [`color`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color /// [`Text`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html -#[cfg(feature = "bevy_ui")] +#[cfg(feature = "bevy_text")] #[derive(Debug, Copy, Clone, PartialEq)] pub struct TextColorLens { /// Start color. @@ -90,7 +90,7 @@ pub struct TextColorLens { pub section: usize, } -#[cfg(feature = "bevy_ui")] +#[cfg(feature = "bevy_text")] impl Lens<Text> for TextColorLens { fn lerp(&mut self, target: &mut Text, ratio: f32) { // Note: Add<f32> for Color affects alpha, but not Mul<f32>. So use Vec4 for @@ -377,7 +377,7 @@ mod tests { use super::*; - #[cfg(feature = "bevy_ui")] + #[cfg(feature = "bevy_text")] #[test] fn text_color() { let mut lens = TextColorLens {