Fix: Image Previews Have Constant Size
Description
Right now, CodeEdit attempts to display image previews at image's native resolution. This is done by restricting the view's size to the image's size. However, the preview view is scrollable and zoomable. This leads to issues like brought up in #2066 where the image is small.
This change removes the restricted size for image previews. This means they now fill the available editor space by default. They can still be zoomed, and their resolution is still listed in the status bar.
Detailed Changes
- Removed
ImageFileViewas it was redundant after removing the image size restriction. - Adjusted a nested
ifstatement inNonTextFileViewafter removingImageFileView.
Related Issues
- closes #2066
Checklist
- [x] I read and understood the contributing guide as well as the code of conduct
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code
Screenshots
Before, image is displayed at native resolution but has inset scroll bars and doesn't correctly zoom:
https://github.com/user-attachments/assets/75b831ed-54c1-4781-9bb9-d5a6258120ee
With change, image is zoomed to fit width but has correct scrolling and zooming UI and UX:
https://github.com/user-attachments/assets/64f91329-e536-48cb-8a53-38853d233319
Some images are small. Filing the space would mean a very pixelated image. Ideally there would be a threshold of some kind so smaller images show actual pixels but still are zoom-able.
Some images are small. Filing the space would mean a very pixelated image. Ideally there would be a threshold of some kind so smaller images show actual pixels but still are zoom-able.
I agree, that's annoying. The issue is we can't control the zoom level. ~~If we could even set the initial zoom level it'd be a different story.~~ I just found that the QLPreviewController takes a delegate that lets us do exactly that. I'll see if I can refactor this to use QLPreviewController instead of QLPreviewView and make the changes to set the initial zoom level.
@austincondiff QLPreviewController is only available on iOS so we're back to where we started here. I think the best UX will be to let QLPreviewView decide the size and allow the user to zoom it correctly.
@austincondiff
QLPreviewControlleris only available on iOS so we're back to where we started here. I think the best UX will be to letQLPreviewViewdecide the size and allow the user to zoom it correctly.
Working a lot with pixelated images, that would be my preference. If my image is small I expect it to be pixelated and can just zoom out, no big deal!