Files
loop/src/Dodge/SelectionList.hs
T
2023-05-15 06:46:09 +01:00

25 lines
706 B
Haskell

module Dodge.SelectionList (
getShownItems,
getAvailableListLines,
) where
import Dodge.Data.ScreenPos
import Dodge.Data.Universe
import LensHelp
import Linear
getAvailableListLines :: ListDisplayParams -> Configuration -> Int
getAvailableListLines ldps cfig = floor ((dToBot - vgap) / itmHeight)
where
vgap = ldps ^. ldpVerticalGap
itmHeight = 20 * ldps ^. ldpScale + vgap
winy = fromIntegral $ cfig ^. windowY
dToBot =
winy / 2 + winy * (ldps ^. ldpPos . spScreenOff . _y)
+ (ldps ^. ldpPos . spPixelOff . _y)
getShownItems :: SelectionList a -> [SelectionItem a]
getShownItems sl = case sl ^. slRegexList of
[] -> sl ^. slItems
xs -> fmap fst xs