Skip to content

Image Viewer bounds expansion when zooming #878

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

Closed
Chiheisen opened this issue May 13, 2021 · 0 comments · Fixed by #885
Closed

Image Viewer bounds expansion when zooming #878

Chiheisen opened this issue May 13, 2021 · 0 comments · Fixed by #885
Labels
bug Something isn't working
Milestone

Comments

@Chiheisen
Copy link
Contributor

Chiheisen commented May 13, 2021

This is both a question and depending on if I missed something a feature request.

Right now, when using the viewer as follows:

image::viewer::Viewer::new(&mut self.viewer_state, img.clone())
    .width(Length::Fill)
    .height(Length::Fill)

the result is an image constrained by it's viewport.

This creates an in my opinion somewhat unexpected result when zooming into the image:
On a blank screen with just the viewer, the image can never exceed the original bounds even when zoomed in even if space would be available.

Image displayed in full window, no zooming (container has centerx, centery hence in middle):
1620919390
Slightly zoomed and moved with explain turned on, image now cut off on the right:
1620919405

As width/height are specified as Length::Fill my expectation would have been that the image expands as far as it can within those constraints, not stay bound to it's original size.

Did I miss something or is this currently not possible?

From what I can see this is due to the layout function in viewer.rs always receiving the same width / height, not letting them be bigger than the initially displayed image. If I do an ugly hack and replace renderer.dimensions(&self.handle) with hardcoded values, I get my desired effect, but I didn't see an obvious way to do it cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants