{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RecordWildCards #-}
module XMonad.Layout.DecorationEx.TabbedGeometry (
textTabbed,
TabbedGeometry (..),
HorizontalTabPlacement (..),
VerticalTabPlacement (..),
HorizontalTabWidth (..),
HorizontalTabsAlignment (..),
SingleTabMode (..)
) where
import XMonad
import qualified XMonad.StackSet as W
import XMonad.Prelude
import XMonad.Layout.Decoration (ModifiedLayout, Shrinker (..))
import XMonad.Layout.DecorationEx.LayoutModifier
import XMonad.Layout.DecorationEx.Common
import XMonad.Layout.DecorationEx.Geometry
import XMonad.Layout.DecorationEx.Widgets
import XMonad.Layout.DecorationEx.TextEngine
data HorizontalTabPlacement = Top | Bottom
deriving (HorizontalTabPlacement -> HorizontalTabPlacement -> Bool
(HorizontalTabPlacement -> HorizontalTabPlacement -> Bool)
-> (HorizontalTabPlacement -> HorizontalTabPlacement -> Bool)
-> Eq HorizontalTabPlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HorizontalTabPlacement -> HorizontalTabPlacement -> Bool
== :: HorizontalTabPlacement -> HorizontalTabPlacement -> Bool
$c/= :: HorizontalTabPlacement -> HorizontalTabPlacement -> Bool
/= :: HorizontalTabPlacement -> HorizontalTabPlacement -> Bool
Eq, ReadPrec [HorizontalTabPlacement]
ReadPrec HorizontalTabPlacement
Int -> ReadS HorizontalTabPlacement
ReadS [HorizontalTabPlacement]
(Int -> ReadS HorizontalTabPlacement)
-> ReadS [HorizontalTabPlacement]
-> ReadPrec HorizontalTabPlacement
-> ReadPrec [HorizontalTabPlacement]
-> Read HorizontalTabPlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS HorizontalTabPlacement
readsPrec :: Int -> ReadS HorizontalTabPlacement
$creadList :: ReadS [HorizontalTabPlacement]
readList :: ReadS [HorizontalTabPlacement]
$creadPrec :: ReadPrec HorizontalTabPlacement
readPrec :: ReadPrec HorizontalTabPlacement
$creadListPrec :: ReadPrec [HorizontalTabPlacement]
readListPrec :: ReadPrec [HorizontalTabPlacement]
Read, Int -> HorizontalTabPlacement -> ShowS
[HorizontalTabPlacement] -> ShowS
HorizontalTabPlacement -> String
(Int -> HorizontalTabPlacement -> ShowS)
-> (HorizontalTabPlacement -> String)
-> ([HorizontalTabPlacement] -> ShowS)
-> Show HorizontalTabPlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HorizontalTabPlacement -> ShowS
showsPrec :: Int -> HorizontalTabPlacement -> ShowS
$cshow :: HorizontalTabPlacement -> String
show :: HorizontalTabPlacement -> String
$cshowList :: [HorizontalTabPlacement] -> ShowS
showList :: [HorizontalTabPlacement] -> ShowS
Show)
data VerticalTabPlacement = TabsAtLeft | TabsAtRight
deriving (VerticalTabPlacement -> VerticalTabPlacement -> Bool
(VerticalTabPlacement -> VerticalTabPlacement -> Bool)
-> (VerticalTabPlacement -> VerticalTabPlacement -> Bool)
-> Eq VerticalTabPlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerticalTabPlacement -> VerticalTabPlacement -> Bool
== :: VerticalTabPlacement -> VerticalTabPlacement -> Bool
$c/= :: VerticalTabPlacement -> VerticalTabPlacement -> Bool
/= :: VerticalTabPlacement -> VerticalTabPlacement -> Bool
Eq, ReadPrec [VerticalTabPlacement]
ReadPrec VerticalTabPlacement
Int -> ReadS VerticalTabPlacement
ReadS [VerticalTabPlacement]
(Int -> ReadS VerticalTabPlacement)
-> ReadS [VerticalTabPlacement]
-> ReadPrec VerticalTabPlacement
-> ReadPrec [VerticalTabPlacement]
-> Read VerticalTabPlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS VerticalTabPlacement
readsPrec :: Int -> ReadS VerticalTabPlacement
$creadList :: ReadS [VerticalTabPlacement]
readList :: ReadS [VerticalTabPlacement]
$creadPrec :: ReadPrec VerticalTabPlacement
readPrec :: ReadPrec VerticalTabPlacement
$creadListPrec :: ReadPrec [VerticalTabPlacement]
readListPrec :: ReadPrec [VerticalTabPlacement]
Read, Int -> VerticalTabPlacement -> ShowS
[VerticalTabPlacement] -> ShowS
VerticalTabPlacement -> String
(Int -> VerticalTabPlacement -> ShowS)
-> (VerticalTabPlacement -> String)
-> ([VerticalTabPlacement] -> ShowS)
-> Show VerticalTabPlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerticalTabPlacement -> ShowS
showsPrec :: Int -> VerticalTabPlacement -> ShowS
$cshow :: VerticalTabPlacement -> String
show :: VerticalTabPlacement -> String
$cshowList :: [VerticalTabPlacement] -> ShowS
showList :: [VerticalTabPlacement] -> ShowS
Show)
data HorizontalTabWidth =
AutoWidth
| FixedWidth !Dimension
deriving (HorizontalTabWidth -> HorizontalTabWidth -> Bool
(HorizontalTabWidth -> HorizontalTabWidth -> Bool)
-> (HorizontalTabWidth -> HorizontalTabWidth -> Bool)
-> Eq HorizontalTabWidth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HorizontalTabWidth -> HorizontalTabWidth -> Bool
== :: HorizontalTabWidth -> HorizontalTabWidth -> Bool
$c/= :: HorizontalTabWidth -> HorizontalTabWidth -> Bool
/= :: HorizontalTabWidth -> HorizontalTabWidth -> Bool
Eq, ReadPrec [HorizontalTabWidth]
ReadPrec HorizontalTabWidth
Int -> ReadS HorizontalTabWidth
ReadS [HorizontalTabWidth]
(Int -> ReadS HorizontalTabWidth)
-> ReadS [HorizontalTabWidth]
-> ReadPrec HorizontalTabWidth
-> ReadPrec [HorizontalTabWidth]
-> Read HorizontalTabWidth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS HorizontalTabWidth
readsPrec :: Int -> ReadS HorizontalTabWidth
$creadList :: ReadS [HorizontalTabWidth]
readList :: ReadS [HorizontalTabWidth]
$creadPrec :: ReadPrec HorizontalTabWidth
readPrec :: ReadPrec HorizontalTabWidth
$creadListPrec :: ReadPrec [HorizontalTabWidth]
readListPrec :: ReadPrec [HorizontalTabWidth]
Read, Int -> HorizontalTabWidth -> ShowS
[HorizontalTabWidth] -> ShowS
HorizontalTabWidth -> String
(Int -> HorizontalTabWidth -> ShowS)
-> (HorizontalTabWidth -> String)
-> ([HorizontalTabWidth] -> ShowS)
-> Show HorizontalTabWidth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HorizontalTabWidth -> ShowS
showsPrec :: Int -> HorizontalTabWidth -> ShowS
$cshow :: HorizontalTabWidth -> String
show :: HorizontalTabWidth -> String
$cshowList :: [HorizontalTabWidth] -> ShowS
showList :: [HorizontalTabWidth] -> ShowS
Show)
data HorizontalTabsAlignment = AlignTabsLeft | AlignTabsCenter | AlignTabsRight
deriving (HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool
(HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool)
-> (HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool)
-> Eq HorizontalTabsAlignment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool
== :: HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool
$c/= :: HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool
/= :: HorizontalTabsAlignment -> HorizontalTabsAlignment -> Bool
Eq, ReadPrec [HorizontalTabsAlignment]
ReadPrec HorizontalTabsAlignment
Int -> ReadS HorizontalTabsAlignment
ReadS [HorizontalTabsAlignment]
(Int -> ReadS HorizontalTabsAlignment)
-> ReadS [HorizontalTabsAlignment]
-> ReadPrec HorizontalTabsAlignment
-> ReadPrec [HorizontalTabsAlignment]
-> Read HorizontalTabsAlignment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS HorizontalTabsAlignment
readsPrec :: Int -> ReadS HorizontalTabsAlignment
$creadList :: ReadS [HorizontalTabsAlignment]
readList :: ReadS [HorizontalTabsAlignment]
$creadPrec :: ReadPrec HorizontalTabsAlignment
readPrec :: ReadPrec HorizontalTabsAlignment
$creadListPrec :: ReadPrec [HorizontalTabsAlignment]
readListPrec :: ReadPrec [HorizontalTabsAlignment]
Read, Int -> HorizontalTabsAlignment -> ShowS
[HorizontalTabsAlignment] -> ShowS
HorizontalTabsAlignment -> String
(Int -> HorizontalTabsAlignment -> ShowS)
-> (HorizontalTabsAlignment -> String)
-> ([HorizontalTabsAlignment] -> ShowS)
-> Show HorizontalTabsAlignment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HorizontalTabsAlignment -> ShowS
showsPrec :: Int -> HorizontalTabsAlignment -> ShowS
$cshow :: HorizontalTabsAlignment -> String
show :: HorizontalTabsAlignment -> String
$cshowList :: [HorizontalTabsAlignment] -> ShowS
showList :: [HorizontalTabsAlignment] -> ShowS
Show)
data SingleTabMode = ShowTab | HideTab
deriving (SingleTabMode -> SingleTabMode -> Bool
(SingleTabMode -> SingleTabMode -> Bool)
-> (SingleTabMode -> SingleTabMode -> Bool) -> Eq SingleTabMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SingleTabMode -> SingleTabMode -> Bool
== :: SingleTabMode -> SingleTabMode -> Bool
$c/= :: SingleTabMode -> SingleTabMode -> Bool
/= :: SingleTabMode -> SingleTabMode -> Bool
Eq, ReadPrec [SingleTabMode]
ReadPrec SingleTabMode
Int -> ReadS SingleTabMode
ReadS [SingleTabMode]
(Int -> ReadS SingleTabMode)
-> ReadS [SingleTabMode]
-> ReadPrec SingleTabMode
-> ReadPrec [SingleTabMode]
-> Read SingleTabMode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS SingleTabMode
readsPrec :: Int -> ReadS SingleTabMode
$creadList :: ReadS [SingleTabMode]
readList :: ReadS [SingleTabMode]
$creadPrec :: ReadPrec SingleTabMode
readPrec :: ReadPrec SingleTabMode
$creadListPrec :: ReadPrec [SingleTabMode]
readListPrec :: ReadPrec [SingleTabMode]
Read, Int -> SingleTabMode -> ShowS
[SingleTabMode] -> ShowS
SingleTabMode -> String
(Int -> SingleTabMode -> ShowS)
-> (SingleTabMode -> String)
-> ([SingleTabMode] -> ShowS)
-> Show SingleTabMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SingleTabMode -> ShowS
showsPrec :: Int -> SingleTabMode -> ShowS
$cshow :: SingleTabMode -> String
show :: SingleTabMode -> String
$cshowList :: [SingleTabMode] -> ShowS
showList :: [SingleTabMode] -> ShowS
Show)
data TabbedGeometry a =
HorizontalTabs {
forall a. TabbedGeometry a -> SingleTabMode
showIfSingleWindow :: !SingleTabMode
, forall a. TabbedGeometry a -> HorizontalTabPlacement
hTabPlacement :: !HorizontalTabPlacement
, forall a. TabbedGeometry a -> HorizontalTabsAlignment
hTabAlignment :: !HorizontalTabsAlignment
, forall a. TabbedGeometry a -> HorizontalTabWidth
hTabWidth :: !HorizontalTabWidth
, forall a. TabbedGeometry a -> Word32
hTabHeight :: !Dimension
}
| VerticalTabs {
showIfSingleWindow :: !SingleTabMode
, forall a. TabbedGeometry a -> VerticalTabPlacement
vTabPlacement :: !VerticalTabPlacement
, forall a. TabbedGeometry a -> Word32
vTabWidth :: !Dimension
, forall a. TabbedGeometry a -> Word32
vTabHeight :: !Dimension
}
deriving (Int -> TabbedGeometry a -> ShowS
[TabbedGeometry a] -> ShowS
TabbedGeometry a -> String
(Int -> TabbedGeometry a -> ShowS)
-> (TabbedGeometry a -> String)
-> ([TabbedGeometry a] -> ShowS)
-> Show (TabbedGeometry a)
forall a. Int -> TabbedGeometry a -> ShowS
forall a. [TabbedGeometry a] -> ShowS
forall a. TabbedGeometry a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Int -> TabbedGeometry a -> ShowS
showsPrec :: Int -> TabbedGeometry a -> ShowS
$cshow :: forall a. TabbedGeometry a -> String
show :: TabbedGeometry a -> String
$cshowList :: forall a. [TabbedGeometry a] -> ShowS
showList :: [TabbedGeometry a] -> ShowS
Show, ReadPrec [TabbedGeometry a]
ReadPrec (TabbedGeometry a)
Int -> ReadS (TabbedGeometry a)
ReadS [TabbedGeometry a]
(Int -> ReadS (TabbedGeometry a))
-> ReadS [TabbedGeometry a]
-> ReadPrec (TabbedGeometry a)
-> ReadPrec [TabbedGeometry a]
-> Read (TabbedGeometry a)
forall a. ReadPrec [TabbedGeometry a]
forall a. ReadPrec (TabbedGeometry a)
forall a. Int -> ReadS (TabbedGeometry a)
forall a. ReadS [TabbedGeometry a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Int -> ReadS (TabbedGeometry a)
readsPrec :: Int -> ReadS (TabbedGeometry a)
$creadList :: forall a. ReadS [TabbedGeometry a]
readList :: ReadS [TabbedGeometry a]
$creadPrec :: forall a. ReadPrec (TabbedGeometry a)
readPrec :: ReadPrec (TabbedGeometry a)
$creadListPrec :: forall a. ReadPrec [TabbedGeometry a]
readListPrec :: ReadPrec [TabbedGeometry a]
Read)
instance Default (TabbedGeometry a) where
def :: TabbedGeometry a
def = SingleTabMode
-> HorizontalTabPlacement
-> HorizontalTabsAlignment
-> HorizontalTabWidth
-> Word32
-> TabbedGeometry a
forall a.
SingleTabMode
-> HorizontalTabPlacement
-> HorizontalTabsAlignment
-> HorizontalTabWidth
-> Word32
-> TabbedGeometry a
HorizontalTabs SingleTabMode
ShowTab HorizontalTabPlacement
Top HorizontalTabsAlignment
AlignTabsLeft HorizontalTabWidth
AutoWidth Word32
20
instance DecorationGeometry TabbedGeometry Window where
describeGeometry :: TabbedGeometry Window -> String
describeGeometry TabbedGeometry Window
_ = String
"Tabbed"
pureDecoration :: TabbedGeometry Window
-> Rectangle
-> Stack Window
-> [(Window, Rectangle)]
-> (Window, Rectangle)
-> Maybe Rectangle
pureDecoration TabbedGeometry Window
tabs Rectangle
_ Stack Window
stack [(Window, Rectangle)]
wrs (Window
window, Rectangle
windowRect) =
let Rectangle Int32
windowX Int32
windowY Word32
windowWidth Word32
windowHeight = Rectangle
windowRect
tabbedWindows :: [Window]
tabbedWindows = (Window -> Bool) -> [Window] -> [Window]
forall a. (a -> Bool) -> [a] -> [a]
filter (Window -> [Window] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ((Window, Rectangle) -> Window)
-> [(Window, Rectangle)] -> [Window]
forall a b. (a -> b) -> [a] -> [b]
map (Window, Rectangle) -> Window
forall a b. (a, b) -> a
fst (((Window, Rectangle) -> Bool)
-> [(Window, Rectangle)] -> [(Window, Rectangle)]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Rectangle -> Rectangle -> Bool
forall a. Eq a => a -> a -> Bool
==Rectangle
windowRect) (Rectangle -> Bool)
-> ((Window, Rectangle) -> Rectangle)
-> (Window, Rectangle)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Window, Rectangle) -> Rectangle
forall a b. (a, b) -> b
snd) [(Window, Rectangle)]
wrs)) (Stack Window -> [Window]
forall a. Stack a -> [a]
W.integrate Stack Window
stack)
mbWindowIndex :: Maybe Int
mbWindowIndex = Window
window Window -> [Window] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
`elemIndex` [Window]
tabbedWindows
numWindows :: Int
numWindows = [Window] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Window]
tabbedWindows
in if Int
numWindows Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1 Bool -> Bool -> Bool
|| (TabbedGeometry Window -> SingleTabMode
forall a. TabbedGeometry a -> SingleTabMode
showIfSingleWindow TabbedGeometry Window
tabs SingleTabMode -> SingleTabMode -> Bool
forall a. Eq a => a -> a -> Bool
== SingleTabMode
ShowTab Bool -> Bool -> Bool
&& Int
numWindows Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
then
case TabbedGeometry Window
tabs of
HorizontalTabs {Word32
HorizontalTabPlacement
HorizontalTabWidth
HorizontalTabsAlignment
SingleTabMode
showIfSingleWindow :: forall a. TabbedGeometry a -> SingleTabMode
hTabPlacement :: forall a. TabbedGeometry a -> HorizontalTabPlacement
hTabAlignment :: forall a. TabbedGeometry a -> HorizontalTabsAlignment
hTabWidth :: forall a. TabbedGeometry a -> HorizontalTabWidth
hTabHeight :: forall a. TabbedGeometry a -> Word32
showIfSingleWindow :: SingleTabMode
hTabPlacement :: HorizontalTabPlacement
hTabAlignment :: HorizontalTabsAlignment
hTabWidth :: HorizontalTabWidth
hTabHeight :: Word32
..} ->
Rectangle -> Maybe Rectangle
forall a. a -> Maybe a
Just (Rectangle -> Maybe Rectangle) -> Rectangle -> Maybe Rectangle
forall a b. (a -> b) -> a -> b
$ case HorizontalTabPlacement
hTabPlacement of
HorizontalTabPlacement
Top -> Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle Int32
decoX Int32
windowY Word32
effectiveTabWidth Word32
hTabHeight
HorizontalTabPlacement
Bottom -> Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle Int32
decoX (Int32
windowY Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi (Word32
windowHeight Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
hTabHeight)) Word32
effectiveTabWidth Word32
hTabHeight
where
decoX :: Int32
decoX = Int32 -> (Int -> Int32) -> Maybe Int -> Int32
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int32
windowX Int -> Int32
tabX Maybe Int
mbWindowIndex
hTabWidth' :: HorizontalTabWidth
hTabWidth' =
case HorizontalTabWidth
hTabWidth of
HorizontalTabWidth
AutoWidth -> HorizontalTabWidth
AutoWidth
FixedWidth Word32
tabWidth
| Word32
tabWidth Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
* Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fi Int
numWindows Word32 -> Word32 -> Bool
forall a. Ord a => a -> a -> Bool
> Word32
windowWidth -> HorizontalTabWidth
AutoWidth
| Bool
otherwise -> Word32 -> HorizontalTabWidth
FixedWidth Word32
tabWidth
effectiveTabWidth :: Word32
effectiveTabWidth =
case HorizontalTabWidth
hTabWidth' of
HorizontalTabWidth
AutoWidth -> Int32 -> Word32
forall a b. (Integral a, Num b) => a -> b
fi (Int32 -> Word32) -> Int32 -> Word32
forall a b. (a -> b) -> a -> b
$ Int32 -> (Int -> Int32) -> Maybe Int -> Int32
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int32
windowX (\Int
i -> Int -> Int32
tabX (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int -> Int32
tabX Int
i) Maybe Int
mbWindowIndex
FixedWidth Word32
tabWidth -> Word32
tabWidth
allTabsWidth :: Int32
allTabsWidth =
case HorizontalTabWidth
hTabWidth' of
HorizontalTabWidth
AutoWidth -> Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
windowWidth
FixedWidth Word32
_ -> Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi (Word32 -> Int32) -> Word32 -> Int32
forall a b. (a -> b) -> a -> b
$ Word32 -> Word32 -> Word32
forall a. Ord a => a -> a -> a
min Word32
windowWidth (Word32 -> Word32) -> Word32 -> Word32
forall a b. (a -> b) -> a -> b
$ Word32
effectiveTabWidth Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
* Word32 -> Word32 -> Word32
forall a. Ord a => a -> a -> a
max Word32
1 (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fi Int
numWindows)
tabsStartX :: Int32
tabsStartX =
case HorizontalTabsAlignment
hTabAlignment of
HorizontalTabsAlignment
AlignTabsLeft -> Int32
windowX
HorizontalTabsAlignment
AlignTabsRight -> Int32
windowX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
windowWidth Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
allTabsWidth
HorizontalTabsAlignment
AlignTabsCenter -> Int32
windowX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ (Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
windowWidth Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
allTabsWidth) Int32 -> Int32 -> Int32
forall a. Integral a => a -> a -> a
`div` Int32
2
tabX :: Int -> Int32
tabX Int
i = Int32
tabsStartX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+
case HorizontalTabWidth
hTabWidth' of
HorizontalTabWidth
AutoWidth -> Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi ((Word32
windowWidth Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
* Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fi Int
i) Word32 -> Word32 -> Word32
forall a. Integral a => a -> a -> a
`div` Word32 -> Word32 -> Word32
forall a. Ord a => a -> a -> a
max Word32
1 (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fi Int
numWindows))
FixedWidth Word32
_ -> Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
effectiveTabWidth Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Int
i
VerticalTabs {Word32
SingleTabMode
VerticalTabPlacement
showIfSingleWindow :: forall a. TabbedGeometry a -> SingleTabMode
vTabPlacement :: forall a. TabbedGeometry a -> VerticalTabPlacement
vTabWidth :: forall a. TabbedGeometry a -> Word32
vTabHeight :: forall a. TabbedGeometry a -> Word32
showIfSingleWindow :: SingleTabMode
vTabPlacement :: VerticalTabPlacement
vTabWidth :: Word32
vTabHeight :: Word32
..} ->
Rectangle -> Maybe Rectangle
forall a. a -> Maybe a
Just (Rectangle -> Maybe Rectangle) -> Rectangle -> Maybe Rectangle
forall a b. (a -> b) -> a -> b
$ case VerticalTabPlacement
vTabPlacement of
VerticalTabPlacement
TabsAtLeft -> Int32 -> Rectangle
fixHeightTab Int32
windowX
VerticalTabPlacement
TabsAtRight -> Int32 -> Rectangle
fixHeightTab (Int32
windowX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi (Word32
windowWidth Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
vTabWidth))
where
fixHeightLoc :: Int -> Int32
fixHeightLoc Int
i = Int32
windowY Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
vTabHeight Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Int
i
fixHeightTab :: Int32 -> Rectangle
fixHeightTab Int32
x = Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle Int32
x
(Int32 -> (Int -> Int32) -> Maybe Int -> Int32
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int32
windowY Int -> Int32
fixHeightLoc Maybe Int
mbWindowIndex) Word32
vTabWidth Word32
vTabHeight
else Maybe Rectangle
forall a. Maybe a
Nothing
shrinkWindow :: TabbedGeometry Window -> Rectangle -> Rectangle -> Rectangle
shrinkWindow TabbedGeometry Window
tabs (Rectangle Int32
_ Int32
_ Word32
dw Word32
dh) (Rectangle Int32
x Int32
y Word32
w Word32
h) =
case TabbedGeometry Window
tabs of
HorizontalTabs {Word32
HorizontalTabPlacement
HorizontalTabWidth
HorizontalTabsAlignment
SingleTabMode
showIfSingleWindow :: forall a. TabbedGeometry a -> SingleTabMode
hTabPlacement :: forall a. TabbedGeometry a -> HorizontalTabPlacement
hTabAlignment :: forall a. TabbedGeometry a -> HorizontalTabsAlignment
hTabWidth :: forall a. TabbedGeometry a -> HorizontalTabWidth
hTabHeight :: forall a. TabbedGeometry a -> Word32
showIfSingleWindow :: SingleTabMode
hTabPlacement :: HorizontalTabPlacement
hTabAlignment :: HorizontalTabsAlignment
hTabWidth :: HorizontalTabWidth
hTabHeight :: Word32
..} ->
case HorizontalTabPlacement
hTabPlacement of
HorizontalTabPlacement
Top -> Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle Int32
x (Int32
y Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
dh) Word32
w (Word32
h Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
dh)
HorizontalTabPlacement
Bottom -> Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle Int32
x Int32
y Word32
w (Word32
h Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
dh)
VerticalTabs {Word32
SingleTabMode
VerticalTabPlacement
showIfSingleWindow :: forall a. TabbedGeometry a -> SingleTabMode
vTabPlacement :: forall a. TabbedGeometry a -> VerticalTabPlacement
vTabWidth :: forall a. TabbedGeometry a -> Word32
vTabHeight :: forall a. TabbedGeometry a -> Word32
showIfSingleWindow :: SingleTabMode
vTabPlacement :: VerticalTabPlacement
vTabWidth :: Word32
vTabHeight :: Word32
..} ->
case VerticalTabPlacement
vTabPlacement of
VerticalTabPlacement
TabsAtLeft -> Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle (Int32
x Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fi Word32
dw) Int32
y (Word32
w Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
dw) Word32
h
VerticalTabPlacement
TabsAtRight -> Int32 -> Int32 -> Word32 -> Word32 -> Rectangle
Rectangle Int32
x Int32
y (Word32
w Word32 -> Word32 -> Word32
forall a. Num a => a -> a -> a
- Word32
dw) Word32
h
textTabbed :: (Shrinker shrinker)
=> shrinker
-> ThemeEx StandardWidget
-> l Window
-> ModifiedLayout (DecorationEx TextDecoration StandardWidget TabbedGeometry shrinker) l Window
textTabbed :: forall shrinker (l :: * -> *).
Shrinker shrinker =>
shrinker
-> ThemeEx StandardWidget
-> l Window
-> ModifiedLayout
(DecorationEx
TextDecoration StandardWidget TabbedGeometry shrinker)
l
Window
textTabbed shrinker
shrinker ThemeEx StandardWidget
theme = shrinker
-> Theme TextDecoration StandardWidget
-> TextDecoration StandardWidget Window
-> TabbedGeometry Window
-> l Window
-> ModifiedLayout
(DecorationEx
TextDecoration StandardWidget TabbedGeometry shrinker)
l
Window
forall (engine :: * -> * -> *) widget a (geom :: * -> *) shrinker
(l :: * -> *).
(DecorationEngine engine widget a, DecorationGeometry geom a,
Shrinker shrinker) =>
shrinker
-> Theme engine widget
-> engine widget a
-> geom a
-> l a
-> ModifiedLayout (DecorationEx engine widget geom shrinker) l a
decorationEx shrinker
shrinker ThemeEx StandardWidget
Theme TextDecoration StandardWidget
theme TextDecoration StandardWidget Window
forall widget a. TextDecoration widget a
TextDecoration TabbedGeometry Window
forall a. Default a => a
def