Make parameters for display of list pictures more sensible

This commit is contained in:
2023-05-10 02:25:38 +01:00
parent f569f3f173
commit 12aa1361eb
5 changed files with 29 additions and 31 deletions
+25 -27
View File
@@ -3,7 +3,7 @@ module Dodge.Render.List (
listCursorNSW,
drawList,
drawSelectionList,
listPicturesAtScaleOff,
listPicturesScaleOff,
drawListElement,
selSecDrawCursor,
dShadCol,
@@ -29,7 +29,7 @@ drawSelectionList ldps cfig sl =
toTopLeft
cfig
( ( translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $
listPicturesAtScaleOff
listPicturesScaleOff
(_ldpVerticalGap ldps)
(_ldpScale ldps)
0
@@ -50,14 +50,14 @@ drawCursorAt ldps mi lis = fromMaybe mempty $ do
let j = sum . map _siHeight $ take i lis
col = _siColor selit
return $
translate (_ldpPosX ldps)
(- _ldpPosY ldps) $
listCursorChooseBorderScale
(_ldpVerticalGap ldps)
(_ldpScale ldps)
(ldps ^. ldpCursorSides)
(_ldpPosX ldps + (9 * fromIntegral (_siOffX selit)))
(_ldpPosY ldps)
j
0
(_siOffX selit)
col
wdth
(_siHeight selit)
@@ -76,10 +76,10 @@ drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownIt
_ -> fmap (+ 1)
listPicturesAtOff :: Int -> [Picture] -> Picture
listPicturesAtOff = listPicturesAtScaleOff 10 1
listPicturesAtOff = listPicturesScaleOff 0 1
listPicturesAtScaleOff :: Float -> Float -> Int -> [Picture] -> Picture
listPicturesAtScaleOff ygap s i =
listPicturesScaleOff :: Float -> Float -> Int -> [Picture] -> Picture
listPicturesScaleOff ygap s i =
mconcat
. zipWith (drawListElement ygap s) [i ..]
@@ -105,8 +105,8 @@ listCursorDisplayParams ::
Int ->
Int ->
Picture
listCursorDisplayParams ldp borders =
listCursorChooseBorderScale ygap s borders xoff yoff
listCursorDisplayParams ldp borders a b c d =
translate xoff (-yoff) . listCursorChooseBorderScale ygap s borders a b c d
where
ygap = _ldpVerticalGap ldp
s = _ldpScale ldp
@@ -120,41 +120,39 @@ listCursorChooseBorderScale ::
Float ->
Float ->
[CardinalPoint] ->
Float ->
Float ->
Int ->
Int ->
Color ->
Int ->
Int ->
Picture
listCursorChooseBorderScale ygap s borders xoff yoff yint xint col cursxsize cursysize =
listCursorChooseBorderScale ygap s borders yint xint col cursxsize cursysize =
translate
(xoff + (10 * s * (fromIntegral xint -1)))
(- (yoff + (s * 10 + ygap) * (fromIntegral yint + 1)))
( (10 * s * (fromIntegral xint ) - 5 * s))
(- (ygap + (s * 20 + ygap) * (fromIntegral yint) + 1))
. color col
$ chooseCursorBorders (s * wth) (s * hgt) borders
where
x = 9
wth = x * fromIntegral cursxsize + 10
hgt = 20 * fromIntegral cursysize -- TODO this should be changed!
wth = 10 * (fromIntegral cursxsize + 1)
hgt = 20 * fromIntegral cursysize + ygap * (fromIntegral cursysize - 1)
-- displays a cursor that should match up to list text pictures
listCursorChooseBorder ::
[CardinalPoint] -> Float -> Float -> Int -> Int -> Color -> Int -> Int -> Picture
[CardinalPoint] -> Int -> Int -> Color -> Int -> Int -> Picture
listCursorChooseBorder = listCursorChooseBorderScale 10 1
-- note we cannot simply scale lines because they are drawn as solid rectangles
chooseCursorBorders :: Float -> Float -> [CardinalPoint] -> Picture
chooseCursorBorders w h = foldMap (line . toLine)
where
toLine North = [V2 0 h, V2 w h]
toLine East = [V2 w h, V2 w 0]
toLine South = [V2 w 0, V2 0 0]
toLine West = [V2 0 0, V2 0 h]
h' = negate h
toLine North = [V2 0 0, V2 w 0]
toLine East = [V2 w 0, V2 w h']
toLine South = [V2 w h', V2 0 h']
toLine West = [V2 0 h', V2 0 0]
listCursorNSW :: Float -> Float -> Int -> Int -> Color -> Int -> Int -> Picture
listCursorNSW = listCursorChooseBorder [North, South, West]
listCursorNSW :: Int -> Int -> Color -> Int -> Int -> Picture
listCursorNSW a b c d = listCursorChooseBorder [North, South, West] a b c d
--fillScreenText :: Configuration -> String -> Picture
--fillScreenText cfig str =
@@ -178,7 +176,7 @@ listCursorNSW = listCursorChooseBorder [North, South, West]
drawListElement :: Float -> Float -> Int -> Picture -> Picture
drawListElement ygap s yint =
translate 0 (negate ((s * 10 + ygap) * (fromIntegral yint + 1)))
translate 0 (negate ((s * 20 + ygap) * (fromIntegral yint + 1)))
. scale (s * 0.1) (s * 0.1)
renderListAt :: Float -> Float -> [(String, Color)] -> Picture
@@ -187,7 +185,7 @@ renderListAt tx ty = translate tx (- ty) . drawList . map (\(str, col) -> color
-- given a list of pictures that are each the size of a "text" call, displays them as
-- a list on the screen
drawList :: [Picture] -> Picture
drawList = listPicturesAtScaleOff 10 1 0
drawList = listPicturesScaleOff 0 1 0
--TODO put the following functions in an appropriate place