~alcinnz/Mondrian

ref: 049383f68f04e735566436964a3d2f23c5c1cd82 Mondrian/lib/Graphics/Rendering/Rect/CSS/Background.hs -rw-r--r-- 959 bytes
049383f6 — Adrian Cochrane Fix colour output, add OpenGL cleanup. 1 year, 4 months ago
                                                                                
a3455462 Adrian Cochrane
7a7ce8ff Adrian Cochrane
a08fe055 Adrian Cochrane
a3455462 Adrian Cochrane
4c875d8e Adrian Cochrane
a3455462 Adrian Cochrane
4c875d8e Adrian Cochrane
a3455462 Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{-# LANGUAGE OverloadedStrings #-}
module Graphics.Rendering.Rect.CSS.Background (Backgrounds(..)) where

import Stylist (PropertyParser(..), parseUnorderedShorthand)
import Graphics.Rendering.Rect.CSS.Colour (ColourPallet, parseColour)
import Data.Colour (AlphaColour, transparent)

data Backgrounds = Backgrounds {
    pallet :: ColourPallet,
    background :: AlphaColour Float
} deriving (Read, Show, Eq)

instance PropertyParser Backgrounds where
    temp = Backgrounds { pallet = temp, background = transparent }
    inherit _ = temp
    priority _ = []

    longhand _ self@Backgrounds{ pallet = c } "background-color" toks
        | Just ([], val) <- parseColour c toks = Just self { background = val }
    longhand _ _ _ _ = Nothing

    shorthand self "background" toks = parseUnorderedShorthand self [
        "background-color"
      ] toks
    shorthand self key val | Just _ <- longhand self self key val = [(key, val)]
        | otherwise = []