Changeset 2920


Ignore:
Timestamp:
Mar 27, 2012, 12:30:05 AM (3 years ago)
Author:
wmb
Message:

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.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpu/x86/pc/olpc/via/mfgtest.fth

    r2893 r2920  
    156156
    157157: init-menu  ( -- )
    158    ?open-screen  ?open-mouse  ?open-touchscreen
     158   ?open-screen  ?open-pointer
    159159   #mfgrows to rows
    160160   #mfgcols to cols
  • ofw/gui/button.fth

    r1329 r2920  
    219219;
    220220: setup  ( -- )
    221    ?open-screen  set-menu-colors  ?open-mouse
     221   ?open-screen  set-menu-colors  ?open-pointer
    222222   clear-menu install-menu cursor-off  refresh
    223223;
  • ofw/gui/dialog.fth

    r2893 r2920  
    300300
    301301: controls-mouse  ( list -- ?? flag )
    302    mouse-ih 0=  if  drop false exit  then
     302   pointer? 0=  if  drop false exit  then
    303303   >r
    304304   false to dialog-ready?
    305    begin  mouse-event?  while         ( x y buttons )
    306       remove-mouse-cursor             ( x y buttons )
    307       -rot  update-position           ( buttons )
     305   begin  pointer-event?  while       ( x y absolute? buttons )
     306      remove-mouse-cursor             ( x y absolute? buttons )
     307      >r  update-position  r>         ( buttons )
    308308      r@ mouse-buttons                ( ?? )
    309309      draw-mouse-cursor               ( ?? )
  • ofw/gui/iconmenu.fth

    r2893 r2920  
    413413;
    414414
    415 : do-mouse  ( -- )
    416    mouse-ih 0=  if  exit  then
    417    begin  mouse-event?  while         ( x y buttons )
    418       remove-mouse-cursor             ( x y buttons )
    419       -rot  update-position           ( buttons )
    420       new-sq?
    421       draw-mouse-cursor
    422    repeat
    423 ;
    424 : do-touchscreen  ( -- )
    425    touchscreen-ih 0=  if  exit  then
    426    begin  touchscreen-event?  while   ( x y buttons )
    427       remove-mouse-cursor             ( x y buttons )
    428       -rot  set-xy                    ( buttons )
     415: do-pointer  ( -- )
     416   pointer? 0=  if  exit  then
     417   begin  pointer-event?  while       ( x y absolute? buttons )
     418      remove-mouse-cursor             ( x y absolute? buttons )
     419      >r  update-position  r>         ( buttons )
    429420      new-sq?
    430421      draw-mouse-cursor
     
    465456: wait-buttons-up  ( -- )
    466457   begin
    467       mouse-event?  if   ( x y buttons )
    468          nip nip 0=  if  exit  then
     458      pointer-event?  if   ( x y buttons )
     459         nip nip nip 0=  if  exit  then
    469460      then
    470461   again
     
    477468   begin
    478469      key?  if  key drop  refresh exit  then
    479       mouse-ih  if
    480          mouse-event?  if
     470      pointer?  if
     471         pointer-event?  if   ( x y absolute? buttons )
    481472            \ Ignore movement, act only on a button down event
    482             nip nip if  wait-buttons-up  refresh exit  then
     473            nip nip nip if  wait-buttons-up  refresh exit  then
    483474         then
    484475      then
     
    494485 
    495486   false to done?
    496    begin   do-touchscreen  do-mouse  do-key   done? until
     487   begin   do-pointer  do-key   done? until
    497488   false to done?
    498489 
     
    507498   save-scroller
    508499   setup-graphics
    509 \  ?open-mouse
     500\  ?open-pointer
    510501   cursor-off
    511502   gui-alerts
    512503;
    513 : unsetup-menu  ( -- )  ?close-mouse  restore-scroller  ;
     504: unsetup-menu  ( -- )  ?close-pointer  restore-scroller  ;
    514505
    515506defer current-menu  ' clear to current-menu
  • ofw/gui/mouse.fth

    r2893 r2920  
    44headerless
    55
    6 0 value mouse-ih
    7 
    8 false value mouse-absolute?  \ True if coordinates are absolute
     6defer pointer-cursor?  ' false to pointer-cursor?
    97
    108\ Current mouse cursor position
     
    137135
    138136: remove-mouse-cursor  ( -- )
     137   pointer-cursor? 0=  if  exit  then
    139138   hardware-cursor?  if  " cursor-off" $call-screen  exit  then
    140    mouse-ih 0=  if  exit  then
    141    mouse-absolute?  if  exit  then
    142139   xpos ypos  old-rect  put-cursor
    143140;
    144141: draw-mouse-cursor  ( -- )
    145    mouse-ih 0=  if  exit  then
    146    mouse-absolute?  if  exit  then
     142   pointer-cursor? 0=  if  exit  then
    147143   hardware-cursor?  if
    148144      xpos ypos " cursor-xy!" $call-screen
     
    159155
    160156: set-xy  ( x y -- )  to ypos  to xpos  ;
    161 : update-position  ( x y -- )
    162    mouse-absolute?  if  set-xy  exit  then
     157: update-position  ( x y absolute? -- )
     158   if  set-xy  exit  then
    163159   2dup or 0=  if  2drop exit  then  \ Avoid flicker if there is no movement
    164160
     
    172168
    173169headers
     170
     171\ XXX this should be structured as a multiplexor node instead of
     172\ having explicit mouse and touchscreen cases.
     173
     1740 value mouse-ih
     175
     176false value mouse-absolute?  \ True if coordinates are absolute
    174177
    1751780 value close-mouse?
     
    228231: touchscreen-event?  ( -- false | x y buttons true )
    229232   " stream-poll?" touchscreen-ih $call-method
     233;
     234
     235: (pointer-cursor?)  ( -- flag )
     236   mouse-ih  if  mouse-absolute? 0=  else  false  then
     237;
     238' (pointer-cursor?)  to pointer-cursor?
     239
     240: ?open-pointer  ( -- )  ?open-mouse ?open-touchscreen  ;
     241: ?close-pointer  ( -- )  ?close-touchscreen ?close-mouse  ;
     242
     243: pointer?  ( -- flag )  mouse-ih 0<>  touchscreen-ih 0<>  or  ;
     244: pointer-event?  ( -- false | x y absolute? buttons true )
     245   mouse-event?  if   ( x y buttons )
     246      mouse-absolute? swap  true  exit
     247   then
     248   touchscreen-event?   if
     249      true swap  true exit
     250   then
     251   false
    230252;
    231253
  • ofw/gui/textfld.fth

    r2893 r2920  
    115115         (key remove-mouse-cursor exit
    116116      then
    117       mouse-ih  if
    118          begin  mouse-event?  while
    119             remove-mouse-cursor
    120             -rot update-position
    121             draw-mouse-cursor
     117      pointer?  if
     118         begin  pointer-event?  while  ( x y absolute? buttons )
     119            remove-mouse-cursor        ( x y absolute? buttons )
     120            >r  update-position  r>    ( buttons )
     121            draw-mouse-cursor          ( buttons )
    122122            interact-list edit-mouse-buttons  if  exit  then
    123123         repeat
Note: See TracChangeset for help on using the changeset viewer.