{-|
Module      : Monomer.Widgets.Util.Theme
Copyright   : (c) 2018 Francisco Vallarino
License     : BSD-3-Clause (see the LICENSE file)
Maintainer  : fjvallarino@gmail.com
Stability   : experimental
Portability : non-portable

Helper functions for loading theme values.
-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Strict #-}

module Monomer.Widgets.Util.Theme where

import Control.Lens (Lens', (&), (^.), (.~), (<>~), at, non)
import Data.Default

import Monomer.Core.StyleTypes
import Monomer.Core.ThemeTypes
import Monomer.Core.WidgetTypes

import qualified Monomer.Core.Lens as L

-- | Updates a the field of style with the field value from the active theme.
collectThemeField_
  :: WidgetEnv s e               -- ^ The widget environment (to get the theme).
  -> Lens' StyleState (Maybe t)  -- ^ The target field of the style.
  -> Lens' ThemeState (Maybe t)  -- ^ The source field of the theme.
  -> Style                       -- ^ The target style.
  -> Style                       -- ^ The updated style.
collectThemeField_ :: forall s e t.
WidgetEnv s e
-> Lens' StyleState (Maybe t)
-> Lens' ThemeState (Maybe t)
-> Style
-> Style
collectThemeField_ WidgetEnv s e
wenv Lens' StyleState (Maybe t)
fieldStyle Lens' ThemeState (Maybe t)
fieldTheme Style
target = Style
style where
  basic :: Maybe StyleState
basic = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ Style
target Style -> Getting StyleState Style StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Style -> Const StyleState Style
forall s a. HasBasic s a => Lens' s a
Lens' Style (Maybe StyleState)
L.basic ((Maybe StyleState -> Const StyleState (Maybe StyleState))
 -> Style -> Const StyleState Style)
-> ((StyleState -> Const StyleState StyleState)
    -> Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Getting StyleState Style StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyleState -> Iso' (Maybe StyleState) StyleState
forall a. Eq a => a -> Iso' (Maybe a) a
non StyleState
forall a. Default a => a
def
    StyleState -> (StyleState -> StyleState) -> StyleState
forall a b. a -> (a -> b) -> b
& (Maybe t -> Identity (Maybe t))
-> StyleState -> Identity StyleState
Lens' StyleState (Maybe t)
fieldStyle ((Maybe t -> Identity (Maybe t))
 -> StyleState -> Identity StyleState)
-> Maybe t -> StyleState -> StyleState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ WidgetEnv s e
wenv WidgetEnv s e
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t) -> Maybe t
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe t) Theme)
-> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe t) Theme)
 -> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e))
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> Theme -> Const (Maybe t) Theme)
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const (Maybe t) ThemeState)
-> Theme -> Const (Maybe t) Theme
forall s a. HasBasic s a => Lens' s a
Lens' Theme ThemeState
L.basic ((ThemeState -> Const (Maybe t) ThemeState)
 -> Theme -> Const (Maybe t) Theme)
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> ThemeState -> Const (Maybe t) ThemeState)
-> (Maybe t -> Const (Maybe t) (Maybe t))
-> Theme
-> Const (Maybe t) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe t -> Const (Maybe t) (Maybe t))
-> ThemeState -> Const (Maybe t) ThemeState
Lens' ThemeState (Maybe t)
fieldTheme
  hover :: Maybe StyleState
hover = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ Style
target Style -> Getting StyleState Style StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Style -> Const StyleState Style
forall s a. HasHover s a => Lens' s a
Lens' Style (Maybe StyleState)
L.hover ((Maybe StyleState -> Const StyleState (Maybe StyleState))
 -> Style -> Const StyleState Style)
-> ((StyleState -> Const StyleState StyleState)
    -> Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Getting StyleState Style StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyleState -> Iso' (Maybe StyleState) StyleState
forall a. Eq a => a -> Iso' (Maybe a) a
non StyleState
forall a. Default a => a
def
    StyleState -> (StyleState -> StyleState) -> StyleState
forall a b. a -> (a -> b) -> b
& (Maybe t -> Identity (Maybe t))
-> StyleState -> Identity StyleState
Lens' StyleState (Maybe t)
fieldStyle ((Maybe t -> Identity (Maybe t))
 -> StyleState -> Identity StyleState)
-> Maybe t -> StyleState -> StyleState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ WidgetEnv s e
wenv WidgetEnv s e
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t) -> Maybe t
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe t) Theme)
-> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe t) Theme)
 -> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e))
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> Theme -> Const (Maybe t) Theme)
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const (Maybe t) ThemeState)
-> Theme -> Const (Maybe t) Theme
forall s a. HasHover s a => Lens' s a
Lens' Theme ThemeState
L.hover ((ThemeState -> Const (Maybe t) ThemeState)
 -> Theme -> Const (Maybe t) Theme)
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> ThemeState -> Const (Maybe t) ThemeState)
-> (Maybe t -> Const (Maybe t) (Maybe t))
-> Theme
-> Const (Maybe t) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe t -> Const (Maybe t) (Maybe t))
-> ThemeState -> Const (Maybe t) ThemeState
Lens' ThemeState (Maybe t)
fieldTheme
  focus :: Maybe StyleState
focus = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ Style
target Style -> Getting StyleState Style StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Style -> Const StyleState Style
forall s a. HasFocus s a => Lens' s a
Lens' Style (Maybe StyleState)
L.focus ((Maybe StyleState -> Const StyleState (Maybe StyleState))
 -> Style -> Const StyleState Style)
-> ((StyleState -> Const StyleState StyleState)
    -> Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Getting StyleState Style StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyleState -> Iso' (Maybe StyleState) StyleState
forall a. Eq a => a -> Iso' (Maybe a) a
non StyleState
forall a. Default a => a
def
    StyleState -> (StyleState -> StyleState) -> StyleState
forall a b. a -> (a -> b) -> b
& (Maybe t -> Identity (Maybe t))
-> StyleState -> Identity StyleState
Lens' StyleState (Maybe t)
fieldStyle ((Maybe t -> Identity (Maybe t))
 -> StyleState -> Identity StyleState)
-> Maybe t -> StyleState -> StyleState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ WidgetEnv s e
wenv WidgetEnv s e
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t) -> Maybe t
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe t) Theme)
-> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe t) Theme)
 -> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e))
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> Theme -> Const (Maybe t) Theme)
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const (Maybe t) ThemeState)
-> Theme -> Const (Maybe t) Theme
forall s a. HasFocus s a => Lens' s a
Lens' Theme ThemeState
L.focus ((ThemeState -> Const (Maybe t) ThemeState)
 -> Theme -> Const (Maybe t) Theme)
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> ThemeState -> Const (Maybe t) ThemeState)
-> (Maybe t -> Const (Maybe t) (Maybe t))
-> Theme
-> Const (Maybe t) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe t -> Const (Maybe t) (Maybe t))
-> ThemeState -> Const (Maybe t) ThemeState
Lens' ThemeState (Maybe t)
fieldTheme
  focusHover :: Maybe StyleState
focusHover = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ Style
target Style -> Getting StyleState Style StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Style -> Const StyleState Style
forall s a. HasFocusHover s a => Lens' s a
Lens' Style (Maybe StyleState)
L.focusHover ((Maybe StyleState -> Const StyleState (Maybe StyleState))
 -> Style -> Const StyleState Style)
-> ((StyleState -> Const StyleState StyleState)
    -> Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Getting StyleState Style StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyleState -> Iso' (Maybe StyleState) StyleState
forall a. Eq a => a -> Iso' (Maybe a) a
non StyleState
forall a. Default a => a
def
    StyleState -> (StyleState -> StyleState) -> StyleState
forall a b. a -> (a -> b) -> b
& (Maybe t -> Identity (Maybe t))
-> StyleState -> Identity StyleState
Lens' StyleState (Maybe t)
fieldStyle ((Maybe t -> Identity (Maybe t))
 -> StyleState -> Identity StyleState)
-> Maybe t -> StyleState -> StyleState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ WidgetEnv s e
wenv WidgetEnv s e
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t) -> Maybe t
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe t) Theme)
-> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe t) Theme)
 -> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e))
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> Theme -> Const (Maybe t) Theme)
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const (Maybe t) ThemeState)
-> Theme -> Const (Maybe t) Theme
forall s a. HasFocusHover s a => Lens' s a
Lens' Theme ThemeState
L.focusHover ((ThemeState -> Const (Maybe t) ThemeState)
 -> Theme -> Const (Maybe t) Theme)
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> ThemeState -> Const (Maybe t) ThemeState)
-> (Maybe t -> Const (Maybe t) (Maybe t))
-> Theme
-> Const (Maybe t) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe t -> Const (Maybe t) (Maybe t))
-> ThemeState -> Const (Maybe t) ThemeState
Lens' ThemeState (Maybe t)
fieldTheme
  active :: Maybe StyleState
active = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ Style
target Style -> Getting StyleState Style StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Style -> Const StyleState Style
forall s a. HasActive s a => Lens' s a
Lens' Style (Maybe StyleState)
L.active ((Maybe StyleState -> Const StyleState (Maybe StyleState))
 -> Style -> Const StyleState Style)
-> ((StyleState -> Const StyleState StyleState)
    -> Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Getting StyleState Style StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyleState -> Iso' (Maybe StyleState) StyleState
forall a. Eq a => a -> Iso' (Maybe a) a
non StyleState
forall a. Default a => a
def
    StyleState -> (StyleState -> StyleState) -> StyleState
forall a b. a -> (a -> b) -> b
& (Maybe t -> Identity (Maybe t))
-> StyleState -> Identity StyleState
Lens' StyleState (Maybe t)
fieldStyle ((Maybe t -> Identity (Maybe t))
 -> StyleState -> Identity StyleState)
-> Maybe t -> StyleState -> StyleState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ WidgetEnv s e
wenv WidgetEnv s e
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t) -> Maybe t
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe t) Theme)
-> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe t) Theme)
 -> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e))
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> Theme -> Const (Maybe t) Theme)
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const (Maybe t) ThemeState)
-> Theme -> Const (Maybe t) Theme
forall s a. HasActive s a => Lens' s a
Lens' Theme ThemeState
L.active ((ThemeState -> Const (Maybe t) ThemeState)
 -> Theme -> Const (Maybe t) Theme)
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> ThemeState -> Const (Maybe t) ThemeState)
-> (Maybe t -> Const (Maybe t) (Maybe t))
-> Theme
-> Const (Maybe t) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe t -> Const (Maybe t) (Maybe t))
-> ThemeState -> Const (Maybe t) ThemeState
Lens' ThemeState (Maybe t)
fieldTheme
  disabled :: Maybe StyleState
disabled = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ Style
target Style -> Getting StyleState Style StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Style -> Const StyleState Style
forall s a. HasDisabled s a => Lens' s a
Lens' Style (Maybe StyleState)
L.disabled ((Maybe StyleState -> Const StyleState (Maybe StyleState))
 -> Style -> Const StyleState Style)
-> ((StyleState -> Const StyleState StyleState)
    -> Maybe StyleState -> Const StyleState (Maybe StyleState))
-> Getting StyleState Style StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyleState -> Iso' (Maybe StyleState) StyleState
forall a. Eq a => a -> Iso' (Maybe a) a
non StyleState
forall a. Default a => a
def
    StyleState -> (StyleState -> StyleState) -> StyleState
forall a b. a -> (a -> b) -> b
& (Maybe t -> Identity (Maybe t))
-> StyleState -> Identity StyleState
Lens' StyleState (Maybe t)
fieldStyle ((Maybe t -> Identity (Maybe t))
 -> StyleState -> Identity StyleState)
-> Maybe t -> StyleState -> StyleState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ WidgetEnv s e
wenv WidgetEnv s e
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t) -> Maybe t
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe t) Theme)
-> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe t) Theme)
 -> WidgetEnv s e -> Const (Maybe t) (WidgetEnv s e))
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> Theme -> Const (Maybe t) Theme)
-> Getting (Maybe t) (WidgetEnv s e) (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const (Maybe t) ThemeState)
-> Theme -> Const (Maybe t) Theme
forall s a. HasDisabled s a => Lens' s a
Lens' Theme ThemeState
L.disabled ((ThemeState -> Const (Maybe t) ThemeState)
 -> Theme -> Const (Maybe t) Theme)
-> ((Maybe t -> Const (Maybe t) (Maybe t))
    -> ThemeState -> Const (Maybe t) ThemeState)
-> (Maybe t -> Const (Maybe t) (Maybe t))
-> Theme
-> Const (Maybe t) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe t -> Const (Maybe t) (Maybe t))
-> ThemeState -> Const (Maybe t) ThemeState
Lens' ThemeState (Maybe t)
fieldTheme
  style :: Style
style = Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Style
Style Maybe StyleState
basic Maybe StyleState
hover Maybe StyleState
focus Maybe StyleState
focusHover Maybe StyleState
active Maybe StyleState
disabled

-- | Collects all the style states from a given field in the active theme.
collectTheme
  :: WidgetEnv s e               -- ^ The widget environment (to get the theme).
  -> Lens' ThemeState StyleState -- ^ The field into the theme
  -> Style                       -- ^ The collected style.
collectTheme :: forall s e. WidgetEnv s e -> Lens' ThemeState StyleState -> Style
collectTheme WidgetEnv s e
wenv Lens' ThemeState StyleState
fieldT = Style
style where
  basic :: Maybe StyleState
basic = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ WidgetEnv s e
wenv WidgetEnv s e
-> Getting StyleState (WidgetEnv s e) StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Theme -> Const StyleState Theme)
-> WidgetEnv s e -> Const StyleState (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const StyleState Theme)
 -> WidgetEnv s e -> Const StyleState (WidgetEnv s e))
-> ((StyleState -> Const StyleState StyleState)
    -> Theme -> Const StyleState Theme)
-> Getting StyleState (WidgetEnv s e) StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const StyleState ThemeState)
-> Theme -> Const StyleState Theme
forall s a. HasBasic s a => Lens' s a
Lens' Theme ThemeState
L.basic ((ThemeState -> Const StyleState ThemeState)
 -> Theme -> Const StyleState Theme)
-> ((StyleState -> Const StyleState StyleState)
    -> ThemeState -> Const StyleState ThemeState)
-> (StyleState -> Const StyleState StyleState)
-> Theme
-> Const StyleState Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Const StyleState StyleState)
-> ThemeState -> Const StyleState ThemeState
Lens' ThemeState StyleState
fieldT
  hover :: Maybe StyleState
hover = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ WidgetEnv s e
wenv WidgetEnv s e
-> Getting StyleState (WidgetEnv s e) StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Theme -> Const StyleState Theme)
-> WidgetEnv s e -> Const StyleState (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const StyleState Theme)
 -> WidgetEnv s e -> Const StyleState (WidgetEnv s e))
-> ((StyleState -> Const StyleState StyleState)
    -> Theme -> Const StyleState Theme)
-> Getting StyleState (WidgetEnv s e) StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const StyleState ThemeState)
-> Theme -> Const StyleState Theme
forall s a. HasHover s a => Lens' s a
Lens' Theme ThemeState
L.hover ((ThemeState -> Const StyleState ThemeState)
 -> Theme -> Const StyleState Theme)
-> ((StyleState -> Const StyleState StyleState)
    -> ThemeState -> Const StyleState ThemeState)
-> (StyleState -> Const StyleState StyleState)
-> Theme
-> Const StyleState Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Const StyleState StyleState)
-> ThemeState -> Const StyleState ThemeState
Lens' ThemeState StyleState
fieldT
  focus :: Maybe StyleState
focus = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ WidgetEnv s e
wenv WidgetEnv s e
-> Getting StyleState (WidgetEnv s e) StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Theme -> Const StyleState Theme)
-> WidgetEnv s e -> Const StyleState (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const StyleState Theme)
 -> WidgetEnv s e -> Const StyleState (WidgetEnv s e))
-> ((StyleState -> Const StyleState StyleState)
    -> Theme -> Const StyleState Theme)
-> Getting StyleState (WidgetEnv s e) StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const StyleState ThemeState)
-> Theme -> Const StyleState Theme
forall s a. HasFocus s a => Lens' s a
Lens' Theme ThemeState
L.focus ((ThemeState -> Const StyleState ThemeState)
 -> Theme -> Const StyleState Theme)
-> ((StyleState -> Const StyleState StyleState)
    -> ThemeState -> Const StyleState ThemeState)
-> (StyleState -> Const StyleState StyleState)
-> Theme
-> Const StyleState Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Const StyleState StyleState)
-> ThemeState -> Const StyleState ThemeState
Lens' ThemeState StyleState
fieldT
  focusHover :: Maybe StyleState
focusHover = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ WidgetEnv s e
wenv WidgetEnv s e
-> Getting StyleState (WidgetEnv s e) StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Theme -> Const StyleState Theme)
-> WidgetEnv s e -> Const StyleState (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const StyleState Theme)
 -> WidgetEnv s e -> Const StyleState (WidgetEnv s e))
-> ((StyleState -> Const StyleState StyleState)
    -> Theme -> Const StyleState Theme)
-> Getting StyleState (WidgetEnv s e) StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const StyleState ThemeState)
-> Theme -> Const StyleState Theme
forall s a. HasFocusHover s a => Lens' s a
Lens' Theme ThemeState
L.focusHover ((ThemeState -> Const StyleState ThemeState)
 -> Theme -> Const StyleState Theme)
-> ((StyleState -> Const StyleState StyleState)
    -> ThemeState -> Const StyleState ThemeState)
-> (StyleState -> Const StyleState StyleState)
-> Theme
-> Const StyleState Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Const StyleState StyleState)
-> ThemeState -> Const StyleState ThemeState
Lens' ThemeState StyleState
fieldT
  active :: Maybe StyleState
active = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ WidgetEnv s e
wenv WidgetEnv s e
-> Getting StyleState (WidgetEnv s e) StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Theme -> Const StyleState Theme)
-> WidgetEnv s e -> Const StyleState (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const StyleState Theme)
 -> WidgetEnv s e -> Const StyleState (WidgetEnv s e))
-> ((StyleState -> Const StyleState StyleState)
    -> Theme -> Const StyleState Theme)
-> Getting StyleState (WidgetEnv s e) StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const StyleState ThemeState)
-> Theme -> Const StyleState Theme
forall s a. HasActive s a => Lens' s a
Lens' Theme ThemeState
L.active ((ThemeState -> Const StyleState ThemeState)
 -> Theme -> Const StyleState Theme)
-> ((StyleState -> Const StyleState StyleState)
    -> ThemeState -> Const StyleState ThemeState)
-> (StyleState -> Const StyleState StyleState)
-> Theme
-> Const StyleState Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Const StyleState StyleState)
-> ThemeState -> Const StyleState ThemeState
Lens' ThemeState StyleState
fieldT
  disabled :: Maybe StyleState
disabled = StyleState -> Maybe StyleState
forall a. a -> Maybe a
Just (StyleState -> Maybe StyleState) -> StyleState -> Maybe StyleState
forall a b. (a -> b) -> a -> b
$ WidgetEnv s e
wenv WidgetEnv s e
-> Getting StyleState (WidgetEnv s e) StyleState -> StyleState
forall s a. s -> Getting a s a -> a
^. (Theme -> Const StyleState Theme)
-> WidgetEnv s e -> Const StyleState (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const StyleState Theme)
 -> WidgetEnv s e -> Const StyleState (WidgetEnv s e))
-> ((StyleState -> Const StyleState StyleState)
    -> Theme -> Const StyleState Theme)
-> Getting StyleState (WidgetEnv s e) StyleState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState -> Const StyleState ThemeState)
-> Theme -> Const StyleState Theme
forall s a. HasDisabled s a => Lens' s a
Lens' Theme ThemeState
L.disabled ((ThemeState -> Const StyleState ThemeState)
 -> Theme -> Const StyleState Theme)
-> ((StyleState -> Const StyleState StyleState)
    -> ThemeState -> Const StyleState ThemeState)
-> (StyleState -> Const StyleState StyleState)
-> Theme
-> Const StyleState Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Const StyleState StyleState)
-> ThemeState -> Const StyleState ThemeState
Lens' ThemeState StyleState
fieldT
  style :: Style
style = Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Style
Style Maybe StyleState
basic Maybe StyleState
hover Maybe StyleState
focus Maybe StyleState
focusHover Maybe StyleState
active Maybe StyleState
disabled

-- | Collects all the style states from a given entry in the map of user styles
--   in the active theme.
collectUserTheme
  :: WidgetEnv s e  -- ^ The widget environment (to get the theme).
  -> String         -- ^ The key into the user map.
  -> Style          -- ^ The collected style.
collectUserTheme :: forall s e. WidgetEnv s e -> String -> Style
collectUserTheme WidgetEnv s e
wenv String
name = Style
style where
  basic :: Maybe (IxValue (Map String StyleState))
basic = WidgetEnv s e
wenv WidgetEnv s e
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
-> Maybe (IxValue (Map String StyleState))
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> WidgetEnv s e
-> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
 -> WidgetEnv s e
 -> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e))
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme
forall s a. HasBasic s a => Lens' s a
Lens' Theme ThemeState
L.basic ((ThemeState
  -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
 -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> ThemeState
    -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> Theme
-> Const (Maybe (IxValue (Map String StyleState))) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map String StyleState
 -> Const
      (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall s a. HasUserStyleMap s a => Lens' s a
Lens' ThemeState (Map String StyleState)
L.userStyleMap ((Map String StyleState
  -> Const
       (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
 -> ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Map String StyleState
    -> Const
         (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map String StyleState)
-> Lens'
     (Map String StyleState) (Maybe (IxValue (Map String StyleState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at String
Index (Map String StyleState)
name
  hover :: Maybe (IxValue (Map String StyleState))
hover = WidgetEnv s e
wenv WidgetEnv s e
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
-> Maybe (IxValue (Map String StyleState))
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> WidgetEnv s e
-> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
 -> WidgetEnv s e
 -> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e))
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme
forall s a. HasHover s a => Lens' s a
Lens' Theme ThemeState
L.hover ((ThemeState
  -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
 -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> ThemeState
    -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> Theme
-> Const (Maybe (IxValue (Map String StyleState))) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map String StyleState
 -> Const
      (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall s a. HasUserStyleMap s a => Lens' s a
Lens' ThemeState (Map String StyleState)
L.userStyleMap ((Map String StyleState
  -> Const
       (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
 -> ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Map String StyleState
    -> Const
         (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map String StyleState)
-> Lens'
     (Map String StyleState) (Maybe (IxValue (Map String StyleState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at String
Index (Map String StyleState)
name
  focus :: Maybe (IxValue (Map String StyleState))
focus = WidgetEnv s e
wenv WidgetEnv s e
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
-> Maybe (IxValue (Map String StyleState))
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> WidgetEnv s e
-> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
 -> WidgetEnv s e
 -> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e))
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme
forall s a. HasFocus s a => Lens' s a
Lens' Theme ThemeState
L.focus ((ThemeState
  -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
 -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> ThemeState
    -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> Theme
-> Const (Maybe (IxValue (Map String StyleState))) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map String StyleState
 -> Const
      (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall s a. HasUserStyleMap s a => Lens' s a
Lens' ThemeState (Map String StyleState)
L.userStyleMap ((Map String StyleState
  -> Const
       (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
 -> ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Map String StyleState
    -> Const
         (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map String StyleState)
-> Lens'
     (Map String StyleState) (Maybe (IxValue (Map String StyleState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at String
Index (Map String StyleState)
name
  focusHover :: Maybe (IxValue (Map String StyleState))
focusHover = WidgetEnv s e
wenv WidgetEnv s e
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
-> Maybe (IxValue (Map String StyleState))
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> WidgetEnv s e
-> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
 -> WidgetEnv s e
 -> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e))
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme
forall s a. HasFocusHover s a => Lens' s a
Lens' Theme ThemeState
L.focusHover ((ThemeState
  -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
 -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> ThemeState
    -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> Theme
-> Const (Maybe (IxValue (Map String StyleState))) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map String StyleState
 -> Const
      (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall s a. HasUserStyleMap s a => Lens' s a
Lens' ThemeState (Map String StyleState)
L.userStyleMap ((Map String StyleState
  -> Const
       (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
 -> ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Map String StyleState
    -> Const
         (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map String StyleState)
-> Lens'
     (Map String StyleState) (Maybe (IxValue (Map String StyleState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at String
Index (Map String StyleState)
name
  active :: Maybe (IxValue (Map String StyleState))
active = WidgetEnv s e
wenv WidgetEnv s e
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
-> Maybe (IxValue (Map String StyleState))
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> WidgetEnv s e
-> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
 -> WidgetEnv s e
 -> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e))
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme
forall s a. HasActive s a => Lens' s a
Lens' Theme ThemeState
L.active ((ThemeState
  -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
 -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> ThemeState
    -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> Theme
-> Const (Maybe (IxValue (Map String StyleState))) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map String StyleState
 -> Const
      (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall s a. HasUserStyleMap s a => Lens' s a
Lens' ThemeState (Map String StyleState)
L.userStyleMap ((Map String StyleState
  -> Const
       (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
 -> ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Map String StyleState
    -> Const
         (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map String StyleState)
-> Lens'
     (Map String StyleState) (Maybe (IxValue (Map String StyleState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at String
Index (Map String StyleState)
name
  disabled :: Maybe (IxValue (Map String StyleState))
disabled = WidgetEnv s e
wenv WidgetEnv s e
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
-> Maybe (IxValue (Map String StyleState))
forall s a. s -> Getting a s a -> a
^. (Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> WidgetEnv s e
-> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e)
forall s a. HasTheme s a => Lens' s a
Lens' (WidgetEnv s e) Theme
L.theme ((Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
 -> WidgetEnv s e
 -> Const (Maybe (IxValue (Map String StyleState))) (WidgetEnv s e))
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> Getting
     (Maybe (IxValue (Map String StyleState)))
     (WidgetEnv s e)
     (Maybe (IxValue (Map String StyleState)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme
forall s a. HasDisabled s a => Lens' s a
Lens' Theme ThemeState
L.disabled ((ThemeState
  -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
 -> Theme -> Const (Maybe (IxValue (Map String StyleState))) Theme)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> ThemeState
    -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> Theme
-> Const (Maybe (IxValue (Map String StyleState))) Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map String StyleState
 -> Const
      (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall s a. HasUserStyleMap s a => Lens' s a
Lens' ThemeState (Map String StyleState)
L.userStyleMap ((Map String StyleState
  -> Const
       (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
 -> ThemeState
 -> Const (Maybe (IxValue (Map String StyleState))) ThemeState)
-> ((Maybe (IxValue (Map String StyleState))
     -> Const
          (Maybe (IxValue (Map String StyleState)))
          (Maybe (IxValue (Map String StyleState))))
    -> Map String StyleState
    -> Const
         (Maybe (IxValue (Map String StyleState))) (Map String StyleState))
-> (Maybe (IxValue (Map String StyleState))
    -> Const
         (Maybe (IxValue (Map String StyleState)))
         (Maybe (IxValue (Map String StyleState))))
-> ThemeState
-> Const (Maybe (IxValue (Map String StyleState))) ThemeState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map String StyleState)
-> Lens'
     (Map String StyleState) (Maybe (IxValue (Map String StyleState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at String
Index (Map String StyleState)
name
  style :: Style
style = Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Maybe StyleState
-> Style
Style Maybe StyleState
basic Maybe StyleState
hover Maybe StyleState
focus Maybe StyleState
focusHover Maybe StyleState
active Maybe StyleState
disabled

{-|
Sets the given value, overwriting the previous one, for each of the states of a
theme.

Useful for customizing a base theme.

@
theme = darkTheme
  & setThemeValue L.sliderRadius (Just 10)
  & setThemeValue L.sliderWidth 10
@
-}
setThemeValue
  :: Lens' ThemeState a
  -> a
  -> Theme
  -> Theme
setThemeValue :: forall a. Lens' ThemeState a -> a -> Theme -> Theme
setThemeValue Lens' ThemeState a
field a
value Theme
theme = Theme
newTheme where
  newTheme :: Theme
newTheme = Theme
theme
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasBasic s a => Lens' s a
Lens' Theme ThemeState
L.basic ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((a -> Identity a) -> ThemeState -> Identity ThemeState)
-> (a -> Identity a)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> ThemeState -> Identity ThemeState
Lens' ThemeState a
field ((a -> Identity a) -> Theme -> Identity Theme)
-> a -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ a
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasHover s a => Lens' s a
Lens' Theme ThemeState
L.hover ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((a -> Identity a) -> ThemeState -> Identity ThemeState)
-> (a -> Identity a)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> ThemeState -> Identity ThemeState
Lens' ThemeState a
field ((a -> Identity a) -> Theme -> Identity Theme)
-> a -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ a
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasFocus s a => Lens' s a
Lens' Theme ThemeState
L.focus ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((a -> Identity a) -> ThemeState -> Identity ThemeState)
-> (a -> Identity a)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> ThemeState -> Identity ThemeState
Lens' ThemeState a
field ((a -> Identity a) -> Theme -> Identity Theme)
-> a -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ a
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasFocusHover s a => Lens' s a
Lens' Theme ThemeState
L.focusHover ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((a -> Identity a) -> ThemeState -> Identity ThemeState)
-> (a -> Identity a)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> ThemeState -> Identity ThemeState
Lens' ThemeState a
field ((a -> Identity a) -> Theme -> Identity Theme)
-> a -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ a
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasActive s a => Lens' s a
Lens' Theme ThemeState
L.active ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((a -> Identity a) -> ThemeState -> Identity ThemeState)
-> (a -> Identity a)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> ThemeState -> Identity ThemeState
Lens' ThemeState a
field ((a -> Identity a) -> Theme -> Identity Theme)
-> a -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ a
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasDisabled s a => Lens' s a
Lens' Theme ThemeState
L.disabled ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((a -> Identity a) -> ThemeState -> Identity ThemeState)
-> (a -> Identity a)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Identity a) -> ThemeState -> Identity ThemeState
Lens' ThemeState a
field ((a -> Identity a) -> Theme -> Identity Theme)
-> a -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ a
value

{-|
Sets the given style options, overwriting the previous style, for each of the
states of a theme.

Useful for customizing a base theme.

@
theme = darkTheme
  & setThemeStyle L.dropdownStyle [padding 6, paddingV 6]
@

Note: In most cases 'mergeThemeStyle' is a better choice, since it keeps all the
other style settings intact.
-}
setThemeStyle
  :: Lens' ThemeState StyleState
  -> [StyleState]
  -> Theme
  -> Theme
setThemeStyle :: Lens' ThemeState StyleState -> [StyleState] -> Theme -> Theme
setThemeStyle Lens' ThemeState StyleState
field [StyleState]
styles Theme
theme = Theme
newTheme where
  !value :: StyleState
value = [StyleState] -> StyleState
forall a. Monoid a => [a] -> a
mconcat [StyleState]
styles
  newTheme :: Theme
newTheme = Theme
theme
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasBasic s a => Lens' s a
Lens' Theme ThemeState
L.basic ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasHover s a => Lens' s a
Lens' Theme ThemeState
L.hover ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasFocus s a => Lens' s a
Lens' Theme ThemeState
L.focus ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasFocusHover s a => Lens' s a
Lens' Theme ThemeState
L.focusHover ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasActive s a => Lens' s a
Lens' Theme ThemeState
L.active ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasDisabled s a => Lens' s a
Lens' Theme ThemeState
L.disabled ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StyleState
value

{-|
Merges the given style options with the existing style, for each of the states
of a theme.

Useful for customizing a base theme.

@
theme = darkTheme
  & mergeThemeStyle L.dropdownStyle [padding 6, paddingV 6]
@
-}
mergeThemeStyle
  :: Lens' ThemeState StyleState
  -> [StyleState]
  -> Theme
  -> Theme
mergeThemeStyle :: Lens' ThemeState StyleState -> [StyleState] -> Theme -> Theme
mergeThemeStyle Lens' ThemeState StyleState
field [StyleState]
styles Theme
theme = Theme
newTheme where
  !value :: StyleState
value = [StyleState] -> StyleState
forall a. Monoid a => [a] -> a
mconcat [StyleState]
styles
  newTheme :: Theme
newTheme = Theme
theme
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasBasic s a => Lens' s a
Lens' Theme ThemeState
L.basic ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall a s t. Semigroup a => ASetter s t a a -> a -> s -> t
<>~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasHover s a => Lens' s a
Lens' Theme ThemeState
L.hover ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall a s t. Semigroup a => ASetter s t a a -> a -> s -> t
<>~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasFocus s a => Lens' s a
Lens' Theme ThemeState
L.focus ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall a s t. Semigroup a => ASetter s t a a -> a -> s -> t
<>~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasFocusHover s a => Lens' s a
Lens' Theme ThemeState
L.focusHover ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall a s t. Semigroup a => ASetter s t a a -> a -> s -> t
<>~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasActive s a => Lens' s a
Lens' Theme ThemeState
L.active ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall a s t. Semigroup a => ASetter s t a a -> a -> s -> t
<>~ StyleState
value
    Theme -> (Theme -> Theme) -> Theme
forall a b. a -> (a -> b) -> b
& (ThemeState -> Identity ThemeState) -> Theme -> Identity Theme
forall s a. HasDisabled s a => Lens' s a
Lens' Theme ThemeState
L.disabled ((ThemeState -> Identity ThemeState) -> Theme -> Identity Theme)
-> ((StyleState -> Identity StyleState)
    -> ThemeState -> Identity ThemeState)
-> (StyleState -> Identity StyleState)
-> Theme
-> Identity Theme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyleState -> Identity StyleState)
-> ThemeState -> Identity ThemeState
Lens' ThemeState StyleState
field ((StyleState -> Identity StyleState) -> Theme -> Identity Theme)
-> StyleState -> Theme -> Theme
forall a s t. Semigroup a => ASetter s t a a -> a -> s -> t
<>~ StyleState
value