Presentation cleanup
parent
8710bf56c0
commit
35a7daf7aa
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
+ ui:
|
+ ui:
|
||||||
|
|
||||||
- command presentation shouldn't really be a presentation at all
|
|
||||||
- completion is not ideal: eg, search for "buttons"
|
- completion is not ideal: eg, search for "buttons"
|
||||||
- live search: timer delay would be nice
|
- live search: timer delay would be nice
|
||||||
- some way of intercepting all gestures
|
- some way of intercepting all gestures
|
||||||
|
|
|
@ -12,7 +12,7 @@ $terpri
|
||||||
$terpri
|
$terpri
|
||||||
"Clicking and holding the right mouse button on a presentation displays a popup menu listing available operations."
|
"Clicking and holding the right mouse button on a presentation displays a popup menu listing available operations."
|
||||||
$terpri
|
$terpri
|
||||||
"Presentation gadgets can be constructed directly using the " { $link <object-presentation> } " word, and they can also be written to " { $link pane } " gadgets using the " { $link write-object } " word." ;
|
"Presentation gadgets can be constructed directly using the " { $link <presentation> } " word, and they can also be written to " { $link pane } " gadgets using the " { $link write-object } " word." ;
|
||||||
|
|
||||||
ARTICLE: "ui-listener" "UI listener"
|
ARTICLE: "ui-listener" "UI listener"
|
||||||
"The graphical listener is based around the terminal listener (" { $link "listener" } ") and adds the following features:"
|
"The graphical listener is based around the terminal listener (" { $link "listener" } ") and adds the following features:"
|
||||||
|
|
|
@ -11,36 +11,10 @@ generic hashtables tools io kernel prettyprint sequences strings
|
||||||
styles words help math models namespaces ;
|
styles words help math models namespaces ;
|
||||||
|
|
||||||
! Clickable objects
|
! Clickable objects
|
||||||
TUPLE: presentation object command ;
|
TUPLE: presentation object ;
|
||||||
|
|
||||||
C: presentation ( button object command -- button )
|
|
||||||
[ set-presentation-command ] keep
|
|
||||||
[ set-presentation-object ] keep
|
|
||||||
[ set-gadget-delegate ] keep ;
|
|
||||||
|
|
||||||
: <object-presentation> ( gadget object -- button )
|
|
||||||
>r f <roll-button> r> f <presentation> ;
|
|
||||||
|
|
||||||
: <command-presentation> ( target command -- button )
|
|
||||||
dup command-name f <bevel-button> -rot <presentation> ;
|
|
||||||
|
|
||||||
: <commands-menu> ( target commands -- gadget )
|
|
||||||
[ hand-clicked get find-world hide-glass ] modify-operations
|
|
||||||
[ <command-presentation> ] map-with
|
|
||||||
make-pile 1 over set-pack-fill ;
|
|
||||||
|
|
||||||
: operations-menu ( presentation -- gadget )
|
|
||||||
dup presentation-command [
|
|
||||||
drop
|
|
||||||
] [
|
|
||||||
dup presentation-object
|
|
||||||
dup object-operations <commands-menu>
|
|
||||||
swap show-menu
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: invoke-presentation ( presentation -- )
|
: invoke-presentation ( presentation -- )
|
||||||
dup presentation-object swap presentation-command
|
dup presentation-object dup default-operation
|
||||||
[ dup default-operation ] unless*
|
|
||||||
invoke-command ;
|
invoke-command ;
|
||||||
|
|
||||||
: show-mouse-help ( presentation -- )
|
: show-mouse-help ( presentation -- )
|
||||||
|
@ -52,17 +26,37 @@ C: presentation ( button object command -- button )
|
||||||
M: presentation ungraft* ( presentation -- )
|
M: presentation ungraft* ( presentation -- )
|
||||||
dup hide-mouse-help delegate ungraft* ;
|
dup hide-mouse-help delegate ungraft* ;
|
||||||
|
|
||||||
|
C: presentation ( gadget object -- button )
|
||||||
|
[ set-presentation-object ] keep
|
||||||
|
swap [ invoke-presentation ] <roll-button>
|
||||||
|
over set-gadget-delegate ;
|
||||||
|
|
||||||
|
: <command-button> ( target command -- button )
|
||||||
|
dup command-name -rot
|
||||||
|
[ invoke-command drop ] curry curry
|
||||||
|
<bevel-button> ;
|
||||||
|
|
||||||
|
: <commands-menu> ( target commands -- gadget )
|
||||||
|
[ hand-clicked get find-world hide-glass ] modify-operations
|
||||||
|
[ <command-button> ] map-with
|
||||||
|
make-pile 1 over set-pack-fill ;
|
||||||
|
|
||||||
|
: operations-menu ( presentation -- gadget )
|
||||||
|
dup presentation-object
|
||||||
|
dup object-operations <commands-menu>
|
||||||
|
swap show-menu ;
|
||||||
|
|
||||||
presentation H{
|
presentation H{
|
||||||
{ T{ button-up } [ [ invoke-presentation ] if-clicked ] }
|
{ T{ button-down f f 3 } [ operations-menu ] }
|
||||||
{ T{ button-down f f 3 } [ [ operations-menu ] if-clicked ] }
|
|
||||||
{ T{ mouse-leave } [ dup hide-mouse-help button-update ] }
|
{ T{ mouse-leave } [ dup hide-mouse-help button-update ] }
|
||||||
{ T{ motion } [ dup show-mouse-help button-update ] }
|
{ T{ motion } [ dup show-mouse-help button-update ] }
|
||||||
} set-gestures
|
} set-gestures
|
||||||
|
|
||||||
! Presentation help bar
|
! Presentation help bar
|
||||||
: <presentation-help> ( model -- gadget )
|
: <presentation-help> ( model -- gadget )
|
||||||
[ [ presentation-object summary ] [ "" ] if* ] <filter>
|
[
|
||||||
<label-control> dup reverse-video-theme ;
|
[ presentation-object summary ] [ "" ] if*
|
||||||
|
] <filter> <label-control> dup reverse-video-theme ;
|
||||||
|
|
||||||
: <listener-button> ( gadget quot -- button )
|
: <listener-button> ( gadget quot -- button )
|
||||||
[ call-listener ] curry <roll-button> ;
|
[ call-listener ] curry <roll-button> ;
|
||||||
|
@ -87,7 +81,7 @@ presentation H{
|
||||||
over specified-font over set-label-font ;
|
over specified-font over set-label-font ;
|
||||||
|
|
||||||
: apply-presentation-style ( style gadget -- style gadget )
|
: apply-presentation-style ( style gadget -- style gadget )
|
||||||
presented [ <object-presentation> ] apply-style ;
|
presented [ <presentation> ] apply-style ;
|
||||||
|
|
||||||
: apply-quotation-style ( style gadget -- style gadget )
|
: apply-quotation-style ( style gadget -- style gadget )
|
||||||
quotation [ <listener-button> ] apply-style ;
|
quotation [ <listener-button> ] apply-style ;
|
||||||
|
|
|
@ -152,8 +152,6 @@ SYMBOL: scroll-direction
|
||||||
hand-gadget get-global hand-clicked set-global
|
hand-gadget get-global hand-clicked set-global
|
||||||
hand-loc get-global hand-click-loc set-global ;
|
hand-loc get-global hand-click-loc set-global ;
|
||||||
|
|
||||||
SYMBOL: menu-mode?
|
|
||||||
|
|
||||||
: move-hand ( loc world -- )
|
: move-hand ( loc world -- )
|
||||||
dup hand-world set-global
|
dup hand-world set-global
|
||||||
under-hand >r over hand-loc set-global
|
under-hand >r over hand-loc set-global
|
||||||
|
|
|
@ -49,6 +49,7 @@ PROVIDE: library/ui {
|
||||||
"tools/operations.factor"
|
"tools/operations.factor"
|
||||||
"text/editor.facts"
|
"text/editor.facts"
|
||||||
} {
|
} {
|
||||||
|
"test/editor.factor"
|
||||||
"test/gadgets.factor"
|
"test/gadgets.factor"
|
||||||
"test/models.factor"
|
"test/models.factor"
|
||||||
"test/document.factor"
|
"test/document.factor"
|
||||||
|
@ -57,7 +58,7 @@ PROVIDE: library/ui {
|
||||||
"test/rectangles.factor"
|
"test/rectangles.factor"
|
||||||
"test/commands.factor"
|
"test/commands.factor"
|
||||||
"test/panes.factor"
|
"test/panes.factor"
|
||||||
"test/editor.factor"
|
"test/presentations.factor"
|
||||||
"test/search.factor"
|
"test/search.factor"
|
||||||
"test/sliders.factor"
|
"test/sliders.factor"
|
||||||
"test/tracks.factor"
|
"test/tracks.factor"
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
IN: temporary
|
||||||
|
USING: math gadgets-presentations gadgets generic test
|
||||||
|
prettyprint gadgets-buttons io kernel ;
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
"Hi" \ + <presentation> [ gadget? ] is?
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ "+" ] [
|
||||||
|
[
|
||||||
|
\ +
|
||||||
|
"Test" f [ pprint ] <command> <command-button>
|
||||||
|
dup button-quot call
|
||||||
|
] string-out
|
||||||
|
] unit-test
|
|
@ -106,12 +106,12 @@ M: #push node-presents >#push< first ;
|
||||||
[ length ] keep
|
[ length ] keep
|
||||||
[
|
[
|
||||||
>r number>string "Child " swap append <label> r>
|
>r number>string "Child " swap append <label> r>
|
||||||
<object-presentation>
|
<presentation>
|
||||||
] 2map ;
|
] 2map ;
|
||||||
|
|
||||||
: <node-presentation> ( node -- gadget )
|
: <node-presentation> ( node -- gadget )
|
||||||
class [ word-name <label> ] keep <link>
|
class [ word-name <label> ] keep <link>
|
||||||
<object-presentation> ;
|
<presentation> ;
|
||||||
|
|
||||||
: default-node-content ( node -- gadget )
|
: default-node-content ( node -- gadget )
|
||||||
dup node-children <child-nodes>
|
dup node-children <child-nodes>
|
||||||
|
@ -167,7 +167,7 @@ DEFER: (compute-heights)
|
||||||
! Then we create gadgets for every node
|
! Then we create gadgets for every node
|
||||||
: node>gadget ( height node -- gadget )
|
: node>gadget ( height node -- gadget )
|
||||||
[ node>gadget* ] keep node-presents
|
[ node>gadget* ] keep node-presents
|
||||||
[ <object-presentation> ] when* ;
|
[ <presentation> ] when* ;
|
||||||
|
|
||||||
: print-node ( d-height node -- )
|
: print-node ( d-height node -- )
|
||||||
dup full-height-node? [
|
dup full-height-node? [
|
||||||
|
|
|
@ -121,7 +121,7 @@ C: titled-gadget ( gadget title -- )
|
||||||
|
|
||||||
: <toolbar> ( target classes -- toolbar )
|
: <toolbar> ( target classes -- toolbar )
|
||||||
[ commands "toolbar" swap hash ] map concat
|
[ commands "toolbar" swap hash ] map concat
|
||||||
[ <command-presentation> ] map-with
|
[ <command-button> ] map-with
|
||||||
make-shelf ;
|
make-shelf ;
|
||||||
|
|
||||||
: command-description ( command -- element )
|
: command-description ( command -- element )
|
||||||
|
|
|
@ -22,6 +22,8 @@ focus focused?
|
||||||
fonts handle
|
fonts handle
|
||||||
loc ;
|
loc ;
|
||||||
|
|
||||||
|
SYMBOL: menu-mode?
|
||||||
|
|
||||||
: free-fonts ( world -- )
|
: free-fonts ( world -- )
|
||||||
dup world-handle select-gl-context
|
dup world-handle select-gl-context
|
||||||
world-fonts hash-values [ second free-sprites ] each ;
|
world-fonts hash-values [ second free-sprites ] each ;
|
||||||
|
|
Loading…
Reference in New Issue