ui.gadgets: rename max-dim and dim-sum.

db4
John Benediktsson 2012-07-13 23:19:21 -07:00
parent af4d839a23
commit bfb6bdd891
7 changed files with 13 additions and 13 deletions

View File

@ -26,7 +26,7 @@ M: book model-changed ( model book -- )
: <empty-book> ( model -- book )
book new-book ;
M: book pref-dim* ( book -- dim ) children>> pref-dims max-dim ;
M: book pref-dim* ( book -- dim ) children>> pref-dims max-dims ;
M: book layout* ( book -- )
[ children>> ] [ dim>> ] bi '[ _ >>dim drop ] each ;

View File

@ -38,11 +38,11 @@ HELP: pick-up
{ $values { "point" "a pair of integers" } { "gadget" gadget } { "child/f" { $maybe gadget } } }
{ $description "Outputs the child at a point in the gadget's co-ordinate system. This word recursively descends the gadget hierarchy, and so outputs the deepest child." } ;
HELP: max-dim
HELP: max-dims
{ $values { "dims" "a sequence of pairs of integers" } { "dim" "a pair of integers" } }
{ $description "Outputs the smallest dimensions of a rectangle which can fit all the dimensions in the sequence." } ;
{ pref-dims max-dim dim-sum } related-words
{ pref-dims max-dims sum-dims } related-words
HELP: each-child
{ $values { "gadget" gadget } { "quot" { $quotation "( child -- )" } } }
@ -88,7 +88,7 @@ HELP: prefer
{ $values { "gadget" gadget } }
{ $contract "Resizes the gadget to assume its preferred dimensions." } ;
HELP: dim-sum
HELP: sum-dims
{ $values { "seq" "a sequence of pairs of integers" } { "dim" "a pair of integers" } }
{ $description "Sums a sequence of dimensions." } ;

View File

@ -87,9 +87,9 @@ M: gadget contains-point? ( loc gadget -- ? )
[ contains-point? ] with find-last nip
[ [ loc>> v- ] [ pick-up ] bi ] [ nip ] ?if ;
: max-dim ( dims -- dim ) { 0 0 } [ vmax ] reduce ;
: max-dims ( dims -- dim ) { 0 0 } [ vmax ] reduce ;
: dim-sum ( seq -- dim ) { 0 0 } [ v+ ] reduce ;
: sum-dims ( seq -- dim ) { 0 0 } [ v+ ] reduce ;
: each-child ( gadget quot -- )
[ children>> ] dip each ; inline

View File

@ -66,11 +66,11 @@ PRIVATE>
: max-pack-dim ( pack sizes -- dim )
over align>> +baseline+ eq?
[ [ children>> ] dip measure-height 0 swap 2array ] [ nip max-dim ] if ;
[ [ children>> ] dip measure-height 0 swap 2array ] [ nip max-dims ] if ;
: pack-pref-dim ( pack sizes -- dim )
[ max-pack-dim ]
[ [ gap-dim ] [ dim-sum ] bi* v+ ]
[ [ gap-dim ] [ sum-dims ] bi* v+ ]
[ drop orientation>> ]
2tri set-axis ;

View File

@ -39,14 +39,14 @@ TUPLE: track < pack sizes ;
M: track layout* ( track -- ) dup track-layout pack-layout ;
: track-pref-dims-1 ( track -- dim )
[ children>> pref-dims max-dim ]
[ children>> pref-dims max-dims ]
[ pref-dim>> { 0 0 } or ] bi vmax ;
: track-pref-dims-2 ( track -- dim )
[
[ children>> pref-dims ] [ normalized-sizes ] bi
[ dup { 0 f } member? [ 2drop { 0 0 } ] [ v/n ] if ] 2map
max-dim [ >fixnum ] map
max-dims [ >fixnum ] map
] [ gap-dim ] bi v+ ;
M: track pref-dim* ( gadget -- dim )

View File

@ -35,5 +35,5 @@ M: polygon draw-interior
tri ;
: <polygon-gadget> ( color points -- gadget )
[ <polygon> ] [ max-dim ] bi
[ <polygon> ] [ max-dims ] bi
[ <gadget> ] 2dip [ >>interior ] [ >>dim ] bi* ;

View File

@ -270,8 +270,8 @@ ARTICLE: "ui-layout-impl" "Implementing layout gadgets"
pref-dim
pref-dims
prefer
max-dim
dim-sum
max-dims
sum-dims
}
{ $warning
"When implementing the " { $link layout* } " generic word for a gadget which inherits from another layout, the " { $link children-on } " word might have to be re-implemented as well."