{-|
Module      : Monomer.Core.Style
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 creating style configurations, and corresponding instances.
-}
{-# LANGUAGE Strict #-}

module Monomer.Core.Style (
  module Monomer.Core.StyleTypes,
  module Monomer.Core.ThemeTypes,
  paddingH,
  paddingV,
  fixedSize,
  flexSize,
  expandSize,
  minSize,
  maxSize,
  rangeSize
) where

import Control.Lens ((&), (.~), (?~), non)
import Data.Default

import Monomer.Core.Combinators
import Monomer.Core.StyleTypes
import Monomer.Core.ThemeTypes
import Monomer.Graphics.Types

import qualified Monomer.Core.Lens as L

-- | Creates an equally sized padding left and right.
paddingH :: (Semigroup a, CmbPaddingL a, CmbPaddingR a) => Double -> a
paddingH :: forall a.
(Semigroup a, CmbPaddingL a, CmbPaddingR a) =>
Double -> a
paddingH Double
p = forall t. CmbPaddingL t => Double -> t
paddingL Double
p forall a. Semigroup a => a -> a -> a
<> forall t. CmbPaddingR t => Double -> t
paddingR Double
p

-- | Creates an equally sized padding top and bottom.
paddingV :: (Semigroup a, CmbPaddingT a, CmbPaddingB a) => Double -> a
paddingV :: forall a.
(Semigroup a, CmbPaddingT a, CmbPaddingB a) =>
Double -> a
paddingV Double
p = forall t. CmbPaddingT t => Double -> t
paddingT Double
p forall a. Semigroup a => a -> a -> a
<> forall t. CmbPaddingB t => Double -> t
paddingB Double
p

-- | Creates a SizeReq with fixed size.
fixedSize :: Double -> SizeReq
fixedSize :: Double -> SizeReq
fixedSize Double
s = forall a. Default a => a
def
  forall a b. a -> (a -> b) -> b
& forall s a. HasFixed s a => Lens' s a
L.fixed forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s

-- | Creates a SizeReq with flex size.
flexSize :: Double -> Double -> SizeReq
flexSize :: Double -> Double -> SizeReq
flexSize Double
s Double
f = forall a. Default a => a
def
  forall a b. a -> (a -> b) -> b
& forall s a. HasFlex s a => Lens' s a
L.flex forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s
  forall a b. a -> (a -> b) -> b
& forall s a. HasFactor s a => Lens' s a
L.factor forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
f

-- | Creates a SizeReq with expand size.
expandSize :: Double -> Double -> SizeReq
expandSize :: Double -> Double -> SizeReq
expandSize Double
s Double
f = forall a. Default a => a
def
  forall a b. a -> (a -> b) -> b
& forall s a. HasFlex s a => Lens' s a
L.flex forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s
  forall a b. a -> (a -> b) -> b
& forall s a. HasExtra s a => Lens' s a
L.extra forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s
  forall a b. a -> (a -> b) -> b
& forall s a. HasFactor s a => Lens' s a
L.factor forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
f

-- | Creates a SizeReq with equal fixed and extra size, using the given factor.
minSize :: Double -> Double -> SizeReq
minSize :: Double -> Double -> SizeReq
minSize Double
s Double
f = forall a. Default a => a
def
  forall a b. a -> (a -> b) -> b
& forall s a. HasFixed s a => Lens' s a
L.fixed forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s
  forall a b. a -> (a -> b) -> b
& forall s a. HasExtra s a => Lens' s a
L.extra forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s
  forall a b. a -> (a -> b) -> b
& forall s a. HasFactor s a => Lens' s a
L.factor forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
f

-- | Creates a SizeReq with flex size, using the given factor.
maxSize :: Double -> Double -> SizeReq
maxSize :: Double -> Double -> SizeReq
maxSize Double
s Double
f = forall a. Default a => a
def
  forall a b. a -> (a -> b) -> b
& forall s a. HasFlex s a => Lens' s a
L.flex forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s
  forall a b. a -> (a -> b) -> b
& forall s a. HasFactor s a => Lens' s a
L.factor forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
f

-- | Creates a SizeReq with fixed and flex size, using the given factor.
rangeSize :: Double -> Double -> Double -> SizeReq
rangeSize :: Double -> Double -> Double -> SizeReq
rangeSize Double
s1 Double
s2 Double
f = forall a. Default a => a
def
  forall a b. a -> (a -> b) -> b
& forall s a. HasFixed s a => Lens' s a
L.fixed forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s1
  forall a b. a -> (a -> b) -> b
& forall s a. HasFlex s a => Lens' s a
L.flex forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
s2 forall a. Num a => a -> a -> a
- Double
s1
  forall a b. a -> (a -> b) -> b
& forall s a. HasFactor s a => Lens' s a
L.factor forall s t a b. ASetter s t a b -> b -> s -> t
.~ Double
f

-- Size
instance CmbWidth SizeReq where
  width :: Double -> SizeReq
width Double
w = Double -> SizeReq
fixedSize Double
w

instance CmbHeight SizeReq where
  height :: Double -> SizeReq
height Double
h = Double -> SizeReq
fixedSize Double
h

instance CmbFlexWidth SizeReq where
  flexWidth :: Double -> SizeReq
flexWidth Double
w = Double -> Double -> SizeReq
expandSize Double
w Double
1

instance CmbFlexHeight SizeReq where
  flexHeight :: Double -> SizeReq
flexHeight Double
h = Double -> Double -> SizeReq
expandSize Double
h Double
1

instance CmbMinWidth SizeReq where
  minWidth :: Double -> SizeReq
minWidth Double
w = Double -> Double -> SizeReq
minSize Double
w Double
1

instance CmbMinHeight SizeReq where
  minHeight :: Double -> SizeReq
minHeight Double
h = Double -> Double -> SizeReq
minSize Double
h Double
1

instance CmbMaxWidth SizeReq where
  maxWidth :: Double -> SizeReq
maxWidth Double
w = Double -> Double -> SizeReq
maxSize Double
w Double
1

instance CmbMaxHeight SizeReq where
  maxHeight :: Double -> SizeReq
maxHeight Double
h = Double -> Double -> SizeReq
maxSize Double
h Double
1

instance CmbExpandWidth SizeReq where
  expandWidth :: Double -> SizeReq
expandWidth Double
w = Double -> Double -> SizeReq
expandSize Double
w Double
1

instance CmbExpandHeight SizeReq where
  expandHeight :: Double -> SizeReq
expandHeight Double
h = Double -> Double -> SizeReq
expandSize Double
h Double
1

instance CmbRangeWidth SizeReq where
  rangeWidth :: Double -> Double -> SizeReq
rangeWidth Double
w1 Double
w2 = Double -> Double -> Double -> SizeReq
rangeSize Double
w1 Double
w2 Double
1

instance CmbRangeHeight SizeReq where
  rangeHeight :: Double -> Double -> SizeReq
rangeHeight Double
h1 Double
h2 = Double -> Double -> Double -> SizeReq
rangeSize Double
h1 Double
h2 Double
1

-- Text
instance CmbTextFont TextStyle where
  textFont :: Font -> TextStyle
textFont Font
font = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasFont s a => Lens' s a
L.font forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Font
font

instance CmbTextSize TextStyle where
  textSize :: Double -> TextStyle
textSize Double
size = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasFontSize s a => Lens' s a
L.fontSize forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> FontSize
FontSize Double
size

instance CmbTextSpaceH TextStyle where
  textSpaceH :: Double -> TextStyle
textSpaceH Double
space = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasFontSpaceH s a => Lens' s a
L.fontSpaceH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> FontSpace
FontSpace Double
space

instance CmbTextSpaceV TextStyle where
  textSpaceV :: Double -> TextStyle
textSpaceV Double
space = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasFontSpaceV s a => Lens' s a
L.fontSpaceV forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> FontSpace
FontSpace Double
space

instance CmbTextColor TextStyle where
  textColor :: Color -> TextStyle
textColor Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasFontColor s a => Lens' s a
L.fontColor forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Color
col

instance CmbTextLeft TextStyle where
  textLeft_ :: Bool -> TextStyle
textLeft_ Bool
False = forall a. Default a => a
def
  textLeft_ Bool
True = AlignTH -> TextStyle
textAlignH AlignTH
ATLeft

instance CmbTextCenter TextStyle where
  textCenter_ :: Bool -> TextStyle
textCenter_ Bool
False = forall a. Default a => a
def
  textCenter_ Bool
True = AlignTH -> TextStyle
textAlignH AlignTH
ATCenter

instance CmbTextRight TextStyle where
  textRight_ :: Bool -> TextStyle
textRight_ Bool
False = forall a. Default a => a
def
  textRight_ Bool
True = AlignTH -> TextStyle
textAlignH AlignTH
ATRight

instance CmbTextTop TextStyle where
  textTop_ :: Bool -> TextStyle
textTop_ Bool
False = forall a. Default a => a
def
  textTop_ Bool
True = AlignTV -> TextStyle
textAlignV AlignTV
ATTop

instance CmbTextMiddle TextStyle where
  textMiddle_ :: Bool -> TextStyle
textMiddle_ Bool
False = forall a. Default a => a
def
  textMiddle_ Bool
True = AlignTV -> TextStyle
textAlignV AlignTV
ATMiddle

instance CmbTextAscender TextStyle where
  textAscender_ :: Bool -> TextStyle
textAscender_ Bool
False = forall a. Default a => a
def
  textAscender_ Bool
True = AlignTV -> TextStyle
textAlignV AlignTV
ATAscender

instance CmbTextLowerX TextStyle where
  textLowerX_ :: Bool -> TextStyle
textLowerX_ Bool
False = forall a. Default a => a
def
  textLowerX_ Bool
True = AlignTV -> TextStyle
textAlignV AlignTV
ATLowerX

instance CmbTextBottom TextStyle where
  textBottom_ :: Bool -> TextStyle
textBottom_ Bool
False = forall a. Default a => a
def
  textBottom_ Bool
True = AlignTV -> TextStyle
textAlignV AlignTV
ATBottom

instance CmbTextBaseline TextStyle where
  textBaseline_ :: Bool -> TextStyle
textBaseline_ Bool
False = forall a. Default a => a
def
  textBaseline_ Bool
True = AlignTV -> TextStyle
textAlignV AlignTV
ATBaseline

instance CmbTextUnderline TextStyle where
  textUnderline_ :: Bool -> TextStyle
textUnderline_ Bool
under = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasUnderline s a => Lens' s a
L.underline forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Bool
under

instance CmbTextOverline TextStyle where
  textOverline_ :: Bool -> TextStyle
textOverline_ Bool
over = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasOverline s a => Lens' s a
L.overline forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Bool
over

instance CmbTextThroughline TextStyle where
  textThroughline_ :: Bool -> TextStyle
textThroughline_ Bool
through = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasThroughline s a => Lens' s a
L.throughline forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Bool
through

instance CmbTextLineBreak TextStyle where
  textLineBreak :: LineBreak -> TextStyle
textLineBreak LineBreak
break = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasLineBreak s a => Lens' s a
L.lineBreak forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ LineBreak
break

-- Padding

instance CmbPadding Padding where
  padding :: Double -> Padding
padding Double
padd = Maybe Double
-> Maybe Double -> Maybe Double -> Maybe Double -> Padding
Padding Maybe Double
jp Maybe Double
jp Maybe Double
jp Maybe Double
jp where
    jp :: Maybe Double
jp = forall a. a -> Maybe a
Just Double
padd

instance CmbPaddingL Padding where
  paddingL :: Double -> Padding
paddingL Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasLeft s a => Lens' s a
L.left forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

instance CmbPaddingR Padding where
  paddingR :: Double -> Padding
paddingR Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRight s a => Lens' s a
L.right forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

instance CmbPaddingT Padding where
  paddingT :: Double -> Padding
paddingT Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasTop s a => Lens' s a
L.top forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

instance CmbPaddingB Padding where
  paddingB :: Double -> Padding
paddingB Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBottom s a => Lens' s a
L.bottom forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

-- Border

instance CmbBorder Border where
  border :: Double -> Color -> Border
border Double
w Color
col = Maybe BorderSide
-> Maybe BorderSide
-> Maybe BorderSide
-> Maybe BorderSide
-> Border
Border Maybe BorderSide
bs Maybe BorderSide
bs Maybe BorderSide
bs Maybe BorderSide
bs where
    bs :: Maybe BorderSide
bs = forall a. a -> Maybe a
Just (Double -> Color -> BorderSide
BorderSide Double
w Color
col)

instance CmbBorderL Border where
  borderL :: Double -> Color -> Border
borderL Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasLeft s a => Lens' s a
L.left forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

instance CmbBorderR Border where
  borderR :: Double -> Color -> Border
borderR Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRight s a => Lens' s a
L.right forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

instance CmbBorderT Border where
  borderT :: Double -> Color -> Border
borderT Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasTop s a => Lens' s a
L.top forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

instance CmbBorderB Border where
  borderB :: Double -> Color -> Border
borderB Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBottom s a => Lens' s a
L.bottom forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

-- Radius

instance CmbRadius Radius where
  radius :: Double -> Radius
radius Double
rad = Maybe RadiusCorner
-> Maybe RadiusCorner
-> Maybe RadiusCorner
-> Maybe RadiusCorner
-> Radius
Radius Maybe RadiusCorner
jrad Maybe RadiusCorner
jrad Maybe RadiusCorner
jrad Maybe RadiusCorner
jrad where
    jrad :: Maybe RadiusCorner
jrad = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusTL Radius where
  radiusTL :: Double -> Radius
radiusTL Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasTopLeft s a => Lens' s a
L.topLeft forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusTR Radius where
  radiusTR :: Double -> Radius
radiusTR Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasTopRight s a => Lens' s a
L.topRight forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusBL Radius where
  radiusBL :: Double -> Radius
radiusBL Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBottomLeft s a => Lens' s a
L.bottomLeft forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusBR Radius where
  radiusBR :: Double -> Radius
radiusBR Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBottomRight s a => Lens' s a
L.bottomRight forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

--
-- StyleState instances
--

-- Size
instance CmbWidth StyleState where
  width :: Double -> StyleState
width Double
w = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbWidth t => Double -> t
width Double
w

instance CmbHeight StyleState where
  height :: Double -> StyleState
height Double
h = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbHeight t => Double -> t
height Double
h

instance CmbFlexWidth StyleState where
  flexWidth :: Double -> StyleState
flexWidth Double
w = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbFlexWidth t => Double -> t
flexWidth Double
w

instance CmbFlexHeight StyleState where
  flexHeight :: Double -> StyleState
flexHeight Double
h = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbFlexHeight t => Double -> t
flexHeight Double
h

instance CmbMinWidth StyleState where
  minWidth :: Double -> StyleState
minWidth Double
w = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbMinWidth t => Double -> t
minWidth Double
w

instance CmbMinHeight StyleState where
  minHeight :: Double -> StyleState
minHeight Double
h = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbMinHeight t => Double -> t
minHeight Double
h

instance CmbMaxWidth StyleState where
  maxWidth :: Double -> StyleState
maxWidth Double
w = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbMaxWidth t => Double -> t
maxWidth Double
w

instance CmbMaxHeight StyleState where
  maxHeight :: Double -> StyleState
maxHeight Double
h = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbMaxHeight t => Double -> t
maxHeight Double
h

instance CmbExpandWidth StyleState where
  expandWidth :: Double -> StyleState
expandWidth Double
w = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbExpandWidth t => Double -> t
expandWidth Double
w

instance CmbExpandHeight StyleState where
  expandHeight :: Double -> StyleState
expandHeight Double
h = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbExpandHeight t => Double -> t
expandHeight Double
h

instance CmbRangeWidth StyleState where
  rangeWidth :: Double -> Double -> StyleState
rangeWidth Double
w1 Double
w2 = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbRangeWidth t => Double -> Double -> t
rangeWidth Double
w1 Double
w2

instance CmbRangeHeight StyleState where
  rangeHeight :: Double -> Double -> StyleState
rangeHeight Double
h1 Double
h2 = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbRangeHeight t => Double -> Double -> t
rangeHeight Double
h1 Double
h2

instance CmbSizeReqW StyleState where
  sizeReqW :: SizeReq -> StyleState
sizeReqW SizeReq
srW = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqW s a => Lens' s a
L.sizeReqW forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ SizeReq
srW

instance CmbSizeReqH StyleState where
  sizeReqH :: SizeReq -> StyleState
sizeReqH SizeReq
srH = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSizeReqH s a => Lens' s a
L.sizeReqH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ SizeReq
srH

-- Color

instance CmbBgColor StyleState where
  bgColor :: Color -> StyleState
bgColor Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBgColor s a => Lens' s a
L.bgColor forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Color
col

instance CmbFgColor StyleState where
  fgColor :: Color -> StyleState
fgColor Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasFgColor s a => Lens' s a
L.fgColor forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Color
col

instance CmbSndColor StyleState where
  sndColor :: Color -> StyleState
sndColor Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasSndColor s a => Lens' s a
L.sndColor forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Color
col

instance CmbHlColor StyleState where
  hlColor :: Color -> StyleState
hlColor Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasHlColor s a => Lens' s a
L.hlColor forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Color
col

-- Cursor

instance CmbCursorIcon StyleState where
  cursorIcon :: CursorIcon -> StyleState
cursorIcon CursorIcon
icon = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasCursorIcon s a => Lens' s a
L.cursorIcon forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ CursorIcon
icon

-- Text
instance CmbTextFont StyleState where
  textFont :: Font -> StyleState
textFont Font
font = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextFont t => Font -> t
textFont Font
font

instance CmbTextSize StyleState where
  textSize :: Double -> StyleState
textSize Double
size = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextSize t => Double -> t
textSize Double
size

instance CmbTextSpaceH StyleState where
  textSpaceH :: Double -> StyleState
textSpaceH Double
space = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextSpaceH t => Double -> t
textSpaceH Double
space

instance CmbTextSpaceV StyleState where
  textSpaceV :: Double -> StyleState
textSpaceV Double
space = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextSpaceV t => Double -> t
textSpaceV Double
space

instance CmbTextColor StyleState where
  textColor :: Color -> StyleState
textColor Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextColor t => Color -> t
textColor Color
col

instance CmbTextLeft StyleState where
  textLeft_ :: Bool -> StyleState
textLeft_ Bool
False = forall a. Default a => a
def
  textLeft_ Bool
True = AlignTH -> StyleState
styleTextAlignH AlignTH
ATLeft

instance CmbTextCenter StyleState where
  textCenter_ :: Bool -> StyleState
textCenter_ Bool
False = forall a. Default a => a
def
  textCenter_ Bool
True = AlignTH -> StyleState
styleTextAlignH AlignTH
ATCenter

instance CmbTextRight StyleState where
  textRight_ :: Bool -> StyleState
textRight_ Bool
False = forall a. Default a => a
def
  textRight_ Bool
True = AlignTH -> StyleState
styleTextAlignH AlignTH
ATRight

instance CmbTextTop StyleState where
  textTop_ :: Bool -> StyleState
textTop_ Bool
False = forall a. Default a => a
def
  textTop_ Bool
True = AlignTV -> StyleState
styleTextAlignV AlignTV
ATTop

instance CmbTextMiddle StyleState where
  textMiddle_ :: Bool -> StyleState
textMiddle_ Bool
False = forall a. Default a => a
def
  textMiddle_ Bool
True = AlignTV -> StyleState
styleTextAlignV AlignTV
ATMiddle

instance CmbTextAscender StyleState where
  textAscender_ :: Bool -> StyleState
textAscender_ Bool
False = forall a. Default a => a
def
  textAscender_ Bool
True = AlignTV -> StyleState
styleTextAlignV AlignTV
ATAscender

instance CmbTextLowerX StyleState where
  textLowerX_ :: Bool -> StyleState
textLowerX_ Bool
False = forall a. Default a => a
def
  textLowerX_ Bool
True = AlignTV -> StyleState
styleTextAlignV AlignTV
ATLowerX

instance CmbTextBottom StyleState where
  textBottom_ :: Bool -> StyleState
textBottom_ Bool
False = forall a. Default a => a
def
  textBottom_ Bool
True = AlignTV -> StyleState
styleTextAlignV AlignTV
ATBottom

instance CmbTextBaseline StyleState where
  textBaseline_ :: Bool -> StyleState
textBaseline_ Bool
False = forall a. Default a => a
def
  textBaseline_ Bool
True = AlignTV -> StyleState
styleTextAlignV AlignTV
ATBaseline

instance CmbTextUnderline StyleState where
  textUnderline_ :: Bool -> StyleState
textUnderline_ Bool
False = forall a. Default a => a
def
  textUnderline_ Bool
True = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextUnderline t => t
textUnderline

instance CmbTextOverline StyleState where
  textOverline_ :: Bool -> StyleState
textOverline_ Bool
False = forall a. Default a => a
def
  textOverline_ Bool
True = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextOverline t => t
textOverline

instance CmbTextThroughline StyleState where
  textThroughline_ :: Bool -> StyleState
textThroughline_ Bool
False = forall a. Default a => a
def
  textThroughline_ Bool
True = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextThroughline t => t
textThroughline

instance CmbTextLineBreak StyleState where
  textLineBreak :: LineBreak -> StyleState
textLineBreak LineBreak
break = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbTextLineBreak t => LineBreak -> t
textLineBreak LineBreak
break

-- Padding
instance CmbPadding StyleState where
  padding :: Double -> StyleState
padding Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasPadding s a => Lens' s a
L.padding forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbPadding t => Double -> t
padding Double
padd

instance CmbPaddingL StyleState where
  paddingL :: Double -> StyleState
paddingL Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasPadding s a => Lens' s a
L.padding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasLeft s a => Lens' s a
L.left forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

instance CmbPaddingR StyleState where
  paddingR :: Double -> StyleState
paddingR Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasPadding s a => Lens' s a
L.padding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasRight s a => Lens' s a
L.right forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

instance CmbPaddingT StyleState where
  paddingT :: Double -> StyleState
paddingT Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasPadding s a => Lens' s a
L.padding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasTop s a => Lens' s a
L.top forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

instance CmbPaddingB StyleState where
  paddingB :: Double -> StyleState
paddingB Double
padd = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasPadding s a => Lens' s a
L.padding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasBottom s a => Lens' s a
L.bottom forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double
padd

-- Border
instance CmbBorder StyleState where
  border :: Double -> Color -> StyleState
border Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBorder s a => Lens' s a
L.border forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbBorder t => Double -> Color -> t
border Double
w Color
col

instance CmbBorderL StyleState where
  borderL :: Double -> Color -> StyleState
borderL Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBorder s a => Lens' s a
L.border forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasLeft s a => Lens' s a
L.left forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

instance CmbBorderR StyleState where
  borderR :: Double -> Color -> StyleState
borderR Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBorder s a => Lens' s a
L.border forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasRight s a => Lens' s a
L.right forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

instance CmbBorderT StyleState where
  borderT :: Double -> Color -> StyleState
borderT Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBorder s a => Lens' s a
L.border forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasTop s a => Lens' s a
L.top forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

instance CmbBorderB StyleState where
  borderB :: Double -> Color -> StyleState
borderB Double
w Color
col = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasBorder s a => Lens' s a
L.border forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasBottom s a => Lens' s a
L.bottom forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> Color -> BorderSide
BorderSide Double
w Color
col

-- Radius
instance CmbRadius StyleState where
  radius :: Double -> StyleState
radius Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRadius s a => Lens' s a
L.radius forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ forall t. CmbRadius t => Double -> t
radius Double
rad

instance CmbRadiusTL StyleState where
  radiusTL :: Double -> StyleState
radiusTL Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRadius s a => Lens' s a
L.radius forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasTopLeft s a => Lens' s a
L.topLeft forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusTR StyleState where
  radiusTR :: Double -> StyleState
radiusTR Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRadius s a => Lens' s a
L.radius forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasTopRight s a => Lens' s a
L.topRight forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusBL StyleState where
  radiusBL :: Double -> StyleState
radiusBL Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRadius s a => Lens' s a
L.radius forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasBottomLeft s a => Lens' s a
L.bottomLeft forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

instance CmbRadiusBR StyleState where
  radiusBR :: Double -> StyleState
radiusBR Double
rad = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasRadius s a => Lens' s a
L.radius forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasBottomRight s a => Lens' s a
L.bottomRight forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Double -> RadiusCorner
radiusCorner Double
rad

-- Internal

radiusCorner :: Double -> RadiusCorner
radiusCorner :: Double -> RadiusCorner
radiusCorner Double
rad = Double -> RadiusCorner
RadiusCorner Double
rad

textAlignH :: AlignTH -> TextStyle
textAlignH :: AlignTH -> TextStyle
textAlignH AlignTH
align = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasAlignH s a => Lens' s a
L.alignH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ AlignTH
align

textAlignV :: AlignTV -> TextStyle
textAlignV :: AlignTV -> TextStyle
textAlignV AlignTV
align = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasAlignV s a => Lens' s a
L.alignV forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ AlignTV
align

styleTextAlignH :: AlignTH -> StyleState
styleTextAlignH :: AlignTH -> StyleState
styleTextAlignH AlignTH
align = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasAlignH s a => Lens' s a
L.alignH forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ AlignTH
align

styleTextAlignV :: AlignTV -> StyleState
styleTextAlignV :: AlignTV -> StyleState
styleTextAlignV AlignTV
align = forall a. Default a => a
def forall a b. a -> (a -> b) -> b
& forall s a. HasText s a => Lens' s a
L.text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> Iso' (Maybe a) a
non forall a. Default a => a
def forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasAlignV s a => Lens' s a
L.alignV forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ AlignTV
align