-- | Module    : Hum.Attributes
-- Copyright   : (c) Itai Y. Efrat 2020-2021
-- License     : GPLv2-or-later (see LICENSE)
-- Maintainer  : Itai Y. Efrat <itai3397@gmail.com>
--
-- Brick/Vty color attributes.

module Hum.Attributes where

import           Brick.AttrMap
import           Brick.Types
import           Brick.Widgets.Core
import           Brick.Widgets.List             ( listAttr
                                                , listSelectedAttr
                                                , listSelectedFocusedAttr
                                                )
import qualified Brick.Util                    as BU
import           Graphics.Vty                   ( defAttr )
import qualified Graphics.Vty                  as Vty

humAttrMap :: AttrMap
humAttrMap :: AttrMap
humAttrMap = Attr -> [(AttrName, Attr)] -> AttrMap
attrMap
  Attr
defAttr
  [ (AttrName
listAttr               , Attr -> Style -> Attr
Vty.withStyle (Color -> Attr
BU.fg Color
Vty.white) Style
Vty.defaultStyleMask)
  , (AttrName
listSelectedAttr       , Attr -> Style -> Attr
Vty.withStyle Attr
defAttr Style
Vty.underline)
  , (AttrName
listSelectedFocusedAttr, Attr -> Style -> Attr
Vty.withStyle Attr
defAttr Style
Vty.reverseVideo)
  , (AttrName
listHighlightedAttr    , Color -> Attr
BU.fg Color
Vty.yellow)
  , (AttrName
headerAttr             , Attr -> Style -> Attr
Vty.withStyle Attr
defAttr Style
Vty.underline)
  , (AttrName
albumAttr              , Color -> Attr
BU.fg Color
Vty.red)
  , (AttrName
trackAttr              , Color -> Attr
BU.fg Color
Vty.magenta)
  , (AttrName
titleAttr              , Color -> Attr
BU.fg Color
Vty.cyan)
  , (AttrName
artistAttr             , Color -> Attr
BU.fg Color
Vty.green)
  , (AttrName
timeAttr               , Color -> Attr
BU.fg Color
Vty.blue)
  , (AttrName
dateAttr               , Color -> Attr
BU.fg Color
Vty.yellow)
  , ( AttrName
queueNowPlayingAttr   , Attr -> Style -> Attr
Vty.withStyle
                                (Attr -> Style -> Attr
Vty.withStyle Attr
defAttr Style
Vty.bold) Style
Vty.underline)
  , (AttrName
titleBoldAttr          , Attr -> Style -> Attr
Vty.withStyle Attr
defAttr Style
Vty.bold)
  , (AttrName
editorAttr             , Color -> Attr
BU.bg Color
Vty.black)
  , (AttrName
searchAttr             , Attr -> Style -> Attr
Vty.withStyle Attr
defAttr Style
Vty.reverseVideo)
  , (AttrName
searchFocusedAttr      , Color -> Attr
BU.fg Color
Vty.red)
  ]

wobAttr :: Vty.Attr
wobAttr :: Attr
wobAttr = Color -> Attr
BU.fg Color
Vty.white

queueAttr, albumAttr, titleAttr, trackAttr, artistAttr, timeAttr, dateAttr
  :: AttrName
queueAttr :: AttrName
queueAttr = AttrName
"queue"
albumAttr :: AttrName
albumAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"album"
titleAttr :: AttrName
titleAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"title"
trackAttr :: AttrName
trackAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"track"
artistAttr :: AttrName
artistAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"artist"
timeAttr :: AttrName
timeAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"time"
dateAttr :: AttrName
dateAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"date"

headerAttr :: AttrName
headerAttr :: AttrName
headerAttr = AttrName
"header"

listHighlightedAttr :: AttrName
listHighlightedAttr :: AttrName
listHighlightedAttr = AttrName
listAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"highlighted"
queueNowPlayingAttr :: AttrName
queueNowPlayingAttr :: AttrName
queueNowPlayingAttr = AttrName
queueAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"now playing"

titleBoldAttr :: AttrName
titleBoldAttr :: AttrName
titleBoldAttr = AttrName
titleAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"bold"

editorAttr :: AttrName
editorAttr :: AttrName
editorAttr = AttrName
"editor"

searchAttr, searchFocusedAttr  :: AttrName
searchAttr :: AttrName
searchAttr = AttrName
"search"
searchFocusedAttr :: AttrName
searchFocusedAttr = AttrName
searchAttr AttrName -> AttrName -> AttrName
forall a. Semigroup a => a -> a -> a
<> AttrName
"focus"

-- | Overwrites attributes for item to be highlighted.
highlightOverAttrs :: Widget n -> Widget n -- HACK?
highlightOverAttrs :: Widget n -> Widget n
highlightOverAttrs = (AttrMap -> AttrMap) -> Widget n -> Widget n
forall n. (AttrMap -> AttrMap) -> Widget n -> Widget n
updateAttrMap
  ([(AttrName, AttrName)] -> AttrMap -> AttrMap
mapAttrNames
    (   (AttrName
listHighlightedAttr, )
    (AttrName -> (AttrName, AttrName))
-> [AttrName] -> [(AttrName, AttrName)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ AttrName
albumAttr
        , AttrName
trackAttr
        , AttrName
titleAttr
        , AttrName
artistAttr
        , AttrName
timeAttr
        ]
    )
  )