diff options
| author | jao <jao@gnu.org> | 2022-09-21 00:52:59 +0100 | 
|---|---|---|
| committer | jao <jao@gnu.org> | 2022-09-21 01:11:33 +0100 | 
| commit | 832985aec801620baa08bc434def294da8ef3f44 (patch) | |
| tree | 6bbc9d5903d753062932b5979b3f28e44e569b9e /src/Xmobar/Draw | |
| parent | c824651f98a84eab63cb5ba4a1a5cd98ba761036 (diff) | |
| download | xmobar-832985aec801620baa08bc434def294da8ef3f44.tar.gz xmobar-832985aec801620baa08bc434def294da8ef3f44.tar.bz2 | |
better abstracted icon drawing interface
Diffstat (limited to 'src/Xmobar/Draw')
| -rw-r--r-- | src/Xmobar/Draw/Cairo.hs | 5 | ||||
| -rw-r--r-- | src/Xmobar/Draw/Types.hs | 23 | 
2 files changed, 6 insertions, 22 deletions
| diff --git a/src/Xmobar/Draw/Cairo.hs b/src/Xmobar/Draw/Cairo.hs index a25cca0..7e22df4 100644 --- a/src/Xmobar/Draw/Cairo.hs +++ b/src/Xmobar/Draw/Cairo.hs @@ -94,11 +94,10 @@ withRenderinfo _ _ seg@(P.Hspace w, _, _, _) =    return (seg, \_ _ _ -> return (), fromIntegral w)  withRenderinfo _ dctx seg@(P.Icon p, _, _, _) = do -  let bm = T.dcBitmapLookup dctx p -      wd = maybe 0 (fromIntegral . T.bWidth) bm +  let (wd, _) = T.dcIconLookup dctx p        ioff = C.iconOffset (T.dcConfig dctx)        vpos = T.dcHeight dctx / 2  + fromIntegral ioff -      render _ off mx = when (off + wd <= mx) $ T.dcBitmapDrawer dctx off vpos p +      render _ off mx = when (off + wd <= mx) $ T.dcIconDrawer dctx off vpos p    return (seg, render, wd)  drawBox :: T.DrawContext -> Surface -> Double -> Double -> P.Box -> IO () diff --git a/src/Xmobar/Draw/Types.hs b/src/Xmobar/Draw/Types.hs index 219a64b..75dd714 100644 --- a/src/Xmobar/Draw/Types.hs +++ b/src/Xmobar/Draw/Types.hs @@ -17,10 +17,6 @@  module Xmobar.Draw.Types where -import GHC.Word (Word32, Word64) - -import Data.Map (Map) -  import Xmobar.Config.Types (Config)  import Xmobar.Run.Actions (Action)  import Xmobar.Run.Parsers (Segment) @@ -29,22 +25,11 @@ type Position = Double  type ActionPos = ([Action], Position, Position)  type Actions = [ActionPos] -type BitmapDrawer = Double -> Double -> String -> IO () - -data BitmapType = Mono Word64 | Poly - -data Bitmap = Bitmap { bWidth  :: Word32 -                     , bHeight :: Word32 -                     , bPixmap :: Word64 -                     , bShapepixmap :: Maybe Word64 -                     , bBitmaptype :: BitmapType -                     } - -type BitmapCache = Map FilePath Bitmap - +type IconLookup = String -> (Double, Double) +type IconDrawer = Double -> Double -> String -> IO () -data DrawContext = DC { dcBitmapDrawer :: BitmapDrawer -                      , dcBitmapLookup :: String -> Maybe Bitmap +data DrawContext = DC { dcIconDrawer :: IconDrawer +                      , dcIconLookup :: IconLookup                        , dcConfig :: Config                        , dcWidth :: Double                        , dcHeight :: Double | 
