2008-07-10 21:32:17 -04:00
|
|
|
! Copyright (C) 2005, 2008 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-07-11 01:01:22 -04:00
|
|
|
USING: arrays accessors definitions hashtables io kernel
|
2008-12-08 14:58:57 -05:00
|
|
|
sequences strings io.styles words help math models
|
2008-07-11 01:01:22 -04:00
|
|
|
namespaces quotations
|
|
|
|
ui.gadgets ui.gadgets.borders ui.gadgets.buttons
|
|
|
|
ui.gadgets.labels ui.gadgets.menus ui.gadgets.worlds
|
|
|
|
ui.gadgets.status-bar ui.commands ui.operations ui.gestures ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: ui.gadgets.presentations
|
|
|
|
|
2008-07-10 21:32:17 -04:00
|
|
|
TUPLE: presentation < button object hook ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: invoke-presentation ( presentation command -- )
|
2008-08-31 02:42:30 -04:00
|
|
|
over dup hook>> call
|
2008-11-28 01:02:02 -05:00
|
|
|
[ object>> ] dip invoke-command ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: invoke-primary ( presentation -- )
|
2008-08-31 02:42:30 -04:00
|
|
|
dup object>> primary-operation
|
2007-09-20 18:09:08 -04:00
|
|
|
invoke-presentation ;
|
|
|
|
|
|
|
|
: invoke-secondary ( presentation -- )
|
2008-08-31 02:42:30 -04:00
|
|
|
dup object>> secondary-operation
|
2007-09-20 18:09:08 -04:00
|
|
|
invoke-presentation ;
|
|
|
|
|
|
|
|
: show-mouse-help ( presentation -- )
|
2008-08-31 02:42:30 -04:00
|
|
|
dup object>> over show-summary button-update ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: <presentation> ( label object -- button )
|
2008-07-10 21:32:17 -04:00
|
|
|
swap [ invoke-primary ] presentation new-button
|
|
|
|
swap >>object
|
|
|
|
[ drop ] >>hook
|
|
|
|
roll-button-theme ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
M: presentation ungraft*
|
|
|
|
dup hand-gadget get-global child? [ dup hide-status ] when
|
2008-07-10 21:32:17 -04:00
|
|
|
call-next-method ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: <operations-menu> ( presentation -- menu )
|
2008-11-30 16:03:05 -05:00
|
|
|
[ object>> ]
|
|
|
|
[ dup hook>> curry ]
|
|
|
|
[ object>> object-operations ]
|
|
|
|
tri <commands-menu> ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: operations-menu ( presentation -- )
|
2008-11-30 16:03:05 -05:00
|
|
|
dup <operations-menu> show-menu ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
presentation H{
|
|
|
|
{ T{ button-down f f 3 } [ operations-menu ] }
|
|
|
|
{ T{ mouse-leave } [ dup hide-status button-update ] }
|
|
|
|
{ T{ mouse-enter } [ show-mouse-help ] }
|
|
|
|
! Responding to motion too allows nested presentations to
|
|
|
|
! display status help properly, when the mouse leaves a
|
|
|
|
! nested presentation and is still inside the parent, the
|
|
|
|
! parent doesn't receive a mouse-enter
|
|
|
|
{ T{ motion } [ show-mouse-help ] }
|
|
|
|
} set-gestures
|