From eaec328b5bc89f4e0ab81d7e172775524618143f Mon Sep 17 00:00:00 2001 From: slava Date: Sat, 17 Jun 2006 20:15:12 +0000 Subject: [PATCH] grid-gap is now a vector not a scalar --- TODO.FACTOR.txt | 1 - library/ui/gadgets/grids.factor | 21 +++++++++------------ library/ui/gadgets/presentations.factor | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index bea1e6fab4..928c031134 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -14,7 +14,6 @@ - automatically update help graph and search index when adding/removing articles/words - help search: - - edit distance algorithm - store positions in index - phrase scoring algorithm based on how close the terms occur? - fix remaining HTML stream issues diff --git a/library/ui/gadgets/grids.factor b/library/ui/gadgets/grids.factor index 80525d6a72..c8cfb9d560 100644 --- a/library/ui/gadgets/grids.factor +++ b/library/ui/gadgets/grids.factor @@ -5,16 +5,14 @@ USING: arrays gadgets kernel math namespaces sequences words ; TUPLE: grid children gap ; -: collapse-grid concat [ ] subset ; - : set-grid-children* ( children grid -- ) [ set-grid-children ] 2keep - >r collapse-grid r> add-gadgets ; + >r concat [ ] subset r> add-gadgets ; C: grid ( children -- grid ) dup delegate>gadget [ set-grid-children* ] keep - 0 over set-grid-gap ; + { 0 0 0 } over set-grid-gap ; : grid-child ( grid i j -- gadget ) rot grid-children nth nth ; @@ -31,30 +29,29 @@ C: grid ( children -- grid ) : compute-grid ( -- horiz vert ) pref-dim-grid - dup flip [ max-dim first ] map swap [ max-dim second ] map ; + dup flip [ max-dim ] map swap [ max-dim ] map ; : with-grid ( grid quot -- | quot: horiz vert -- ) [ >r grid set compute-grid r> call ] with-scope ; inline : gap grid get grid-gap ; +: pair-up ( horiz vert -- dims ) + [ >r first r> second 0 3array ] 2map ; + M: grid pref-dim* ( grid -- dim ) [ - [ - [ sum ] keep length 1 [-] gap * + - ] 2apply 0 3array + [ [ length 1 [-] ] 2apply 0 3array gap v*n ] 2keep + [ { 0 0 0 } [ v+ ] reduce ] 2apply pair-up v+ ] with-grid ; -: pair-up ( horiz vert -- dims ) - [ swap [ swap 0 3array ] map-with ] map-with ; - : do-grid ( dims quot -- ) swap grid get grid-children [ [ dup [ pick call ] [ 2drop ] if ] 2each ] 2each drop ; inline : position-grid ( horiz vert -- ) - [ 0 [ + gap + ] accumulate ] 2apply + [ { 0 0 0 } [ v+ gap v+ ] accumulate ] 2apply pair-up [ set-rect-loc ] do-grid ; : resize-grid ( horiz vert -- ) diff --git a/library/ui/gadgets/presentations.factor b/library/ui/gadgets/presentations.factor index 58b74147e7..40a8d8d410 100644 --- a/library/ui/gadgets/presentations.factor +++ b/library/ui/gadgets/presentations.factor @@ -90,7 +90,7 @@ M: object-button gadget-help ( button -- string ) >r swap with-pane r> ; inline : styled-grid ( style grid -- ) - 5 over set-grid-gap + { 5 5 0 } over set-grid-gap border-width rot hash [ 5 ] unless* ; : ( quot style grid -- gadget )