45 lines
1.1 KiB
Haskell
45 lines
1.1 KiB
Haskell
{-# LANGUAGE MultiParamTypeClasses, StandaloneDeriving, ExistentialQuantification, FlexibleInstances #-}
|
|
|
|
module Phi.Widgets.AlphaBox ( AlphaBox
|
|
, alphaBox
|
|
) where
|
|
|
|
import Phi.Types
|
|
import Phi.Widget
|
|
|
|
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)
|
|
|
|
instance Eq d => Widget (AlphaBox w d) d where
|
|
initWidget (AlphaBox _ w) = initWidget w
|
|
|
|
minSize (AlphaBox _ w) = minSize w
|
|
|
|
weight (AlphaBox _ w) = weight w
|
|
|
|
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
|
|
|
|
setOperator OperatorDestIn
|
|
setSourceRGBA 0 0 0 alpha
|
|
paint
|
|
|
|
withPatternForSurface surface setSource
|
|
paint
|
|
|
|
handleMessage (AlphaBox _ w) = handleMessage w
|
|
|
|
|
|
alphaBox :: (Widget w d) => Double -> w -> AlphaBox w d
|
|
alphaBox = AlphaBox
|
|
|