Author: wmb Date: Tue Mar 27 02:30:05 2012 New Revision: 2920 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2920
Log: Graphical menu - rearranged the mouse and touchscreen handling code so the multiplexing is done in one place, using the name "pointer" to mean the collection of positional input devices. That should make it easier to support additional devices. Ideally, there would be a multiplexor node to which devices could be attached, akin to the input and output mux nodes, but that improvement is left to a later date.
Modified: cpu/x86/pc/olpc/via/mfgtest.fth ofw/gui/button.fth ofw/gui/dialog.fth ofw/gui/iconmenu.fth ofw/gui/mouse.fth ofw/gui/textfld.fth
Modified: cpu/x86/pc/olpc/via/mfgtest.fth ============================================================================== --- cpu/x86/pc/olpc/via/mfgtest.fth Tue Mar 27 02:22:52 2012 (r2919) +++ cpu/x86/pc/olpc/via/mfgtest.fth Tue Mar 27 02:30:05 2012 (r2920) @@ -155,7 +155,7 @@ : quit-item ( -- ) menu-done ;
: init-menu ( -- ) - ?open-screen ?open-mouse ?open-touchscreen + ?open-screen ?open-pointer #mfgrows to rows #mfgcols to cols d# 180 to sq-size
Modified: ofw/gui/button.fth ============================================================================== --- ofw/gui/button.fth Tue Mar 27 02:22:52 2012 (r2919) +++ ofw/gui/button.fth Tue Mar 27 02:30:05 2012 (r2920) @@ -218,7 +218,7 @@ def-alert-col-row alert-text-box center-text key drop restore-rectangle ; : setup ( -- ) - ?open-screen set-menu-colors ?open-mouse + ?open-screen set-menu-colors ?open-pointer clear-menu install-menu cursor-off refresh ; [then]
Modified: ofw/gui/dialog.fth ============================================================================== --- ofw/gui/dialog.fth Tue Mar 27 02:22:52 2012 (r2919) +++ ofw/gui/dialog.fth Tue Mar 27 02:30:05 2012 (r2920) @@ -299,12 +299,12 @@ ;
: controls-mouse ( list -- ?? flag ) - mouse-ih 0= if drop false exit then + pointer? 0= if drop false exit then >r false to dialog-ready? - begin mouse-event? while ( x y buttons ) - remove-mouse-cursor ( x y buttons ) - -rot update-position ( buttons ) + begin pointer-event? while ( x y absolute? buttons ) + remove-mouse-cursor ( x y absolute? buttons ) + >r update-position r> ( buttons ) r@ mouse-buttons ( ?? ) draw-mouse-cursor ( ?? ) repeat ( ?? )
Modified: ofw/gui/iconmenu.fth ============================================================================== --- ofw/gui/iconmenu.fth Tue Mar 27 02:22:52 2012 (r2919) +++ ofw/gui/iconmenu.fth Tue Mar 27 02:30:05 2012 (r2920) @@ -412,20 +412,11 @@ then ( ) ;
-: do-mouse ( -- ) - mouse-ih 0= if exit then - begin mouse-event? while ( x y buttons ) - remove-mouse-cursor ( x y buttons ) - -rot update-position ( buttons ) - new-sq? - draw-mouse-cursor - repeat -; -: do-touchscreen ( -- ) - touchscreen-ih 0= if exit then - begin touchscreen-event? while ( x y buttons ) - remove-mouse-cursor ( x y buttons ) - -rot set-xy ( buttons ) +: do-pointer ( -- ) + pointer? 0= if exit then + begin pointer-event? while ( x y absolute? buttons ) + remove-mouse-cursor ( x y absolute? buttons ) + >r update-position r> ( buttons ) new-sq? draw-mouse-cursor repeat @@ -464,8 +455,8 @@
: wait-buttons-up ( -- ) begin - mouse-event? if ( x y buttons ) - nip nip 0= if exit then + pointer-event? if ( x y buttons ) + nip nip nip 0= if exit then then again ; @@ -476,10 +467,10 @@ gui-alerts begin key? if key drop refresh exit then - mouse-ih if - mouse-event? if + pointer? if + pointer-event? if ( x y absolute? buttons ) \ Ignore movement, act only on a button down event - nip nip if wait-buttons-up refresh exit then + nip nip nip if wait-buttons-up refresh exit then then then again @@ -493,7 +484,7 @@ draw-mouse-cursor
false to done? - begin do-touchscreen do-mouse do-key done? until + begin do-pointer do-key done? until false to done?
remove-mouse-cursor @@ -506,11 +497,11 @@ : setup-menu ( -- ) save-scroller setup-graphics -\ ?open-mouse +\ ?open-pointer cursor-off gui-alerts ; -: unsetup-menu ( -- ) ?close-mouse restore-scroller ; +: unsetup-menu ( -- ) ?close-pointer restore-scroller ;
defer current-menu ' clear to current-menu : set-menu ( xt -- ) to current-menu current-menu ;
Modified: ofw/gui/mouse.fth ============================================================================== --- ofw/gui/mouse.fth Tue Mar 27 02:22:52 2012 (r2919) +++ ofw/gui/mouse.fth Tue Mar 27 02:30:05 2012 (r2920) @@ -3,9 +3,7 @@
headerless
-0 value mouse-ih - -false value mouse-absolute? \ True if coordinates are absolute +defer pointer-cursor? ' false to pointer-cursor?
\ Current mouse cursor position
@@ -136,14 +134,12 @@ ;
: remove-mouse-cursor ( -- ) + pointer-cursor? 0= if exit then hardware-cursor? if " cursor-off" $call-screen exit then - mouse-ih 0= if exit then - mouse-absolute? if exit then xpos ypos old-rect put-cursor ; : draw-mouse-cursor ( -- ) - mouse-ih 0= if exit then - mouse-absolute? if exit then + pointer-cursor? 0= if exit then hardware-cursor? if xpos ypos " cursor-xy!" $call-screen exit @@ -158,8 +154,8 @@ : clamp ( n min max - m ) rot min max ;
: set-xy ( x y -- ) to ypos to xpos ; -: update-position ( x y -- ) - mouse-absolute? if set-xy exit then +: update-position ( x y absolute? -- ) + if set-xy exit then 2dup or 0= if 2drop exit then \ Avoid flicker if there is no movement
\ Minimize the time the cursor is down by doing computation in advance @@ -172,6 +168,13 @@
headers
+\ XXX this should be structured as a multiplexor node instead of +\ having explicit mouse and touchscreen cases. + +0 value mouse-ih + +false value mouse-absolute? \ True if coordinates are absolute + 0 value close-mouse? : ?close-mouse ( -- ) close-mouse? if @@ -229,6 +232,25 @@ " stream-poll?" touchscreen-ih $call-method ;
+: (pointer-cursor?) ( -- flag ) + mouse-ih if mouse-absolute? 0= else false then +; +' (pointer-cursor?) to pointer-cursor? + +: ?open-pointer ( -- ) ?open-mouse ?open-touchscreen ; +: ?close-pointer ( -- ) ?close-touchscreen ?close-mouse ; + +: pointer? ( -- flag ) mouse-ih 0<> touchscreen-ih 0<> or ; +: pointer-event? ( -- false | x y absolute? buttons true ) + mouse-event? if ( x y buttons ) + mouse-absolute? swap true exit + then + touchscreen-event? if + true swap true exit + then + false +; + \ LICENSE_BEGIN \ Copyright (c) 2006 FirmWorks \
Modified: ofw/gui/textfld.fth ============================================================================== --- ofw/gui/textfld.fth Tue Mar 27 02:22:52 2012 (r2919) +++ ofw/gui/textfld.fth Tue Mar 27 02:30:05 2012 (r2920) @@ -114,11 +114,11 @@ redraw-mouse-cursor? on (key remove-mouse-cursor exit then - mouse-ih if - begin mouse-event? while - remove-mouse-cursor - -rot update-position - draw-mouse-cursor + pointer? if + begin pointer-event? while ( x y absolute? buttons ) + remove-mouse-cursor ( x y absolute? buttons ) + >r update-position r> ( buttons ) + draw-mouse-cursor ( buttons ) interact-list edit-mouse-buttons if exit then repeat then