diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-14 00:09:20 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-14 00:09:20 +0200 |
commit | 55d15b73caa4b8d74cf7d678842da69302e600d9 (patch) | |
tree | f24500cc8ffb6a1c1ad3bff774d741081069d082 /lib/Phi/Panel.hs | |
parent | 90c25a997bf951ea4b5c13cb95ef0dbb8105777e (diff) | |
download | phi-55d15b73caa4b8d74cf7d678842da69302e600d9.tar phi-55d15b73caa4b8d74cf7d678842da69302e600d9.zip |
Restructured widget state
Diffstat (limited to 'lib/Phi/Panel.hs')
-rw-r--r-- | lib/Phi/Panel.hs | 66 |
1 files changed, 4 insertions, 62 deletions
diff --git a/lib/Phi/Panel.hs b/lib/Phi/Panel.hs index d54124f..a31ffad 100644 --- a/lib/Phi/Panel.hs +++ b/lib/Phi/Panel.hs @@ -1,73 +1,15 @@ -{-# LANGUAGE ExistentialQuantification #-} - -module Phi.Panel ( Position(..) - , Color - , Panel(..) - , PanelClass(..) - , (<~>) - , PanelConfig(..) +module Phi.Panel ( PanelConfig(..) , defaultPanelConfig - , separator ) where -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 - mempty = CompoundPanel [] - mappend a b = makePanel $ (toList a) ++ (toList b) - where - toList (Panel p) = [Panel p] - toList (CompoundPanel panels) = panels - - makePanel [p] = p - makePanel panels = CompoundPanel panels - -instance PanelClass Panel where - minSize (Panel p) = minSize p - minSize (CompoundPanel panels) = sum $ map minSize panels - - 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 +import Phi.Types +import Phi.Widget data PanelConfig = PanelConfig { panelPosition :: Position , panelSize :: Int - , panelContent :: Panel } defaultPanelConfig :: PanelConfig -defaultPanelConfig = PanelConfig { panelPosition = Top, panelSize = 24, panelContent = mempty } - -data Separator = Separator Int Float - -instance PanelClass Separator where - minSize (Separator s _) = s - weight (Separator _ w) = w - render (Separator _ _) _ _ = return () +defaultPanelConfig = PanelConfig { panelPosition = Top, panelSize = 24 } -separator :: Int -> Float -> Panel -separator s w = Panel $ Separator s w |