]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/common/common.factor
398e154f03c11a848c98f03c515c6698234b3d9d
[factor.git] / basis / ui / tools / common / common.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors classes combinators.short-circuit kernel ui
4 ui.gadgets ui.gadgets.borders ui.gadgets.scrollers
5 ui.gadgets.tracks ui.pens.solid ui.theme ui.tools.button-list words ;
6
7 IN: ui.tools.common
8
9 : set-tool-dim ( class dim -- )
10     "tool-dim" set-word-prop ;
11
12 : get-tool-dim ( class -- dim )
13     "tool-dim" word-prop ;
14
15 TUPLE: tool < track ;
16
17 M: tool pref-dim*
18     { [ class-of get-tool-dim ] [ call-next-method ] } 1|| ;
19
20 M: tool layout*
21     [ call-next-method ]
22     [
23         dup fullscreen? [ drop ] [
24             [ class-of ] [ dim>> ] bi set-tool-dim
25         ] if
26     ] bi ;
27
28 SLOT: scroller
29
30 : com-page-up ( tool -- )
31     scroller>> scroll-up-page ;
32
33 : com-page-down ( tool -- )
34     scroller>> scroll-down-page ;
35
36 : com-scroll-up ( tool -- )
37     scroller>> scroll-up-line ;
38
39 : com-scroll-down ( tool -- )
40     scroller>> scroll-down-line ;
41
42 : margins ( child -- border )
43     { 9 9 } <filled-border> ;
44
45 : with-lines ( track -- track )
46     dup orientation>> >>gap
47     line-color <solid> >>interior ;
48
49 : white-interior ( track -- track )
50     content-background <solid> >>interior ;
51
52 : com-show-active-buttons ( tool -- )
53     show-active-buttons-popup ;