diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-08-29 15:34:56 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-08-29 15:34:56 +0200 |
commit | eca887df7c5e71606e6e0f80d48067e1ebdf5159 (patch) | |
tree | 430237ce8d77ab4722a45ed24a5682438cc2f7e7 /lib/Phi/Widget.hs | |
parent | 7a87ba6f2e3e864fb1c487c097e2cf17bfca2df6 (diff) | |
download | phi-eca887df7c5e71606e6e0f80d48067e1ebdf5159.tar phi-eca887df7c5e71606e6e0f80d48067e1ebdf5159.zip |
Don't use the widget definition as a part of the render cache state
Diffstat (limited to 'lib/Phi/Widget.hs')
-rw-r--r-- | lib/Phi/Widget.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Phi/Widget.hs b/lib/Phi/Widget.hs index 791eff1..e3f8388 100644 --- a/lib/Phi/Widget.hs +++ b/lib/Phi/Widget.hs @@ -86,7 +86,7 @@ class Eq s => Widget w s c | w -> s, w -> c where handleMessage _ priv _ = priv type IOCache = CacheArrow (Kleisli IO) -type RenderCache w s = IOCache (w, s, Int, Int, Int, Int, Xlib.Rectangle) Surface +type RenderCache s = IOCache (s, Int, Int, Int, Int, Xlib.Rectangle) Surface createIOCache :: Eq a => (a -> IO b) -> IOCache a b createIOCache = lift . Kleisli @@ -98,21 +98,21 @@ runIOCache a = do put cache' return b -createRenderCache :: (w -> s -> Int -> Int -> Int -> Int -> Xlib.Rectangle -> Render ()) - -> CacheArrow (Kleisli IO) (w, s, Int, Int, Int, Int, Xlib.Rectangle) Surface -createRenderCache f = lift . Kleisli $ \(widget, state, x, y, w, h, screen) -> do +createRenderCache :: (s -> Int -> Int -> Int -> Int -> Xlib.Rectangle -> Render ()) + -> CacheArrow (Kleisli IO) (s, Int, Int, Int, Int, Xlib.Rectangle) Surface +createRenderCache f = lift . Kleisli $ \(state, x, y, w, h, screen) -> do surface <- createImageSurface FormatARGB32 w h renderWith surface $ do setOperator OperatorClear paint setOperator OperatorOver - f widget state x y w h screen + f state x y w h screen return surface -renderCached :: (Eq w, Eq s) => w -> s -> Int -> Int -> Int -> Int -> Xlib.Rectangle -> StateT (RenderCache w s) IO [(Bool, SurfaceSlice)] -renderCached widget state x y w h screen = do +renderCached :: Eq s => s -> Int -> Int -> Int -> Int -> Xlib.Rectangle -> StateT (RenderCache s) IO [(Bool, SurfaceSlice)] +renderCached state x y w h screen = do cache <- get - (surf, updated, cache') <- liftIO $ runKleisli (runCache' cache) (widget, state, x, y, w, h, screen) + (surf, updated, cache') <- liftIO $ runKleisli (runCache' cache) (state, x, y, w, h, screen) put cache' return [(updated, SurfaceSlice 0 surf)] @@ -157,15 +157,15 @@ a <~> b = CompoundWidget a b data Separator = Separator !Int !Float deriving (Show, Eq) -instance Widget Separator () (RenderCache Separator ()) where +instance Widget Separator () (RenderCache ()) where initWidget _ _ _ _ = return () - initCache _ = createRenderCache $ \_ _ _ _ _ _ _ -> do + initCache _ = createRenderCache $ \_ _ _ _ _ _ -> do setOperator OperatorClear paint minSize (Separator s _) _ _ _ = s weight (Separator _ w) = w - render = renderCached + render _ = renderCached separator :: Int -> Float -> Separator |