From 125da5cf0747b32a52226c6ac90fc4281c46c22f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 1 Dec 2014 20:19:14 -0500 Subject: [PATCH] lib/sdl: intro `grab_input`, `ignore_mouse_motion_events` and fix `show_cursor=` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/sdl.nit | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/sdl.nit b/lib/sdl.nit index 5225f9f..26ae459 100644 --- a/lib/sdl.nit +++ b/lib/sdl.nit @@ -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 -- 1.7.9.5