Table borders
parent
afe77c6b0a
commit
6017ad861b
|
@ -180,6 +180,7 @@ sequences vectors words ;
|
|||
"/library/ui/gadgets/frames.factor"
|
||||
"/library/ui/world.factor"
|
||||
"/library/ui/paint.factor"
|
||||
"/library/ui/gadgets/grid-lines.factor"
|
||||
"/library/ui/gadgets/theme.factor"
|
||||
"/library/ui/gadgets/labels.factor"
|
||||
"/library/ui/gestures.factor"
|
||||
|
|
|
@ -157,14 +157,19 @@ M: link summary "Link: " swap link-name unparse append ;
|
|||
] ($block)
|
||||
] if ;
|
||||
|
||||
: $table ( content -- )
|
||||
: $grid ( content style -- )
|
||||
[
|
||||
table-style [
|
||||
H{ { table-gap { 5 5 0 } } }
|
||||
table-content-style [
|
||||
[ print-element ] tabular-output
|
||||
] with-style
|
||||
] ($block) table last-element set ;
|
||||
|
||||
: $list ( content -- )
|
||||
[ "\u00b7" swap 2array ] map list-style $grid ;
|
||||
|
||||
: $table ( content -- )
|
||||
table-style $grid ;
|
||||
|
||||
: $values ( content -- )
|
||||
"Arguments and values" $heading
|
||||
[ unclip \ $snippet swap 2array swap 2array ] map $table ;
|
||||
|
@ -177,8 +182,6 @@ M: link summary "Link: " swap link-name unparse append ;
|
|||
" class." ,
|
||||
] { } make $description ;
|
||||
|
||||
: $list ( content -- ) [ "-" swap 2array ] map $table ;
|
||||
|
||||
: $errors ( content -- )
|
||||
"Errors" $heading print-element ;
|
||||
|
||||
|
|
|
@ -11,7 +11,10 @@ USING: styles ;
|
|||
} ;
|
||||
|
||||
: link-style
|
||||
H{ { foreground { 0.3 0 0 1 } } { font-style bold } } ;
|
||||
H{
|
||||
{ foreground { 0 0 0.3 1 } }
|
||||
{ font-style bold }
|
||||
} ;
|
||||
|
||||
: emphasis-style
|
||||
H{ { font-style italic } } ;
|
||||
|
@ -33,7 +36,6 @@ USING: styles ;
|
|||
H{
|
||||
{ font-size 14 }
|
||||
{ font-style bold }
|
||||
{ foreground { 0.2 0.2 0.4 1 } }
|
||||
} ;
|
||||
|
||||
: subsection-style
|
||||
|
@ -75,7 +77,16 @@ USING: styles ;
|
|||
{ border-width 5 }
|
||||
} ;
|
||||
|
||||
: table-style
|
||||
: table-content-style
|
||||
H{
|
||||
{ wrap-margin 350 }
|
||||
} ;
|
||||
|
||||
: table-style
|
||||
H{
|
||||
{ table-gap { 5 5 0 } }
|
||||
{ table-border { 0.8 0.8 0.8 1.0 } }
|
||||
} ;
|
||||
|
||||
: list-style
|
||||
H{ { table-gap { 10 2 0 } } } ;
|
||||
|
|
|
@ -27,6 +27,7 @@ SYMBOL: outline
|
|||
|
||||
! Table styles
|
||||
SYMBOL: table-gap
|
||||
SYMBOL: table-border
|
||||
|
||||
! Input history
|
||||
TUPLE: input string ;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
! Copyright (C) 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: gadgets-grids
|
||||
USING: gadgets kernel math namespaces opengl sequences ;
|
||||
|
||||
! You can set a grid's gadget-boundary to this.
|
||||
TUPLE: grid-lines color ;
|
||||
|
||||
SYMBOL: grid-dim
|
||||
|
||||
: half-gap gap 2 v/n ; inline
|
||||
|
||||
: grid-line-from/to ( orientation point -- from to )
|
||||
half-gap v-
|
||||
[ half-gap swap rot set-axis ] 2keep
|
||||
grid-dim get swap rot set-axis ;
|
||||
|
||||
: draw-grid-lines ( gaps orientation -- )
|
||||
#! Clean this up later.
|
||||
swap grid-positions grid get rect-dim { 1 0 } v- add
|
||||
[ grid-line-from/to gl-line ] each-with ;
|
||||
|
||||
M: grid-lines draw-boundary ( gadget paint -- )
|
||||
#! Clean this up later.
|
||||
GL_MODELVIEW [
|
||||
0.5 0.5 0 glTranslated
|
||||
grid-lines-color gl-color [
|
||||
grid get rect-dim half-gap v- grid-dim set
|
||||
{ 0 1 } draw-grid-lines
|
||||
{ 1 0 } draw-grid-lines
|
||||
] with-grid
|
||||
] do-matrix ;
|
|
@ -39,13 +39,9 @@ C: grid ( children -- grid )
|
|||
: (pair-up) ( horiz vert -- dim )
|
||||
>r first r> second 2array ;
|
||||
|
||||
: pair-up ( horiz vert -- dims )
|
||||
[ swap [ swap (pair-up) ] map-with ] map-with ;
|
||||
|
||||
M: grid pref-dim* ( grid -- dim )
|
||||
[
|
||||
[ [ length 1 [-] ] 2apply 2array gap v* ] 2keep
|
||||
[ { 0 0 } [ v+ ] reduce ] 2apply (pair-up) v+
|
||||
[ gap [ v+ gap v+ ] reduce ] 2apply (pair-up)
|
||||
] with-grid ;
|
||||
|
||||
: do-grid ( dims quot -- )
|
||||
|
@ -53,8 +49,14 @@ M: grid pref-dim* ( grid -- dim )
|
|||
[ dup [ pick call ] [ 2drop ] if ] 2each
|
||||
] 2each drop ; inline
|
||||
|
||||
: pair-up ( horiz vert -- dims )
|
||||
[ swap [ swap (pair-up) ] map-with ] map-with ;
|
||||
|
||||
: grid-positions ( dims -- locs )
|
||||
gap [ v+ gap v+ ] accumulate ;
|
||||
|
||||
: position-grid ( horiz vert -- )
|
||||
[ { 0 0 } [ v+ gap v+ ] accumulate ] 2apply
|
||||
[ grid-positions ] 2apply
|
||||
pair-up [ set-rect-loc ] do-grid ;
|
||||
|
||||
: resize-grid ( horiz vert -- )
|
||||
|
|
|
@ -89,9 +89,18 @@ M: object-button gadget-help ( button -- string )
|
|||
>r <pane> dup r> swap <styled-paragraph>
|
||||
>r swap with-pane r> ; inline
|
||||
|
||||
: styled-grid ( style grid -- )
|
||||
: apply-table-gap-style ( grid style -- grid style )
|
||||
table-gap [ over set-grid-gap ] apply-style ;
|
||||
|
||||
: apply-table-border-style ( grid style -- grid style )
|
||||
table-border [ <grid-lines> over set-gadget-boundary ]
|
||||
apply-style ;
|
||||
|
||||
: styled-grid ( style grid -- grid )
|
||||
<grid>
|
||||
table-gap rot hash [ { 0 0 } ] unless* over set-grid-gap ;
|
||||
apply-table-gap-style
|
||||
apply-table-border-style
|
||||
nip ;
|
||||
|
||||
: <pane-grid> ( quot style grid -- gadget )
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue