From 43b20221767dbbcbd171ec824f23a4d57b0f4a66 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Tue, 15 Jul 2008 02:25:37 -0500 Subject: [PATCH] ui.gadgets.tracks: rewrite pref-dim* method --- extra/ui/gadgets/tracks/tracks.factor | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/extra/ui/gadgets/tracks/tracks.factor b/extra/ui/gadgets/tracks/tracks.factor index 9ab3c5200f..09e3d5307a 100644 --- a/extra/ui/gadgets/tracks/tracks.factor +++ b/extra/ui/gadgets/tracks/tracks.factor @@ -16,8 +16,7 @@ TUPLE: track < pack sizes ; V{ } clone >>sizes 1 >>fill ; inline -: ( orientation -- track ) - track new-track ; +: ( orientation -- track ) track new-track ; : alloted-dim ( track -- dim ) dup gadget-children swap track-sizes { 0 0 } @@ -29,21 +28,20 @@ TUPLE: track < pack sizes ; dup available-dim over gadget-children rot normalized-sizes [ [ over n*v ] [ pref-dim ] ?if ] 2map nip ; -M: track layout* - dup track-layout pack-layout ; +M: track layout* ( track -- ) dup track-layout pack-layout ; -: track-pref-dims-1 ( track -- dim ) - gadget-children pref-dims max-dim ; +: track-pref-dims-1 ( track -- dim ) children>> pref-dims max-dim ; : track-pref-dims-2 ( track -- dim ) dup gadget-children pref-dims swap normalized-sizes [ [ v/n ] when* ] 2map max-dim [ >fixnum ] map ; -M: track pref-dim* - dup track-pref-dims-1 - over alloted-dim - pick track-pref-dims-2 v+ - rot gadget-orientation set-axis ; +M: track pref-dim* ( gadget -- dim ) + [ track-pref-dims-1 ] + [ [ alloted-dim ] [ track-pref-dims-1 ] bi v+ ] + [ orientation>> ] + tri + set-axis ; : track-add ( gadget track constraint -- ) over track-sizes push swap add-gadget drop ;