bevy/crates
Eero Lehtinen 47c4e3084a
Add custom cursors (#14284)
# Objective

- Add custom images as cursors
- Fixes #9557 

## Solution

- Change cursor type to accommodate both native and image cursors
- I don't really like this solution because I couldn't use
`Handle<Image>` directly. I would need to import `bevy_assets` and that
causes a circular dependency. Alternatively we could use winit's
`CustomCursor` smart pointers, but that seems hard because the event
loop is needed to create those and is not easily accessable for users.
So now I need to copy around rgba buffers which is sad.
- I use a cache because especially on the web creating cursor images is
really slow
- Sorry to #14196 for yoinking, I just wanted to make a quick solution
for myself and thought that I should probably share it too.

Update:
- Now uses `Handle<Image>`, reads rgba data in `bevy_render` and uses
resources to send the data to `bevy_winit`, where the final cursors are
created.

## Testing

- Added example which works fine at least on Linux Wayland (winit side
has been tested with all platforms).
- I haven't tested if the url cursor works.

## Migration Guide

- `CursorIcon` is no longer a field in `Window`, but a separate
component can be inserted to a window entity. It has been changed to an
enum that can hold custom images in addition to system icons.
- `Cursor` is renamed to `CursorOptions` and `cursor` field of `Window`
is renamed to `cursor_options`
- `CursorIcon` is renamed to `SystemCursorIcon`

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
2024-08-12 15:49:03 +00:00
..
bevy_a11y Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_animation Make AnimationPlayer::start and ::play work accordingly to documentation (#14546) 2024-07-31 14:07:53 +00:00
bevy_app bevy_reflect: Anonymous function parsing (#14641) 2024-08-07 03:11:08 +00:00
bevy_asset Making bevy_render an optional dependency for bevy_gizmos (#14448) 2024-08-06 13:09:10 +00:00
bevy_audio Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_color Glam 0.28 update - adopted (#14613) 2024-08-06 01:28:00 +00:00
bevy_core Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_core_pipeline Use BinnedRenderPhase for Opaque2d (#13091) 2024-08-12 15:38:24 +00:00
bevy_derive Remove deprecated bevy_dynamic_plugin (#14534) 2024-07-30 15:31:08 +00:00
bevy_dev_tools Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_diagnostic Add freebsd support for sysinfo (#14553) 2024-07-31 21:41:40 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Support more kinds of system params in buildable systems. (#14050) 2024-08-12 15:45:35 +00:00
bevy_encase_derive Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gilrs Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gizmos Fix 3D Gizmo webgpu rendering (#14653) 2024-08-09 02:55:56 +00:00
bevy_gltf Export glTF skins as a Gltf struct (#14343) 2024-08-06 01:14:42 +00:00
bevy_hierarchy Add link to with_children in with_child doc (#14604) 2024-08-04 13:36:52 +00:00
bevy_input Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
bevy_internal Making bevy_render an optional dependency for bevy_gizmos (#14448) 2024-08-06 13:09:10 +00:00
bevy_log Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
bevy_macro_utils Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_math A Curve trait for general interoperation — Part I (#14630) 2024-08-09 14:19:44 +00:00
bevy_mikktspace Glam 0.28 update - adopted (#14613) 2024-08-06 01:28:00 +00:00
bevy_pbr Glam 0.28 update - adopted (#14613) 2024-08-06 01:28:00 +00:00
bevy_picking Mod picking upstream 2 (#14686) 2024-08-09 23:16:37 +00:00
bevy_ptr Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_reflect bevy_reflect: Add DynamicSet to dynamic_types example (#14665) 2024-08-08 22:26:18 +00:00
bevy_render Add custom cursors (#14284) 2024-08-12 15:49:03 +00:00
bevy_scene Change SceneInstanceReady to trigger an observer. (#13859) 2024-07-30 21:23:48 +00:00
bevy_sprite Use BinnedRenderPhase for Opaque2d (#13091) 2024-08-12 15:38:24 +00:00
bevy_state bevy_state: Make reflect module public (#14667) 2024-08-08 20:15:38 +00:00
bevy_tasks Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
bevy_text Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_time time_system is ambiguous_with event_update_system (#14544) 2024-07-31 12:13:17 +00:00
bevy_transform Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ui Explicitly order CameraUpdateSystem before UiSystem::Prepare (#14609) 2024-08-04 13:34:51 +00:00
bevy_utils update hashbrown to 0.14.2 (#14603) 2024-08-04 13:23:28 +00:00
bevy_window Add custom cursors (#14284) 2024-08-12 15:49:03 +00:00
bevy_winit Add custom cursors (#14284) 2024-08-12 15:49:03 +00:00