L.Cross: clarify documentation

Amend-record earlier patch to work with byorgey's fix,
this one is just the documentation typo fixes and 
clarifications.
This commit is contained in:
wirtwolff
2009-02-22 04:22:20 +00:00
parent edcba03217
commit 1b682cbceb

View File

@@ -9,7 +9,7 @@
-- Stability : stable -- Stability : stable
-- Portability : portable -- Portability : portable
-- --
-- A Cross Layout with a main window in the center. -- A Cross Layout with the main window in the center.
-- --
module XMonad.Layout.Cross( module XMonad.Layout.Cross(
-- * Usage -- * Usage
@@ -26,7 +26,7 @@ import Control.Monad( msum )
-- --
-- > import XMonad.Layout.Cross -- > import XMonad.Layout.Cross
-- --
-- Then edit your @layoutHook@ by adding the Spiral layout: -- Then edit your @layoutHook@ by adding one of the Cross layouts:
-- --
-- > myLayouts = simpleCross ||| etc.. -- > myLayouts = simpleCross ||| etc..
-- > main = xmonad defaultConfig { layoutHook = myLayouts } -- > main = xmonad defaultConfig { layoutHook = myLayouts }
@@ -36,31 +36,28 @@ import Control.Monad( msum )
(<%>) :: Dimension -> Rational -> Dimension (<%>) :: Dimension -> Rational -> Dimension
d <%> f = floor $ f * (fromIntegral d) d <%> f = floor $ f * (fromIntegral d)
-- | The Cross Layout draw the focused window on the center of the screen -- | The Cross Layout draws the focused window in the center of the screen
-- and part of the other windows on the sides. The 'Shrink' and 'Expand' -- and part of the other windows on the sides. The 'Shrink' and 'Expand'
-- messages increment the size of the main window. -- messages increment the size of the main window.
-- --
-- With the focus keys you change the window on the center and the other -- The focus keybindings change the center window, while other windows
-- windows put itself on the sides in a cycle way. -- cycle through the side positions. With the Cross layout only four
-- -- windows are shown around the focused window, two ups and two downs,
-- e.g: focus down put down[0] on focus, focus up put up[0] on -- no matter how many are in the current stack. I.e. focus down cycles the
-- focus. -- window below focused into the center; focus up cycles the window above.
--
-- Only five windows are shown in the Cross Layout, focus two ups and two
-- downs. Everything else is hide.
data Cross a = Cross { data Cross a = Cross {
crossProp :: !Rational, -- ^ Proportion of screen occupies for main window. crossProp :: !Rational, -- ^ Proportion of screen occupied by the main window.
crossInc :: !Rational -- ^ Percent of main window to increment by when resizing. crossInc :: !Rational -- ^ Percent of main window to increment by when resizing.
} }
deriving( Show, Read ) deriving( Show, Read )
-- | A simple Cross Layout. It has a main window with focused windos on the center. -- | A simple Cross Layout. It places the focused window in the center.
-- The proportion of screen of main window is 3\/4. -- The proportion of the screen used by the main window is 4\/5.
simpleCross :: Cross a simpleCross :: Cross a
simpleCross = Cross (4/5) (1/100) simpleCross = Cross (4/5) (1/100)
instance LayoutClass Cross a where instance LayoutClass Cross a where
pureLayout (Cross f _) r s = [(focus s, mainRect r f)] ++ pureLayout (Cross f _) r s = [(focus s, mainRect r f)] ++
(zip winCycle (upRects r f)) ++ (zip winCycle (upRects r f)) ++
(zip (reverse winCycle) (downRects r f)) (zip (reverse winCycle) (downRects r f))
where winCycle = (up s) ++ (reverse (down s)) where winCycle = (up s) ++ (reverse (down s))
@@ -74,14 +71,14 @@ instance LayoutClass Cross a where
-- get the Rectangle for the focused window -- get the Rectangle for the focused window
mainRect :: Rectangle -> Rational -> Rectangle mainRect :: Rectangle -> Rational -> Rectangle
mainRect (Rectangle rx ry rw rh) f = Rectangle mainRect (Rectangle rx ry rw rh) f = Rectangle
(rx + (fromIntegral (rw <%> invf))) (rx + (fromIntegral (rw <%> invf)))
(ry + (fromIntegral (rh <%> invf))) (ry + (fromIntegral (rh <%> invf)))
(rw <%> f) (rh <%> f) (rw <%> f) (rh <%> f)
where invf = (1/2) * (1-f) where invf = (1/2) * (1-f)
-- get the rectangles for the up windows -- get the rectangles for the up windows
upRects :: Rectangle -> Rational -> [Rectangle] upRects :: Rectangle -> Rational -> [Rectangle]
upRects r f = [topRectangle r nf, rigthRectangle r nf] upRects r f = [topRectangle r nf, rightRectangle r nf]
where nf = f * (8/10) where nf = f * (8/10)
-- get the rectangles for the down windows -- get the rectangles for the down windows
@@ -90,19 +87,19 @@ downRects r f = [bottomRectangle r nf, leftRectangle r nf]
where nf = f * (8/10) where nf = f * (8/10)
topRectangle :: Rectangle -> Rational -> Rectangle topRectangle :: Rectangle -> Rational -> Rectangle
topRectangle (Rectangle rx ry rw rh) f = Rectangle topRectangle (Rectangle rx ry rw rh) f = Rectangle
(rx + (fromIntegral (rw <%> ((1-f)*(1/2))))) (rx + (fromIntegral (rw <%> ((1-f)*(1/2)))))
ry ry
(rw <%> f) (rh <%> ((1-f)*(1/2))) (rw <%> f) (rh <%> ((1-f)*(1/2)))
rigthRectangle :: Rectangle -> Rational -> Rectangle rightRectangle :: Rectangle -> Rational -> Rectangle
rigthRectangle (Rectangle rx ry rw rh) f = Rectangle rightRectangle (Rectangle rx ry rw rh) f = Rectangle
(rx + (fromIntegral (rw - (rw <%> (1/2))))) (rx + (fromIntegral (rw - (rw <%> (1/2)))))
(ry + (fromIntegral (rh <%> ((1-f)*(1/2))))) (ry + (fromIntegral (rh <%> ((1-f)*(1/2)))))
(rw <%> (1/2)) (rh <%> f) (rw <%> (1/2)) (rh <%> f)
bottomRectangle :: Rectangle -> Rational -> Rectangle bottomRectangle :: Rectangle -> Rational -> Rectangle
bottomRectangle (Rectangle rx ry rw rh) f = Rectangle bottomRectangle (Rectangle rx ry rw rh) f = Rectangle
(rx + (fromIntegral (rw <%> ((1-f)*(1/2))))) (rx + (fromIntegral (rw <%> ((1-f)*(1/2)))))
(ry + (fromIntegral (rh - (rh <%> ((1-f)*(1/2)))))) (ry + (fromIntegral (rh - (rh <%> ((1-f)*(1/2))))))
(rw <%> f) (rh <%> ((1-f)*(1/2))) (rw <%> f) (rh <%> ((1-f)*(1/2)))