Allow selection items to have a payload

This commit is contained in:
2022-12-24 00:28:04 +00:00
parent 5356d21778
commit a97c5ec8ef
8 changed files with 65 additions and 92 deletions
-19
View File
@@ -6,25 +6,6 @@ import Dodge.Data.Universe
import LensHelp
import Data.Maybe
setShownSelectionItems :: ScreenLayer -> ScreenLayer
setShownSelectionItems sl = fromMaybe sl $ do
offset <- sl ^? scOffset
maxlines <- sl ^? scAvailableLines
return $ setShownSelectionItems' maxlines offset sl
setShownSelectionItems' :: Int -> Int -> ScreenLayer -> ScreenLayer
setShownSelectionItems' maxlines offset sl = case sl ^? scListDisplayParams . ldpSizeRestriction of
Just (SelectionSizeRestriction botit)
| length allitems > maxlines ->
sl & scShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
++ [(botit,ScrollSelectionItem)]
& scSelectionList . slItems .~ map fst ( take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
++ [(botit,ScrollSelectionItem)])
_ -> sl & scShownItems .~ allitems
where
-- dummyitem = (SelectionItem [] 1 False 0 white 0, DummySelectionItem)
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. scSelectionList . slItems) [0..]
getAvailableListLines :: ListDisplayParams -> Configuration -> Int
getAvailableListLines ldps cfig = nlines
where