]> gitweb.factorcode.org Git - factor.git/commitdiff
nicer-looking menus in UI
authorSlava Pestov <slava@factorcode.org>
Fri, 26 Aug 2005 04:55:56 +0000 (04:55 +0000)
committerSlava Pestov <slava@factorcode.org>
Fri, 26 Aug 2005 04:55:56 +0000 (04:55 +0000)
TODO.FACTOR.txt
library/help/tutorial.factor
library/inference/print-dataflow.factor
library/ui/buttons.factor
library/ui/menus.factor
library/ui/paint.factor
library/ui/panes.factor
library/ui/presentations.factor
library/ui/ui.factor
library/ui/world.factor

index b42562bf6d8f2c5c8183bca986237927470fa74d..fcce0145afeb8af366b8671daedac94eb0b7a7e2 100644 (file)
@@ -8,15 +8,12 @@
 - off-by-one error in pick-up?\r
 - closing ui does not stop timers\r
 - adding/removing timers automatically for animated gadgets\r
-- fix listener prompt display after presentation commands invoked\r
 - theme abstraction in ui\r
 - menu dragging\r
 - fix up the min thumb size hack\r
 - gaps in pack layout\r
 - find out why so many small bignums get consed\r
 - faster mouse tracking\r
-- an interior paint that is only painted on rollover and mouse press;\r
-  use it for menu items. give menus a gradient background\r
 - scroll bar: more intuitive behavior when clicking inside the elevator\r
 - nicer scrollbars with up/down buttons\r
 - icons\r
index 75c9a8b7e82b28a8e9f2d1426da05ea88d1fd411..48c06339a00298a052988848542e91c9710ee336 100644 (file)
@@ -17,6 +17,7 @@ M: string tutorial-line <label> ;
 M: general-list tutorial-line\r
     car dup <label> dup rot [ pane get pane-input set-editor-text drop ] cons\r
     button-gestures\r
+    dup roll-button-theme\r
     dup "Monospaced" font set-paint-prop ;\r
 \r
 : <page> ( list -- gadget )\r
@@ -343,3 +344,7 @@ M: general-list tutorial-line
 \r
 : tutorial ( -- )\r
     <tutorial> gadget. ;\r
+\r
+: <tutorial-button>\r
+    "Tutorial" [ drop [ tutorial ] pane get pane-call ] <button> ;\r
+\r
index daf33f0c7791ba2443925694d93a2bd84d94d8ba..3f7349bc7eb9da78998501ef35366262eb833f01 100644 (file)
@@ -11,7 +11,7 @@ TUPLE: comment node text ;
 
 M: comment pprint* ( ann -- )
     "( " over comment-text " )" append3
-    swap comment-node presented swons unit format ;
+    swap comment-node presented swons unit text ;
 
 : comment, ( ? node text -- )
     rot [ <comment> , ] [ 2drop ] ifte ;
index f099eeeaad4fb4cb30d317a8636d2cfe2cf7829f..b06efb4de0529c6fab1e237159ed627c1d833ae7 100644 (file)
@@ -29,12 +29,20 @@ sequences io sequences styles ;
     dup mouse-over?
     [ [ action ] swap handle-gesture drop ] [ drop ] ifte ;
 
+: button-theme ( button -- )
+    dup { 216 216 216 } background set-paint-prop
+    dup f reverse-video set-paint-prop
+    << solid f >> interior set-paint-prop ;
+
+: roll-button-theme ( button -- )
+    dup f reverse-video set-paint-prop
+    dup <rollover-only> interior set-paint-prop
+    <rollover-only> boundary set-paint-prop ;
+
 : button-action ( action -- quot )
     [ [ swap handle-gesture drop ] cons ] [ [ drop ] ] ifte* ;
 
 : button-gestures ( button quot -- )
-    over f reverse-video set-paint-prop
-    over << solid f >> interior set-paint-prop
     dupd [ action ] set-action
     dup [ dup button-update button-clicked ] [ button-up 1 ] set-action
     dup [ button-update ] [ button-down 1 ] set-action
@@ -42,9 +50,11 @@ sequences io sequences styles ;
     dup [ button-update ] [ mouse-enter ] set-action
     [ drop ] [ drag 1 ] set-action ;
 
+: (button) ( label quot -- button )
+    >r <label> bevel-border dup r> button-gestures ;
+
 : <button> ( label quot -- button )
-    >r
-    <label> bevel-border
-    dup { 216 216 216 } background set-paint-prop
-    dup
-    r> button-gestures ;
+    (button) dup button-theme ;
+
+: <roll-button> ( label quot -- button )
+    (button) dup roll-button-theme ;
index 79ef5d0220c041e8c3022b5324a2c89abed9ee21..5b6d468aef693ca879971e6b9e2930d8cd3d813c 100644 (file)
@@ -10,7 +10,8 @@ USING: generic kernel lists math namespaces sequences ;
     <plain-gadget> { 1 1 0 } <border> ;
 
 : <menu-item> ( label quot -- gadget )
-    >r <label> menu-item-border dup r> button-gestures ;
+    >r <label> menu-item-border dup roll-button-theme dup
+    r> button-gestures ;
 
 TUPLE: menu ;
 
@@ -24,8 +25,13 @@ TUPLE: menu ;
         uncons \ hide-glass swons <menu-item> swap add-gadget
     ] each-with ;
 
+: menu-theme ( menu -- )
+    << gradient f { 1 0 0 } { 240 240 255 } { 216 216 216 } >>
+    interior set-paint-prop ;
+
 C: menu ( assoc -- gadget )
     #! Given an association list mapping labels to quotations.
     [ f line-border swap set-delegate ] keep
     0 1 <pile> [ swap add-gadget ] 2keep
-    rot assoc>menu dup menu-actions ;
+    rot assoc>menu dup menu-actions
+    dup menu-theme ;
index 39c3587a228b6ad1ab71a11712e778666caec0ff..be5adf95eafc52b15c42c98323164556ca45145c 100644 (file)
@@ -64,6 +64,7 @@ GENERIC: draw-boundary ( gadget boundary -- )
 M: f draw-interior 2drop ;
 M: f draw-boundary 2drop ;
 
+! Solid fill/border
 TUPLE: solid ;
 
 : rect>screen ( shape -- x1 y1 x2 y2 )
@@ -78,6 +79,19 @@ M: solid draw-boundary
     drop >r surface get r> [ rect>screen ] keep
     fg rgb rectangleColor ;
 
+! Rollover only
+TUPLE: rollover-only ;
+
+C: rollover-only << solid f >> over set-delegate ;
+
+M: rollover-only draw-interior ( gadget interior -- )
+    over rollover paint-prop
+    [ delegate draw-interior ] [ 2drop ] ifte ;
+
+M: rollover-only draw-boundary ( gadget boundary -- )
+    over rollover paint-prop
+    [ delegate draw-boundary ] [ 2drop ] ifte ;
+
 ! Gradient pen
 TUPLE: gradient vector from to ;
 
index d9102a76e3cb0e9e4426d561f742df1d524f8dfe..8ee2fe2a6a434813850b22a160e4dd07e60b59e7 100644 (file)
@@ -32,16 +32,29 @@ TUPLE: pane output active current input continuation ;
     dup pane-continuation f rot set-pane-continuation ;
 
 : pane-eval ( string pane -- )
-    2dup stream-print pop-continuation in-thread drop ;
+    pop-continuation in-thread drop ;
+
+SYMBOL: structured-input
+
+: elements. ( quot -- )
+    [
+        1 nesting-limit set
+        5 length-limit set
+        <block pprint-elements block> t newline
+    ] with-pprint ;
 
 : pane-call ( quot pane -- )
-    [ "(Structured input) " write dup . call ] with-stream* ;
+    2dup [ elements. ] with-stream*
+    >r structured-input global set-hash
+    "structured-input global hash call" r> pane-eval ;
+
+: editor-commit ( editor -- line )
+    #! Add current line to the history, and clear the editor.
+    [ commit-history line-text get line-clear ] with-editor ;
 
 : pane-return ( pane -- )
-    [
-        pane-input
-        [ commit-history line-text get line-clear ] with-editor
-    ] keep pane-eval ;
+    [ pane-input editor-commit ] keep
+    2dup stream-print pane-eval ;
  
 : pane-actions ( line -- )
     [
index 810a5ad2f1aa72df0cbd18292154895b51ccd5e6..a41c862370f54c1f787239e72ef5dfbe3ae62a13 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: generic hashtables inspector io jedit kernel lists memory
-namespaces parser prettyprint sequences styles vectors words ;
+USING: compiler generic hashtables inference inspector io jedit
+kernel lists memory namespaces parser prettyprint sequences
+styles vectors words ;
 
 SYMBOL: commands
 
@@ -15,8 +16,10 @@ SYMBOL: commands
     commands get [ first call ] subset-with ;
 
 : command-quot ( presented quot -- quot )
-    [ swap literalize , % ] [ ] make
-    [ pane get pane-call drop ] cons ;
+    [
+        [ swap literalize , % ] [ ] make ,
+        [ pane get pane-call ] %
+    ] [ ] make ;
 
 : command-menu ( presented -- menu )
     dup applicable
@@ -24,6 +27,7 @@ SYMBOL: commands
     <menu> ;
 
 : init-commands ( gadget -- )
+    dup roll-button-theme
     dup presented paint-prop dup [
         [
             \ drop ,
@@ -49,10 +53,21 @@ SYMBOL: commands
 
 [ drop t ] "Prettyprint" [ . ] define-command
 [ drop t ] "Inspect" [ inspect ] define-command
-[ drop t ] "References" [ references inspect ] define-command
+[ drop t ] "Inspect variable" [ get inspect ] define-command
+[ drop t ] "Inspect references" [ references inspect ] define-command
+[ drop t ] "Push on data stack" [ ] define-command
 
-[ word? ] "See" [ see ] define-command
-[ word? ] "Usage" [ usage . ] define-command
-[ word? ] "jEdit" [ jedit ] define-command
+[ word? ] "See word" [ see ] define-command
+[ word? ] "Word usage" [ usage . ] define-command
+[ word? ] "Open in jEdit" [ jedit ] define-command
+[ word? ] "Reload original source" [ reload ] define-command
+[ compound? ] "Annotate with watchpoint" [ watch ] define-command
+[ compound? ] "Annotate with breakpoint" [ break ] define-command
+[ compound? ] "Annotate with profiling" [ profile ] define-command
+[ word? ] "Compile" [ recompile ] define-command
+[ word? ] "Decompile" [ decompile ] define-command
+[ word? ] "Show stack effect" [ unit infer . ] define-command
+[ word? ] "Show dataflow IR" [ word-def t dataflow. ] define-command
+[ word? ] "Show linear IR" [ precompile ] define-command
 
-[ [ gadget? ] is? ] "Display" [ gadget. ] define-command
+[ [ gadget? ] is? ] "Display gadget" [ gadget. ] define-command
index fd40ea8fdc2501b43b403a0389c22f34aabda85b..4c1030eb32be395f163aaceda2f80476edf6a068 100644 (file)
@@ -1,24 +1,37 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: help
-DEFER: tutorial
+DEFER: <tutorial-button>
 
 IN: gadgets
 USING: generic help io kernel listener math namespaces
-prettyprint sdl sequences styles threads words ;
+prettyprint sdl sequences styles threads words shells ;
 
 SYMBOL: stack-display
 
 : ui.s ( -- )
     stack-display get dup pane-clear [ .s ] with-stream* ;
 
+: listener-thread
+    pane get [
+        [ ui.s ] listener-hook set <tutorial-button> gadget. tty
+    ] with-stream* ;
+
+: listener-application
+    <pane> dup pane set <scroller>
+    <pane> dup stack-display set <scroller>
+    5/6 <x-splitter> add-layer
+    [ clear listener-thread ] in-thread
+    pane get request-focus ;
+
 : init-world
     global [
         <world> world set
+        { 700 800 0 } world get set-gadget-dim
         
         {{
             [[ background { 255 255 255 } ]]
-            [[ rollover-bg { 216 216 255 } ]]
+            [[ rollover-bg { 236 230 232 } ]]
             [[ bevel-1 { 160 160 160 } ]]
             [[ bevel-2 { 216 216 216 } ]]
             [[ foreground { 0 0 0 } ]]
@@ -27,26 +40,11 @@ SYMBOL: stack-display
             [[ font-size 12 ]]
             [[ font-style plain ]]
         }} world get set-gadget-paint
-        
-        { 700 800 0 } world get set-gadget-dim
-        
+
         <plain-gadget> add-layer
-    
-        <pane> dup pane set <scroller>
-        <pane> dup stack-display set <scroller>
-        5/6 <x-splitter> add-layer
-        
-        [
-            pane get [
-                [ ui.s ] listener-hook set
-                clear print-banner
-                "Tutorial" [ drop [ tutorial ] pane get pane-call ] <button> gadget.
-                listener
-            ] with-stream
-        ] in-thread
-    ] bind
-        
-        pane get request-focus ;
+
+        listener-application
+    ] bind ;
 
 SYMBOL: first-time
 
@@ -54,8 +52,12 @@ global [ first-time on ] bind
 
 : ?init-world
     first-time get [ init-world first-time off ] when ;
+
 IN: shells
 
+: ui-title
+    [ "Factor " % version % " - " % "image" get % ] "" make ;
+
 : ui ( -- )
     #! Start the Factor graphics subsystem with the given screen
     #! dimensions.
@@ -63,7 +65,7 @@ IN: shells
     ?init-world
     world get rect-dim 2unseq 0 SDL_RESIZABLE [
         [
-            "Factor " version append dup SDL_WM_SetCaption
+            ui-title dup SDL_WM_SetCaption
             start-world
             run-world
         ] with-screen
index d303b728502de8b840ea8519d68e519f3ad910ce..153c2f58d1d7dc7353359f74f69b16ffcf9432ab 100644 (file)
@@ -13,7 +13,9 @@ TUPLE: world running? hand glass invalid ;
 
 DEFER: <hand>
 DEFER: update-hand
-DEFER: do-timers
+
+: add-layer ( gadget -- )
+    world get add-gadget ;
 
 C: world ( -- world )
     <stack> over set-delegate
@@ -30,9 +32,6 @@ C: world ( -- world )
     world get world-invalid
     [ pop-invalid [ layout ] each layout-world ] when ;
 
-: add-layer ( gadget -- )
-    world get add-gadget ;
-
 : hide-glass ( -- )
     world get world-glass unparent f
     world get set-world-glass ;