packages feed

mp-1.0.0: src/Mp/Configuration/AppColors.hs

{-
 *  Programmer:	Piotr Borek
 *  E-mail:     piotrborek@op.pl
 *  Copyright 2017 Piotr Borek
 *
 *  Distributed under the terms of the GPL (GNU Public License)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}
{-# LANGUAGE TemplateHaskell #-}

module Mp.Configuration.AppColors where

import           Control.Lens
import           Data.ConfigFile
import           Graphics.Vty                   as Vty

import           Mp.Configuration.Configuration
import           Mp.Utils.Utils

data AppColors = AppColors
    { _tabForeground              :: Vty.Color
    , _tabBackground              :: Vty.Color
    , _tabActiveForeground        :: Vty.Color
    , _tabActiveBackground        :: Vty.Color

    , _statusForeground           :: Vty.Color
    , _statusBackground           :: Vty.Color

    , _helpForeground             :: Vty.Color
    , _helpBackground             :: Vty.Color

    , _browserBackground          :: Vty.Color
    , _browserDirForeground       :: Vty.Color
    , _browserFileForeground      :: Vty.Color
    , _browserActiveBackground    :: Vty.Color
    , _browserSelectedForeground  :: Vty.Color

    , _queueForeground            :: Vty.Color
    , _queueBackground            :: Vty.Color
    , _queueActiveBackground      :: Vty.Color
    , _queueSelectedForeground    :: Vty.Color

    , _playlistBackground         :: Vty.Color
    , _playlistForeground         :: Vty.Color
    , _playlistFileForeground     :: Vty.Color
    , _playlistSelectedForeground :: Vty.Color
    , _playlistActiveBackground   :: Vty.Color

    , _editBackground             :: Vty.Color
    , _editForeground             :: Vty.Color
    }

makeLenses ''AppColors

parseColors :: ConfigParser -> AppColors
parseColors conf = AppColors
    { _tabForeground = toVtyColor $ getConfigurationColor conf "tab_foreground"
    , _tabBackground = toVtyColor $ getConfigurationColor conf "tab_background"
    , _tabActiveForeground = toVtyColor $ getConfigurationColor conf "tab_active_foreground"
    , _tabActiveBackground = toVtyColor $ getConfigurationColor conf "tab_active_background"

    , _statusForeground = toVtyColor $ getConfigurationColor conf "status_foreground"
    , _statusBackground = toVtyColor $ getConfigurationColor conf "status_background"

    , _helpForeground = toVtyColor $ getConfigurationColor conf "help_foreground"
    , _helpBackground = toVtyColor $ getConfigurationColor conf "help_background"

    , _browserBackground = toVtyColor $ getConfigurationColor conf "browser_background"
    , _browserDirForeground = toVtyColor $ getConfigurationColor conf "browser_dir_foreground"
    , _browserFileForeground = toVtyColor $ getConfigurationColor conf "browser_file_foreground"
    , _browserActiveBackground = toVtyColor $ getConfigurationColor conf "browser_active_background"
    , _browserSelectedForeground = toVtyColor $ getConfigurationColor conf "browser_selected_foreground"

    , _queueForeground = toVtyColor $ getConfigurationColor conf "queue_foreground"
    , _queueBackground = toVtyColor $ getConfigurationColor conf "queue_background"
    , _queueActiveBackground = toVtyColor $ getConfigurationColor conf "queue_active_background"
    , _queueSelectedForeground = toVtyColor $ getConfigurationColor conf "queue_selected_foreground"

    , _playlistBackground = toVtyColor $ getConfigurationColor conf "playlist_background"
    , _playlistForeground = toVtyColor $ getConfigurationColor conf "playlist_foreground"
    , _playlistFileForeground = toVtyColor $ getConfigurationColor conf "playlist_file_foreground"
    , _playlistSelectedForeground = toVtyColor $ getConfigurationColor conf "playlist_selected_foreground"
    , _playlistActiveBackground = toVtyColor $ getConfigurationColor conf "playlist_active_background"

    , _editBackground = toVtyColor $ getConfigurationColor conf "edit_background"
    , _editForeground = toVtyColor $ getConfigurationColor conf "edit_foreground"
    }