Skip to content
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

Expose additional mouse::Interaction cursors #2551

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

airstrike
Copy link
Contributor

This PR adds a few more common mouse interaction cursors to interaction.rs, namely:

  • Resizing diagonally in both directions (pick the right name is probably the hardest part here)
  • Zooming out (we already had a cursor for zooming in but not one for zooming out)
  • Cell selector (used in Microsoft Excel and possibly other spreadsheet or table-like UI elements)
  • Move

Since the Cell selector is a bit niche, here is a screenshot of what it looks like in Excel. My use case is building a spreadsheet app, so users would expect this cursor to be there.

image

I take it ZoomOut and Move are pretty standard and need no specific use case.

There's an argument to be made that iced could just expose all of the cursors from winit and let the users figure it out, even if some of the cursors are very unusual. I'm not making that argument so I have only added those cursors whose inclusion was more immediately defensible IMHO but open to suggestions.

Admittedly I have not tested the specific resizing cursors because I'm on MacOS and they don't work, but naturally everything compiles and runs fine. They just default to the standard cursor, but I tested other cursors from winit and they were fine (including, for example, sizing westward, which is not in this PR) so I'm confident nothing's wrong with the code per se.

FYI this winit issue is being tracked here: rust-windowing/winit#3724

@airstrike
Copy link
Contributor Author

Also maybe we have to wait until the winit issue is fixed before merging buggy cursors into iced, but I didn't want to forget about this PR so I'm submitting it now as it's unlikely the code will break between now and when it gets merged and we can at least track it, debate names and debate including additional cursors.

@stevenxxiu
Copy link

I also would love to add another cursor, being the copy cursor.

I'm porting a Conky like project of mine, from GTK to Iced. Iced feels like a more direct toolkit than using the GTK Rust wrapper.

The use case is when I hover my cursor over some labels, I show a copy cursor to indicate the text can be copied.

Since this is a dashboard, the UI should be kept very simple. So I felt like a cursor was the best way to go.

@hecrj hecrj added this to the 0.13 milestone Aug 19, 2024
@hecrj hecrj added feature New feature or request shell addition labels Aug 19, 2024
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Thanks!

@stevenxxiu I added Copy as well.

@hecrj hecrj changed the title Expose additional mouse interaction cursors Expose additional mouse::Interaction cursors Sep 13, 2024
@hecrj hecrj merged commit e9e8e83 into iced-rs:master Sep 13, 2024
12 checks passed
@airstrike airstrike deleted the mouse-interactions branch September 13, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition feature New feature or request shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants