{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module XMonad.Layout.SimpleDecoration
(
simpleDeco
, Theme (..)
, def
, SimpleDecoration (..)
, shrinkText, CustomShrink(CustomShrink)
, Shrinker(..)
) where
import XMonad
import XMonad.Layout.Decoration
simpleDeco :: (Eq a, Shrinker s) => s -> Theme
-> l a -> ModifiedLayout (Decoration SimpleDecoration s) l a
simpleDeco :: forall a s (l :: * -> *).
(Eq a, Shrinker s) =>
s
-> Theme
-> l a
-> ModifiedLayout (Decoration SimpleDecoration s) l a
simpleDeco s
s Theme
c = forall (ds :: * -> *) a s (l :: * -> *).
(DecorationStyle ds a, Shrinker s) =>
s -> Theme -> ds a -> l a -> ModifiedLayout (Decoration ds s) l a
decoration s
s Theme
c forall a b. (a -> b) -> a -> b
$ forall a. Bool -> SimpleDecoration a
Simple Bool
True
newtype SimpleDecoration a = Simple Bool deriving (Int -> SimpleDecoration a -> ShowS
forall a. Int -> SimpleDecoration a -> ShowS
forall a. [SimpleDecoration a] -> ShowS
forall a. SimpleDecoration a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleDecoration a] -> ShowS
$cshowList :: forall a. [SimpleDecoration a] -> ShowS
show :: SimpleDecoration a -> String
$cshow :: forall a. SimpleDecoration a -> String
showsPrec :: Int -> SimpleDecoration a -> ShowS
$cshowsPrec :: forall a. Int -> SimpleDecoration a -> ShowS
Show, ReadPrec [SimpleDecoration a]
ReadPrec (SimpleDecoration a)
ReadS [SimpleDecoration a]
forall a. ReadPrec [SimpleDecoration a]
forall a. ReadPrec (SimpleDecoration a)
forall a. Int -> ReadS (SimpleDecoration a)
forall a. ReadS [SimpleDecoration a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimpleDecoration a]
$creadListPrec :: forall a. ReadPrec [SimpleDecoration a]
readPrec :: ReadPrec (SimpleDecoration a)
$creadPrec :: forall a. ReadPrec (SimpleDecoration a)
readList :: ReadS [SimpleDecoration a]
$creadList :: forall a. ReadS [SimpleDecoration a]
readsPrec :: Int -> ReadS (SimpleDecoration a)
$creadsPrec :: forall a. Int -> ReadS (SimpleDecoration a)
Read)
instance Eq a => DecorationStyle SimpleDecoration a where
describeDeco :: SimpleDecoration a -> String
describeDeco SimpleDecoration a
_ = String
"Simple"
shrink :: SimpleDecoration a -> Rectangle -> Rectangle -> Rectangle
shrink (Simple Bool
b) (Rectangle Position
_ Position
_ Dimension
_ Dimension
dh) r :: Rectangle
r@(Rectangle Position
x Position
y Dimension
w Dimension
h) =
if Bool
b then Position -> Position -> Dimension -> Dimension -> Rectangle
Rectangle Position
x (Position
y forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Dimension
dh) Dimension
w (Dimension
h forall a. Num a => a -> a -> a
- Dimension
dh) else Rectangle
r
pureDecoration :: SimpleDecoration a
-> Dimension
-> Dimension
-> Rectangle
-> Stack a
-> [(a, Rectangle)]
-> (a, Rectangle)
-> Maybe Rectangle
pureDecoration (Simple Bool
b) Dimension
wh Dimension
ht Rectangle
_ Stack a
s [(a, Rectangle)]
_ (a
w,Rectangle Position
x Position
y Dimension
wid Dimension
_) =
if forall a. Eq a => Stack a -> a -> Bool
isInStack Stack a
s a
w
then if Bool
b
then forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Position -> Position -> Dimension -> Dimension -> Rectangle
Rectangle Position
x Position
y Dimension
nwh Dimension
ht
else forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Position -> Position -> Dimension -> Dimension -> Rectangle
Rectangle Position
x (Position
y forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Dimension
ht) Dimension
nwh Dimension
ht
else forall a. Maybe a
Nothing
where nwh :: Dimension
nwh = forall a. Ord a => a -> a -> a
min Dimension
wid Dimension
wh