Do not limit fit-to-win to smallest zoom level

Related to issue #303
This commit is contained in:
Bert Münnich 2018-01-22 10:47:30 +01:00
parent 727939b3e6
commit 6d1e00627b

11
image.c
View file

@ -393,12 +393,11 @@ void img_check_pan(img_t *img, bool moved)
bool img_fit(img_t *img) bool img_fit(img_t *img)
{ {
float z, zmax, zw, zh; float z, zw, zh;
if (img->scalemode == SCALE_ZOOM) if (img->scalemode == SCALE_ZOOM)
return false; return false;
zmax = img->scalemode == SCALE_DOWN ? 1.0 : zoom_max;
zw = (float) img->win->w / (float) img->w; zw = (float) img->win->w / (float) img->w;
zh = (float) img->win->h / (float) img->h; zh = (float) img->win->h / (float) img->h;
@ -413,9 +412,7 @@ bool img_fit(img_t *img)
z = MIN(zw, zh); z = MIN(zw, zh);
break; break;
} }
z = MIN(z, img->scalemode == SCALE_DOWN ? 1.0 : zoom_max);
z = MAX(z, zoom_min);
z = MIN(z, zmax);
if (zoomdiff(img, z) != 0) { if (zoomdiff(img, z) != 0) {
img->zoom = z; img->zoom = z;
@ -563,7 +560,7 @@ bool img_zoom_in(img_t *img)
int i; int i;
float z; float z;
for (i = 1; i < ARRLEN(zoom_levels); i++) { for (i = 0; i < ARRLEN(zoom_levels); i++) {
z = zoom_levels[i] / 100.0; z = zoom_levels[i] / 100.0;
if (zoomdiff(img, z) > 0) if (zoomdiff(img, z) > 0)
return img_zoom(img, z); return img_zoom(img, z);
@ -576,7 +573,7 @@ bool img_zoom_out(img_t *img)
int i; int i;
float z; float z;
for (i = ARRLEN(zoom_levels) - 2; i >= 0; i--) { for (i = ARRLEN(zoom_levels) - 1; i >= 0; i--) {
z = zoom_levels[i] / 100.0; z = zoom_levels[i] / 100.0;
if (zoomdiff(img, z) < 0) if (zoomdiff(img, z) < 0)
return img_zoom(img, z); return img_zoom(img, z);