diff options
Diffstat (limited to 'lib/Phi/Border.hs')
-rw-r--r-- | lib/Phi/Border.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Phi/Border.hs b/lib/Phi/Border.hs index 791845d..a025ab6 100644 --- a/lib/Phi/Border.hs +++ b/lib/Phi/Border.hs @@ -41,7 +41,7 @@ data BorderConfig = BorderConfig { margin :: !BorderWidth , padding :: !BorderWidth , borderColor :: !Color , backgroundColor :: !Color - , cornerRadius :: !Double + , cornerRadius :: !Int , borderWeight :: !Float } deriving Show @@ -60,11 +60,14 @@ instance WidgetClass Border where type WidgetData Border = BorderState initWidget (Border _ widgets) phi disp = liftM BorderState $ mapM (createWidgetState phi disp) widgets - minSize (Border config widgets) = sum (map (\(Widget w) -> minSize w) widgets) + borderH p + 2*bw + borderH m + minSize (Border config _) (BorderState widgetStates) height = + max (borderH m+2*(bw+cr)) $ sum (map (\(WidgetState {stateWidget = w, statePrivateData = priv}) -> minSize w priv height') widgetStates) + borderH p + 2*bw + borderH m where m = margin config bw = borderWidth config p = padding config + cr = cornerRadius config + height' = height - borderV m - 2*bw - borderV p weight (Border config _) = borderWeight config @@ -102,7 +105,7 @@ drawBorder config dx dy w h = do m = margin config bw = borderWidth config p = padding config - radius = cornerRadius config + radius = fromIntegral $ cornerRadius config x = (fromIntegral dx) + (fromIntegral $ borderLeft m) + (fromIntegral bw)/2 y = (fromIntegral dy) + (fromIntegral $ borderTop m) + (fromIntegral bw)/2 |