]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/labeled/labeled.factor
Replaced hard-coded colors with constants
[factor.git] / basis / ui / gadgets / labeled / labeled.factor
1 ! Copyright (C) 2006, 2009 Slava Pestov, 2015 Nicolas PĂ©net.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors colors.constants kernel system ui.gadgets
4 ui.gadgets.borders ui.gadgets.labels ui.gadgets.packs
5 ui.gadgets.theme ui.gadgets.tracks ui.pens.gradient
6 ui.pens.solid ui.tools.common ;
7 IN: ui.gadgets.labeled
8
9 TUPLE: labeled-gadget < track content color ;
10
11 <PRIVATE
12
13 M: labeled-gadget focusable-child* content>> ;
14
15 ! gradients don't work as backgrounds on windows, see #152 and #1397
16 : title-bar-interior ( -- interior )
17     os windows?
18     [ toolbar-background <solid> ]
19     [ title-bar-gradient <gradient> ]
20     if ;
21
22 : add-title-bar ( title track -- track )
23     swap >label
24     [ t >>bold? ] change-font
25     { 0 4 } <border>
26     title-bar-interior >>interior
27     f track-add ;
28
29 : add-content ( content track -- track )
30     swap 1 track-add ;
31
32 : add-color-line ( color track -- track )
33     <shelf> { 0 1.5 } <border>
34     rot <solid> >>interior
35     f track-add ;
36
37 : add-content-area ( labeled -- labeled )
38     [ ] [ content>> ] [ color>> ] tri
39     vertical <track>
40     add-color-line
41     add-content
42     1 track-add ;
43
44 PRIVATE>
45
46 : <labeled> ( gadget title color -- labeled )
47     vertical labeled-gadget new-track with-lines
48     swap >>color
49     add-title-bar
50     swap >>content
51     add-content-area ;
52
53 : <framed-labeled> ( gadget title color -- labeled )
54     <labeled> labeled-border-color <solid> >>boundary ;
55
56 : <labeled-gadget> ( gadget title -- labeled )
57     vertical labeled-gadget new-track with-lines
58     add-title-bar
59     swap [ >>content ] keep
60     vertical <track>
61     add-content
62     { 5 5 } <border>
63     content-background <solid> >>interior
64     1 track-add
65     labeled-border-color <solid> >>boundary
66     { 3 3 } <border> ;