~alcinnz/Mondrian

a08fe0554fcdf787beb65c1c767b9ecbd7e6e1de — Adrian Cochrane 1 year, 6 months ago 10e61b6
Improve debuggability, correct rect shrinking.
M app/Main.hs => app/Main.hs +2 -1
@@ 26,7 26,8 @@ parseStyle syn
    toks = tokenize $ pack syn
    apply ((key, val):props)
        | Just self' <- longhand self self key val = self'
        | otherwise = apply (shorthand self key val ++ props)
        | props'@(_:_) <- shorthand self key val = apply (props' ++ props)
        | otherwise = trace ("Unsupported property " ++ unpack key) self
      where self = apply props
    apply [] = temp


M lib/Graphics/Rendering/Rect.hs => lib/Graphics/Rendering/Rect.hs +1 -1
@@ 10,7 10,7 @@ import Control.Monad.IO.Class (MonadIO)

shrink :: Rect -> Float -> Float -> Float -> Float -> Rect
shrink self dLeft dTop dRight dBottom =
    Rect (left self - dLeft) (top self - dTop)
    Rect (left self + dLeft) (top self + dTop)
         (right self - dRight) (bottom self - dBottom)
shrink1 :: Rect -> Float -> Rect
shrink1 self d = shrink self d d d d

M lib/Graphics/Rendering/Rect/CSS.hs => lib/Graphics/Rendering/Rect/CSS.hs +4 -1
@@ 5,7 5,10 @@ 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 }
data RectStyle = RectStyle {
    colours :: ColourPallet,
    backgrounds :: Backgrounds
} deriving (Read, Show, Eq)
colour = foreground . colours

instance PropertyParser RectStyle where

M lib/Graphics/Rendering/Rect/CSS/Background.hs => lib/Graphics/Rendering/Rect/CSS/Background.hs +1 -1
@@ 8,7 8,7 @@ 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 }

M lib/Graphics/Rendering/Rect/CSS/Colour.hs => lib/Graphics/Rendering/Rect/CSS/Colour.hs +1 -1
@@ 25,7 25,7 @@ hsl' h s l = uncurryRGB rgb $ hsl h s l
data ColourPallet = ColourPallet {
    foreground :: AlphaColour Float,
    accent :: AlphaColour Float
}
} deriving (Read, Show, Eq)

instance PropertyParser ColourPallet where
    temp = ColourPallet { foreground = opaque black, accent = opaque blue }