Work on a selection list datatype
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Render.List where
|
||||
|
||||
import ListHelp
|
||||
import Dodge.Data.SelectionList
|
||||
import Data.Foldable
|
||||
import Data.Maybe
|
||||
@@ -18,6 +19,25 @@ drawSelectionList cfig sl = listPicturesAtScaleOff
|
||||
cfig
|
||||
(_slOffset sl)
|
||||
(concatMap _siPictures (_slItems sl))
|
||||
<> drawSelectionCursor cfig sl
|
||||
|
||||
drawSelectionCursor :: Configuration -> SelectionList -> Picture
|
||||
drawSelectionCursor cfig sl = fromMaybe mempty $ do
|
||||
i <- _slSelPos sl
|
||||
selit <- (filter _siIsSelectable lis) !? i
|
||||
f <- case _slCursorType sl of
|
||||
NSEWCursor -> Just listCursorNESW
|
||||
NSWCursor -> Just listCursorNSW
|
||||
NSCursor -> Just listCursorNS
|
||||
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)
|
||||
where
|
||||
lis = _slItems sl
|
||||
wdth = case _slWidth sl of
|
||||
FixedSelectionWidth x -> x
|
||||
_ -> 1
|
||||
|
||||
-- given a list of pictures that are each the size of a "text" call, displays them as
|
||||
-- a list on the screen
|
||||
|
||||
Reference in New Issue
Block a user