Grid/HintedGrid: prefer wider windows

This commit is contained in:
Lukas Mai
2008-07-17 20:51:38 +00:00
parent 94101637c9
commit e9980e2052
2 changed files with 2 additions and 2 deletions

View File

@@ -46,7 +46,7 @@ arrange :: Rectangle -> [a] -> [(a, Rectangle)]
arrange (Rectangle rx ry rw rh) st = zip st rectangles arrange (Rectangle rx ry rw rh) st = zip st rectangles
where where
nwins = length st nwins = length st
ncols = max 1 . round . sqrt $ fromIntegral nwins * fromIntegral rw / (fromIntegral rh :: Double) ncols = max 1 . round . sqrt $ fromIntegral nwins * 9 * fromIntegral rw / (16 * fromIntegral rh :: Double)
mincs = nwins `div` ncols mincs = nwins `div` ncols
extrs = nwins - ncols * mincs extrs = nwins - ncols * mincs
chop :: Int -> Dimension -> [(Position, Dimension)] chop :: Int -> Dimension -> [(Position, Dimension)]

View File

@@ -109,7 +109,7 @@ arrange' :: D -> [D -> D] -> [Rectangle]
arrange' (rw, rh) adjs = reverse $ doRect rh rw (fromIntegral ncolumns) (ecols ++ cols) arrange' (rw, rh) adjs = reverse $ doRect rh rw (fromIntegral ncolumns) (ecols ++ cols)
where where
nwindows = length adjs nwindows = length adjs
ncolumns = max 1 . round . sqrt $ fromIntegral nwindows * fromIntegral rw / (fromIntegral rh :: Double) ncolumns = max 1 . round . sqrt $ fromIntegral nwindows * 9 * fromIntegral rw / (16 * fromIntegral rh :: Double)
nrows = nwindows `div` ncolumns nrows = nwindows `div` ncolumns
nextras = nwindows - ncolumns * nrows nextras = nwindows - ncolumns * nrows
(ecols, adjs') = replicateS nextras (splitAt (nrows + 1)) $ reverse adjs (ecols, adjs') = replicateS nextras (splitAt (nrows + 1)) $ reverse adjs