{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# LANGUAGE MultiParamTypeClasses, Rank2Types, TypeFamilies #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Layout.Groups.Examples
-- Description :  Example layouts for "XMonad.Layout.Groups".
-- Copyright   :  Quentin Moser <moserq@gmail.com>
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  orphaned
-- Stability   :  unstable
-- Portability :  unportable
--
-- Example layouts for "XMonad.Layout.Groups".
--
-----------------------------------------------------------------------------

module XMonad.Layout.Groups.Examples ( -- * Usage
                                       -- $usage

                                       -- * Example: Row of columns
                                       -- $example1
                                       rowOfColumns
                                     , zoomColumnIn
                                     , zoomColumnOut
                                     , zoomColumnReset
                                     , toggleColumnFull
                                     , zoomWindowIn
                                     , zoomWindowOut
                                     , zoomWindowReset
                                     , toggleWindowFull

                                       -- * Example: Tiled tab groups
                                       -- $example2
                                     , tallTabs
                                     , mirrorTallTabs
                                     , fullTabs
                                     , TiledTabsConfig(..)
                                     , def
                                     , increaseNMasterGroups
                                     , decreaseNMasterGroups
                                     , shrinkMasterGroups
                                     , expandMasterGroups
                                     , nextOuterLayout


                                       -- * Useful re-exports and utils
                                     , module XMonad.Layout.Groups.Helpers
                                     , shrinkText
                                     , GroupEQ(..)
                                     , zoomRowG
                                     ) where

import XMonad

import qualified XMonad.Layout.Groups as G
import XMonad.Layout.Groups.Helpers

import XMonad.Layout.ZoomRow
import XMonad.Layout.Tabbed
import XMonad.Layout.Named
import XMonad.Layout.Renamed
import XMonad.Layout.Decoration
import XMonad.Layout.Simplest


-- $usage
-- This module contains example 'G.Groups'-based layouts.
-- You can either import this module directly, or look at its source
-- for ideas of how "XMonad.Layout.Groups" may be used.
--
-- You can use the contents of this module by adding
--
-- > import XMonad.Layout.Groups.Examples
--
-- to the top of your @.\/.xmonad\/xmonad.hs@.
--
-- For more information on using any of the layouts, jump directly
--   to its \"Example\" section.
--
-- Whichever layout you choose to use, you will probably want to be
--   able to move focus and windows between groups in a consistent
--   manner. For this, you should take a look at the functions from
--   the "XMonad.Layout.Groups.Helpers" module, which are all
--   re-exported by this module.
--
-- For more information on how to extend your layour hook and key bindings, see
--   "XMonad.Doc.Extending".


-- * Helper: ZoomRow of Group elements

-- | Compare two 'Group's by comparing the ids of their layouts.
data GroupEQ a = GroupEQ
  deriving (Int -> GroupEQ a -> ShowS
[GroupEQ a] -> ShowS
GroupEQ a -> String
(Int -> GroupEQ a -> ShowS)
-> (GroupEQ a -> String)
-> ([GroupEQ a] -> ShowS)
-> Show (GroupEQ a)
forall a. Int -> GroupEQ a -> ShowS
forall a. [GroupEQ a] -> ShowS
forall a. GroupEQ a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupEQ a] -> ShowS
$cshowList :: forall a. [GroupEQ a] -> ShowS
show :: GroupEQ a -> String
$cshow :: forall a. GroupEQ a -> String
showsPrec :: Int -> GroupEQ a -> ShowS
$cshowsPrec :: forall a. Int -> GroupEQ a -> ShowS
Show, ReadPrec [GroupEQ a]
ReadPrec (GroupEQ a)
Int -> ReadS (GroupEQ a)
ReadS [GroupEQ a]
(Int -> ReadS (GroupEQ a))
-> ReadS [GroupEQ a]
-> ReadPrec (GroupEQ a)
-> ReadPrec [GroupEQ a]
-> Read (GroupEQ a)
forall a. ReadPrec [GroupEQ a]
forall a. ReadPrec (GroupEQ a)
forall a. Int -> ReadS (GroupEQ a)
forall a. ReadS [GroupEQ a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupEQ a]
$creadListPrec :: forall a. ReadPrec [GroupEQ a]
readPrec :: ReadPrec (GroupEQ a)
$creadPrec :: forall a. ReadPrec (GroupEQ a)
readList :: ReadS [GroupEQ a]
$creadList :: forall a. ReadS [GroupEQ a]
readsPrec :: Int -> ReadS (GroupEQ a)
$creadsPrec :: forall a. Int -> ReadS (GroupEQ a)
Read)

instance Eq a => EQF GroupEQ (G.Group l a) where
    eq :: GroupEQ (Group l a) -> Group l a -> Group l a -> Bool
eq GroupEQ (Group l a)
_ (G.G WithID l a
l1 Zipper a
_) (G.G WithID l a
l2 Zipper a
_) = WithID l a -> WithID l a -> Bool
forall (l :: * -> *) a. WithID l a -> WithID l a -> Bool
G.sameID WithID l a
l1 WithID l a
l2

zoomRowG :: (Eq a, Show a, Read a, Show (l a), Read (l a))
            => ZoomRow GroupEQ (G.Group l a)
zoomRowG :: forall a (l :: * -> *).
(Eq a, Show a, Read a, Show (l a), Read (l a)) =>
ZoomRow GroupEQ (Group l a)
zoomRowG = GroupEQ (Group l a) -> ZoomRow GroupEQ (Group l a)
forall (f :: * -> *) a.
(EQF f a, Show (f a), Read (f a), Show a, Read a) =>
f a -> ZoomRow f a
zoomRowWith GroupEQ (Group l a)
forall a. GroupEQ a
GroupEQ


-- * Example 1: Row of columns

-- $example1
-- A layout that arranges windows in a row of columns. It uses 'ZoomRow's for
-- both, allowing you to:
--
--  * Freely change the proportion of the screen width allocated to each column
--
--  * Freely change the proportion of a column's heigth allocated to each of its windows
--
--  * Set a column to occupy the whole screen space whenever it has focus
--
--  * Set a window to occupy its whole column whenever it has focus
--
-- to use this layout, add 'rowOfColumns' to your layout hook, for example:
--
-- > myLayout = rowOfColumns
--
-- To be able to change the sizes of columns and windows, you can create key bindings
-- for the relevant actions:
--
-- > ((modMask, xK_minus), zoomWindowOut)
--
-- and so on.

rowOfColumns :: Groups
  (ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)))
  (ZoomRow GroupEQ)
  Window
rowOfColumns = ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)) Window
-> ZoomRow
     GroupEQ
     (Group (ModifiedLayout Rename (Mirror (ZoomRow ClassEQ))) Window)
-> Groups
     (ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)))
     (ZoomRow GroupEQ)
     Window
forall (l :: * -> *) (l2 :: * -> *).
l Window -> l2 (Group l Window) -> Groups l l2 Window
G.group ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)) Window
column ZoomRow
  GroupEQ
  (Group (ModifiedLayout Rename (Mirror (ZoomRow ClassEQ))) Window)
forall a (l :: * -> *).
(Eq a, Show a, Read a, Show (l a), Read (l a)) =>
ZoomRow GroupEQ (Group l a)
zoomRowG
    where column :: ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)) Window
column = [Rename Window]
-> Mirror (ZoomRow ClassEQ) Window
-> ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)) Window
forall a (l :: * -> *).
[Rename a] -> l a -> ModifiedLayout Rename l a
renamed [Int -> Rename Window
forall a. Int -> Rename a
CutWordsLeft Int
2, String -> Rename Window
forall a. String -> Rename a
PrependWords String
"ZoomColumn"] (Mirror (ZoomRow ClassEQ) Window
 -> ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)) Window)
-> Mirror (ZoomRow ClassEQ) Window
-> ModifiedLayout Rename (Mirror (ZoomRow ClassEQ)) Window
forall a b. (a -> b) -> a -> b
$ ZoomRow ClassEQ Window -> Mirror (ZoomRow ClassEQ) Window
forall (l :: * -> *) a. l a -> Mirror l a
Mirror ZoomRow ClassEQ Window
forall a. (Eq a, Show a, Read a) => ZoomRow ClassEQ a
zoomRow

-- | Increase the width of the focused column
zoomColumnIn :: X ()
zoomColumnIn :: X ()
zoomColumnIn = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ ZoomMessage -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage ZoomMessage
zoomIn

-- | Decrease the width of the focused column
zoomColumnOut :: X ()
zoomColumnOut :: X ()
zoomColumnOut = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ ZoomMessage -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage ZoomMessage
zoomOut

-- | Reset the width of the focused column
zoomColumnReset :: X ()
zoomColumnReset :: X ()
zoomColumnReset = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ ZoomMessage -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage ZoomMessage
zoomReset

-- | Toggle whether the currently focused column should
-- take up all available space whenever it has focus
toggleColumnFull :: X ()
toggleColumnFull :: X ()
toggleColumnFull = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ ZoomMessage -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage ZoomMessage
ZoomFullToggle

-- | Increase the heigth of the focused window
zoomWindowIn :: X ()
zoomWindowIn :: X ()
zoomWindowIn = ZoomMessage -> X ()
forall a. Message a => a -> X ()
sendMessage ZoomMessage
zoomIn

-- | Decrease the height of the focused window
zoomWindowOut :: X ()
zoomWindowOut :: X ()
zoomWindowOut = ZoomMessage -> X ()
forall a. Message a => a -> X ()
sendMessage ZoomMessage
zoomOut

-- | Reset the height of the focused window
zoomWindowReset :: X ()
zoomWindowReset :: X ()
zoomWindowReset = ZoomMessage -> X ()
forall a. Message a => a -> X ()
sendMessage ZoomMessage
zoomReset

-- | Toggle whether the currently focused window should
-- take up the whole column whenever it has focus
toggleWindowFull :: X ()
toggleWindowFull :: X ()
toggleWindowFull = ZoomMessage -> X ()
forall a. Message a => a -> X ()
sendMessage ZoomMessage
ZoomFullToggle


-- * Example 2: Tabbed groups in a Tall/Full layout.

-- $example2
-- A layout which arranges windows into tabbed groups, and the groups
-- themselves according to XMonad's default algorithm
-- (@'Tall' ||| 'Mirror' 'Tall' ||| 'Full'@). As their names
-- indicate, 'tallTabs' starts as 'Tall', 'mirrorTallTabs' starts
-- as 'Mirror' 'Tall' and 'fullTabs' starts as 'Full', but in any
-- case you can freely switch between the three afterwards.
--
-- You can use any of these three layouts by including it in your layout hook.
-- You will need to provide it with a 'TiledTabsConfig' containing the size
-- parameters for 'Tall' and 'Mirror' 'Tall', and the shrinker and decoration theme
-- for the tabs. If you're happy with defaults, you can use 'def':
--
-- > myLayout = tallTabs def
--
-- To be able to increase\/decrease the number of master groups and shrink\/expand
-- the master area, you can create key bindings for the relevant actions:
--
-- > ((modMask, xK_h), shrinkMasterGroups)
--
-- and so on.

-- | Configuration data for the "tiled tab groups" layout
data TiledTabsConfig s = TTC { forall s. TiledTabsConfig s -> Int
vNMaster :: Int
                             , forall s. TiledTabsConfig s -> Rational
vRatio :: Rational
                             , forall s. TiledTabsConfig s -> Rational
vIncrement :: Rational
                             , forall s. TiledTabsConfig s -> Int
hNMaster :: Int
                             , forall s. TiledTabsConfig s -> Rational
hRatio :: Rational
                             , forall s. TiledTabsConfig s -> Rational
hIncrement :: Rational
                             , forall s. TiledTabsConfig s -> s
tabsShrinker :: s
                             , forall s. TiledTabsConfig s -> Theme
tabsTheme :: Theme }

instance s ~ DefaultShrinker => Default (TiledTabsConfig s) where
    def :: TiledTabsConfig s
def = Int
-> Rational
-> Rational
-> Int
-> Rational
-> Rational
-> DefaultShrinker
-> Theme
-> TiledTabsConfig DefaultShrinker
forall s.
Int
-> Rational
-> Rational
-> Int
-> Rational
-> Rational
-> s
-> Theme
-> TiledTabsConfig s
TTC Int
1 Rational
0.5 (Rational
3Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/Rational
100) Int
1 Rational
0.5 (Rational
3Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/Rational
100) DefaultShrinker
shrinkText Theme
forall a. Default a => a
def

fullTabs :: TiledTabsConfig s
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              Full
              (Choose
                 (ModifiedLayout Rename Tall)
                 (ModifiedLayout Rename (Mirror Tall))))))
     Window
fullTabs TiledTabsConfig s
c = TiledTabsConfig s
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        Full
        (Choose
           (ModifiedLayout Rename Tall)
           (ModifiedLayout Rename (Mirror Tall))))
     Window
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              Full
              (Choose
                 (ModifiedLayout Rename Tall)
                 (ModifiedLayout Rename (Mirror Tall))))))
     Window
forall {a} {l :: * -> *} {s}.
(Eq a, LayoutClass l a, Shrinker s) =>
TiledTabsConfig s
-> l a
-> ModifiedLayout
     Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a
_tab TiledTabsConfig s
c (Groups
   (ModifiedLayout Rename Simplest)
   (Choose
      Full
      (Choose
         (ModifiedLayout Rename Tall)
         (ModifiedLayout Rename (Mirror Tall))))
   Window
 -> ModifiedLayout
      Rename
      (ModifiedLayout
         (Decoration TabbedDecoration s)
         (Groups
            (ModifiedLayout Rename Simplest)
            (Choose
               Full
               (Choose
                  (ModifiedLayout Rename Tall)
                  (ModifiedLayout Rename (Mirror Tall))))))
      Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        Full
        (Choose
           (ModifiedLayout Rename Tall)
           (ModifiedLayout Rename (Mirror Tall))))
     Window
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              Full
              (Choose
                 (ModifiedLayout Rename Tall)
                 (ModifiedLayout Rename (Mirror Tall))))))
     Window
forall a b. (a -> b) -> a -> b
$ ModifiedLayout Rename Simplest Window
-> Choose
     Full
     (Choose
        (ModifiedLayout Rename Tall) (ModifiedLayout Rename (Mirror Tall)))
     (Group (ModifiedLayout Rename Simplest) Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        Full
        (Choose
           (ModifiedLayout Rename Tall)
           (ModifiedLayout Rename (Mirror Tall))))
     Window
forall (l :: * -> *) (l2 :: * -> *).
l Window -> l2 (Group l Window) -> Groups l l2 Window
G.group ModifiedLayout Rename Simplest Window
forall {a}. ModifiedLayout Rename Simplest a
_tabs (Choose
   Full
   (Choose
      (ModifiedLayout Rename Tall) (ModifiedLayout Rename (Mirror Tall)))
   (Group (ModifiedLayout Rename Simplest) Window)
 -> Groups
      (ModifiedLayout Rename Simplest)
      (Choose
         Full
         (Choose
            (ModifiedLayout Rename Tall)
            (ModifiedLayout Rename (Mirror Tall))))
      Window)
-> Choose
     Full
     (Choose
        (ModifiedLayout Rename Tall) (ModifiedLayout Rename (Mirror Tall)))
     (Group (ModifiedLayout Rename Simplest) Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        Full
        (Choose
           (ModifiedLayout Rename Tall)
           (ModifiedLayout Rename (Mirror Tall))))
     Window
forall a b. (a -> b) -> a -> b
$ Full (Group (ModifiedLayout Rename Simplest) Window)
forall a. Full a
Full Full (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     (ModifiedLayout Rename Tall)
     (ModifiedLayout Rename (Mirror Tall))
     (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     Full
     (Choose
        (ModifiedLayout Rename Tall) (ModifiedLayout Rename (Mirror Tall)))
     (Group (ModifiedLayout Rename Simplest) Window)
forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
||| TiledTabsConfig s
-> ModifiedLayout
     Rename Tall (Group (ModifiedLayout Rename Simplest) Window)
forall {s} {a}. TiledTabsConfig s -> ModifiedLayout Rename Tall a
_vert TiledTabsConfig s
c ModifiedLayout
  Rename Tall (Group (ModifiedLayout Rename Simplest) Window)
-> ModifiedLayout
     Rename
     (Mirror Tall)
     (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     (ModifiedLayout Rename Tall)
     (ModifiedLayout Rename (Mirror Tall))
     (Group (ModifiedLayout Rename Simplest) Window)
forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
||| TiledTabsConfig s
-> ModifiedLayout
     Rename
     (Mirror Tall)
     (Group (ModifiedLayout Rename Simplest) Window)
forall {s} {a}.
TiledTabsConfig s -> ModifiedLayout Rename (Mirror Tall) a
_horiz TiledTabsConfig s
c

tallTabs :: TiledTabsConfig s
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              (ModifiedLayout Rename Tall)
              (Choose (ModifiedLayout Rename (Mirror Tall)) Full))))
     Window
tallTabs TiledTabsConfig s
c = TiledTabsConfig s
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename Tall)
        (Choose (ModifiedLayout Rename (Mirror Tall)) Full))
     Window
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              (ModifiedLayout Rename Tall)
              (Choose (ModifiedLayout Rename (Mirror Tall)) Full))))
     Window
forall {a} {l :: * -> *} {s}.
(Eq a, LayoutClass l a, Shrinker s) =>
TiledTabsConfig s
-> l a
-> ModifiedLayout
     Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a
_tab TiledTabsConfig s
c (Groups
   (ModifiedLayout Rename Simplest)
   (Choose
      (ModifiedLayout Rename Tall)
      (Choose (ModifiedLayout Rename (Mirror Tall)) Full))
   Window
 -> ModifiedLayout
      Rename
      (ModifiedLayout
         (Decoration TabbedDecoration s)
         (Groups
            (ModifiedLayout Rename Simplest)
            (Choose
               (ModifiedLayout Rename Tall)
               (Choose (ModifiedLayout Rename (Mirror Tall)) Full))))
      Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename Tall)
        (Choose (ModifiedLayout Rename (Mirror Tall)) Full))
     Window
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              (ModifiedLayout Rename Tall)
              (Choose (ModifiedLayout Rename (Mirror Tall)) Full))))
     Window
forall a b. (a -> b) -> a -> b
$ ModifiedLayout Rename Simplest Window
-> Choose
     (ModifiedLayout Rename Tall)
     (Choose (ModifiedLayout Rename (Mirror Tall)) Full)
     (Group (ModifiedLayout Rename Simplest) Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename Tall)
        (Choose (ModifiedLayout Rename (Mirror Tall)) Full))
     Window
forall (l :: * -> *) (l2 :: * -> *).
l Window -> l2 (Group l Window) -> Groups l l2 Window
G.group ModifiedLayout Rename Simplest Window
forall {a}. ModifiedLayout Rename Simplest a
_tabs (Choose
   (ModifiedLayout Rename Tall)
   (Choose (ModifiedLayout Rename (Mirror Tall)) Full)
   (Group (ModifiedLayout Rename Simplest) Window)
 -> Groups
      (ModifiedLayout Rename Simplest)
      (Choose
         (ModifiedLayout Rename Tall)
         (Choose (ModifiedLayout Rename (Mirror Tall)) Full))
      Window)
-> Choose
     (ModifiedLayout Rename Tall)
     (Choose (ModifiedLayout Rename (Mirror Tall)) Full)
     (Group (ModifiedLayout Rename Simplest) Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename Tall)
        (Choose (ModifiedLayout Rename (Mirror Tall)) Full))
     Window
forall a b. (a -> b) -> a -> b
$ TiledTabsConfig s
-> ModifiedLayout
     Rename Tall (Group (ModifiedLayout Rename Simplest) Window)
forall {s} {a}. TiledTabsConfig s -> ModifiedLayout Rename Tall a
_vert TiledTabsConfig s
c ModifiedLayout
  Rename Tall (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     (ModifiedLayout Rename (Mirror Tall))
     Full
     (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     (ModifiedLayout Rename Tall)
     (Choose (ModifiedLayout Rename (Mirror Tall)) Full)
     (Group (ModifiedLayout Rename Simplest) Window)
forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
||| TiledTabsConfig s
-> ModifiedLayout
     Rename
     (Mirror Tall)
     (Group (ModifiedLayout Rename Simplest) Window)
forall {s} {a}.
TiledTabsConfig s -> ModifiedLayout Rename (Mirror Tall) a
_horiz TiledTabsConfig s
c ModifiedLayout
  Rename
  (Mirror Tall)
  (Group (ModifiedLayout Rename Simplest) Window)
-> Full (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     (ModifiedLayout Rename (Mirror Tall))
     Full
     (Group (ModifiedLayout Rename Simplest) Window)
forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
||| Full (Group (ModifiedLayout Rename Simplest) Window)
forall a. Full a
Full

mirrorTallTabs :: TiledTabsConfig s
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              (ModifiedLayout Rename (Mirror Tall))
              (Choose Full (ModifiedLayout Rename Tall)))))
     Window
mirrorTallTabs TiledTabsConfig s
c = TiledTabsConfig s
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename (Mirror Tall))
        (Choose Full (ModifiedLayout Rename Tall)))
     Window
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              (ModifiedLayout Rename (Mirror Tall))
              (Choose Full (ModifiedLayout Rename Tall)))))
     Window
forall {a} {l :: * -> *} {s}.
(Eq a, LayoutClass l a, Shrinker s) =>
TiledTabsConfig s
-> l a
-> ModifiedLayout
     Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a
_tab TiledTabsConfig s
c (Groups
   (ModifiedLayout Rename Simplest)
   (Choose
      (ModifiedLayout Rename (Mirror Tall))
      (Choose Full (ModifiedLayout Rename Tall)))
   Window
 -> ModifiedLayout
      Rename
      (ModifiedLayout
         (Decoration TabbedDecoration s)
         (Groups
            (ModifiedLayout Rename Simplest)
            (Choose
               (ModifiedLayout Rename (Mirror Tall))
               (Choose Full (ModifiedLayout Rename Tall)))))
      Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename (Mirror Tall))
        (Choose Full (ModifiedLayout Rename Tall)))
     Window
-> ModifiedLayout
     Rename
     (ModifiedLayout
        (Decoration TabbedDecoration s)
        (Groups
           (ModifiedLayout Rename Simplest)
           (Choose
              (ModifiedLayout Rename (Mirror Tall))
              (Choose Full (ModifiedLayout Rename Tall)))))
     Window
forall a b. (a -> b) -> a -> b
$ ModifiedLayout Rename Simplest Window
-> Choose
     (ModifiedLayout Rename (Mirror Tall))
     (Choose Full (ModifiedLayout Rename Tall))
     (Group (ModifiedLayout Rename Simplest) Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename (Mirror Tall))
        (Choose Full (ModifiedLayout Rename Tall)))
     Window
forall (l :: * -> *) (l2 :: * -> *).
l Window -> l2 (Group l Window) -> Groups l l2 Window
G.group ModifiedLayout Rename Simplest Window
forall {a}. ModifiedLayout Rename Simplest a
_tabs (Choose
   (ModifiedLayout Rename (Mirror Tall))
   (Choose Full (ModifiedLayout Rename Tall))
   (Group (ModifiedLayout Rename Simplest) Window)
 -> Groups
      (ModifiedLayout Rename Simplest)
      (Choose
         (ModifiedLayout Rename (Mirror Tall))
         (Choose Full (ModifiedLayout Rename Tall)))
      Window)
-> Choose
     (ModifiedLayout Rename (Mirror Tall))
     (Choose Full (ModifiedLayout Rename Tall))
     (Group (ModifiedLayout Rename Simplest) Window)
-> Groups
     (ModifiedLayout Rename Simplest)
     (Choose
        (ModifiedLayout Rename (Mirror Tall))
        (Choose Full (ModifiedLayout Rename Tall)))
     Window
forall a b. (a -> b) -> a -> b
$ TiledTabsConfig s
-> ModifiedLayout
     Rename
     (Mirror Tall)
     (Group (ModifiedLayout Rename Simplest) Window)
forall {s} {a}.
TiledTabsConfig s -> ModifiedLayout Rename (Mirror Tall) a
_horiz TiledTabsConfig s
c ModifiedLayout
  Rename
  (Mirror Tall)
  (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     Full
     (ModifiedLayout Rename Tall)
     (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     (ModifiedLayout Rename (Mirror Tall))
     (Choose Full (ModifiedLayout Rename Tall))
     (Group (ModifiedLayout Rename Simplest) Window)
forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
||| Full (Group (ModifiedLayout Rename Simplest) Window)
forall a. Full a
Full Full (Group (ModifiedLayout Rename Simplest) Window)
-> ModifiedLayout
     Rename Tall (Group (ModifiedLayout Rename Simplest) Window)
-> Choose
     Full
     (ModifiedLayout Rename Tall)
     (Group (ModifiedLayout Rename Simplest) Window)
forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
||| TiledTabsConfig s
-> ModifiedLayout
     Rename Tall (Group (ModifiedLayout Rename Simplest) Window)
forall {s} {a}. TiledTabsConfig s -> ModifiedLayout Rename Tall a
_vert TiledTabsConfig s
c

_tabs :: ModifiedLayout Rename Simplest a
_tabs = String -> Simplest a -> ModifiedLayout Rename Simplest a
forall (l :: * -> *) a. String -> l a -> ModifiedLayout Rename l a
named String
"Tabs" Simplest a
forall a. Simplest a
Simplest

_tab :: TiledTabsConfig s
-> l a
-> ModifiedLayout
     Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a
_tab TiledTabsConfig s
c l a
l = [Rename a]
-> ModifiedLayout (Decoration TabbedDecoration s) l a
-> ModifiedLayout
     Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a
forall a (l :: * -> *).
[Rename a] -> l a -> ModifiedLayout Rename l a
renamed [Int -> Rename a
forall a. Int -> Rename a
CutWordsLeft Int
1] (ModifiedLayout (Decoration TabbedDecoration s) l a
 -> ModifiedLayout
      Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a)
-> ModifiedLayout (Decoration TabbedDecoration s) l a
-> ModifiedLayout
     Rename (ModifiedLayout (Decoration TabbedDecoration s) l) a
forall a b. (a -> b) -> a -> b
$ s
-> Theme
-> l a
-> ModifiedLayout (Decoration TabbedDecoration s) l a
forall a (l :: * -> *) s.
(Eq a, LayoutClass l a, Shrinker s) =>
s
-> Theme
-> l a
-> ModifiedLayout (Decoration TabbedDecoration s) l a
addTabs (TiledTabsConfig s -> s
forall s. TiledTabsConfig s -> s
tabsShrinker TiledTabsConfig s
c) (TiledTabsConfig s -> Theme
forall s. TiledTabsConfig s -> Theme
tabsTheme TiledTabsConfig s
c) l a
l

_vert :: TiledTabsConfig s -> ModifiedLayout Rename Tall a
_vert TiledTabsConfig s
c = String -> Tall a -> ModifiedLayout Rename Tall a
forall (l :: * -> *) a. String -> l a -> ModifiedLayout Rename l a
named String
"Vertical" (Tall a -> ModifiedLayout Rename Tall a)
-> Tall a -> ModifiedLayout Rename Tall a
forall a b. (a -> b) -> a -> b
$ Int -> Rational -> Rational -> Tall a
forall a. Int -> Rational -> Rational -> Tall a
Tall (TiledTabsConfig s -> Int
forall s. TiledTabsConfig s -> Int
vNMaster TiledTabsConfig s
c) (TiledTabsConfig s -> Rational
forall s. TiledTabsConfig s -> Rational
vIncrement TiledTabsConfig s
c) (TiledTabsConfig s -> Rational
forall s. TiledTabsConfig s -> Rational
vRatio TiledTabsConfig s
c)

_horiz :: TiledTabsConfig s -> ModifiedLayout Rename (Mirror Tall) a
_horiz TiledTabsConfig s
c = String -> Mirror Tall a -> ModifiedLayout Rename (Mirror Tall) a
forall (l :: * -> *) a. String -> l a -> ModifiedLayout Rename l a
named String
"Horizontal" (Mirror Tall a -> ModifiedLayout Rename (Mirror Tall) a)
-> Mirror Tall a -> ModifiedLayout Rename (Mirror Tall) a
forall a b. (a -> b) -> a -> b
$ Tall a -> Mirror Tall a
forall (l :: * -> *) a. l a -> Mirror l a
Mirror (Tall a -> Mirror Tall a) -> Tall a -> Mirror Tall a
forall a b. (a -> b) -> a -> b
$ Int -> Rational -> Rational -> Tall a
forall a. Int -> Rational -> Rational -> Tall a
Tall (TiledTabsConfig s -> Int
forall s. TiledTabsConfig s -> Int
hNMaster TiledTabsConfig s
c) (TiledTabsConfig s -> Rational
forall s. TiledTabsConfig s -> Rational
hIncrement TiledTabsConfig s
c) (TiledTabsConfig s -> Rational
forall s. TiledTabsConfig s -> Rational
hRatio TiledTabsConfig s
c)

-- | Increase the number of master groups by one
increaseNMasterGroups :: X ()
increaseNMasterGroups :: X ()
increaseNMasterGroups = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ IncMasterN -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage (IncMasterN -> SomeMessage) -> IncMasterN -> SomeMessage
forall a b. (a -> b) -> a -> b
$ Int -> IncMasterN
IncMasterN Int
1

-- | Decrease the number of master groups by one
decreaseNMasterGroups :: X ()
decreaseNMasterGroups :: X ()
decreaseNMasterGroups = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ IncMasterN -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage (IncMasterN -> SomeMessage) -> IncMasterN -> SomeMessage
forall a b. (a -> b) -> a -> b
$ Int -> IncMasterN
IncMasterN (-Int
1)

-- | Shrink the master area
shrinkMasterGroups :: X ()
shrinkMasterGroups :: X ()
shrinkMasterGroups = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ Resize -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage Resize
Shrink

-- | Expand the master area
expandMasterGroups :: X ()
expandMasterGroups :: X ()
expandMasterGroups = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ Resize -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage Resize
Expand

-- | Rotate the available outer layout algorithms
nextOuterLayout :: X ()
nextOuterLayout :: X ()
nextOuterLayout = GroupsMessage -> X ()
forall a. Message a => a -> X ()
sendMessage (GroupsMessage -> X ()) -> GroupsMessage -> X ()
forall a b. (a -> b) -> a -> b
$ SomeMessage -> GroupsMessage
G.ToEnclosing (SomeMessage -> GroupsMessage) -> SomeMessage -> GroupsMessage
forall a b. (a -> b) -> a -> b
$ ChangeLayout -> SomeMessage
forall a. Message a => a -> SomeMessage
SomeMessage ChangeLayout
NextLayout