summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-17 20:06:33 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-17 20:06:33 +0200
commitfe9d19a394cdb4492d7daf2dfc8f883227fc119e (patch)
tree61b8f496fd9da46d97ef3f14099f87082fda0b27 /lib
parent0fefcaa35f217ca2e1f15e2dd77742adfd231571 (diff)
downloadphi-fe9d19a394cdb4492d7daf2dfc8f883227fc119e.tar
phi-fe9d19a394cdb4492d7daf2dfc8f883227fc119e.zip
Nicer downscaling of taskbar icons
Diffstat (limited to 'lib')
-rw-r--r--lib/Phi/Widgets/Taskbar.hs61
1 files changed, 40 insertions, 21 deletions
diff --git a/lib/Phi/Widgets/Taskbar.hs b/lib/Phi/Widgets/Taskbar.hs
index bd45add..72fd5c8 100644
--- a/lib/Phi/Widgets/Taskbar.hs
+++ b/lib/Phi/Widgets/Taskbar.hs
@@ -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
- withPatternForSurface icon setSource
- paint
-
- setOperator OperatorHslSaturation
- setSourceRGBA 0 0 0 (1-v)
- paint
-
- withPatternForSurface surface2 setSource
- paint
+ 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
- setOperator OperatorDestIn
- withPatternForSurface icon 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,12 +236,13 @@ 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
- taskIconStyle style icon
paint
restore