Allow selection items to have a payload
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user