make Roledex work with Layout class

This commit is contained in:
Andrea Rossato
2007-09-25 15:32:37 +00:00
parent 1f986de3f6
commit 2c29ae74df

View File

@@ -16,14 +16,13 @@
module XMonadContrib.Roledex ( module XMonadContrib.Roledex (
-- * Usage -- * Usage
-- $usage -- $usage
roledex) where Roledex(Roledex)) where
import XMonad import XMonad
import Operations import Operations
import qualified StackSet as W import qualified StackSet as W
import Graphics.X11.Xlib import Graphics.X11.Xlib
import Data.Ratio import Data.Ratio
import XMonadContrib.LayoutHelpers ( idModify )
-- $usage -- $usage
-- --
@@ -33,10 +32,12 @@ import XMonadContrib.LayoutHelpers ( idModify )
-- %import XMonadContrib.Roledex -- %import XMonadContrib.Roledex
-- %layout , roledex -- %layout , roledex
roledex :: Eq a => Layout a data Roledex a = Roledex deriving ( Show, Read )
roledex = Layout { doLayout = roledexLayout, modifyLayout = idModify }
roledexLayout :: Eq a => Rectangle -> W.Stack a -> X ([(a, Rectangle)], Maybe (Layout a)) instance Layout Roledex Window where
doLayout _ = roledexLayout
roledexLayout :: Eq a => Rectangle -> W.Stack a -> X ([(a, Rectangle)], Maybe (Roledex a))
roledexLayout sc ws = return ([(W.focus ws, mainPane)] ++ roledexLayout sc ws = return ([(W.focus ws, mainPane)] ++
(zip ups tops) ++ (zip ups tops) ++
(reverse (zip dns bottoms)) (reverse (zip dns bottoms))
@@ -44,7 +45,7 @@ roledexLayout sc ws = return ([(W.focus ws, mainPane)] ++
where ups = W.up ws where ups = W.up ws
dns = W.down ws dns = W.down ws
c = length ups + length dns c = length ups + length dns
rect = fst $ splitHorizontallyBy (2% 3) $ fst (splitVerticallyBy (2% 3) sc) rect = fst $ splitHorizontallyBy (2%3 :: Ratio Int) $ fst (splitVerticallyBy (2%3 :: Ratio Int) sc)
gw = div' (w - rw) (fromIntegral c) gw = div' (w - rw) (fromIntegral c)
where where
(Rectangle _ _ w _) = sc (Rectangle _ _ w _) = sc