menu positioning fix

cvs
Slava Pestov 2005-08-27 02:22:00 +00:00
parent 9b361d749b
commit 2636a247c9
3 changed files with 15 additions and 7 deletions

View File

@ -8,10 +8,8 @@
- fix up the min thumb size hack
- scroll bar: more intuitive behavior when clicking inside the elevator
- nicer scrollbars with up/down buttons
- clicking outside menu doesn't close
- only redraw dirty gadgets
- faster mouse tracking
- better menu positioning
- off-by-one error in pick-up?
- closing ui does not stop timers

View File

@ -3,8 +3,20 @@
IN: gadgets
USING: generic kernel lists math namespaces sequences ;
: menu-actions ( glass -- )
[ drop hide-glass ] [ button-down 1 ] set-action ;
: fit-bounds ( loc dim max -- loc )
#! Adjust loc to fit inside max.
swap v- { 0 0 0 } vmax vmin ;
: menu-loc ( menu -- loc )
hand rect-loc swap rect-dim world get rect-dim fit-bounds ;
: show-menu ( menu -- )
hand screen-loc over set-rect-loc show-glass ;
dup show-glass
dup menu-loc swap set-rect-loc
world get world-glass menu-actions ;
: menu-items ( assoc -- pile )
#! Given an association list mapping labels to quotations.

View File

@ -38,8 +38,7 @@ C: world ( -- world )
: show-glass ( gadget -- )
hide-glass
<gadget> dup
world get 2dup add-gadget set-world-glass
<gadget> dup add-layer dup world get set-world-glass
dupd add-gadget prefer ;
: draw-world ( world -- )
@ -54,8 +53,7 @@ DEFER: handle-event
world get dup world-invalid >r layout-world r>
[ dup world-hand update-hand draw-world ] [ drop ] ifte ;
: next-event ( -- event ? )
<event> dup SDL_PollEvent ;
: next-event ( -- event ? ) <event> dup SDL_PollEvent ;
: run-world ( -- )
#! Keep polling for events until there are no more events in