From 426dc2156ec608e4451966d4418d2e449b098eec Mon Sep 17 00:00:00 2001 From: malc Date: Mon, 15 Oct 2012 19:04:49 +0400 Subject: [PATCH] Address soem multicolumn vertical centering issues --- main.ml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/main.ml b/main.ml index ac0c237..3be5440 100644 --- a/main.ml +++ b/main.ml @@ -1064,6 +1064,23 @@ let calcheight () = else 0 ;; +let rowyh (c, coverA, coverB) b n = + if c = 1 || (n < coverA || n > state.pagecount - coverB) + then + let _, _, vy, (_, _, h, _) = b.(n) in + (vy, h) + else + let d = n mod c in + let s = n - d in + let e = s + c in + let rec find m miny maxh = if m = e then miny, maxh else + let _, _, y, (_, _, h, _) = b.(m) in + let miny = min miny y in + let maxh = max maxh h in + find (m+1) miny maxh + in find s max_int 0 +;; + let getpageyh pageno = let pageno = bound pageno 0 (state.pagecount-1) in match conf.columns with @@ -1078,12 +1095,10 @@ let getpageyh pageno = else y in y, h - | Cmulti (_, b) -> + | Cmulti (cl, b) -> if Array.length b = 0 then 0, 0 - else - let (_, _, y, (_, _, h, _)) = b.(pageno) in - y, h + else rowyh cl b pageno | Csplit (c, b) -> if Array.length b = 0 then 0, 0 @@ -1115,7 +1130,7 @@ let nogeomcmds cmds = ;; let page_of_y y = - let (c, coverA, coverB), b = + let ((c, coverA, coverB) as cl), b = match conf.columns with | Csingle b -> (1, 0, 0), b | Cmulti (c, b) -> c, b @@ -1126,7 +1141,7 @@ let page_of_y y = then bound nmin 0 (state.pagecount-1) else let n = (nmax + nmin) / 2 in - let _, _, vy, (_, _, h, _) = b.(n) in + let vy, h = rowyh cl b n in let y0, y1 = if c = 1 && conf.presentation then -- 2.11.4.GIT