grid-gap is now a vector not a scalar
parent
da6ddf5d8b
commit
eaec328b5b
|
@ -14,7 +14,6 @@
|
||||||
- automatically update help graph and search index when adding/removing
|
- automatically update help graph and search index when adding/removing
|
||||||
articles/words
|
articles/words
|
||||||
- help search:
|
- help search:
|
||||||
- edit distance algorithm
|
|
||||||
- store positions in index
|
- store positions in index
|
||||||
- phrase scoring algorithm based on how close the terms occur?
|
- phrase scoring algorithm based on how close the terms occur?
|
||||||
- fix remaining HTML stream issues
|
- fix remaining HTML stream issues
|
||||||
|
|
|
@ -5,16 +5,14 @@ USING: arrays gadgets kernel math namespaces sequences words ;
|
||||||
|
|
||||||
TUPLE: grid children gap ;
|
TUPLE: grid children gap ;
|
||||||
|
|
||||||
: collapse-grid concat [ ] subset ;
|
|
||||||
|
|
||||||
: set-grid-children* ( children grid -- )
|
: set-grid-children* ( children grid -- )
|
||||||
[ set-grid-children ] 2keep
|
[ set-grid-children ] 2keep
|
||||||
>r collapse-grid r> add-gadgets ;
|
>r concat [ ] subset r> add-gadgets ;
|
||||||
|
|
||||||
C: grid ( children -- grid )
|
C: grid ( children -- grid )
|
||||||
dup delegate>gadget
|
dup delegate>gadget
|
||||||
[ set-grid-children* ] keep
|
[ 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 ;
|
: grid-child ( grid i j -- gadget ) rot grid-children nth nth ;
|
||||||
|
|
||||||
|
@ -31,30 +29,29 @@ C: grid ( children -- grid )
|
||||||
|
|
||||||
: compute-grid ( -- horiz vert )
|
: compute-grid ( -- horiz vert )
|
||||||
pref-dim-grid
|
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 -- )
|
: with-grid ( grid quot -- | quot: horiz vert -- )
|
||||||
[ >r grid set compute-grid r> call ] with-scope ; inline
|
[ >r grid set compute-grid r> call ] with-scope ; inline
|
||||||
|
|
||||||
: gap grid get grid-gap ;
|
: gap grid get grid-gap ;
|
||||||
|
|
||||||
|
: pair-up ( horiz vert -- dims )
|
||||||
|
[ >r first r> second 0 3array ] 2map ;
|
||||||
|
|
||||||
M: grid pref-dim* ( grid -- dim )
|
M: grid pref-dim* ( grid -- dim )
|
||||||
[
|
[
|
||||||
[
|
[ [ length 1 [-] ] 2apply 0 3array gap v*n ] 2keep
|
||||||
[ sum ] keep length 1 [-] gap * +
|
[ { 0 0 0 } [ v+ ] reduce ] 2apply pair-up v+
|
||||||
] 2apply 0 3array
|
|
||||||
] with-grid ;
|
] with-grid ;
|
||||||
|
|
||||||
: pair-up ( horiz vert -- dims )
|
|
||||||
[ swap [ swap 0 3array ] map-with ] map-with ;
|
|
||||||
|
|
||||||
: do-grid ( dims quot -- )
|
: do-grid ( dims quot -- )
|
||||||
swap grid get grid-children [
|
swap grid get grid-children [
|
||||||
[ dup [ pick call ] [ 2drop ] if ] 2each
|
[ dup [ pick call ] [ 2drop ] if ] 2each
|
||||||
] 2each drop ; inline
|
] 2each drop ; inline
|
||||||
|
|
||||||
: position-grid ( horiz vert -- )
|
: position-grid ( horiz vert -- )
|
||||||
[ 0 [ + gap + ] accumulate ] 2apply
|
[ { 0 0 0 } [ v+ gap v+ ] accumulate ] 2apply
|
||||||
pair-up [ set-rect-loc ] do-grid ;
|
pair-up [ set-rect-loc ] do-grid ;
|
||||||
|
|
||||||
: resize-grid ( horiz vert -- )
|
: resize-grid ( horiz vert -- )
|
||||||
|
|
|
@ -90,7 +90,7 @@ M: object-button gadget-help ( button -- string )
|
||||||
>r swap with-pane r> ; inline
|
>r swap with-pane r> ; inline
|
||||||
|
|
||||||
: styled-grid ( style grid -- )
|
: 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> ;
|
border-width rot hash [ 5 ] unless* <border> ;
|
||||||
|
|
||||||
: <pane-grid> ( quot style grid -- gadget )
|
: <pane-grid> ( quot style grid -- gadget )
|
||||||
|
|
Loading…
Reference in New Issue