bubble_manager_test.anubis 1.66 KB

   
   A simple test for the bubble manager. 
   
   
   
read widget.anubis
read host_window.anubis
read bubble_manager.anubis   
read ticket_keeper.anubis
read mouse_tracker.anubis
read space.anubis   
read tools/basis.anubis
read background.anubis
read text.anubis   

   
   The next monitor is attached (see  below) to the variable 'mouse_position'. Hence it is
   called each time the position of the mouse changes. 
   
define One -> One
   monitor
     (
       Var((Word32,Word32))    mouse_position,
       Var(BMCommand)        command_v,
       Widget                the_bubble
     ) =
   (One _) |-> 
     if *mouse_position is (mx,my) then 
     command_v <- show(abs_area([rect(mx,my,mx+1,my+1)]),the_bubble). 
   
   
   
global define One
   bubble_manager_test
     (
       List(String) args
     ) =
   if load_system_font("helvetica_medium_r_10") is 
     {
       failure then print("Cannot load system font.\n"), 
       success(font) then 
   
   with     mouse_pos = var(((Word32,Word32))(0,0)),
            command_v = var((BMCommand)clear), 
            the_bubble = background(4,rgb(200,255,200),
                                    text("The bubble",font,rgb(0,0,0),0)), 
               ticket = register_monitor(mouse_pos,
                                         monitor(mouse_pos,command_v,the_bubble)), 
                 root = ticket_keeper((One _) |-> forget(ticket), 
                          mouse_tracker(mouse_pos, 
                                        bubble_manager(command_v,
                                                       space(500,400,rgb(255,255,255))))), 
   forget(open_host_window(root,"Bubble Manager Test"))
   
     }.