Don't position popups at negative x co-ordinates

db4
Slava Pestov 2009-02-13 19:16:37 -06:00
parent f0bc2e1176
commit d186f10f52
2 changed files with 8 additions and 1 deletions

View File

@ -36,4 +36,11 @@ IN: math.rectangles.positioning.tests
{ 50 50 }
{ 100 100 }
popup-loc
] unit-test
[ { 0 20 } ] [
{ -50 70 } { 0 0 } <rect>
{ 50 50 }
{ 100 100 }
popup-loc
] unit-test

View File

@ -7,7 +7,7 @@ IN: math.rectangles.positioning
! in a semi-intelligent manner
: popup-x ( visible-rect popup-dim screen-dim -- x )
[ loc>> first ] 2dip swap [ first ] bi@ - min ;
[ loc>> first ] 2dip swap [ first ] bi@ - min 0 max ;
: preferred-y ( visible-rect -- y )
[ loc>> ] [ dim>> ] bi [ second ] bi@ + ;