carygravel / gtk3-imageview

2 stars 3 forks source link

Make set_zoom_to_fit() not stretch small image to huge window #3

Closed DarthGandalf closed 4 years ago

carygravel commented 4 years ago

I think a minimum zoom factor would be better as a class property than a method argument.

Additionally, would you mind adding a test, please?

DarthGandalf commented 4 years ago

Having it as a class property would imply that zoom is limited by it. But intention here is to limit only automatic zoom when trying to fit image to the window. Manual zoom by mouse wheel or zoom_in() methods shouldn't be affected

carygravel commented 4 years ago

OK. But which call to zoom_to_box() are you going to change to implement that? At the moment set_zoom_to_fit() just takes a boolean.

DarthGandalf commented 4 years ago

For shutter case, this change works as is, I just wanted functionality of Gtk2::ImageView::set_fitting(TRUE).

zoom_to_box() is never called directly, but only from set_zoom_to_fit() etc, where it doesn't pass the additional parameter, therefore using the default of 1. I added it as a parameter only to try to preserve existing functionality.

How does gscan2pdf use this?

carygravel commented 4 years ago

gscan2pdf uses zoom_to_box to zoom to a word of OCR output in order to allow the user to edit/correct it - zoom_to_selection() is the shortcut, and the extra factor allows some context.

At least with gscan2pdf, you don't need a very small image or a very large monitor to have zoom levels below 1 to fit the image to the window.

i.e. your new default would change the default used by gscan2pdf.

How about a minimum-zoom-to-fit property?

DarthGandalf commented 4 years ago

I couldn't come up with a good API for this to preserve various defaults, but it seems to work now more or less. PTAL