diff options
author | joe.thornber <joe.thornber@gmail.com> | 2007-05-24 11:02:11 +0200 |
---|---|---|
committer | joe.thornber <joe.thornber@gmail.com> | 2007-05-24 11:02:11 +0200 |
commit | a4f7c29788f80c2fd2165420ebf52a5203fa8a1d (patch) | |
tree | 22d243f0475e4eaf6f1cc4df1c5fa5966215f783 /Spiral.hs | |
parent | 307ed257419a4b61b9e2c04ab43322d2e36c7442 (diff) | |
download | XMonadContrib-a4f7c29788f80c2fd2165420ebf52a5203fa8a1d.tar.gz XMonadContrib-a4f7c29788f80c2fd2165420ebf52a5203fa8a1d.tar.xz XMonadContrib-a4f7c29788f80c2fd2165420ebf52a5203fa8a1d.zip |
[Spiral] divideRects now takes a list of directions to split in
darcs-hash:20070524090211-db939-61c879bea31e548c7cc924d8d366d84bfc0353a3.gz
Diffstat (limited to 'Spiral.hs')
-rw-r--r-- | Spiral.hs | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -22,6 +22,8 @@ mkRatios :: [Integer] -> [Rational] mkRatios (x1:x2:xs) = (x1 % x2) : mkRatios (x2:xs) mkRatios _ = [] +data Direction = East | South | West | North deriving (Enum) + spiral :: Rational -> Layout spiral scale = Layout { doLayout = fibLayout, modifyLayout = \m -> fmap resize (fromMessage m) } @@ -29,24 +31,17 @@ spiral scale = Layout { doLayout = fibLayout, fibLayout sc ws = return $ zip ws rects where len = length ws ratios = map (* scale) . reverse . take len . mkRatios $ fibs - rects = divideRects ratios len East sc - - resize Expand = spiral $ (11 % 10) * scale - resize Shrink = spiral $ (10 % 11) * scale - -data Direction = East | South | West | North + rects = divideRects ratios (cycle [East .. North]) len sc -nextDir :: Direction -> Direction -nextDir East = South -nextDir South = West -nextDir West = North -nextDir North = East + resize Expand = spiral $ (21 % 20) * scale + resize Shrink = spiral $ (20 % 21) * scale -divideRects :: [Rational] -> Int -> Direction -> Rectangle -> [Rectangle] +divideRects :: [Rational] -> [Direction] -> Int -> Rectangle -> [Rectangle] divideRects [] _ _ _ = [] -divideRects (r:rs) n dir rect | n <= 1 = [rect] - | otherwise = case divideRect r dir rect of - (r1, r2) -> r1 : (divideRects rs (n - 1) (nextDir dir) r2) +divideRects _ [] _ _ = [] +divideRects (r:rs) (d:ds) n rect | n <= 1 = [rect] + | otherwise = case divideRect r d rect of + (r1, r2) -> r1 : (divideRects rs ds (n - 1) r2) divideRect :: Rational -> Direction -> Rectangle -> (Rectangle, Rectangle) divideRect ratio East (Rectangle x y w h) = let (w1, w2) = chop ratio (fromIntegral w) in |