From 9a1f823bcae2852b8797cfdcb86bbc74fa8e390d Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 18 Oct 2014 12:50:39 -0400 Subject: [PATCH] 2.0.4 GUI backend additions --- src/SDL2.cs | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index ed5c14a..8c833bb 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1003,7 +1003,26 @@ namespace SDL2 SDL_WINDOW_FULLSCREEN_DESKTOP = (SDL_WINDOW_FULLSCREEN | 0x00001000), SDL_WINDOW_FOREIGN = 0x00000800, - SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /* Only available in 2.0.1 */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /* Only available in 2.0.1 */ + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /* Only available in 2.0.4 */ + } + + /// + /// Possible return values from the SDL_HitTest callback. + /// This is only available in 2.0.4. + /// + public enum SDL_HitTestResult + { + SDL_HITTEST_NORMAL, /* Region is normal. No special properties. */ + SDL_HITTEST_DRAGGABLE, /* Region can drag entire window. */ + SDL_HITTEST_RESIZE_TOPLEFT, + SDL_HITTEST_RESIZE_TOP, + SDL_HITTEST_RESIZE_TOPRIGHT, + SDL_HITTEST_RESIZE_RIGHT, + SDL_HITTEST_RESIZE_BOTTOMRIGHT, + SDL_HITTEST_RESIZE_BOTTOM, + SDL_HITTEST_RESIZE_BOTTOMLEFT, + SDL_HITTEST_RESIZE_LEFT } public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; @@ -1044,6 +1063,10 @@ namespace SDL2 public IntPtr driverdata; // void* } + /* win refers to an SDL_Window*, area to a cosnt SDL_Point*, data to a void* */ + /* Only available in 2.0.4 */ + public delegate SDL_HitTestResult SDL_HitTest(IntPtr win, IntPtr area, IntPtr data); + /// /// Use this function to create a window with the specified position, dimensions, and flags. /// @@ -1620,6 +1643,15 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_VideoQuit(); + /* window refers to an SDL_Window*, callback_data to a void* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowHitTest( + IntPtr window, + SDL_HitTest callback, + IntPtr callback_data + ); + #endregion #region SDL_render.h @@ -2651,6 +2683,10 @@ namespace SDL2 public int h; } + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_PointInRect(ref SDL_Point p, ref SDL_Rect r); + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern SDL_bool SDL_EnclosePoints( [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)] @@ -4394,20 +4430,24 @@ namespace SDL2 public static extern UInt32 SDL_GetMouseState(IntPtr x, IntPtr y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(out int x, out int y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ /* This overload allows for passing NULL to x */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, out int y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ /* This overload allows for passing NULL to y */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(out int x, IntPtr y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ /* This overload allows for passing NULL to both x and y */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, IntPtr y); @@ -4422,6 +4462,7 @@ namespace SDL2 public static extern void SDL_WarpMouseInWindow(IntPtr window, int x, int y); /* Set the mouse cursor's position in global screen space */ + /* Only available in 2.0.4 */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_WarpMouseGlobal(int x, int y); @@ -4429,6 +4470,11 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_SetRelativeMouseMode(SDL_bool enabled); + /* Capture the mouse, to track input outside an SDL window */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_CaptureMouse(SDL_bool enabled); + /* Query if the relative mouse mode is enabled */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern SDL_bool SDL_GetRelativeMouseMode();