~alcinnz/Mondrian

ref: 595c10c349e1810e1deb4ed192b7f6a54d554d70 Mondrian/lib/Graphics/Rendering/Rect/CSS.hs -rw-r--r-- 1.1 KiB
595c10c3 — Adrian Cochrane Fix transformation matrix (should be fixed upstream, but that'd be breaking). 1 year, 4 months ago
                                                                                
a3455462 Adrian Cochrane
4c875d8e Adrian Cochrane
a3455462 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
27
28
29
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
module Graphics.Rendering.Rect.CSS(RectStyle(..), colour) where

import Stylist (PropertyParser(..))
import Graphics.Rendering.Rect.CSS.Colour (ColourPallet(foreground))
import Graphics.Rendering.Rect.CSS.Background (Backgrounds(..))

data RectStyle = RectStyle {
    colours :: ColourPallet,
    backgrounds :: Backgrounds
} deriving (Read, Show, Eq)
colour = foreground . colours

instance PropertyParser RectStyle where
    temp = RectStyle { colours = temp, backgrounds = temp }
    inherit RectStyle {..} = RectStyle {
        colours = inherit colours, backgrounds = temp
    }

    shorthand self key value
        | Just _ <- longhand self self key value = [(key, value)]
        | otherwise = []
    longhand parent self key value
        | Just ret <- longhand (backgrounds parent) { pallet = colours parent }
                (backgrounds self) { pallet = colours self } key value =
            Just self { backgrounds = ret }
        | Just ret <- longhand (colours parent) (colours self) key value =
            Just self { colours = ret }
        | otherwise = Nothing