Nicer downscaling of taskbar icons
This commit is contained in:
parent
0fefcaa35f
commit
fe9d19a394
1 changed files with 41 additions and 22 deletions
|
@ -58,25 +58,43 @@ desaturateIconStyle v icon = do
|
|||
w <- imageSurfaceGetWidth icon
|
||||
h <- imageSurfaceGetHeight icon
|
||||
|
||||
renderWithSimilarSurface ContentColorAlpha w h $ \surface1 -> do
|
||||
renderWithSimilarSurface ContentColor w h $ \surface2 -> do
|
||||
renderWith surface1 $ do
|
||||
renderWith surface2 $ do
|
||||
renderWithSimilarSurface ContentColorAlpha w h $ \surface -> do
|
||||
renderWith surface $ do
|
||||
setOperator OperatorAdd
|
||||
withPatternForSurface icon setSource
|
||||
paint
|
||||
|
||||
setSourceRGB 0 0 0
|
||||
paint
|
||||
|
||||
setOperator OperatorHslSaturation
|
||||
setSourceRGBA 0 0 0 (1-v)
|
||||
paint
|
||||
|
||||
withPatternForSurface surface2 setSource
|
||||
paint
|
||||
|
||||
setOperator OperatorDestIn
|
||||
withPatternForSurface icon setSource
|
||||
paint
|
||||
|
||||
withPatternForSurface surface1 setSource
|
||||
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
|
||||
|
||||
|
||||
data TaskStyle = TaskStyle { taskFont :: !String
|
||||
, taskColor :: !Color
|
||||
|
@ -218,13 +236,14 @@ instance WidgetClass Taskbar where
|
|||
imageH <- imageSurfaceGetHeight icon
|
||||
|
||||
let scalef = (fromIntegral h')/(fromIntegral $ max imageW imageH)
|
||||
scale scalef scalef
|
||||
|
||||
when (imageH < imageW) $
|
||||
translate 0 $ (fromIntegral (imageW-imageH))/2
|
||||
|
||||
renderWithSimilarSurface ContentColorAlpha imageW imageH $ \surface -> do
|
||||
renderWith surface $ do
|
||||
taskIconStyle style icon
|
||||
paint
|
||||
downscaled scalef surface
|
||||
|
||||
paint
|
||||
restore
|
||||
|
||||
Nothing -> return ()
|
||||
|
|
Reference in a new issue