summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Widgets/AlphaBox.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Phi/Widgets/AlphaBox.hs')
-rw-r--r--lib/Phi/Widgets/AlphaBox.hs26
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