-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add screen absolute mouse position to CursorMoved #3071
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
Conversation
|
|
|
Optional might be valid, here's my actual user case Baseview → Conversion → Iced → Widget Baseview provides Conversion layer does simple type conversion: Iced runtime dispatches the event to all widgets. Standard widgets use Widget ResizeHandle widget uses Why I modified iced: Core iced didn't have Baseview vs Winit: Baseview provides both coordinates natively (simple passthrough). Winit must calculate |
|
Yeah, I just misread the code at first. It might be better to have users explicitly handle the case where screenspace coordinates aren't available or might be incorrect, but this way works too. In the end that's a design decision hecrj will have to make though. |
|
I was also trying to think of a way to make it an opt-in so it wouldn't be a breaking change but couldn't see a logical way of doing that unfortunately. It's a really useful feature for us audio plugin devs, but might be out of scope and too niche to have it in iced 🤷 edit: I'm happy to have a scenario where users explicitly handle the case you mentioned, it was more I had this code that made my resizing work perfectly, so though why not share it upstream just incase 😄 |
|
I am unconvinced this is a use case that must be solved at the widget level. This seems like it should not leak further than the shell itself. I am closing this until we can come up with a better design. |
|
@hecrj could you expand a little on you're previous comment. I'm keen to help have this feature but if you think it lives elsewhere what would be a logical place? I'm not quite understanding:
|
|
Why does the burden of implementation fall on |
|
The plugin needs to implement resizing itself because in this case iced is embedded into a foreign window, where the plugin needs to request the host to resize the window instead of it just being handled by the native resize controls. Typically this is solved by adding a "resize handle" widget somewhere in the bottom right of the window, and using that instead of the native controls. For example, That being said, I'm not sure I understand why this needs the cursor screen-coordinates vs just window-coordinates. |
I thought it was because only iced has access to the window event. But not to worry I'll try something else, pretty sure I tried putting it into EDIT: Sorry I should have deleted this PR once I'd done the other. I write code then just forget about it!!! 🤦 |
Add screen-absolute mouse position to CursorMoved event
Problem:
When implementing custom window resize handles, window-relative mouse coordinates become unreliable as the window dimensions change. The position jumps around because it's relative to a moving target.
This is particularly problematic for audio plugins (using nih-plug + baseview) where you can't access native window resize controls and have to implement resize handles yourself.
Solution:
Add
screen_position: Pointtomouse::Event::CursorMovedalongside the existing window-relative position.The screen position stays constant during resize operations, making drag calculations straightforward.
Implementation:
window.outer_position() + cursor_positionconversion::window_event()to accept pre-extractedwindow_positionparameter (consistent with existingscale_factorpattern)Breaking Changes:
CursorMovedhas new field - existing pattern matches need..conversion::window_event()signature changedIt closes #2773 (only issue I could find related to it)
Working Result:
