Skip to content

Commit

Permalink
Don't Render Price Out of Bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
btmura committed Jun 26, 2011
1 parent 48d3011 commit 17cf92b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/B1/Program/Chart/Overlay.hs
Expand Up @@ -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

Expand Down

0 comments on commit 17cf92b

Please sign in to comment.