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

Get bounds of a container? #1120

Closed
QuinnFreedman opened this issue Nov 17, 2021 · 5 comments · Fixed by #1193
Closed

Get bounds of a container? #1120

QuinnFreedman opened this issue Nov 17, 2021 · 5 comments · Fixed by #1193

Comments

@QuinnFreedman
Copy link

Is there a way to get the bounds of an element? For example, if I want to set an element to fill available space, but then I want to know how big that element actually ended up being, is there a way to query that? If not, I guess this is a feature request for that.

Also, it would be nice to know the x,y position of an element so you could translate mouse events from iced_native::subscription::events() into the relative coordinates of the element.

For example, Elm provides that functionality in Browser.Dom

@davidclevenger
Copy link

I am also wondering this. I am trying to get relative pixel locations of an image by querying the cursor position over a displayed image.

@13r0ck
Copy link
Member

13r0ck commented Jan 2, 2022

@QuinnFreedman
It sounds like you are looking for something like getElement from elm. That is not yet implemented in iced

@13r0ck
Copy link
Member

13r0ck commented Jan 2, 2022

@davidclevenger

You will need to use a canvas for that. The game of life example uses a canvas to track mouse inputs

@hecrj
Copy link
Member

hecrj commented Jan 12, 2022

I have just opened #1193, which implements a Responsive widget that may suit some of the use cases described here. Let me know!

@davidclevenger
Copy link

@hecrj I believe this should work for my use case. I am trying to create a photo editor so I need to track mouse location inside the Image widget to mark pixel locations. I will update here with any successes or difficulties. Thanks for adding!

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

Successfully merging a pull request may close this issue.

4 participants