]> gitweb.factorcode.org Git - factor.git/commitdiff
color-table: add column filled with respective colors 1621/head
authorAlexander Iljin <ajsoft@yandex.ru>
Sat, 30 Apr 2016 14:01:28 +0000 (17:01 +0300)
committerAlexander Iljin <ajsoft@yandex.ru>
Sat, 30 Apr 2016 14:53:48 +0000 (17:53 +0300)
Side note: it would be better to simply set the cell background color.
Unfortunately, no such mechanism exists at the moment.

extra/color-table/color-table.factor

index a154ff82d0902e3392834e74f537d95f9858ca81..dc5bc8eff54ee49cdb392529b1284b0e00272562 100644 (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 ]