From 45508f6a368c123d538a9a17343b12b61f13e3a6 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Mon, 18 Feb 2008 19:09:22 +0100 Subject: TabBarDecoration: simpleTabBar automatically applies resizeVertical Added some comments too. darcs-hash:20080218180922-32816-48097596437bbc30cd3414a7555fa5cf55ecec75.gz --- XMonad/Layout/DecorationMadness.hs | 10 +++++----- XMonad/Layout/TabBarDecoration.hs | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Layout/DecorationMadness.hs b/XMonad/Layout/DecorationMadness.hs index 611e918..6a616a3 100644 --- a/XMonad/Layout/DecorationMadness.hs +++ b/XMonad/Layout/DecorationMadness.hs @@ -222,7 +222,7 @@ circleDwmStyle s t = decoration s t Dwm Circle -- -- circleSimpleTabbed :: ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) (ModifiedLayout ResizeScreen Circle) Window -circleSimpleTabbed = simpleTabBar (resizeVertical 20 Circle) +circleSimpleTabbed = simpleTabBar Circle -- | Similar to 'circleSimpleTabbed' but with the -- possibility of setting a custom shrinker and a custom theme. @@ -315,7 +315,7 @@ accordionDwmStyle s t = decoration s t Dwm Accordion -- -- accordionSimpleTabbed :: ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) (ModifiedLayout ResizeScreen Accordion) Window -accordionSimpleTabbed = simpleTabBar (resizeVertical 20 Accordion) +accordionSimpleTabbed = simpleTabBar Accordion -- | Similar to 'accordionSimpleTabbed' but with the -- possibility of setting a custom shrinker and a custom theme. @@ -419,7 +419,7 @@ tallDwmStyle s t = decoration s t Dwm tall -- -- tallSimpleTabbed :: ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) (ModifiedLayout ResizeScreen Tall) Window -tallSimpleTabbed = simpleTabBar (resizeVertical 20 tall) +tallSimpleTabbed = simpleTabBar tall -- | Similar to 'tallSimpleTabbed' but with the -- possibility of setting a custom shrinker and a custom theme. @@ -522,7 +522,7 @@ mirrorTallDwmStyle s t = decoration s t Dwm mirrorTall -- -- mirrorTallSimpleTabbed :: ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) (ModifiedLayout ResizeScreen (Mirror Tall)) Window -mirrorTallSimpleTabbed = simpleTabBar (resizeVertical 20 mirrorTall) +mirrorTallSimpleTabbed = simpleTabBar mirrorTall -- | Similar to 'mirrorTallSimpleTabbed' but with the -- possibility of setting a custom shrinker and a custom theme. @@ -590,7 +590,7 @@ floatDwmStyle s t = decoration s t Dwm (mouseResize $ windowArrangeAll $ SF (dec -- floatSimpleTabbed :: (Show a, Eq a) => ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) (ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a -floatSimpleTabbed = simpleTabBar (mouseResize $ windowArrangeAll $ SF 20) +floatSimpleTabbed = tabBar shrinkText defaultTheme Top (mouseResize $ windowArrangeAll $ SF 20) -- | Same as 'floatSimpleTabbed', but with the possibility of setting a -- custom shrinker and a custom theme. diff --git a/XMonad/Layout/TabBarDecoration.hs b/XMonad/Layout/TabBarDecoration.hs index 00cfd03..0bae9ef 100644 --- a/XMonad/Layout/TabBarDecoration.hs +++ b/XMonad/Layout/TabBarDecoration.hs @@ -18,13 +18,16 @@ module XMonad.Layout.TabBarDecoration simpleTabBar, tabBar , defaultTheme, shrinkText , TabBarDecoration (..), XPPosition (..) + , module XMonad.Layout.ResizeScreen ) where import Data.List import XMonad import qualified XMonad.StackSet as S import XMonad.Layout.Decoration +import XMonad.Layout.ResizeScreen import XMonad.Prompt ( XPPosition (..) ) + -- $usage -- You can use this module with the following in your -- @~\/.xmonad\/xmonad.hs@: @@ -46,9 +49,15 @@ import XMonad.Prompt ( XPPosition (..) ) -- selector. See "XMonad.Prompt.Theme". For more themse, look at -- "XMonad.Util.Themes" -simpleTabBar :: Eq a => l a -> ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) l a -simpleTabBar = decoration shrinkText defaultTheme (TabBar Top) +-- | Add, on the top of the screen, a simple bar of tabs to a given +-- | layout, with the default theme and the default shrinker. +simpleTabBar :: Eq a => l a -> ModifiedLayout (Decoration TabBarDecoration DefaultShrinker) + (ModifiedLayout ResizeScreen l) a +simpleTabBar = decoration shrinkText defaultTheme (TabBar Top) . resizeVertical 20 +-- | Same of 'simpleTabBar', but with the possibility of setting a +-- custom shrinker, a custom theme and the position: 'Top' or +-- 'Bottom'. tabBar :: (Eq a, Shrinker s) => s -> Theme -> XPPosition -> l a -> ModifiedLayout (Decoration TabBarDecoration s) l a tabBar s t p = decoration s t (TabBar p) @@ -61,10 +70,11 @@ instance Eq a => DecorationStyle TabBarDecoration a where decorationMouseDragHook _ _ _ = return () pureDecoration (TabBar p) _ dht (Rectangle x y wh ht) s _ (w,_) = if isInStack s w then Just $ Rectangle nx ny nwh (fi dht) else Nothing - where nwh = wh `div` max 1 (fi $ length $ S.integrate s) - ny = case p of + where wrs = S.integrate s + nwh = wh `div` max 1 (fi $ length wrs) + ny = case p of Top -> y Bottom -> y + fi ht - fi dht - nx = case w `elemIndex` (S.integrate s) of + nx = case w `elemIndex` wrs of Just i -> x + (fi nwh * fi i) Nothing -> x -- cgit v1.2.3