Remove cursor type from ListDisplayParams

This commit is contained in:
2024-10-25 17:41:37 +01:00
parent bd505b072a
commit 6424899afd
7 changed files with 252 additions and 208 deletions
+25 -11
View File
@@ -36,9 +36,12 @@ drawSelectionList ldps cfig sl =
(_ldpScale ldps)
0
(makeSelectionListPictures sl)
<> drawSelectionCursor sl ldps
<> drawSelectionCursor sl ldps (CursorDisplay [North,West,South])
drawSelectionCursor :: SelectionList a -> ListDisplayParams -> Picture
drawSelectionCursor :: SelectionList a
-> ListDisplayParams
-> CursorDisplay
-> Picture
drawSelectionCursor sl = drawCursorAt (f $ sl ^. slSelPos) (getShownItems sl)
where
-- the following is quite hacky
@@ -53,15 +56,18 @@ makeSelectionListPictures = concatMap f . getShownItems
f si = map (color (_siColor si) . text) $ _siPictures si
--f si = map ((flip inverseText) ((_siColor si))) $ _siPictures si
drawCursorAt :: Maybe Int -> [SelectionItem a] -> ListDisplayParams -> Picture
drawCursorAt mi lis ldps = fromMaybe mempty $ do
drawCursorAt :: Maybe Int -> [SelectionItem a]
-> ListDisplayParams
-> CursorDisplay
-> Picture
drawCursorAt mi lis ldps curs = fromMaybe mempty $ do
i <- mi
selit <- lis !? i
return $
listCursorChooseBorderScale
(_ldpVerticalGap ldps)
(_ldpScale ldps)
(ldps ^. ldpCursorSides)
(curs ^. cursSides)
(sum . map _siHeight $ take i lis)
(_siOffX selit)
(_siColor selit)
@@ -85,8 +91,14 @@ stackPicturesAt = stackPicturesAtOff 0
stackPicturesAtOff :: Int -> [Picture] -> Picture
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
selSecDrawCursorAt :: (Int,Int) -> Int -> ListDisplayParams -> SelectionSections a -> Picture
selSecDrawCursorAt (i,j) xsize ldp sss = fromMaybe mempty $ do
selSecDrawCursorAt
:: (Int,Int)
-> Int
-> ListDisplayParams
-> CursorDisplay
-> SelectionSections a
-> Picture
selSecDrawCursorAt (i,j) xsize ldp curs sss = fromMaybe mempty $ do
yint <- selSecYint i j sss
xint <- sss ^? sssSections . ix i . ssIndent
si <- sss ^? sssSections . ix i . ssItems . ix j
@@ -94,17 +106,19 @@ selSecDrawCursorAt (i,j) xsize ldp sss = fromMaybe mempty $ do
listCursorChooseBorderScale
(ldp ^. ldpVerticalGap)
(ldp ^. ldpScale)
(ldp ^. ldpCursorSides)
(curs ^. cursSides)
yint
(xint + _siOffX si)
(_siColor si)
xsize
(_siHeight si)
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a ->
selSecDrawCursor :: Int -> ListDisplayParams
-> CursorDisplay
-> SelectionSections a ->
Maybe (Int,Int) -> Picture
selSecDrawCursor xsize ldp sss msel = maybe mempty
(\x -> selSecDrawCursorAt x xsize ldp sss)
selSecDrawCursor xsize ldp curs sss msel = maybe mempty
(\x -> selSecDrawCursorAt x xsize ldp curs sss)
msel
-- displays a cursor that should match up to list text pictures