From 17cf92b254c87df5ca7f3ac7e7ddaa30e9aa564f Mon Sep 17 00:00:00 2001 From: Brian Muramatsu Date: Sat, 25 Jun 2011 23:49:37 -0700 Subject: [PATCH] Don't Render Price Out of Bounds --- src/B1/Program/Chart/Overlay.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/B1/Program/Chart/Overlay.hs b/src/B1/Program/Chart/Overlay.hs index 8202c8f..377804b 100644 --- a/src/B1/Program/Chart/Overlay.hs +++ b/src/B1/Program/Chart/Overlay.hs @@ -186,9 +186,16 @@ renderCrosshair resources bounds maybeTextX maybeTextY = do when (isJust maybeTextX) $ preservingMatrix $ do - let translateX = (-boxWidth bounds / 2) + textPadding - translateY = (-boxHeight bounds / 2) - boxBottom bounds + let fullTextSpec = textSpec $ fromJust maybeTextX + textBox <- measureText fullTextSpec + let (graphTop, graphBottom) = (boxHeight bounds / 2, -boxHeight bounds / 2) + translateX = (-boxWidth bounds / 2) + textPadding + idealTranslateY = (-boxHeight bounds / 2) - boxBottom bounds + mouseY + textPadding + translateY + | idealTranslateY + boxHeight textBox + textPadding > graphTop = + graphTop - boxHeight textBox - textPadding + | otherwise = idealTranslateY translate $ vector3 translateX translateY 0 renderText $ textSpec $ fromJust maybeTextX