Work on menus

This commit is contained in:
2022-11-22 10:14:25 +00:00
parent 054405244f
commit 860d63df45
13 changed files with 251 additions and 167 deletions
+16
View File
@@ -0,0 +1,16 @@
module Dodge.SelectionList where
import Dodge.Data.SelectionList
import LensHelp
setShownSelectionItems :: SelectionList -> SelectionList
setShownSelectionItems sl = case sl ^? slSizeRestriction of
Just (SelectionSizeRestriction maxlines topit botit _)
| length allitems <= maxlines -> sl & slShownItems .~ allitems
| otherwise -> if offset > 0
then sl & slShownItems .~ ((topit,ScrollUpSelectionItem) : take (maxlines - 2) (drop offset allitems))
else sl & slShownItems .~ (take (maxlines - 2) allitems ++ [(botit,ScrollDownSelectionItem)])
_ -> sl & slShownItems .~ allitems
where
offset = sl ^. slOffset
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. slItems) [0..]