color-picker: fix lamer indentation, clean up

db4
Slava Pestov 2009-02-12 01:40:33 -06:00
parent 64f716b8d2
commit 83a1e9f07c
1 changed files with 22 additions and 22 deletions

View File

@ -1,4 +1,4 @@
! Copyright (C) 2006, 2008 Slava Pestov. ! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.functions math.parser models USING: kernel math math.functions math.parser models
models.filter models.range models.compose sequences ui models.filter models.range models.compose sequences ui
@ -9,9 +9,6 @@ IN: color-picker
! Simple example demonstrating the use of models. ! Simple example demonstrating the use of models.
: <color-slider> ( model -- gadget )
<x-slider> 1 >>line ;
TUPLE: color-preview < gadget ; TUPLE: color-preview < gadget ;
: <color-preview> ( model -- gadget ) : <color-preview> ( model -- gadget )
@ -25,25 +22,28 @@ M: color-preview model-changed
: <color-model> ( model -- model ) : <color-model> ( model -- model )
[ first3 [ 256 /f ] tri@ 1 <rgba> <solid> ] <filter> ; [ first3 [ 256 /f ] tri@ 1 <rgba> <solid> ] <filter> ;
: <color-sliders> ( -- model gadget ) : <color-slider> ( model -- gadget )
horizontal <slider> 1 >>line ;
: <color-sliders> ( -- gadget model )
3 [ 0 0 0 255 <range> ] replicate 3 [ 0 0 0 255 <range> ] replicate
dup [ range-model ] map <compose> [ <filled-pile> { 5 5 } >>gap [ <color-slider> add-gadget ] reduce ]
swap [ [ range-model ] map <compose> ]
<filled-pile> bi ;
swap
[ <color-slider> add-gadget ] each ;
: <color-picker> ( -- gadget ) : <color-picker> ( -- gadget )
<frame> <frame>
{ 5 5 } >>gap
<color-sliders> <color-sliders>
swap dup
[ @top grid-add ] [ @top grid-add ]
[
[ <color-model> <color-preview> @center grid-add ] [ <color-model> <color-preview> @center grid-add ]
[ [
[ [ truncate number>string ] map " " join ] <filter> <label-control> [ [ truncate number>string ] map " " join ]
<filter> <label-control>
@bottom grid-add @bottom grid-add
] ] bi
tri* ; ] bi* ;
: color-picker-window ( -- ) : color-picker-window ( -- )
[ <color-picker> "Color Picker" open-window ] with-ui ; [ <color-picker> "Color Picker" open-window ] with-ui ;