Fix BESTFIT to work well when pages-per-row > 1.

There are two causes of the problem:

    - page_ratio should be defined differently

        This is because the usefull page ratio is max_height/total_width
        or max_width/total_height. This then changes accordingly if
        pages_per_row != 1, otherwise, if the pages are of the same
        size, the page ratios will not change, which screws up the
        resizing.

    - Sometimes we need to do height or width division diferently.

        This is because not always total_height or total_width is
        meaningful in BESTFIT condition.

This commit also should fix the bug #0000226.

Signed-off-by: Ignas Anikevicius (gns_ank) <anikevicius@gmail.com>
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Ignas Anikevicius (gns_ank) 2012-07-16 21:22:54 +01:00 committed by Sebastian Ramacher
parent 9c28be7c11
commit e4b9924c4d

View File

@ -122,11 +122,11 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
}
unsigned int rotation = zathura_document_get_rotation(zathura->document);
double page_ratio = total_height / total_width;
double page_ratio = max_height / total_width;
double window_ratio = height / width;
if (rotation == 90 || rotation == 270) {
page_ratio = total_width / total_height;
page_ratio = max_width / total_height;
}
switch (argument->n) {
@ -142,13 +142,13 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
if (page_ratio < window_ratio) {
zathura_document_set_scale(zathura->document, width / total_width);
} else {
zathura_document_set_scale(zathura->document, height / total_height);
zathura_document_set_scale(zathura->document, height / max_height);
}
} else {
if (page_ratio < window_ratio) {
zathura_document_set_scale(zathura->document, width / total_height);
} else {
zathura_document_set_scale(zathura->document, height / total_width);
zathura_document_set_scale(zathura->document, height / max_width);
}
}
break;