From a41e502bad9f4ad290bc2d3ae51223376bac57cc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 12 Feb 2009 01:40:02 -0600 Subject: [PATCH] ui.gadgets.packs: cleanup --- basis/ui/gadgets/packs/packs-docs.factor | 2 +- basis/ui/gadgets/packs/packs.factor | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/basis/ui/gadgets/packs/packs-docs.factor b/basis/ui/gadgets/packs/packs-docs.factor index c08f2c48f1..40e41ae01d 100644 --- a/basis/ui/gadgets/packs/packs-docs.factor +++ b/basis/ui/gadgets/packs/packs-docs.factor @@ -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" } } diff --git a/basis/ui/gadgets/packs/packs.factor b/basis/ui/gadgets/packs/packs.factor index 7b5f91b1c2..d9121943ba 100644 --- a/basis/ui/gadgets/packs/packs.factor +++ b/basis/ui/gadgets/packs/packs.factor @@ -61,15 +61,18 @@ PRIVATE> > ] [ [ 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 ;