Commits

Paweł Wieczorek committed a2da190 Draft

added mouse motion event

  • Participants
  • Parent commits fb6ebe6
  • Branches better_ui

Comments (0)

Files changed (5)

File src/Screen.ml

   | Continue
   | ChangeScreen of screen_handle
 and screen_handle =
-    { screen_draw      : Video.image -> screen_action
-    ; screen_keydown   : Input.key -> screen_action
-    ; screen_mouseup   : int -> int -> screen_action
-    ; screen_mousedown : int -> int -> screen_action
-
+    { screen_draw        : Video.image -> screen_action
+    ; screen_keydown     : Input.key -> screen_action
+    ; screen_mouseup     : int -> int -> screen_action
+    ; screen_mousedown   : int -> int -> screen_action
+    ; screen_mousemotion : int -> int -> screen_action
     }
 
 (**************************************************************************
  *)
 
 let dummy_screen =
-    { screen_draw      = (fun _ -> Continue)
-    ; screen_keydown   = (fun _ -> Continue)
-    ; screen_mouseup   = (fun _ _ -> Continue)
-    ; screen_mousedown = (fun _ _ -> Continue)
+    { screen_draw        = (fun _ -> Continue)
+    ; screen_keydown     = (fun _ -> Continue)
+    ; screen_mouseup     = (fun _ _ -> Continue)
+    ; screen_mousedown   = (fun _ _ -> Continue)
+    ; screen_mousemotion = (fun _ _ -> Continue)
     }

File src/Screen.mli

 
 type screen_action = ShutdownEngine | Continue | ChangeScreen of screen_handle
 and screen_handle = 
-    { screen_draw : Video.image -> screen_action
-    ; screen_keydown : Input.key -> screen_action
-    ; screen_mouseup : int -> int -> screen_action
-    ; screen_mousedown : int -> int -> screen_action
+    { screen_draw        : Video.image -> screen_action
+    ; screen_keydown     : Input.key -> screen_action
+    ; screen_mouseup     : int -> int -> screen_action
+    ; screen_mousedown   : int -> int -> screen_action
+    ; screen_mousemotion : int -> int -> screen_action
     }
 
 (**************************************************************************

File src/Screens/MainScreen.ml

   Printf.printf "Mouse down at (%u, %u)\n%!" mx my;
   Continue
 
+let _screen_mousemotion state mx my =
+  Printf.printf "Mouse down at (%u, %u)\n%!" mx my;
+  Continue
+
 (**************************************************************************
  * Creator
  *)
     } in
   let mainScreen =
     { dummy_screen with
-      screen_draw      = _screen_draw img fresh_state
-    ; screen_keydown   = _screen_keydown fresh_state 
-    ; screen_mouseup   = _screen_mouseup fresh_state
-    ; screen_mousedown = _screen_mousedown fresh_state
+      screen_draw        = _screen_draw img fresh_state
+    ; screen_keydown     = _screen_keydown fresh_state 
+    ; screen_mouseup     = _screen_mouseup fresh_state
+    ; screen_mousedown   = _screen_mousedown fresh_state
+    ; screen_mousemotion = _screen_mousemotion fresh_state
     } in
   fresh_state.subscreens.play_screen    <- mainScreen;
   fresh_state.subscreens.options_screen <- mainScreen;

File src/System.ml

               let res = state.current_screen.screen_mousedown e.mbe_x e.mbe_y in
               handle_screen_action state res
 
+          | MOUSEMOTION e ->
+              let res = state.current_screen.screen_mousemotion e.mme_x e.mme_y in
+              handle_screen_action state res
+
           | _ ->
               ()
         end;

File src/Util/ClickMap.ml

     | [] -> None
     | (_,x)::xs -> Some x
 
-