Start unifying drawn cursors
This commit is contained in:
+33
-20
@@ -7,8 +7,11 @@ import Data.Maybe
|
||||
import Dodge.Base.WinScale
|
||||
import Dodge.Base.Window
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.CardinalPoint
|
||||
import Geometry
|
||||
import Picture
|
||||
import Data.Set (Set)
|
||||
import qualified Data.Set as Set
|
||||
|
||||
drawSelectionList :: Configuration -> SelectionList -> Picture
|
||||
drawSelectionList cfig sl = listPicturesAtScaleOff
|
||||
@@ -26,9 +29,7 @@ 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
|
||||
BorderCursor cps -> Just $ listCursorChooseBorderScale (_slVerticalGap sl) (_slScale sl) 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
|
||||
@@ -56,11 +57,29 @@ stackPicturesAt tx ty cfig = stackPicturesAtOff tx ty cfig 0
|
||||
stackPicturesAtOff :: Float -> Float -> Configuration -> Int -> [Picture] -> Picture
|
||||
stackPicturesAtOff tx ty cfig i = mconcat . zipWith (listTextPictureAt tx ty cfig) [i, i-1 ..]
|
||||
|
||||
-- displays a cursor that should match up to list text pictures
|
||||
-- the width of a character appears to be 9(?!)
|
||||
-- this is probably because it is 8 pixels plus one for the border
|
||||
listCursorChooseBorderScale ::
|
||||
Float ->
|
||||
Float -> Set CardinalPoint -> Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorChooseBorderScale ygap s borders xoff yoff cfig yint col cursxsize cursysize =
|
||||
winScale cfig
|
||||
. translate
|
||||
(6 + xoff - halfWidth cfig)
|
||||
(halfHeight cfig + 12.5 - (20 * fromIntegral yint + yoff + 20 + hgt + ygap))
|
||||
. color col
|
||||
$ chooseCursorBorders (s * wth) (s * hgt) borders
|
||||
where
|
||||
x = 9
|
||||
wth = x * fromIntegral cursxsize + 9
|
||||
hgt = 20 * fromIntegral cursysize
|
||||
|
||||
-- displays a cursor that should match up to list text pictures
|
||||
-- the width of a character appears to be 9(?!)
|
||||
-- this is probably because it is 8 pixels plus one for the border
|
||||
listCursorChooseBorder ::
|
||||
[Bool] -> Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
Set CardinalPoint -> Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorChooseBorder borders xoff yoff cfig yint col cursxsize cursysize =
|
||||
winScale cfig
|
||||
. translate
|
||||
@@ -74,31 +93,25 @@ listCursorChooseBorder borders xoff yoff cfig yint col cursxsize cursysize =
|
||||
hgt = 20 * fromIntegral cursysize
|
||||
|
||||
-- note we cannot simply scale lines because they are drawn as solid rectangles
|
||||
chooseCursorBorders :: Float -> Float -> [Bool] -> Picture
|
||||
chooseCursorBorders wth hgt =
|
||||
fold . catMaybes
|
||||
. zipWith
|
||||
f
|
||||
[ line [V2 0 hgt, V2 wth hgt]
|
||||
, line [V2 wth hgt, V2 wth 0]
|
||||
, line [V2 wth 0, V2 0 0]
|
||||
, line [V2 0 0, V2 0 hgt]
|
||||
]
|
||||
chooseCursorBorders :: Float -> Float -> Set CardinalPoint -> Picture
|
||||
chooseCursorBorders wth hgt = fold . Set.map (line . toLine)
|
||||
where
|
||||
f _ False = Nothing
|
||||
f a True = Just a
|
||||
toLine North = [V2 0 hgt, V2 wth hgt]
|
||||
toLine East = [V2 wth hgt, V2 wth 0]
|
||||
toLine South = [V2 wth 0, V2 0 0]
|
||||
toLine West = [V2 0 0, V2 0 hgt]
|
||||
|
||||
listCursorNS :: Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorNS = listCursorChooseBorder [True, False, True]
|
||||
listCursorNS = listCursorChooseBorder (Set.fromList [North,South])
|
||||
|
||||
listCursorNES :: Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorNES = listCursorChooseBorder [True, True, True]
|
||||
listCursorNES = listCursorChooseBorder (Set.fromList [North,South,East])
|
||||
|
||||
listCursorNESW :: Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorNESW = listCursorChooseBorder [True, True, True, True]
|
||||
listCursorNESW = listCursorChooseBorder (Set.fromList [North,South,East,West])
|
||||
|
||||
listCursorNSW :: Float -> Float -> Configuration -> Int -> Color -> Int -> Int -> Picture
|
||||
listCursorNSW = listCursorChooseBorder [True, False, True, True]
|
||||
listCursorNSW = listCursorChooseBorder (Set.fromList [North,South,West])
|
||||
|
||||
fillScreenText :: Configuration -> String -> Picture
|
||||
fillScreenText cfig str =
|
||||
|
||||
Reference in New Issue
Block a user