]> gitweb.factorcode.org Git - factor.git/commitdiff
math.rectangles.positioning: fix popups that draw super small at the bottom of the...
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 14 Feb 2022 00:09:18 +0000 (16:09 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 14 Feb 2022 00:09:18 +0000 (16:09 -0800)
basis/math/rectangles/positioning/positioning-tests.factor
basis/math/rectangles/positioning/positioning.factor

index 52b8c56626c7748a8d7601825ec4987770cd52a1..98c74336950df97a32c0f43c369b5e8703ff0398 100644 (file)
@@ -45,7 +45,7 @@ IN: math.rectangles.positioning.tests
     popup-rect
 ] unit-test
 
-{ T{ rect f { 0 50 } { 50 50 } } } [
+{ T{ rect f { 0 0 } { 50 60 } } } [
     T{ rect f { 0 50 } { 0 0 } }
     { 50 60 }
     { 100 100 }
index 05febe4ba8afb3230f61d9ae5024d38553e28f19..2f1dfdec825b94666cb91c8111376e71a969cca2 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel accessors math math.vectors
-math.rectangles math.order arrays locals fry
+USING: combinators sequences kernel accessors math math.vectors
+math.rectangles math.order arrays locals
 combinators.short-circuit ;
 IN: math.rectangles.positioning
 
@@ -20,17 +20,13 @@ IN: math.rectangles.positioning
     rect-bounds [ second ] bi@ + ;
 
 : alternate-y ( visible-rect popup-dim -- y )
-    [ loc>> ] dip [ second ] bi@ - ;
+    [ loc>> ] dip [ second ] bi@ [-] ;
 
 : preferred-fit? ( visible-rect popup-dim screen-dim -- ? )
     [ [ preferred-y ] [ second ] bi* + ] dip second < ;
 
-: alternate-fit? ( visible-rect popup-dim -- ? )
-    alternate-y 0 >= ;
-
 : popup-y ( visible-rect popup-dim screen-dim -- y )
-    3dup { [ preferred-fit? not ] [ drop alternate-fit? ] } 3&&
-    [ drop alternate-y ] [ 2drop preferred-y ] if ;
+    3dup preferred-fit? [ 2drop preferred-y ] [ drop alternate-y ] if ;
 
 : popup-loc ( visible-rect popup-dim screen-dim -- loc )
     [ popup-x ] [ popup-y ] 3bi 2array ;