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

Cursor should change when operating sliders #314

Open
joulei opened this issue Nov 21, 2024 · 9 comments
Open

Cursor should change when operating sliders #314

joulei opened this issue Nov 21, 2024 · 9 comments

Comments

@joulei
Copy link
Collaborator

joulei commented Nov 21, 2024

Context

Currently when operating the sliders on the chat settings panel, the cursor always stays as a pointer.
We should add behavior to the sliders to match the visual effects of most platforms.

Goal

When hovering over the handle of a slider, the cursor should change to an open hand, indicating the user to drag. When dragging, the open hand should change to a close hand.

image

This might require to add the behaviour directly into Makepad's Slider widget.

@Guocork
Copy link
Collaborator

Guocork commented Nov 27, 2024

@joulei
Hello,I'm currently working on this issue and have submitted a PR to Makepad to fix the problem where cursor: Hand doesn't display properly on Linux. PR606

At the same time, I noticed that Makepad currently doesn't support a "close hand" cursor—grab is commented out and hasn't been implemented for any platform yet. If I want to add corresponding behavior to the slider, I'll need to implement the grab property for Makepad and integrate it across all platforms. What do you think about this?
image

@joulei
Copy link
Collaborator Author

joulei commented Nov 27, 2024

@Guocork thanks for working on this, I forgot about the cursor issue in Linux. But I'm glad that you found a solution for it.
If you are comfortable with adding support for grab cursor in Makepad, that would be great. I can provide assistance when working on the different platforms.
Otherwise let me know I can put in my to-do list.

@Guocork
Copy link
Collaborator

Guocork commented Nov 27, 2024

@joulei Alright, I'm happy to handle this issue in Makepad. Currently, I’m facing a problem as I haven’t found the API documentation for the respective platform. Do you have any related documentation? Or could you tell me where I can find the platform’s API documentation?

@joulei
Copy link
Collaborator Author

joulei commented Nov 27, 2024

@Guocork we don't have much documentation surrounding platform, but I will provide you with a guide tomorrow of where you can find the code handling the cursors on each platform and how'd you introduce the new cursor type in Makepad.

@Guocork
Copy link
Collaborator

Guocork commented Nov 27, 2024

@Guocork we don't have much documentation surrounding platform, but I will provide you with a guide tomorrow of where you can find the code handling the cursors on each platform and how'd you introduce the new cursor type in Makepad.

OK,that's great, thank you.

@joulei
Copy link
Collaborator Author

joulei commented Nov 28, 2024

@Guocork ok so after a quick look it seems like the necessary changes are as follows:

  1. Enable the commented-out Grab and Grabbing cursor variants in platform/src/cursor.rs

  2. Handle the new variants in each platform

  • Apple platform/src/os/apple/apple_util.rs
  • Linux x11 platform/src/os/linux/x11/xlib_app.rs
  • Web platform/src/os/web/from_wasm.rs - platform/src/os/web/web.js
  • Windows platform/src/os/windows/win32_app.rs

You might have to do some research into the names of the pointers in each plaform.
For example, for macOS. The following worked:

// apple_util.rs
pub fn load_mouse_cursor(cursor: MouseCursor) -> ObjcId {
    match cursor {
        ...
        // added these two lines
        MouseCursor::Grab => load_native_cursor("openHandCursor"), 
        MouseCursor::Grabbing => load_native_cursor("closedHandCursor"), 

You can debug this by using cursor: <VariantName> in a View:

 <View> {
     // ...
     cursor: Grab
 }
 <View> {
     // ...
     cursor: Grabbing
 }
Screen.Recording.2024-11-28.at.2.44.14.PM.mov

I can help you test on macOS and Windows.
Does that make sense?

@Guocork
Copy link
Collaborator

Guocork commented Nov 28, 2024

Okay, thank you. I got it. I'll fix this issue.

@Guocork
Copy link
Collaborator

Guocork commented Dec 9, 2024

@joulei
Hello, I've finished this task, except on the Windows platform where I couldn't find the corresponding cursor name. pr609
Also, I've enhanced the slider functionality so that users can click on the slider to jump to the desired position, and the cursor changes while dragging. See details for more information. Slider enhancement and pr611

@joulei
Copy link
Collaborator Author

joulei commented Dec 9, 2024

@Guocork great work! I'll review it and add the cursor on Windows, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants