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

visible_bounds operation for Container #1971

Merged
merged 5 commits into from
Jul 27, 2023
Merged

Conversation

hecrj
Copy link
Member

@hecrj hecrj commented Jul 26, 2023

This PR introduces a brand new visible_bounds operation to container which can be used to obtain the visible screen bounds of a Container widget with an Id.

This operation can be very useful when combined with the window::screenshot command.

2023-07-27.01-20-41.mp4

Closes #1911.

@hecrj hecrj added this to the 0.10.0 milestone Jul 26, 2023
@bungoboingo
Copy link
Contributor

bungoboingo commented Jul 27, 2023

Looks good, tested it in an example with screenshots and bounds all seem correct, in scrollables too! 🥳 Only issue with the workflow is that Screenshot's size is in physical pixels bc it's based off the underlying texture size, and this operation returns logical. I think the best way to handle it would be to include the scale_factor in the Screenshot data, and then for the crop method just do the scaling for the user. I'll pop up a PR for it now.

Edit: Actually after thinking about it more, maybe the user would want to choose to use scale_factor or not in crop()? Maybe we should just include it in Screenshot and let the user handle it.

@hecrj hecrj merged commit 18f1ab5 into master Jul 27, 2023
20 checks passed
@hecrj hecrj deleted the visible-bounds-operation branch July 27, 2023 16:48
@hecrj
Copy link
Member Author

hecrj commented Jul 27, 2023

I think including scale_factor in Screenshot makes sense. Everything in iced is in logical units.

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

Successfully merging this pull request may close these issues.

2 participants