color-table: add column filled with respective colors

Side note: it would be better to simply set the cell background color.
Unfortunately, no such mechanism exists at the moment.
locals-and-roots
Alexander Iljin 2016-04-30 17:01:28 +03:00
parent 8f8ab48346
commit f8b1269ef2
1 changed files with 10 additions and 3 deletions

View File

@ -1,21 +1,28 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors combinators.smart sorting.human
models colors.constants present sorting.slots
ui ui.gadgets.tables ui.gadgets.scrollers ;
models colors.constants present sorting.slots combinators
ui ui.gadgets.tables ui.gadgets.scrollers strings literals ;
IN: color-table
! ui.gadgets.tables demo
SINGLETON: color-renderer
<PRIVATE
CONSTANT: full-block-string $[ 10 CHAR: full-block <string> ]
PRIVATE>
M: color-renderer filled-column
drop 0 ;
M: color-renderer column-titles
drop { "Name" "Red" "Green" "Blue" } ;
drop { "Color" "Name" "Red" "Green" "Blue" } ;
M: color-renderer row-columns
drop [
full-block-string swap
dup named-color
[ red>> present ]
[ green>> present ]