summaryrefslogtreecommitdiffstats
path: root/lib/Phi
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Phi')
-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