ThreeColumns support middle column, with more backwards compatiblity

This commit is contained in:
Adam Vogt
2009-04-14 06:18:19 +00:00
parent 71139c1fb3
commit 7410b9826c

View File

@@ -38,7 +38,7 @@ import Control.Monad
-- --
-- Then edit your @layoutHook@ by adding the ThreeCol layout: -- Then edit your @layoutHook@ by adding the ThreeCol layout:
-- --
-- > myLayouts = ThreeCol False 1 (3/100) (1/2) ||| etc.. -- > myLayouts = ThreeCol 1 (3/100) (1/2) ||| etc..
-- > main = xmonad defaultConfig { layoutHook = myLayouts } -- > main = xmonad defaultConfig { layoutHook = myLayouts }
-- --
-- If the first argument is true, the main window is placed in the center -- If the first argument is true, the main window is placed in the center
@@ -54,20 +54,28 @@ import Control.Monad
-- --
-- "XMonad.Doc.Extending#Editing_the_layout_hook" -- "XMonad.Doc.Extending#Editing_the_layout_hook"
data ThreeCol a = ThreeCol !Bool !Int !Rational !Rational deriving (Show,Read) -- | Arguments are nmaster, delta, fraction
data ThreeCol a = ThreeColMid { threeColNMaster :: !Int, threeColDelta :: !Rational, threeColFrac :: !Rational}
| ThreeCol { threeColNMaster :: !Int, threeColDelta :: !Rational, threeColFrac :: !Rational}
deriving (Show,Read)
instance LayoutClass ThreeCol a where instance LayoutClass ThreeCol a where
doLayout (ThreeCol middle nmaster _ frac) r = pureLayout (ThreeCol n _ f) r = doL False n f r
return . (\x->(x,Nothing)) . pureLayout (ThreeColMid n _ f) r = doL True n f r
ap zip (tile3 middle frac r nmaster . length) . W.integrate handleMessage l m =
handleMessage (ThreeCol middle nmaster delta frac) m =
return $ msum [fmap resize (fromMessage m) return $ msum [fmap resize (fromMessage m)
,fmap incmastern (fromMessage m)] ,fmap incmastern (fromMessage m)]
where resize Shrink = ThreeCol middle nmaster delta (max (-0.5) $ frac-delta) where resize Shrink = l { threeColFrac = max (-0.5) $ f-d }
resize Expand = ThreeCol middle nmaster delta (min 1 $ frac+delta) resize Expand = l { threeColFrac = min 1 $ f+d }
incmastern (IncMasterN d) = ThreeCol middle (max 0 (nmaster+d)) delta frac incmastern (IncMasterN x) = l { threeColNMaster = max 0 (n+x) }
n = threeColNMaster l
d = threeColDelta l
f = threeColFrac l
description _ = "ThreeCol" description _ = "ThreeCol"
doL :: Bool-> Int-> Rational-> Rectangle-> W.Stack a-> [(a, Rectangle)]
doL m n f r = ap zip (tile3 m f r n . length) . W.integrate
-- | tile3. Compute window positions using 3 panes -- | tile3. Compute window positions using 3 panes
tile3 :: Bool -> Rational -> Rectangle -> Int -> Int -> [Rectangle] tile3 :: Bool -> Rational -> Rectangle -> Int -> Int -> [Rectangle]
tile3 middle f r nmaster n tile3 middle f r nmaster n