Rethink selection lists as intmaps
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Render.List where
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import Data.Foldable
|
||||
import Dodge.SelectionList
|
||||
import Data.Maybe
|
||||
@@ -25,11 +26,28 @@ drawSelectionList ldps cfig sl =
|
||||
(makeSelectionListPictures sl)
|
||||
<> drawSelectionCursor ldps cfig sl
|
||||
|
||||
drawSelectionMap :: ListDisplayParams -> Configuration -> SelectionIntMap a -> Picture
|
||||
drawSelectionMap ldps cfig sl =
|
||||
listPicturesAtScaleOff
|
||||
(_ldpVerticalGap ldps)
|
||||
(_ldpScale ldps)
|
||||
(_ldpPosX ldps)
|
||||
(_ldpPosY ldps)
|
||||
cfig
|
||||
0 --(_slOffset sl)
|
||||
(makeSelectionMapPictures sl)
|
||||
<> drawSelectionMapCursor ldps cfig sl
|
||||
|
||||
makeSelectionListPictures :: SelectionList a -> [Picture]
|
||||
makeSelectionListPictures sl = concatMap f $ getShownItems sl
|
||||
where
|
||||
f si = map (color (_siColor si) . text) $ _siPictures si
|
||||
|
||||
makeSelectionMapPictures :: SelectionIntMap a -> [Picture]
|
||||
makeSelectionMapPictures sl = foldMap f $ _smShownItems sl
|
||||
where
|
||||
f si = map (color (_siColor si) . text) $ _siPictures si
|
||||
|
||||
drawCursorAt :: ListDisplayParams -> Configuration -> Maybe Int -> [SelectionItem a] -> Picture
|
||||
drawCursorAt ldps cfig mi lis = fromMaybe mempty $ do
|
||||
i <- mi
|
||||
@@ -45,6 +63,9 @@ drawCursorAt ldps cfig mi lis = fromMaybe mempty $ do
|
||||
FixedSelectionWidth x -> x
|
||||
_ -> 1
|
||||
|
||||
drawSelectionMapCursor :: ListDisplayParams -> Configuration -> SelectionIntMap a -> Picture
|
||||
drawSelectionMapCursor ldps cfig sl = drawCursorAt ldps cfig (sl ^. smSelPos) (IM.elems $ _smShownItems sl)
|
||||
|
||||
drawSelectionCursor :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
|
||||
drawSelectionCursor ldps cfig sl = drawCursorAt ldps cfig (f $ sl ^. slSelPos) (getShownItems sl)
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user