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,15 +9,12 @@ 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 )
color-preview new-gadget color-preview new-gadget
swap >>model swap >>model
{ 100 100 } >>dim ; { 100 100 } >>dim ;
M: color-preview model-changed M: color-preview model-changed
swap value>> >>interior relayout-1 ; swap value>> >>interior relayout-1 ;
@ -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>
<color-sliders> { 5 5 } >>gap
swap dup <color-sliders>
[ @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> [
@bottom grid-add [ [ truncate number>string ] map " " join ]
] <filter> <label-control>
tri* ; @bottom grid-add
] bi
] bi* ;
: color-picker-window ( -- ) : color-picker-window ( -- )
[ <color-picker> "Color Picker" open-window ] with-ui ; [ <color-picker> "Color Picker" open-window ] with-ui ;