1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel memoize namespaces ui.commands ui.gadgets
4 ui.gadgets.borders ui.gadgets.buttons ui.gadgets.buttons.private
5 ui.gadgets.glass ui.gadgets.menus ui.gadgets.status-bar
6 ui.gadgets.worlds ui.gestures ui.operations ui.pens.solid ui.theme ;
7 IN: ui.gadgets.presentations
9 TUPLE: presentation < button object hook ;
11 TUPLE: presentation-menu < border presentation ;
13 : invoke-presentation ( presentation command -- )
14 [ [ dup hook>> call( presentation -- ) ] [ object>> ] bi ] dip
17 : invoke-primary ( presentation -- )
18 dup object>> primary-operation
21 : invoke-secondary ( presentation -- )
22 dup object>> secondary-operation
25 : show-mouse-help ( presentation -- )
26 [ [ object>> ] keep show-summary ] [ button-update ] bi ;
28 : <presentation> ( label object -- button )
29 [ [ invoke-primary ] presentation new-button ] dip
34 M: presentation ungraft*
35 dup hand-gadget get-global child? [ dup hide-status ] when
38 MEMO: selected-pen-boundary ( -- button-pen )
39 roll-button-rollover-border <solid> dup dup f f <button-pen> ;
42 : setup-presentation ( presentation -- presentation )
43 selected-pen-boundary >>boundary ;
46 : <presentation-menu> ( presentation target hook -- menu )
47 <operations-menu> presentation-menu new-border
51 : show-presentation-menu ( presentation -- )
52 setup-presentation dup
53 [ ] [ object>> ] [ dup hook>> curry ] tri
54 <presentation-menu> show-menu ;
56 M: presentation-menu hide-glass-hook
57 presentation>> button-pen-boundary >>boundary drop ;
60 { T{ button-down f f 3 } [ show-presentation-menu ] }
61 { mouse-leave [ [ hide-status ] [ button-update ] bi ] }
62 { mouse-enter [ show-mouse-help ] }
63 ! Responding to motion too allows nested presentations to
64 ! display status help properly, when the mouse leaves a
65 ! nested presentation and is still inside the parent, the
66 ! parent doesn't receive a mouse-enter
67 { motion [ show-mouse-help ] }