Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5614f11
Removed bevy_winit dependency from bevy_feathers
ickshonpe Aug 2, 2025
3357d08
Moved `CustomCursorImage` to `bevy_image`
ickshonpe Aug 2, 2025
73f118f
Removes the `bevy_feathers` dependency on `bevy_winit`.
ickshonpe Aug 2, 2025
466fb14
Removed unused dependencies
ickshonpe Aug 2, 2025
ea4d2cb
Fixed bevy_feathers custom cursor feature
ickshonpe Aug 2, 2025
ca28dbc
cargo run -p build-templated-pages -- update features
ickshonpe Aug 2, 2025
c8d0057
Removed broken imports from `bevy_image`
ickshonpe Aug 2, 2025
7ec820e
Merge branch 'main' into remove_feathers_winit_dep
ickshonpe Aug 2, 2025
f85ed0e
Fixed missing import for feature
ickshonpe Aug 2, 2025
b665cc0
Added migration guide
ickshonpe Aug 2, 2025
8cc805e
Merge branch 'remove_feathers_winit_dep' of https://github.com/icksho…
ickshonpe Aug 2, 2025
fe2070d
US spelling gdi, customisation -> customization
ickshonpe Aug 2, 2025
abdf90d
cargo fmt --all
ickshonpe Aug 2, 2025
1478025
Fixed migration guide
ickshonpe Aug 2, 2025
bbd4889
Added release note
ickshonpe Aug 2, 2025
887de8b
Fixed typo.
ickshonpe Aug 2, 2025
44927d6
Fixed cargo.toml
ickshonpe Aug 2, 2025
9932d6a
Renamed `bevy_window_cursor` to `bevy_cursor_icon`
ickshonpe Aug 2, 2025
54b9b32
renamed plugin to CursorIconPlugin
ickshonpe Aug 2, 2025
cbcdf3c
cargo run -p build-templated-pages -- update features
ickshonpe Aug 2, 2025
cae0d3d
cargo fmt --all
ickshonpe Aug 2, 2025
3529f3d
Fixed prelude
ickshonpe Aug 2, 2025
291fa76
Fixed cursor_icon alias in bevy_internal
ickshonpe Aug 2, 2025
19ebe10
Fixed more imports
ickshonpe Aug 2, 2025
2069fc4
Updated release and migration note file names.
ickshonpe Aug 2, 2025
4c15b60
Fixed example's imports
ickshonpe Aug 2, 2025
0db07f8
Removed trailing space
ickshonpe Aug 2, 2025
b85e4e2
Fixed import for wasm target
ickshonpe Aug 2, 2025
5e6dbc6
fixed feature import
ickshonpe Aug 2, 2025
7758d02
Merge branch 'main' into remove_feathers_winit_dep
ickshonpe Aug 2, 2025
dc4df4c
Merge branch 'main' into remove_feathers_winit_dep
ickshonpe Aug 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ default = [
"bevy_asset",
"bevy_audio",
"bevy_color",
"bevy_cursor_icon",
"bevy_core_pipeline",
"bevy_core_widgets",
"bevy_anti_aliasing",
Expand Down Expand Up @@ -212,6 +213,9 @@ bevy_audio = ["bevy_internal/bevy_audio"]
# Provides shared color types and operations
bevy_color = ["bevy_internal/bevy_color"]

# Provides cursor
bevy_cursor_icon = ["bevy_internal/bevy_cursor_icon"]

# Provides cameras and other basic render pipeline features
bevy_core_pipeline = [
"bevy_internal/bevy_core_pipeline",
Expand Down
29 changes: 29 additions & 0 deletions crates/bevy_cursor_icon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "bevy_cursor_icon"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the real problem here is that bevy_window isn't serving the role as a backend-agnostic layer. bevy_asset requires bevy_window because it is using bevy_window::ANDROID_APP. ANDROID_APP is not a backend-agnostic window API.

I'm going to play around with relocating that instead, freeing up bevy_window to depend on bevy_asset.

version = "0.17.0-dev"
edition = "2024"
description = "Provides custom cursor icon support"
homepage = "https://bevy.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
default = []

# Functionality

## Custom cursor image
custom_cursor = ["bevy_image", "bevy_asset"]

# Platform Compatibility

[dependencies]
bevy_app = { path = "../bevy_app", version = "0.17.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.17.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }

# bevy optional
bevy_asset = { path = "../bevy_asset", version = "0.17.0-dev", optional = true }
bevy_image = { path = "../bevy_image", version = "0.17.0-dev", optional = true }
176 changes: 176 additions & 0 deletions crates/bevy_cursor_icon/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
19 changes: 19 additions & 0 deletions crates/bevy_cursor_icon/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions crates/bevy_cursor_icon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Bevy Color

[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/bevyengine/bevy#license)
[![Crates.io](https://img.shields.io/crates/v/bevy_cursor_icon.svg)](https://crates.io/crates/bevy_cursor_icon)
[![Downloads](https://img.shields.io/crates/d/bevy_cursor_icon.svg)](https://crates.io/crates/bevy_cursor_icon)
[![Docs](https://docs.rs/bevy_cursor_icon/badge.svg)](https://docs.rs/bevy_cursor_icon/latest/bevy_cursor_icon/)
[![Discord](https://img.shields.io/discord/691052431525675048.svg?label=&logo=discord&logoColor=ffffff&cursor=7389D8&labelColor=6A7EC2)](https://discord.gg/bevy)
45 changes: 45 additions & 0 deletions crates/bevy_cursor_icon/src/cursor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use bevy_ecs::component::Component;
use bevy_ecs::reflect::ReflectComponent;
use bevy_reflect::prelude::ReflectDefault;
use bevy_reflect::Reflect;

#[cfg(feature = "custom_cursor")]
use crate::custom_cursor::CustomCursor;

use crate::SystemCursorIcon;

/// Insert into a window entity to set the cursor for that window.
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
#[reflect(Component, Debug, Default, PartialEq, Clone)]
pub enum CursorIcon {
#[cfg(feature = "custom_cursor")]
/// Custom cursor image.
Custom(CustomCursor),
/// System provided cursor icon.
System(SystemCursorIcon),
}

impl Default for CursorIcon {
fn default() -> Self {
CursorIcon::System(Default::default())
}
}

impl From<SystemCursorIcon> for CursorIcon {
fn from(icon: SystemCursorIcon) -> Self {
CursorIcon::System(icon)
}
}

#[cfg(all(target_family = "wasm", target_os = "unknown"))]
/// A custom cursor created from a URL.
#[derive(Debug, Clone, Default, Reflect, PartialEq, Eq, Hash)]
#[reflect(Debug, Default, Hash, PartialEq, Clone)]
pub struct CustomCursorUrl {
/// Web URL to an image to use as the cursor. PNGs are preferred. Cursor
/// creation can fail if the image is invalid or not reachable.
pub url: String,
/// X and Y coordinates of the hotspot in pixels. The hotspot must be within
/// the image bounds.
pub hotspot: (u16, u16),
}
59 changes: 59 additions & 0 deletions crates/bevy_cursor_icon/src/custom_cursor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use crate::CursorIcon;
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use crate::CustomCursorUrl;
use bevy_asset::Handle;
use bevy_image::{Image, TextureAtlas};
use bevy_math::URect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};

/// Custom cursor image data.
#[derive(Debug, Clone, Reflect, PartialEq, Eq, Hash)]
#[reflect(Clone, PartialEq, Hash)]
pub enum CustomCursor {
/// Use an image as the cursor.
Image(CustomCursorImage),
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
/// Use a URL to an image as the cursor.
Url(CustomCursorUrl),
}

impl From<CustomCursor> for CursorIcon {
fn from(cursor: CustomCursor) -> Self {
CursorIcon::Custom(cursor)
}
}

/// A custom cursor created from an image.
#[derive(Debug, Clone, Default, Reflect, PartialEq, Eq, Hash)]
#[reflect(Debug, Default, Hash, PartialEq, Clone)]
pub struct CustomCursorImage {
/// Handle to the image to use as the cursor. The image must be in 8 bit int
/// or 32 bit float rgba. PNG images work well for this.
pub handle: Handle<Image>,
/// An optional texture atlas used to render the image.
pub texture_atlas: Option<TextureAtlas>,
/// Whether the image should be flipped along its x-axis.
///
/// If true, the cursor's `hotspot` automatically flips along with the
/// image.
pub flip_x: bool,
/// Whether the image should be flipped along its y-axis.
///
/// If true, the cursor's `hotspot` automatically flips along with the
/// image.
pub flip_y: bool,
/// An optional rectangle representing the region of the image to render,
/// instead of rendering the full image. This is an easy one-off alternative
/// to using a [`TextureAtlas`].
///
/// When used with a [`TextureAtlas`], the rect is offset by the atlas's
/// minimal (top-left) corner position.
pub rect: Option<URect>,
/// X and Y coordinates of the hotspot in pixels. The hotspot must be within
/// the image bounds.
///
/// If you are flipping the image using `flip_x` or `flip_y`, you don't need
/// to adjust this field to account for the flip because it is adjusted
/// automatically.
pub hotspot: (u16, u16),
}
28 changes: 28 additions & 0 deletions crates/bevy_cursor_icon/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
mod cursor;
mod system_cursor;

#[cfg(feature = "custom_cursor")]
mod custom_cursor;

use bevy_app::{App, Plugin};
pub use cursor::*;
pub use system_cursor::SystemCursorIcon;

#[cfg(feature = "custom_cursor")]
pub use custom_cursor::*;

pub mod prelude {
pub use crate::cursor::*;
#[cfg(feature = "custom_cursor")]
pub use crate::custom_cursor::*;
pub use crate::system_cursor::*;
}

#[derive(Default)]
pub struct CursorIconPlugin;

impl Plugin for CursorIconPlugin {
fn build(&self, app: &mut App) {
app.register_type::<CursorIcon>();
}
}
Loading
Loading