1 ! Copyright (C) 2005, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays accessors definitions hashtables io kernel
4 sequences strings io.styles words help math models
6 ui.gadgets ui.gadgets.borders ui.gadgets.buttons
7 ui.gadgets.labels ui.gadgets.menus ui.gadgets.worlds
8 ui.gadgets.status-bar ui.commands ui.operations ui.gestures ;
9 IN: ui.gadgets.presentations
11 TUPLE: presentation < button object hook ;
13 : invoke-presentation ( presentation command -- )
14 [ [ dup hook>> call ] [ 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 swap [ invoke-primary ] presentation new-button
34 M: presentation ungraft*
35 dup hand-gadget get-global child? [ dup hide-status ] when
38 : show-operations-menu ( presentation -- )
39 [ ] [ object>> ] [ dup hook>> curry ] tri
40 <operations-menu> show-menu ;
43 { T{ button-down f f 3 } [ show-operations-menu ] }
44 { T{ mouse-leave } [ [ hide-status ] [ button-update ] bi ] }
45 { T{ mouse-enter } [ show-mouse-help ] }
46 ! Responding to motion too allows nested presentations to
47 ! display status help properly, when the mouse leaves a
48 ! nested presentation and is still inside the parent, the
49 ! parent doesn't receive a mouse-enter
50 { T{ motion } [ show-mouse-help ] }