]> gitweb.factorcode.org Git - factor.git/commitdiff
Presentation cleanup
authorslava <slava@factorcode.org>
Tue, 10 Oct 2006 05:07:11 +0000 (05:07 +0000)
committerslava <slava@factorcode.org>
Tue, 10 Oct 2006 05:07:11 +0000 (05:07 +0000)
TODO.FACTOR.txt
doc/handbook/ui/tools.facts
library/ui/gadgets/presentations.factor
library/ui/gestures.factor
library/ui/load.factor
library/ui/test/presentations.factor [new file with mode: 0644]
library/ui/tools/dataflow.factor
library/ui/ui.factor
library/ui/world.factor

index a1ae42f29045ff34c54be1e57a042c107046123c..b51c04905d382390f824e604fb1199979cd9bdcf 100644 (file)
@@ -4,7 +4,6 @@
 
 + ui:
 
-- command presentation shouldn't really be a presentation at all
 - completion is not ideal: eg, search for "buttons"
 - live search: timer delay would be nice
 - some way of intercepting all gestures
index 52ce942427c2024b242ad6aa4f24ef2033a9f493..c69ad0d1489692b01c5da8a5b178ef06a1d51449 100644 (file)
@@ -12,7 +12,7 @@ $terpri
 $terpri
 "Clicking and holding the right mouse button on a presentation displays a popup menu listing available operations."
 $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"
 "The graphical listener is based around the terminal listener (" { $link "listener" } ") and adds the following features:"
index 1351162a9c54a4a94617e38058c34dcf3e292b7d..d4cb6a58a29d1313f85527048416dcdd8e2c47b5 100644 (file)
@@ -11,36 +11,10 @@ generic hashtables tools io kernel prettyprint sequences strings
 styles words help math models namespaces ;
 
 ! Clickable objects
-TUPLE: presentation object command ;
-
-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 ;
+TUPLE: presentation object ;
 
 : invoke-presentation ( presentation -- )
-    dup presentation-object swap presentation-command
-    [ dup default-operation ] unless*
+    dup presentation-object dup default-operation
     invoke-command ;
 
 : show-mouse-help ( presentation -- )
@@ -52,17 +26,37 @@ C: presentation ( button object command -- button )
 M: presentation ungraft* ( presentation -- )
     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{
-    { T{ button-up } [ [ invoke-presentation ] if-clicked ] }
-    { T{ button-down f f 3 } [ [ operations-menu ] if-clicked ] }
+    { T{ button-down f f 3 } [ operations-menu ] }
     { T{ mouse-leave } [ dup hide-mouse-help button-update ] }
     { T{ motion } [ dup show-mouse-help button-update ] }
 } set-gestures
 
 ! Presentation help bar
 : <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 )
     [ call-listener ] curry <roll-button> ;
@@ -87,7 +81,7 @@ presentation H{
     over specified-font over set-label-font ;
 
 : apply-presentation-style ( style gadget -- style gadget )
-    presented [ <object-presentation> ] apply-style ;
+    presented [ <presentation> ] apply-style ;
 
 : apply-quotation-style ( style gadget -- style gadget )
     quotation [ <listener-button> ] apply-style ;
index d77689de18a631229c4c3f2a308cbfd99de49793..44c8d967728f9bddae3a05966af9d692c7867428 100644 (file)
@@ -152,8 +152,6 @@ SYMBOL: scroll-direction
     hand-gadget get-global hand-clicked set-global
     hand-loc get-global hand-click-loc set-global ;
 
-SYMBOL: menu-mode?
-
 : move-hand ( loc world -- )
     dup hand-world set-global
     under-hand >r over hand-loc set-global
index ba14d4096dcb6d4d0ab2146e635ac86a08f5760f..a14c525d112caff082466b6084feb9aa2e04a54c 100644 (file)
@@ -49,6 +49,7 @@ PROVIDE: library/ui {
     "tools/operations.factor"
     "text/editor.facts"
 } {
+    "test/editor.factor"
     "test/gadgets.factor"
     "test/models.factor"
     "test/document.factor"
@@ -57,7 +58,7 @@ PROVIDE: library/ui {
     "test/rectangles.factor"
     "test/commands.factor"
     "test/panes.factor"
-    "test/editor.factor"
+    "test/presentations.factor"
     "test/search.factor"
     "test/sliders.factor"
     "test/tracks.factor"
diff --git a/library/ui/test/presentations.factor b/library/ui/test/presentations.factor
new file mode 100644 (file)
index 0000000..217a2b3
--- /dev/null
@@ -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
index 5965b08450d6ed6c9c8549217cfe73436b2a056f..9851fd5a9abf0e648fe96d6f23e0499053985010 100644 (file)
@@ -106,12 +106,12 @@ M: #push node-presents >#push< first ;
     [ length ] keep
     [
         >r number>string "Child " swap append <label> r>
-        <object-presentation>
+        <presentation>
     ] 2map ;
 
 : <node-presentation> ( node -- gadget )
     class [ word-name <label> ] keep <link>
-    <object-presentation> ;
+    <presentation> ;
 
 : default-node-content ( node -- gadget )
     dup node-children <child-nodes>
@@ -167,7 +167,7 @@ DEFER: (compute-heights)
 ! Then we create gadgets for every node
 : node>gadget ( height node -- gadget )
     [ node>gadget* ] keep node-presents
-    [ <object-presentation> ] when* ;
+    [ <presentation> ] when* ;
 
 : print-node ( d-height node -- )
     dup full-height-node? [
index 7867beffffbc3817464c7f16481de724a4a96f24..c5e8467c93739b97dc57578ffed2dd7adb8da19d 100644 (file)
@@ -121,7 +121,7 @@ C: titled-gadget ( gadget title -- )
 
 : <toolbar> ( target classes -- toolbar )
     [ commands "toolbar" swap hash ] map concat
-    [ <command-presentation> ] map-with
+    [ <command-button> ] map-with
     make-shelf ;
 
 : command-description ( command -- element )
index 2846ac58746ab88d075354fe96189dd6786d0eca..139de9e0e9dd8cb9f093011134c4a77f62d45ea7 100644 (file)
@@ -22,6 +22,8 @@ focus focused?
 fonts handle
 loc ;
 
+SYMBOL: menu-mode?
+
 : free-fonts ( world -- )
     dup world-handle select-gl-context
     world-fonts hash-values [ second free-sprites ] each ;