{-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Layout.MultiToggle.TabBarDecoration
-- Copyright   :  (c) 2018  Lucian Poston
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  <lucianposton@pm.me>
-- Stability   :  unstable
-- Portability :  unportable
--
-- Provides a simple transformer for use with "XMonad.Layout.MultiToggle" to
-- dynamically toggle "XMonad.Layout.TabBarDecoration".
-----------------------------------------------------------------------------

module XMonad.Layout.MultiToggle.TabBarDecoration (
    SimpleTabBar(..)
) where

import XMonad.Layout.MultiToggle

import XMonad
import XMonad.Layout.LayoutModifier
import XMonad.Layout.TabBarDecoration

-- $usage
-- To use this module with "XMonad.Layout.MultiToggle", add the @SIMPLETABBAR@
-- to your layout For example, from a basic layout like
--
-- > layout = tiled ||| Full
--
-- Add @SIMPLETABBAR@ by changing it this to
--
-- > layout = mkToggle (single SIMPLETABBAR) (tiled ||| Full)
--
-- You can now dynamically toggle the 'XMonad.Layout.TabBarDecoration'
-- transformation by adding a key binding such as @mod-x@ as follows.
--
-- > ...
-- >   , ((modm,               xK_x     ), sendMessage $ Toggle SIMPLETABBAR)
-- > ...

-- | Transformer for "XMonad.Layout.TabBarDecoration".
data SimpleTabBar = SIMPLETABBAR deriving (ReadPrec [SimpleTabBar]
ReadPrec SimpleTabBar
Int -> ReadS SimpleTabBar
ReadS [SimpleTabBar]
(Int -> ReadS SimpleTabBar)
-> ReadS [SimpleTabBar]
-> ReadPrec SimpleTabBar
-> ReadPrec [SimpleTabBar]
-> Read SimpleTabBar
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS SimpleTabBar
readsPrec :: Int -> ReadS SimpleTabBar
$creadList :: ReadS [SimpleTabBar]
readList :: ReadS [SimpleTabBar]
$creadPrec :: ReadPrec SimpleTabBar
readPrec :: ReadPrec SimpleTabBar
$creadListPrec :: ReadPrec [SimpleTabBar]
readListPrec :: ReadPrec [SimpleTabBar]
Read, Int -> SimpleTabBar -> ShowS
[SimpleTabBar] -> ShowS
SimpleTabBar -> String
(Int -> SimpleTabBar -> ShowS)
-> (SimpleTabBar -> String)
-> ([SimpleTabBar] -> ShowS)
-> Show SimpleTabBar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SimpleTabBar -> ShowS
showsPrec :: Int -> SimpleTabBar -> ShowS
$cshow :: SimpleTabBar -> String
show :: SimpleTabBar -> String
$cshowList :: [SimpleTabBar] -> ShowS
showList :: [SimpleTabBar] -> ShowS
Show, SimpleTabBar -> SimpleTabBar -> Bool
(SimpleTabBar -> SimpleTabBar -> Bool)
-> (SimpleTabBar -> SimpleTabBar -> Bool) -> Eq SimpleTabBar
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SimpleTabBar -> SimpleTabBar -> Bool
== :: SimpleTabBar -> SimpleTabBar -> Bool
$c/= :: SimpleTabBar -> SimpleTabBar -> Bool
/= :: SimpleTabBar -> SimpleTabBar -> Bool
Eq)
instance Transformer SimpleTabBar Window where
    transform :: forall (l :: * -> *) b.
LayoutClass l Window =>
SimpleTabBar
-> l Window
-> (forall (l' :: * -> *).
    LayoutClass l' Window =>
    l' Window -> (l' Window -> l Window) -> b)
-> b
transform SimpleTabBar
_ l Window
x forall (l' :: * -> *).
LayoutClass l' Window =>
l' Window -> (l' Window -> l Window) -> b
k = ModifiedLayout
  (Decoration TabBarDecoration DefaultShrinker)
  (ModifiedLayout ResizeScreen l)
  Window
-> (ModifiedLayout
      (Decoration TabBarDecoration DefaultShrinker)
      (ModifiedLayout ResizeScreen l)
      Window
    -> l Window)
-> b
forall (l' :: * -> *).
LayoutClass l' Window =>
l' Window -> (l' Window -> l Window) -> b
k (l Window
-> ModifiedLayout
     (Decoration TabBarDecoration DefaultShrinker)
     (ModifiedLayout ResizeScreen l)
     Window
forall a (l :: * -> *).
Eq a =>
l a
-> ModifiedLayout
     (Decoration TabBarDecoration DefaultShrinker)
     (ModifiedLayout ResizeScreen l)
     a
simpleTabBar l Window
x) (\(ModifiedLayout Decoration TabBarDecoration DefaultShrinker Window
_ (ModifiedLayout ResizeScreen Window
_ l Window
x')) -> l Window
x')