lib/sdl: intro `grab_input`, `ignore_mouse_motion_events` and fix `show_cursor=`
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 2 Dec 2014 01:19:14 +0000 (20:19 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 14 Jan 2015 13:47:15 +0000 (08:47 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/sdl.nit

index 5225f9f..26ae459 100644 (file)
@@ -160,7 +160,26 @@ extern class SDLDisplay `{SDL_Surface *`}
        fun warp_mouse(x,y: Int) `{ SDL_WarpMouse(x, y); `}
 
        # Show or hide the cursor
-       fun show_cursor(show: Bool) `{ SDL_ShowCursor(show); `}
+       fun show_cursor=(val: Bool) `{ SDL_ShowCursor(val? SDL_ENABLE: SDL_DISABLE); `}
+
+       # Is the cursor visible?
+       fun show_cursor: Bool `{ SDL_ShowCursor(SDL_QUERY); `}
+
+       # Grab or release the input
+       fun grab_input=(val: Bool) `{ SDL_WM_GrabInput(val? SDL_GRAB_ON: SDL_GRAB_OFF); `}
+
+       # Is the input grabbed?
+       fun grab_input: Bool `{ SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON; `}
+
+       # Are instances of `SDLMouseMotionEvent` ignored?
+       fun ignore_mouse_motion_events: Bool `{
+               return SDL_EventState(SDL_MOUSEMOTION, SDL_QUERY);
+       `}
+
+       # Do not raise instances of `SDLMouseMotionEvent` if `val`
+       fun ignore_mouse_motion_events=(val: Bool) `{
+               SDL_EventState(SDL_MOUSEMOTION, val? SDL_IGNORE: SDL_ENABLE);
+       `}
 end
 
 # Basic Drawing figures