Render table column separator lines
parent
d2f1ead23e
commit
1914a57b40
|
@ -22,6 +22,7 @@ M: color blue>> ( color -- blue ) >rgba blue>> ;
|
||||||
: blue T{ rgba f 0.0 0.0 1.0 1.0 } ; inline
|
: blue T{ rgba f 0.0 0.0 1.0 1.0 } ; inline
|
||||||
: cyan T{ rgba f 0 0.941 0.941 1 } ; inline
|
: cyan T{ rgba f 0 0.941 0.941 1 } ; inline
|
||||||
: gray T{ rgba f 0.6 0.6 0.6 1.0 } ; inline
|
: gray T{ rgba f 0.6 0.6 0.6 1.0 } ; inline
|
||||||
|
: dark-gray T{ rgba f 0.8 0.8 0.8 1.0 } ; inline
|
||||||
: green T{ rgba f 0.0 1.0 0.0 1.0 } ; inline
|
: green T{ rgba f 0.0 1.0 0.0 1.0 } ; inline
|
||||||
: light-gray T{ rgba f 0.95 0.95 0.95 0.95 } ; inline
|
: light-gray T{ rgba f 0.95 0.95 0.95 0.95 } ; inline
|
||||||
: light-purple T{ rgba f 0.8 0.8 1.0 1.0 } ; inline
|
: light-purple T{ rgba f 0.8 0.8 1.0 1.0 } ; inline
|
||||||
|
|
|
@ -19,7 +19,7 @@ M: object row-value drop ;
|
||||||
TUPLE: table < gadget
|
TUPLE: table < gadget
|
||||||
renderer filled-column column-alignment action
|
renderer filled-column column-alignment action
|
||||||
column-widths total-width
|
column-widths total-width
|
||||||
font text-color selection-color mouse-color
|
font text-color selection-color mouse-color column-line-color
|
||||||
selected-index selected-value
|
selected-index selected-value
|
||||||
mouse-index
|
mouse-index
|
||||||
focused? ;
|
focused? ;
|
||||||
|
@ -32,6 +32,7 @@ focused? ;
|
||||||
f <model> >>selected-value
|
f <model> >>selected-value
|
||||||
sans-serif-font >>font
|
sans-serif-font >>font
|
||||||
selection-color >>selection-color
|
selection-color >>selection-color
|
||||||
|
dark-gray >>column-line-color
|
||||||
black >>mouse-color
|
black >>mouse-color
|
||||||
black >>text-color ;
|
black >>text-color ;
|
||||||
|
|
||||||
|
@ -100,6 +101,16 @@ M: table layout*
|
||||||
: draw-moused ( table -- )
|
: draw-moused ( table -- )
|
||||||
[ ] [ mouse-index>> ] [ mouse-color>> ] tri f highlight-row ;
|
[ ] [ mouse-index>> ] [ mouse-color>> ] tri f highlight-row ;
|
||||||
|
|
||||||
|
: column-lines ( widths -- xs )
|
||||||
|
0 [ + ] accumulate nip rest-slice ; inline
|
||||||
|
|
||||||
|
: draw-columns ( table -- )
|
||||||
|
[ column-line-color>> gl-color ]
|
||||||
|
[
|
||||||
|
[ column-widths>> column-lines ] [ dim>> second ] bi
|
||||||
|
'[ [ 0 2array ] [ _ 2array ] bi gl-line ] each
|
||||||
|
] bi ;
|
||||||
|
|
||||||
: y>row ( y table -- n )
|
: y>row ( y table -- n )
|
||||||
line-height /i ;
|
line-height /i ;
|
||||||
|
|
||||||
|
@ -157,10 +168,12 @@ M: table layout*
|
||||||
M: table draw-gadget*
|
M: table draw-gadget*
|
||||||
dup control-value empty? [ drop ] [
|
dup control-value empty? [ drop ] [
|
||||||
origin get [
|
origin get [
|
||||||
[ draw-selected ]
|
{
|
||||||
[ draw-moused ]
|
[ draw-selected ]
|
||||||
[ draw-rows ]
|
[ draw-columns ]
|
||||||
tri
|
[ draw-moused ]
|
||||||
|
[ draw-rows ]
|
||||||
|
} cleave
|
||||||
] with-translation
|
] with-translation
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue