diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-18 20:57:19 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-18 20:57:19 +0200 |
commit | 581e1f9c63101fd2a00711748415997b0c20b793 (patch) | |
tree | ab2ee291354819727939593655e0a53383870b03 /lib/Phi/Widget.hs | |
parent | 4cc0f0f2ee44aa5c65b8b7f759620b5de0c874a3 (diff) | |
download | phi-581e1f9c63101fd2a00711748415997b0c20b793.tar phi-581e1f9c63101fd2a00711748415997b0c20b793.zip |
Make minSize depend on the screen if necessary
Diffstat (limited to 'lib/Phi/Widget.hs')
-rw-r--r-- | lib/Phi/Widget.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/Phi/Widget.hs b/lib/Phi/Widget.hs index d954b58..6a2a9f6 100644 --- a/lib/Phi/Widget.hs +++ b/lib/Phi/Widget.hs @@ -64,13 +64,13 @@ class Show a => WidgetClass a where initWidget :: a -> Phi -> Display -> IO (WidgetData a) - minSize :: a -> WidgetData a -> Int -> Int + minSize :: a -> WidgetData a -> Int -> Xlib.Rectangle -> Int weight :: a -> Float weight _ = 0 - layout :: a -> WidgetData a -> Int -> Int -> WidgetData a - layout _ priv _ _ = priv + layout :: a -> WidgetData a -> Int -> Int -> Xlib.Rectangle -> WidgetData a + layout _ priv _ _ _ = priv render :: a -> WidgetData a -> Int -> Int -> Xlib.Rectangle -> Render () @@ -101,10 +101,10 @@ createWidgetState phi disp (Widget w) = do , statePrivateData = priv } -layoutWidgets :: [WidgetState] -> Int -> Int -> Int -> Int -> [WidgetState] -layoutWidgets widgets x y width height = snd $ mapAccumL layoutWidgetAndX x widgets +layoutWidgets :: [WidgetState] -> Int -> Int -> Int -> Int -> Xlib.Rectangle -> [WidgetState] +layoutWidgets widgets x y width height screen = snd $ mapAccumL layoutWidgetAndX x widgets where - sizesum = sum $ map (\(WidgetState {stateWidget = w, statePrivateData = priv} ) -> nneg $ minSize w priv height) widgets + sizesum = sum $ map (\(WidgetState {stateWidget = w, statePrivateData = priv} ) -> nneg $ minSize w priv height screen) widgets wsum = let wsum = sum $ map (\(WidgetState {stateWidget = w} ) -> nneg . weight $ w) widgets in if wsum > 0 then wsum else 1 @@ -115,8 +115,8 @@ layoutWidgets widgets x y width height = snd $ mapAccumL layoutWidgetAndX x widg layoutWidget wX state = case state of WidgetState {stateWidget = w, statePrivateData = priv} -> - let wWidth = floor $ (fromIntegral $ minSize w priv height) + (fromIntegral surplus)*(nneg $ weight w)/wsum - priv' = layout w priv wWidth height + let wWidth = floor $ (fromIntegral $ minSize w priv height screen) + (fromIntegral surplus)*(nneg $ weight w)/wsum + priv' = layout w priv wWidth height screen in WidgetState w wX y wWidth height priv' nneg :: (Num a, Ord a) => a -> a @@ -145,7 +145,7 @@ instance WidgetClass Separator where type WidgetData Separator = () initWidget _ _ _ = return () - minSize (Separator s _) _ _ = s + minSize (Separator s _) _ _ _ = s weight (Separator _ w) = w render _ _ _ _ _ = return () |