Nicer downscaling of taskbar icons

This commit is contained in:
Matthias Schiffer 2011-07-17 20:06:33 +02:00
parent 0fefcaa35f
commit fe9d19a394

View file

@ -58,25 +58,43 @@ desaturateIconStyle v icon = do
w <- imageSurfaceGetWidth icon w <- imageSurfaceGetWidth icon
h <- imageSurfaceGetHeight icon h <- imageSurfaceGetHeight icon
renderWithSimilarSurface ContentColorAlpha w h $ \surface1 -> do renderWithSimilarSurface ContentColorAlpha w h $ \surface -> do
renderWithSimilarSurface ContentColor w h $ \surface2 -> do renderWith surface $ do
renderWith surface1 $ do setOperator OperatorAdd
renderWith surface2 $ do withPatternForSurface icon setSource
withPatternForSurface icon setSource paint
paint
setOperator OperatorHslSaturation setSourceRGB 0 0 0
setSourceRGBA 0 0 0 (1-v) paint
paint
withPatternForSurface surface2 setSource setOperator OperatorHslSaturation
paint setSourceRGBA 0 0 0 (1-v)
paint
setOperator OperatorDestIn setOperator OperatorDestIn
withPatternForSurface icon setSource withPatternForSurface icon setSource
paint paint
withPatternForSurface surface setSource
downscaled :: Double -> Surface -> Render ()
downscaled s surface = do
case True of
_ | s < 0.5 -> do
w <- imageSurfaceGetWidth surface
h <- imageSurfaceGetHeight surface
renderWithSimilarSurface ContentColorAlpha w h $ \surface' -> do
renderWith surface' $ do
scale 0.5 0.5
downscaled (2*s) surface
paint
withPatternForSurface surface' setSource
| otherwise -> do
scale s s
withPatternForSurface surface setSource
withPatternForSurface surface1 setSource
data TaskStyle = TaskStyle { taskFont :: !String data TaskStyle = TaskStyle { taskFont :: !String
, taskColor :: !Color , taskColor :: !Color
@ -218,12 +236,13 @@ instance WidgetClass Taskbar where
imageH <- imageSurfaceGetHeight icon imageH <- imageSurfaceGetHeight icon
let scalef = (fromIntegral h')/(fromIntegral $ max imageW imageH) let scalef = (fromIntegral h')/(fromIntegral $ max imageW imageH)
scale scalef scalef
when (imageH < imageW) $ renderWithSimilarSurface ContentColorAlpha imageW imageH $ \surface -> do
translate 0 $ (fromIntegral (imageW-imageH))/2 renderWith surface $ do
taskIconStyle style icon
paint
downscaled scalef surface
taskIconStyle style icon
paint paint
restore restore