diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-08-21 19:34:16 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-08-21 19:34:16 +0200 |
commit | 42c14fa1ca9d47ae32766aaa2aa995c684b7e9cb (patch) | |
tree | 7c12e75cf89573c2d3ecb8c0c4fcc4ccbc56b24d /lib/Phi/Widgets/AlphaBox.hs | |
parent | ddca7c3ec59a5b7c62a11afe225de40edbde85ff (diff) | |
download | phi-42c14fa1ca9d47ae32766aaa2aa995c684b7e9cb.tar phi-42c14fa1ca9d47ae32766aaa2aa995c684b7e9cb.zip |
Make render function return cachable surface slices
Diffstat (limited to 'lib/Phi/Widgets/AlphaBox.hs')
-rw-r--r-- | lib/Phi/Widgets/AlphaBox.hs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/Phi/Widgets/AlphaBox.hs b/lib/Phi/Widgets/AlphaBox.hs index eacda5a..cd540e3 100644 --- a/lib/Phi/Widgets/AlphaBox.hs +++ b/lib/Phi/Widgets/AlphaBox.hs @@ -12,11 +12,11 @@ import Control.Monad import Graphics.Rendering.Cairo -data AlphaBox w d = (Widget w d) => AlphaBox !Double !w -deriving instance Show (AlphaBox w d) -deriving instance Eq (AlphaBox w d) +data AlphaBox w s c = (Widget w s c) => AlphaBox !Double !w +deriving instance Show (AlphaBox w s c) +deriving instance Eq (AlphaBox w s c) -instance Eq d => Widget (AlphaBox w d) d where +instance Eq s => Widget (AlphaBox w s c) s () where initWidget (AlphaBox _ w) = initWidget w minSize (AlphaBox _ w) = minSize w @@ -25,21 +25,25 @@ instance Eq d => Widget (AlphaBox w d) d where layout (AlphaBox _ w) = layout w - render (AlphaBox alpha w) d x y width height screen = do - renderWithSimilarSurface ContentColorAlpha width height $ \surface -> do - renderWith surface $ do - render w d x y width height screen + render (AlphaBox alpha w) s x y width height screen = do + surfaces <- render w s x y width height screen + let surfacesWidths = zipWith (\(updated, SurfaceSlice x surf) x' -> (updated, x, x'-x, surf)) surfaces (map (\(_, SurfaceSlice x _) -> x) (tail surfaces) ++ [width]) + forM surfacesWidths $ \(updated, x, surfWidth, surf) -> do + surf' <- createImageSurface FormatARGB32 surfWidth height + renderWith surf' $ do + setOperator OperatorSource + withPatternForSurface surf setSource + paint setOperator OperatorDestIn setSourceRGBA 0 0 0 alpha paint - withPatternForSurface surface setSource - paint + return (updated, SurfaceSlice x surf') handleMessage (AlphaBox _ w) = handleMessage w -alphaBox :: (Widget w d) => Double -> w -> AlphaBox w d +alphaBox :: (Widget w s c) => Double -> w -> AlphaBox w s c alphaBox = AlphaBox |