From 5c9c99b41ce1ecfee70071ecd3b369855b72d259 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 13 Jul 2011 02:13:01 +0200 Subject: Added basic rendering functions --- lib/Phi/Panel.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/Phi/Panel.hs') diff --git a/lib/Phi/Panel.hs b/lib/Phi/Panel.hs index b15f6ab..d54124f 100644 --- a/lib/Phi/Panel.hs +++ b/lib/Phi/Panel.hs @@ -1,6 +1,7 @@ {-# LANGUAGE ExistentialQuantification #-} module Phi.Panel ( Position(..) + , Color , Panel(..) , PanelClass(..) , (<~>) @@ -12,14 +13,21 @@ module Phi.Panel ( Position(..) import Data.Function import Data.Monoid +import Graphics.Rendering.Cairo + + data Position = Top | Bottom +type Color = (Double, Double, Double, Double) + class PanelClass a where minSize :: a -> Int weight :: a -> Float weight _ = 0 + render :: a -> Int -> Int -> Render () + data Panel = forall a. PanelClass a => Panel a | CompoundPanel [Panel] instance Monoid Panel where @@ -38,6 +46,9 @@ instance PanelClass Panel where weight (Panel p) = weight p weight (CompoundPanel panels) = sum $ map weight panels + + render (Panel p) w h = render p w h + render (CompoundPanel panels) _ _ = return () (<~>) :: Panel -> Panel -> Panel (<~>) = mappend @@ -56,6 +67,7 @@ data Separator = Separator Int Float instance PanelClass Separator where minSize (Separator s _) = s weight (Separator _ w) = w + render (Separator _ _) _ _ = return () separator :: Int -> Float -> Panel separator s w = Panel $ Separator s w -- cgit v1.2.3