Add top and bottom desktop border margins and paddings, for the sake of consistency
This commit is contained in:
parent
4292cbce3e
commit
cc55ee7678
2 changed files with 66 additions and 60 deletions
|
@ -211,67 +211,73 @@ instance WidgetClass Taskbar where
|
|||
renderText (desktopFont ds) (fromIntegral (dx - dlabelwidth desktop - gap desktop ds)) 0 (dlabelwidth desktop) h $ show (desktop+1)
|
||||
|
||||
restore
|
||||
_ -> return ()
|
||||
|
||||
forM_ (zip [0..] desktopWindows) $ \(i, window) -> do
|
||||
let style = (if window == activeWindow then activeTaskStyle else normalTaskStyle) config
|
||||
(r, g, b, a) = taskColor style
|
||||
leftBorder = (borderLeft $ margin $ taskBorder style) + (borderWidth $ taskBorder style) + (borderLeft $ padding $ taskBorder style)
|
||||
rightBorder = (borderRight $ margin $ taskBorder style) + (borderWidth $ taskBorder style) + (borderRight $ padding $ taskBorder style)
|
||||
h' = h - (borderV $ margin $ taskBorder style)
|
||||
mstate = M.lookup window windowStates
|
||||
micons = M.lookup window windowIcons
|
||||
mscaledIconRef = M.lookup window windowScaledIcons
|
||||
x = dx + i*windowWidth
|
||||
|
||||
case (mstate, micons, mscaledIconRef) of
|
||||
(Just state, Just icons, Just scaledIconRef) -> do
|
||||
save
|
||||
drawBorder (taskBorder style) x 0 windowWidth h
|
||||
clip
|
||||
forM_ (zip [0..] desktopWindows) $ \(i, window) -> do
|
||||
let style = (if window == activeWindow then activeTaskStyle else normalTaskStyle) config
|
||||
(r, g, b, a) = taskColor style
|
||||
leftBorder = (borderLeft $ margin $ taskBorder style) + (borderWidth $ taskBorder style) + (borderLeft $ padding $ taskBorder style)
|
||||
rightBorder = (borderRight $ margin $ taskBorder style) + (borderWidth $ taskBorder style) + (borderRight $ padding $ taskBorder style)
|
||||
hd = h - (borderV $ margin $ desktopBorder ds) - 2*(borderWidth $ desktopBorder ds) - (borderV $ padding $ desktopBorder ds)
|
||||
h' = hd - (borderV $ margin $ taskBorder style)
|
||||
mstate = M.lookup window windowStates
|
||||
micons = M.lookup window windowIcons
|
||||
mscaledIconRef = M.lookup window windowScaledIcons
|
||||
x = dx + i*windowWidth
|
||||
|
||||
setSourceRGBA r g b a
|
||||
renderText (taskFont style) (fromIntegral (x + leftBorder + h' + 3)) 0 (windowWidth - leftBorder - h' - 3 - rightBorder) h $ windowTitle state
|
||||
|
||||
restore
|
||||
|
||||
mscaledIcon <- liftIO $ readIORef scaledIconRef
|
||||
scaledIcon <- case mscaledIcon of
|
||||
Just (size, icon) | size == h' -> do
|
||||
return $ Just icon
|
||||
_ -> do
|
||||
case bestIcon icons of
|
||||
Just icon -> do
|
||||
scaledIcon <- liftIO $ createSimilarSurface icon ContentColorAlpha h' h'
|
||||
renderWith scaledIcon $ do
|
||||
imageW <- imageSurfaceGetWidth icon
|
||||
imageH <- imageSurfaceGetHeight icon
|
||||
|
||||
let scalef = (fromIntegral h')/(fromIntegral $ max imageW imageH)
|
||||
|
||||
case True of
|
||||
_ | imageH < imageW -> translate 0 (fromIntegral (imageW-imageH)*scalef/2)
|
||||
| otherwise -> translate (fromIntegral (imageH-imageW)*scalef/2) 0
|
||||
|
||||
downscaled scalef icon
|
||||
paint
|
||||
liftIO $ writeIORef scaledIconRef $ Just (h', scaledIcon)
|
||||
return $ Just scaledIcon
|
||||
|
||||
Nothing -> return Nothing
|
||||
|
||||
case scaledIcon of
|
||||
Just icon -> do
|
||||
case (mstate, micons, mscaledIconRef) of
|
||||
(Just state, Just icons, Just scaledIconRef) -> do
|
||||
save
|
||||
translate (fromIntegral $ x + leftBorder) (fromIntegral $ borderTop $ margin $ taskBorder style)
|
||||
taskIconStyle style icon
|
||||
paint
|
||||
translate 0 $ fromIntegral $ ((borderTop $ margin $ desktopBorder ds) + (borderWidth $ desktopBorder ds) + (borderTop $ padding $ desktopBorder ds))
|
||||
save
|
||||
drawBorder (taskBorder style) x 0 windowWidth hd
|
||||
clip
|
||||
|
||||
setSourceRGBA r g b a
|
||||
renderText (taskFont style) (fromIntegral (x + leftBorder + h' + 3)) 0 (windowWidth - leftBorder - h' - 3 - rightBorder) hd $ windowTitle state
|
||||
|
||||
restore
|
||||
|
||||
mscaledIcon <- liftIO $ readIORef scaledIconRef
|
||||
scaledIcon <- case mscaledIcon of
|
||||
Just (size, icon) | size == h' -> do
|
||||
return $ Just icon
|
||||
_ -> do
|
||||
case bestIcon icons of
|
||||
Just icon -> do
|
||||
scaledIcon <- liftIO $ createSimilarSurface icon ContentColorAlpha h' h'
|
||||
renderWith scaledIcon $ do
|
||||
imageW <- imageSurfaceGetWidth icon
|
||||
imageH <- imageSurfaceGetHeight icon
|
||||
|
||||
let scalef = (fromIntegral h')/(fromIntegral $ max imageW imageH)
|
||||
|
||||
case True of
|
||||
_ | imageH < imageW -> translate 0 (fromIntegral (imageW-imageH)*scalef/2)
|
||||
| otherwise -> translate (fromIntegral (imageH-imageW)*scalef/2) 0
|
||||
|
||||
downscaled scalef icon
|
||||
paint
|
||||
liftIO $ writeIORef scaledIconRef $ Just (h', scaledIcon)
|
||||
return $ Just scaledIcon
|
||||
|
||||
Nothing -> return Nothing
|
||||
|
||||
case scaledIcon of
|
||||
Just icon -> do
|
||||
save
|
||||
translate (fromIntegral $ x + leftBorder) (fromIntegral $ borderTop $ margin $ taskBorder style)
|
||||
taskIconStyle style icon
|
||||
paint
|
||||
restore
|
||||
|
||||
Nothing ->
|
||||
return ()
|
||||
|
||||
restore
|
||||
|
||||
Nothing ->
|
||||
return ()
|
||||
|
||||
_ -> return ()
|
||||
_ -> return ()
|
||||
|
||||
_ -> return ()
|
||||
|
||||
return $ nwindows + length desktopWindows
|
||||
|
||||
|
|
Reference in a new issue