- fix up the min thumb size hack\r
- scroll bar: more intuitive behavior when clicking inside the elevator\r
- nicer scrollbars with up/down buttons\r
-- clicking outside menu doesn't close\r
- only redraw dirty gadgets\r
- faster mouse tracking\r
-- better menu positioning\r
\r
- off-by-one error in pick-up?\r
- closing ui does not stop timers\r
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.
: 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 -- )
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