module XMonad.Layout.Tabbed
(
simpleTabbed, tabbed, addTabs
, simpleTabbedBottom, tabbedBottom, addTabsBottom
, Theme (..)
, defaultTheme
, TabbedDecoration (..)
, shrinkText, CustomShrink(CustomShrink)
, Shrinker(..)
) where
import Data.Maybe
import Data.List
import XMonad
import qualified XMonad.StackSet as S
import XMonad.Layout.Decoration
import XMonad.Layout.Simplest ( Simplest(Simplest) )
simpleTabbed :: ModifiedLayout (Decoration TabbedDecoration DefaultShrinker) Simplest Window
simpleTabbed = decoration shrinkText defaultTheme Tabbed Simplest
simpleTabbedBottom :: ModifiedLayout (Decoration TabbedDecoration DefaultShrinker) Simplest Window
simpleTabbedBottom = decoration shrinkText defaultTheme TabbedBottom Simplest
tabbed :: (Eq a, Shrinker s) => s -> Theme
-> ModifiedLayout (Decoration TabbedDecoration s) Simplest a
tabbed s c = decoration s c Tabbed Simplest
tabbedBottom :: (Eq a, Shrinker s) => s -> Theme
-> ModifiedLayout (Decoration TabbedDecoration s) Simplest a
tabbedBottom s c = decoration s c TabbedBottom Simplest
addTabs :: (Eq a, LayoutClass l a, Shrinker s) => s -> Theme -> l a
-> ModifiedLayout (Decoration TabbedDecoration s) l a
addTabs s c l = decoration s c Tabbed l
addTabsBottom :: (Eq a, LayoutClass l a, Shrinker s) => s -> Theme -> l a
-> ModifiedLayout (Decoration TabbedDecoration s) l a
addTabsBottom s c l = decoration s c TabbedBottom l
data TabbedDecoration a = Tabbed | TabbedBottom deriving (Read, Show)
instance Eq a => DecorationStyle TabbedDecoration a where
describeDeco Tabbed = "Tabbed"
describeDeco TabbedBottom = "Tabbed Bottom"
decorationMouseDragHook _ _ _ = return ()
pureDecoration ds _ ht _ s wrs (w,r@(Rectangle x y wh hh)) =
if length ws <= 1
then Nothing
else Just $ case ds of
Tabbed -> Rectangle nx y wid (fi ht)
TabbedBottom -> Rectangle nx (y+fi(hhht)) wid (fi ht)
where ws = filter (`elem` map fst (filter ((==r) . snd) wrs)) (S.integrate s)
loc i = x + fi ((wh * fi i) `div` max 1 (fi $ length ws))
wid = fi $ maybe x (\i -> loc (i+1) loc i) $ w `elemIndex` ws
nx = maybe x loc $ w `elemIndex` ws
shrink ds (Rectangle _ _ _ dh) (Rectangle x y w h) = case ds of
Tabbed -> Rectangle x (y + fi dh) w (h dh)
TabbedBottom -> Rectangle x y w (h dh)