Separate selection list items from display parameters
This commit is contained in:
+17
-16
@@ -15,36 +15,37 @@ import ListHelp
|
||||
import Picture
|
||||
import LensHelp
|
||||
|
||||
drawSelectionList :: Configuration -> SelectionList -> Picture
|
||||
drawSelectionList cfig sl =
|
||||
drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList -> Picture
|
||||
drawSelectionList ldps cfig sl =
|
||||
listPicturesAtScaleOff
|
||||
(_slVerticalGap sl)
|
||||
(_slScale sl)
|
||||
(_slPosX sl)
|
||||
(_slPosY sl)
|
||||
(_ldpVerticalGap ldps)
|
||||
(_ldpScale ldps)
|
||||
(_ldpPosX ldps)
|
||||
(_ldpPosY ldps)
|
||||
cfig
|
||||
0 --(_slOffset sl)
|
||||
(makeSelectionListPictures sl)
|
||||
<> drawSelectionCursor cfig sl
|
||||
<> drawSelectionCursor ldps cfig sl
|
||||
|
||||
makeSelectionListPictures :: SelectionList -> [Picture]
|
||||
makeSelectionListPictures sl = case sl ^. slSizeRestriction of
|
||||
SelectionSizeRestriction {} -> concatMap (_siPictures . fst) $ _slShownItems sl
|
||||
_ -> concatMap _siPictures $ _slItems sl
|
||||
makeSelectionListPictures sl = concatMap _siPictures $ _slItems sl
|
||||
--case sl ^. slSizeRestriction of
|
||||
-- SelectionSizeRestriction {} -> concatMap (_siPictures . fst) $ _slShownItems sl
|
||||
-- _ -> concatMap _siPictures $ _slItems sl
|
||||
|
||||
drawSelectionCursor :: Configuration -> SelectionList -> Picture
|
||||
drawSelectionCursor cfig sl = fromMaybe mempty $ do
|
||||
drawSelectionCursor :: ListDisplayParams -> Configuration -> SelectionList -> Picture
|
||||
drawSelectionCursor ldps cfig sl = fromMaybe mempty $ do
|
||||
i <- _slSelPos sl
|
||||
selit <- filter _siIsSelectable lis !? i
|
||||
f <- case _slCursorType sl of
|
||||
BorderCursor cps -> Just $ listCursorChooseBorderScale (_slVerticalGap sl) (_slScale sl) cps
|
||||
f <- case _ldpCursorType ldps of
|
||||
BorderCursor cps -> Just $ listCursorChooseBorderScale (_ldpVerticalGap ldps) (_ldpScale ldps) cps
|
||||
NoCursor -> Nothing
|
||||
let j = sum . map _siHeight $ takeWhileArb (<= i) (\x itsel -> x + if _siIsSelectable itsel then 1 else 0) 0 lis
|
||||
col = _siColor selit
|
||||
return $ f (_slPosX sl + (9 * fromIntegral (_siOffX selit))) (_slPosY sl) cfig j col wdth (_siHeight selit)
|
||||
return $ f (_ldpPosX ldps + (9 * fromIntegral (_siOffX selit))) (_ldpPosY ldps) cfig j col wdth (_siHeight selit)
|
||||
where
|
||||
lis = _slItems sl
|
||||
wdth = case _slWidth sl of
|
||||
wdth = case _ldpWidth ldps of
|
||||
FixedSelectionWidth x -> x
|
||||
_ -> 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user