summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-15 17:57:22 +0100
committerjao <jao@gnu.org>2022-09-15 17:57:22 +0100
commitcffab2fb8df0a7804e626af913d5b3d0df65ee65 (patch)
treeac3eb3975a071ff7da9e73bea46997871f7c69c7 /src
parente39f66aac6805d832e8a5bc765ba9b385a20cd16 (diff)
downloadxmobar-cffab2fb8df0a7804e626af913d5b3d0df65ee65.tar.gz
xmobar-cffab2fb8df0a7804e626af913d5b3d0df65ee65.tar.bz2
cairo: boxes, take two
Diffstat (limited to 'src')
-rw-r--r--src/Xmobar/X11/CairoDraw.hs27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/Xmobar/X11/CairoDraw.hs b/src/Xmobar/X11/CairoDraw.hs
index df6f1e4..9086792 100644
--- a/src/Xmobar/X11/CairoDraw.hs
+++ b/src/Xmobar/X11/CairoDraw.hs
@@ -143,26 +143,23 @@ renderRects color wd rects = do
boxRects :: Box -> Double -> Double -> Double -> [(Double, Double, Double, Double)]
boxRects (Box bd offset lw _ margins) ht x0 x1 =
case bd of
- BBTop -> [rtop]
- BBBottom -> [rbot]
- BBVBoth -> [rtop, rbot]
- BBLeft -> [rleft]
- BBRight -> [rright]
- BBHBoth -> [rleft, rright]
+ BBTop -> [rtop]; BBBottom -> [rbot]; BBVBoth -> [rtop, rbot]
+ BBLeft -> [rleft]; BBRight -> [rright]; BBHBoth -> [rleft, rright]
BBFull -> [rtop, rbot, rleft, rright]
where (BoxMargins top right bot left) = margins
(BoxOffset align m) = offset
ma = fromIntegral m
- (p0, p1) = case align of
- L -> (0, -ma)
- C -> (ma, -ma)
- R -> (ma, 0)
- lc = fromIntegral (lw `div` 2)
+ (p0, p1) = case align of L -> (0, -ma); C -> (ma, -ma); R -> (ma, 0)
+ lc = fromIntegral lw / 2
[mt, mr, mb, ml] = map fromIntegral [top, right, bot, left]
- rtop = (x0 + p0, mt + lc, x1 + p1 - x0 - p0, 0)
- rbot = (x0 + p0, ht - mb - max lc 1, x1 + p1 - x0 - p0, 0)
- rleft = (x0 - 1 + ml, p0, 0, ht + p1 - p0)
- rright = (x1 + lc - 1 - mr, p0, 0, ht + p1 - p0)
+ xmin = x0 - ml - lc
+ xmax = x1 + mr + lc
+ ymin = mt + lc
+ ymax = ht - mb - lc
+ rtop = (xmin + p0, ymin, xmax + p1 - xmin - p0, 0)
+ rbot = (xmin + p0, ymax, xmax + p1 - xmin - p0, 0)
+ rleft = (xmin, ymin + p0, 0, ymax + p1 - ymin - p0)
+ rright = (xmax, ymin + p0, 0, ymax + p1 - ymin - p0)
drawBox :: DrawContext -> Surface -> Double -> Double -> Box -> IO ()
drawBox dctx surf x0 x1 box@(Box _ _ w color _) =