Attempt to globally translate drawn lists

This commit is contained in:
2023-05-09 00:58:03 +01:00
parent 865706df3b
commit 93519345de
6 changed files with 30 additions and 33 deletions
+18 -21
View File
@@ -26,13 +26,12 @@ import Picture
drawSelectionList :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
drawSelectionList ldps cfig sl =
toTopLeft cfig (listPicturesAtScaleOff
toTopLeft cfig ((translate (ldps ^. ldpPosX) (negate $ ldps ^. ldpPosY) $ listPicturesAtScaleOff
(_ldpVerticalGap ldps)
(_ldpScale ldps)
(_ldpPosX ldps)
(_ldpPosY ldps)
0 --(_slOffset sl)
0
(makeSelectionListPictures sl)
)
<> drawSelectionCursor ldps sl
)
@@ -65,20 +64,19 @@ drawSelectionCursor ldps sl = drawCursorAt ldps (f $ sl ^. slSelPos) (getShownIt
"" | not (sl ^. slRegexInput) -> id
_ -> fmap (+ 1)
listPicturesAtOff :: Int -> [Picture] -> Picture
listPicturesAtOff i = mconcat . zipWith (listTextPictureAtScale 10 1) [i ..]
listPicturesAtOff :: Float -> Float -> Int -> [Picture] -> Picture
listPicturesAtOff tx ty i = mconcat . zipWith (listTextPictureAtScale 10 1 tx ty) [i ..]
listPicturesAtScaleOff :: Float -> Float -> Float -> Float -> Int -> [Picture] -> Picture
listPicturesAtScaleOff ygap s tx ty i =
listPicturesAtScaleOff :: Float -> Float -> Int -> [Picture] -> Picture
listPicturesAtScaleOff ygap s i =
mconcat
. zipWith (listTextPictureAtScale ygap s tx ty) [i ..]
. zipWith (listTextPictureAtScale ygap s) [i ..]
stackPicturesAt :: Float -> Float -> [Picture] -> Picture
stackPicturesAt tx ty = stackPicturesAtOff tx ty 0
stackPicturesAt :: [Picture] -> Picture
stackPicturesAt = stackPicturesAtOff 0
stackPicturesAtOff :: Float -> Float -> Int -> [Picture] -> Picture
stackPicturesAtOff tx ty i = mconcat . zipWith (listTextPictureAtScale 10 1 tx ty) [i, i -1 ..]
stackPicturesAtOff :: Int -> [Picture] -> Picture
stackPicturesAtOff i = mconcat . zipWith (listTextPictureAtScale 10 1) [i, i -1 ..]
selSecDrawCursor :: Int -> [CardinalPoint] -> ListDisplayParams -> SelectionSections a -> Int -> Int -> Picture
selSecDrawCursor xsize borders ldp sss i j = fromMaybe mempty $ do
@@ -121,7 +119,6 @@ listCursorChooseBorderScale ::
Picture
listCursorChooseBorderScale ygap s borders xoff yoff yint xint col cursxsize cursysize =
translate
--(15 + (9 * s * (fromIntegral xint - 1)) + xoff - halfWidth cfig)
(xoff + (10 * s * (fromIntegral xint -1)))
( - (yoff + (s * 10 + ygap) * (fromIntegral yint + 1)))
. color col
@@ -168,18 +165,18 @@ listCursorNSW = listCursorChooseBorder [North, South, West]
-- thescale = hw * 0.02 / fromIntegral (length str)
-- hw = halfWidth cfig
listTextPictureAtScale :: Float -> Float -> Float -> Float -> Int -> Picture -> Picture
listTextPictureAtScale ygap s xoff yoff yint =
translate (xoff) (negate yoff - ((s * 10 + ygap) * (fromIntegral yint + 1)))
listTextPictureAtScale :: Float -> Float -> Int -> Picture -> Picture
listTextPictureAtScale ygap s yint =
translate 0 (negate ((s * 10 + ygap) * (fromIntegral yint + 1)))
. scale (s * 0.1) (s * 0.1)
renderListAt :: Float -> Float -> [(String, Color)] -> Picture
renderListAt tx ty = listPicturesAt tx ty . map (\(str, col) -> color col $ text str)
renderListAt tx ty = translate tx (-ty) . listPicturesAt . map (\(str, col) -> color col $ text str)
-- given a list of pictures that are each the size of a "text" call, displays them as
-- a list on the screen
listPicturesAt :: Float -> Float -> [Picture] -> Picture
listPicturesAt tx ty = listPicturesAtScaleOff 10 1 tx ty 0
listPicturesAt :: [Picture] -> Picture
listPicturesAt = listPicturesAtScaleOff 10 1 0
--TODO put the following functions in an appropriate place