This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
phi/lib/Phi/Widgets/AlphaBox.hs

46 lines
1.1 KiB
Haskell
Raw Normal View History

{-# LANGUAGE MultiParamTypeClasses, StandaloneDeriving, ExistentialQuantification, FlexibleInstances #-}
2011-07-18 18:06:00 +02:00
module Phi.Widgets.AlphaBox ( AlphaBox
, alphaBox
2011-07-18 18:06:00 +02:00
) 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)
2011-07-18 18:06:00 +02:00
instance Eq d => Widget (AlphaBox w d) d where
initWidget (AlphaBox _ w) = initWidget w
2011-07-18 18:06:00 +02:00
minSize (AlphaBox _ w) = minSize w
2011-07-18 18:06:00 +02:00
weight (AlphaBox _ w) = weight w
2011-07-18 18:06:00 +02:00
layout (AlphaBox _ w) = layout w
2011-07-18 18:06:00 +02:00
render (AlphaBox alpha w) d x y width height screen = do
renderWithSimilarSurface ContentColorAlpha width height $ \surface -> do
2011-07-18 18:06:00 +02:00
renderWith surface $ do
render w d x y width height screen
2011-07-18 18:06:00 +02:00
setOperator OperatorDestIn
setSourceRGBA 0 0 0 alpha
paint
withPatternForSurface surface setSource
paint
handleMessage (AlphaBox _ w) = handleMessage w
2011-07-18 18:06:00 +02:00
alphaBox :: (Widget w d) => Double -> w -> AlphaBox w d
alphaBox = AlphaBox
2011-07-18 18:06:00 +02:00