Show items that are to be combined

This commit is contained in:
2023-02-20 11:30:10 +00:00
parent 2e46123a92
commit 5ac379959a
3 changed files with 38 additions and 20 deletions
+16 -5
View File
@@ -4,6 +4,8 @@ module Dodge.SelectionSections (
ssLookupGT,
ssSetCursor,
setFirstPosSelectionSections,
selSecSelPos,
selSecSelSize,
) where
import Control.Applicative
@@ -23,11 +25,6 @@ setFirstPosSelectionSections sss = fromMaybe sss $ do
(i, j, _) <- ssLookupMin sss
return $ sss & sssSelPos ?~ (i, j)
--scrollUpSelectionSections :: SelectionSections a -> SelectionSections a
--scrollUpSelectionSections sss = fromMaybe (setFirstPosSelectionSections sss) $ do
-- (i, j) <- sss ^? sssSelPos . _Just
-- (i', j', _) <- ssLookupUp i j sss
-- return $ sss & sssSelPos ?~ (i', j')
scrollUpSelectionSections :: SelectionSections a -> SelectionSections a
scrollUpSelectionSections sss = sss & sssSelPos .~
fmap f (ssScrollUp (sss & sssSections %~ fmap (ssItems %~ IM.filter _siIsSelectable)))
@@ -128,5 +125,19 @@ ssLookupGE' i sss = do
Just (j', si) -> return (i', j', si)
Nothing -> ssLookupGT' i' sss
selSecSelSize :: Int -> Int -> SelectionSections a -> Maybe Int
selSecSelSize i j sss = fmap length $ sss ^? sssSections . ix i . ssItems . ix j . siPictures
selSecSelPos :: Int -> Int -> SelectionSections a -> Maybe Int
selSecSelPos i j sss = do
ss <- sss ^? sssSections . ix i
return . (secpos +)
. subtract (ss ^. ssOffset)
. sum
. fmap (length . _siPictures)
. fst $ IM.split j (ss ^. ssItems)
where
secpos = sum . fmap (length . _ssShownItems) . fst $ IM.split i $ sss ^. sssSections
--getIthPos :: Int -> IM.IntMap (SelectionItem a) -> Int
--getIthPos i sm = sum . fmap _siHeight . fst $ IM.split i sm