grid-gap is now a vector not a scalar

darcs
slava 2006-06-17 20:15:12 +00:00
parent da6ddf5d8b
commit eaec328b5b
3 changed files with 10 additions and 14 deletions

View File

@ -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

View File

@ -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 -- )

View File

@ -90,7 +90,7 @@ M: object-button gadget-help ( button -- string )
>r swap with-pane r> ; inline
: styled-grid ( style grid -- )
<grid> 5 over set-grid-gap
<grid> { 5 5 0 } over set-grid-gap
border-width rot hash [ 5 ] unless* <border> ;
: <pane-grid> ( quot style grid -- gadget )