From ac620cc2309c5059af12eddf850bf772e657dad1 Mon Sep 17 00:00:00 2001 From: malc Date: Fri, 17 Aug 2012 04:14:44 +0400 Subject: [PATCH] Fix zoom to height in split columns case --- link.c | 8 +++++--- main.ml | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/link.c b/link.c index 0802f0c..f648b68 100644 --- a/link.c +++ b/link.c @@ -2958,7 +2958,8 @@ CAMLprim value ml_getmaxw (value unit_v) CAMLreturn (ret_v); } -CAMLprim value ml_zoom_for_height (value winw_v, value winh_v, value dw_v) +CAMLprim value ml_zoom_for_height (value winw_v, value winh_v, + value dw_v, value cols_v) { CAMLparam3 (winw_v, winh_v, dw_v); CAMLlocal1 (ret_v); @@ -2969,6 +2970,7 @@ CAMLprim value ml_zoom_for_height (value winw_v, value winh_v, value dw_v) double winw = Int_val (winw_v); double winh = Int_val (winh_v); double dw = Int_val (dw_v); + double cols = Int_val (cols_v); double pw = 1.0, ph = 1.0, num, den; if (trylock ("ml_zoom_for_height")) { @@ -2976,7 +2978,7 @@ CAMLprim value ml_zoom_for_height (value winw_v, value winh_v, value dw_v) } if (state.proportional) { - maxw = getmaxw (); + maxw = getmaxw () / cols; } for (i = 0, p = state.pagedims; i < state.pagedimcount; ++i, ++p) { @@ -2987,7 +2989,7 @@ CAMLprim value ml_zoom_for_height (value winw_v, value winh_v, value dw_v) y0 = MIN (p->mediabox.y0, p->mediabox.y1); y1 = MAX (p->mediabox.y0, p->mediabox.y1); - w = x1 - x0; + w = (x1 - x0) / cols; h = y1 - y0; if (state.proportional) { diff --git a/main.ml b/main.ml index a2b37e3..b639734 100644 --- a/main.ml +++ b/main.ml @@ -79,7 +79,7 @@ external seltext : string -> (int * int * int * int) -> unit = "ml_seltext";; external copysel : Unix.file_descr -> opaque -> unit = "ml_copysel";; external getpdimrect : int -> float array = "ml_getpdimrect";; external whatsunder : string -> int -> int -> under = "ml_whatsunder";; -external zoomforh : int -> int -> int -> float = "ml_zoom_for_height";; +external zoomforh : int -> int -> int -> int -> float = "ml_zoom_for_height";; external drawstr : int -> int -> int -> string -> float = "ml_draw_string";; external measurestr : int -> string -> float = "ml_measure_string";; external getmaxw : unit -> float = "ml_getmaxw";; @@ -4747,7 +4747,12 @@ let viewkeyboard key mask = setzoom 1.0 | 49 when ctrl -> (* ctrl-1 *) - let zoom = zoomforh conf.winw conf.winh state.scrollw in + let cols = + match conf.columns with + | Csingle | Cmulti _ -> 1 + | Csplit (n, _) -> n + in + let zoom = zoomforh conf.winw conf.winh state.scrollw cols in if zoom < 1.0 then setzoom zoom -- 2.11.4.GIT