From e015cdafd06f7d9bfe7d10a8a1d50c641bff1165 Mon Sep 17 00:00:00 2001 From: Peter De Wachter Date: Thu, 21 Jun 2007 21:11:25 +0200 Subject: Circle cleanups darcs-hash:20070621191125-06a25-f2ca78bb2b6ecc561ee0de5d478a27f882c14caa.gz --- Circle.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Circle.hs') diff --git a/Circle.hs b/Circle.hs index 3934847..fa09e87 100644 --- a/Circle.hs +++ b/Circle.hs @@ -28,19 +28,20 @@ import StackSet (integrate) -- > import XMonadContrib.Circle circle :: Layout a -circle = Layout { doLayout = \r -> circleLayout r . integrate, +circle = Layout { doLayout = \r -> return . circleLayout r . integrate, modifyLayout = return . const Nothing } -circleLayout :: Rectangle -> [a] -> X [(a, Rectangle)] -circleLayout _ [] = return [] -circleLayout r (w:ws) = return $ (w, center r) : (zip ws sats) - where sats = map (satellite r) $ take (length ws) [0, pi * 2 / fromIntegral (length ws) ..] +circleLayout :: Rectangle -> [a] -> [(a, Rectangle)] +circleLayout _ [] = [] +circleLayout r (w:ws) = master : rest + where master = (w, center r) + rest = zip ws $ map (satellite r) [0, pi * 2 / fromIntegral (length ws) ..] center :: Rectangle -> Rectangle center (Rectangle sx sy sw sh) = Rectangle x y w h - where s = sqrt 2 - w = round ((fromIntegral sw / s) :: Double) - h = round ((fromIntegral sh / s) :: Double) + where s = sqrt 2 :: Double + w = round (fromIntegral sw / s) + h = round (fromIntegral sh / s) x = sx + fromIntegral (sw - w) `div` 2 y = sy + fromIntegral (sh - h) `div` 2 -- cgit v1.2.3