aboutsummaryrefslogtreecommitdiffstats
path: root/Spiral.hs
diff options
context:
space:
mode:
authorjoe.thornber <joe.thornber@gmail.com>2007-05-25 05:27:32 +0200
committerjoe.thornber <joe.thornber@gmail.com>2007-05-25 05:27:32 +0200
commit8e0cafeeba94abaa45a9868931d8a7c547bfa406 (patch)
treedf9d73ddf3460e01b17f3795f5df269839c2b87c /Spiral.hs
parent2e0f1062d324c73e53072aa8b979df18f8cdb59d (diff)
downloadXMonadContrib-8e0cafeeba94abaa45a9868931d8a7c547bfa406.tar.gz
XMonadContrib-8e0cafeeba94abaa45a9868931d8a7c547bfa406.tar.xz
XMonadContrib-8e0cafeeba94abaa45a9868931d8a7c547bfa406.zip
[Spiral] blend in the scale factor so it doesn't have any effect on the smallest windows
darcs-hash:20070525032732-db939-16aa2510a8dba52f8a7fdd466b78e3a9a0fba0e1.gz
Diffstat (limited to 'Spiral.hs')
-rw-r--r--Spiral.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/Spiral.hs b/Spiral.hs
index 1f6547d..c17f2cd 100644
--- a/Spiral.hs
+++ b/Spiral.hs
@@ -24,20 +24,27 @@ mkRatios _ = []
data Direction = East | South | West | North deriving (Enum)
+blend :: Rational -> [Rational] -> [Rational]
+blend scale ratios = zipWith (+) ratios scaleFactors
+ where
+ len = length ratios
+ step = (scale - (1 % 1)) / (fromIntegral len)
+ scaleFactors = map (* step) . reverse . take len $ [0..]
+
spiral :: Rational -> Layout
spiral scale = Layout { doLayout = fibLayout,
modifyLayout = \m -> fmap resize $ fromMessage m }
where
fibLayout sc ws = return $ zip ws rects
- where ratios = map (* scale) . reverse . take (length ws) . mkRatios $ fibs
+ where ratios = blend scale . reverse . take (length ws - 1) . mkRatios $ tail fibs
rects = divideRects (zip ratios (cycle [East .. North])) sc
resize Expand = spiral $ (21 % 20) * scale
resize Shrink = spiral $ (20 % 21) * scale
+-- This will produce one more rectangle than there are splits details
divideRects :: [(Rational, Direction)] -> Rectangle -> [Rectangle]
-divideRects [] _ = []
-divideRects [_] r = [r]
+divideRects [] r = [r]
divideRects ((r,d):xs) rect = case divideRect r d rect of
(r1, r2) -> r1 : (divideRects xs r2)