summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Border.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-14 00:09:20 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-14 00:09:20 +0200
commit55d15b73caa4b8d74cf7d678842da69302e600d9 (patch)
treef24500cc8ffb6a1c1ad3bff774d741081069d082 /lib/Phi/Border.hs
parent90c25a997bf951ea4b5c13cb95ef0dbb8105777e (diff)
downloadphi-55d15b73caa4b8d74cf7d678842da69302e600d9.tar
phi-55d15b73caa4b8d74cf7d678842da69302e600d9.zip
Restructured widget state
Diffstat (limited to 'lib/Phi/Border.hs')
-rw-r--r--lib/Phi/Border.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Phi/Border.hs b/lib/Phi/Border.hs
index 42a0e8e..a110f2d 100644
--- a/lib/Phi/Border.hs
+++ b/lib/Phi/Border.hs
@@ -1,9 +1,12 @@
+{-# LANGUAGE TypeFamilies #-}
+
module Phi.Border ( BorderWidth(..)
, simpleBorderWidth
, border
) where
-import Phi.Panel
+import Phi.Types
+import Phi.Widget
import Graphics.Rendering.Cairo
@@ -30,11 +33,14 @@ data Border = Border { margin :: !BorderWidth
, backgroundColor :: !Color
, cornerRadius :: !Double
, borderWeight :: !Float
- , content :: !Panel
+ , content :: ![Widget]
}
-instance PanelClass Border where
- minSize border = minSize c + borderH p + 2*bw + borderH m
+instance WidgetClass Border where
+ type WidgetData Border = ()
+ initialState _ = ()
+
+ minSize border = sum (map (\(Widget w) -> minSize w) c) + borderH p + 2*bw + borderH m
where
m = margin border
bw = borderWidth border
@@ -43,7 +49,7 @@ instance PanelClass Border where
weight border = borderWeight border
- render border w h = do
+ render border _ w h = do
newPath
arc (x + width - radius) (y + radius) radius (-pi/2) 0
arc (x + width - radius) (y + height - radius) radius 0 (pi/2)
@@ -73,5 +79,5 @@ instance PanelClass Border where
(fr, fg, fb, fa) = backgroundColor border
-border :: BorderWidth -> Int -> BorderWidth -> Color -> Color -> Double -> Float -> Panel -> Panel
-border m bw p border bc cr w c = Panel $ Border m bw p border bc cr w c \ No newline at end of file
+border :: BorderWidth -> Int -> BorderWidth -> Color -> Color -> Double -> Float -> [Widget] -> Widget
+border m bw p border bc cr w c = Widget $ Border m bw p border bc cr w c \ No newline at end of file