-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Changed the way cursors are defined in bevy_feathers. #20169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Originally, we re-used the `CursorIcon` component which was intended to be placed on the window, and expanded its use so that it could be placed on any hoverable entity. In this PR, we restore `CursorIcon` to its original usage, and instead introduce a new type `EntityCursor` intended to be placed on hoverable entities. Part of the motivation for this is that it will make it easier to support BSN templates without having to add new trait impls in bevy_winit.
crates/bevy_feathers/src/cursor.rs
Outdated
mut q_windows: Query<(Entity, &mut Window, Option<&CursorIcon>)>, | ||
r_default_cursor: Res<DefaultCursorIcon>, | ||
r_default_cursor: Res<DefaultEntityCursor>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest, does it make sense to make the default cursor a component on window rather than a global resource? Presumably you could then define the per-window default as well.
Is there a case where there’s something further up the tree than a window which would make this suggestion fall apart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer not to add features based on hypothetical use cases - ones that may or may not ever come up. The vast majority of apps only have one window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why you would ever want to have a distinct default cursor per window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I mentioned this is that it seemed like a natural place to put it instead of it being a resource. That is to say, if you only have 1 window most of the time, then your window is your “resource singleton” anyway. The cursor already “belongs to” the window (via CursorIcon) and the code already iterates over all windows AFAICS and so it just felt natural.
But yeah I’m not at all fussed, was just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to resolve this, I can’t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small naming + docs suggestion, then LGTM.
@alice-i-cecile Ideally this whole thing should move to |
Also, I don't know why the check-advisories CI is whinging. |
The issue here is that |
If that's the case, then maybe we need to abstract out cursor definitions from bevy_winit. |
Agreed. I think this was attempted in the past (I vaguely remember advocating for it), but I also vaguely remember there being something that made it non-trivial. |
IIRC the problem was horrible circular dependencies with respect to rendering, assets, windowing and bevy_image. Same flavor of problem as our yet-unfixed "set window decoration" stuff. |
Added #20182 |
Originally, we re-used the
CursorIcon
component which was intended to be placed on the window, and expanded its use so that it could be placed on any hoverable entity.In this PR, we restore
CursorIcon
to its original usage, and instead introduce a new typeEntityCursor
intended to be placed on hoverable entities.Part of the motivation for this is that it will make it easier to support custom cursors in BSN templates without having to add new trait impls in bevy_winit.
Bikeshedding on the name
EntityCursor
is welcome. Originally I had thoughtNodeCursor
, but it's not just for Nodes, it can be placed on any hoverable entity.Note: this was discussed in Discord with @cart