diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-13 02:13:01 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-13 02:13:01 +0200 |
commit | 5c9c99b41ce1ecfee70071ecd3b369855b72d259 (patch) | |
tree | 77e460321ef2375adeaec2e96c09484b5948cc0f /lib/Phi/Panel.hs | |
parent | 982bcffcfeb074b4c1beff64ca7361a9a66ed273 (diff) | |
download | phi-5c9c99b41ce1ecfee70071ecd3b369855b72d259.tar phi-5c9c99b41ce1ecfee70071ecd3b369855b72d259.zip |
Added basic rendering functions
Diffstat (limited to 'lib/Phi/Panel.hs')
-rw-r--r-- | lib/Phi/Panel.hs | 12 |
1 files changed, 12 insertions, 0 deletions
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 |