aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Layout/Grid.hs
diff options
context:
space:
mode:
authordaniel <daniel@wagner-home.com>2008-09-22 03:09:50 +0200
committerdaniel <daniel@wagner-home.com>2008-09-22 03:09:50 +0200
commit577a6c9b6654cf2e3007bce0fa56334e45be06b1 (patch)
treef0182e4772bf9deac078c7f2c805de61a89a2cfa /XMonad/Layout/Grid.hs
parentd92ce0fc37be23cb5db06e7e7c5644218ea1e218 (diff)
downloadXMonadContrib-577a6c9b6654cf2e3007bce0fa56334e45be06b1.tar.gz
XMonadContrib-577a6c9b6654cf2e3007bce0fa56334e45be06b1.tar.xz
XMonadContrib-577a6c9b6654cf2e3007bce0fa56334e45be06b1.zip
let Grid have a configurable aspect ratio goal
darcs-hash:20080922010950-c98ca-2077ed7e1b481c7849d7501ff4435d9a3fabdde9.gz
Diffstat (limited to 'XMonad/Layout/Grid.hs')
-rw-r--r--XMonad/Layout/Grid.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/XMonad/Layout/Grid.hs b/XMonad/Layout/Grid.hs
index 33c4461..09de582 100644
--- a/XMonad/Layout/Grid.hs
+++ b/XMonad/Layout/Grid.hs
@@ -17,7 +17,7 @@
module XMonad.Layout.Grid (
-- * Usage
-- $usage
- Grid(..), arrange
+ Grid(..), arrange, defaultRatio
) where
import XMonad
@@ -33,20 +33,29 @@ import XMonad.StackSet
-- > myLayouts = Grid ||| Full ||| etc..
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
--
+-- You can also specify an aspect ratio for Grid to strive for with the
+-- GridRatio constructor:
+--
+-- > myLayouts = GridRatio (3/4) ||| etc.
+--
-- For more detailed instructions on editing the layoutHook see:
--
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
-data Grid a = Grid deriving (Read, Show)
+data Grid a = Grid | GridRatio Double deriving (Read, Show)
+
+defaultRatio :: Double
+defaultRatio = 9/16
instance LayoutClass Grid a where
- pureLayout Grid r s = arrange r (integrate s)
+ pureLayout Grid r = pureLayout (GridRatio defaultRatio) r
+ pureLayout (GridRatio d) r = arrange d r . integrate
-arrange :: Rectangle -> [a] -> [(a, Rectangle)]
-arrange (Rectangle rx ry rw rh) st = zip st rectangles
+arrange :: Double -> Rectangle -> [a] -> [(a, Rectangle)]
+arrange aspectRatio (Rectangle rx ry rw rh) st = zip st rectangles
where
nwins = length st
- ncols = max 1 . round . sqrt $ fromIntegral nwins * 9 * fromIntegral rw / (16 * fromIntegral rh :: Double)
+ ncols = max 1 . round . sqrt $ aspectRatio * fromIntegral nwins * fromIntegral rw / fromIntegral rh
mincs = nwins `div` ncols
extrs = nwins - ncols * mincs
chop :: Int -> Dimension -> [(Position, Dimension)]