ui.gadgets.packs: cleanup

db4
Slava Pestov 2009-02-12 01:40:02 -06:00
parent a0aabffb31
commit a41e502bad
2 changed files with 7 additions and 4 deletions

View File

@ -23,7 +23,7 @@ HELP: pack
}
"Packs have the following slots:"
{ $list
{ { $snippet "align" } " a rational number between 0 and 1, the alignment of gadgets along the axis perpendicular to the pack's orientation" }
{ { $snippet "align" } " a rational number between 0 and 1, or " { $link +baseline+ } "; the alignment of gadgets along the axis perpendicular to the pack's orientation" }
{ { $snippet "fill" } " a rational number between 0 and 1, where 0 gives each gadget its preferred size and 1 fills the dimension perpendicular to the pack's orientation" }
{ { $snippet "gap" } " a pair of integers, the horizontal and vertical gap between children" }
}

View File

@ -61,15 +61,18 @@ PRIVATE>
<PRIVATE
: gap-dims ( pack sizes -- seeq )
[ gap>> ] [ [ length 1 [-] ] [ dim-sum ] bi ] bi* [ v*n ] dip v+ ;
: gap-dim ( pack -- dim )
[ gap>> ] [ children>> length 1 [-] ] bi v*n ;
: max-pack-dim ( pack sizes -- dim )
over align>> +baseline+ eq?
[ [ children>> ] dip baseline-metrics + 0 swap 2array ] [ nip max-dim ] if ;
: pack-pref-dim ( pack sizes -- dim )
[ max-pack-dim ] [ gap-dims ] [ drop orientation>> ] 2tri set-axis ;
[ max-pack-dim ]
[ [ gap-dim ] [ dim-sum ] bi* v+ ]
[ drop orientation>> ]
2tri set-axis ;
M: pack pref-dim*
dup children>> pref-dims pack-pref-dim ;