Work on mouse selection in options menu
This commit is contained in:
+21
-13
@@ -1,19 +1,22 @@
|
||||
module Dodge.SelectionList where
|
||||
|
||||
import Color
|
||||
import Regex
|
||||
import Data.Maybe
|
||||
import Dodge.Data.ScreenPos
|
||||
import Dodge.Data.Universe
|
||||
import LensHelp
|
||||
import Data.Maybe
|
||||
--import Data.IntMap.Strict (IntMap)
|
||||
import Linear
|
||||
import Regex
|
||||
|
||||
getAvailableListLines :: ListDisplayParams -> Configuration -> Int
|
||||
getAvailableListLines ldps cfig = floor ((dToBot - vgap) / itmHeight)
|
||||
where
|
||||
vgap = ldps ^. ldpVerticalGap
|
||||
itmHeight = 10 * ldps ^. ldpScale + vgap
|
||||
dToBot = fromIntegral (cfig ^. windowY) - (ldps ^. ldpPosY + dFromScreenBot)
|
||||
dFromScreenBot = 5 -- fromMaybe 0 $ sl ^? slSizeRestriction . ssrType . ssrFromScreenBottom
|
||||
itmHeight = 20 * ldps ^. ldpScale + vgap
|
||||
winy = fromIntegral $ cfig ^. windowY
|
||||
dToBot =
|
||||
winy / 2 + winy * (ldps ^. ldpPos . spScreenOff . _y)
|
||||
+ (ldps ^. ldpPos . spPixelOff . _y)
|
||||
|
||||
getShownItems :: SelectionList a -> [SelectionItem a]
|
||||
getShownItems sl = case sl ^. slRegexList of
|
||||
@@ -22,15 +25,19 @@ getShownItems sl = case sl ^. slRegexList of
|
||||
|
||||
makeRegexList :: SelectionList a -> [(SelectionItem a, Maybe Int)]
|
||||
makeRegexList sl = case sl ^. slRegex of
|
||||
"" | not (sl ^. slRegexInput) -> []
|
||||
str -> (SelectionInfo
|
||||
{ _siPictures = ["FILTER: "++str]
|
||||
"" | not (sl ^. slRegexInput) -> []
|
||||
str ->
|
||||
( SelectionInfo
|
||||
{ _siPictures = ["FILTER: " ++ str]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = False
|
||||
--, _siWidth = length $ "FILTER: "++str
|
||||
, _siColor = white
|
||||
, --, _siWidth = length $ "FILTER: "++str
|
||||
_siColor = white
|
||||
, _siOffX = 0
|
||||
}, Nothing) : filter (doregex str) (zip (_slItems sl) $ fmap Just [0..])
|
||||
}
|
||||
, Nothing
|
||||
) :
|
||||
filter (doregex str) (zip (_slItems sl) $ fmap Just [0 ..])
|
||||
where
|
||||
doregex str = regexList str . _siPictures . fst
|
||||
|
||||
@@ -40,7 +47,8 @@ setShownItems sl = sl & slRegexList .~ makeRegexList sl
|
||||
moveSelectionListSelection :: Int -> SelectionList a -> SelectionList a
|
||||
moveSelectionListSelection yi sl = sl & slSelPos %~ f
|
||||
where
|
||||
f x | maxsel == 0 = Nothing
|
||||
f x
|
||||
| maxsel == 0 = Nothing
|
||||
| isNothing x = Just 0
|
||||
| otherwise = fmap ((`mod` maxsel) . subtract yi) x
|
||||
maxsel = case _slRegex sl of
|
||||
|
||||
Reference in New Issue
Block a user