new set-rect-bounds word for when you're setting loc and dim at the same time

db4
Slava Pestov 2009-02-15 23:39:27 -06:00
parent abe0f4bdf4
commit d26ae3d141
4 changed files with 11 additions and 8 deletions

View File

@ -51,3 +51,8 @@ M: rect contains-point?
: rect-min ( rect dim -- rect' ) : rect-min ( rect dim -- rect' )
[ rect-bounds ] dip vmin <rect> ; [ rect-bounds ] dip vmin <rect> ;
: set-rect-bounds ( rect1 rect -- )
[ [ loc>> ] dip (>>loc) ]
[ [ dim>> ] dip (>>dim) ]
2bi ; inline

View File

@ -48,9 +48,7 @@ M: border baseline
dup border-dim [ border-loc ] keep <rect> ; dup border-dim [ border-loc ] keep <rect> ;
M: border layout* M: border layout*
[ gadget-child ] [ border-child-rect ] bi [ border-child-rect ] [ gadget-child ] bi set-rect-bounds ;
[ loc>> >>loc ] [ dim>> >>dim ] bi
drop ;
M: border focusable-child* M: border focusable-child*
gadget-child ; gadget-child ;

View File

@ -26,12 +26,12 @@ TUPLE: glass < gadget visible-rect owner ;
[ visible-rect>> ] [ owner>> ] bi screen-loc offset-rect ; [ visible-rect>> ] [ owner>> ] bi screen-loc offset-rect ;
M: glass layout* M: glass layout*
{ [
[ gadget-child ]
[ visible-rect ] [ visible-rect ]
[ gadget-child pref-dim ] [ gadget-child pref-dim ]
[ find-world dim>> ] [ find-world dim>> ]
} cleave popup-loc >>loc prefer ; tri popup-rect
] [ gadget-child ] bi set-rect-bounds ;
M: glass ungraft* gadget-child hide-glass-hook ; M: glass ungraft* gadget-child hide-glass-hook ;

View File

@ -107,7 +107,7 @@ M: grid pref-dim* <grid-layout> grid-pref-dim ;
: grid-layout ( children grid-layout -- ) : grid-layout ( children grid-layout -- )
[ cell-locs ] [ cell-dims ] bi [ cell-locs ] [ cell-dims ] bi
[ [ [ >>loc ] [ >>dim ] bi* drop ] 3each ] 3each ; [ [ <rect> swap set-rect-bounds ] 3each ] 3each ;
M: grid layout* [ grid>> ] [ <grid-layout> ] bi grid-layout ; M: grid layout* [ grid>> ] [ <grid-layout> ] bi grid-layout ;