diff options
author | Leo Prikler <leo.prikler@student.tugraz.at> | 2020-12-01 16:46:47 +0100 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2020-12-02 10:04:58 -0500 |
commit | 6c28e028509722c27078966a2c94ddb9d0090ca7 (patch) | |
tree | 9356ce73145075a816ea3c5d2515c38287e140b3 | |
parent | 0e627ad72df828882664b87293f9fec3602c5ceb (diff) |
video: Add more bindings.
* sdl2/bindings.scm (sdl-window-get-minimum-size)
(sdl-window-get-maximum-size, sdl-window-set-minimum-size)
(sdl-window-set-maximum-size, sdl-window-set-resizable):
New procedures.
* sdl2/video.scm (window-minimum-size, window-maximum-size)
(set-window-minimum-size!, set-window-maximum-size!)
(set-window-resizable!): New procedures.
* doc/api.texi: Document new (sdl2 video) bindings.
-rw-r--r-- | doc/api.texi | 29 | ||||
-rw-r--r-- | sdl2/bindings.scm | 15 | ||||
-rw-r--r-- | sdl2/video.scm | 21 |
3 files changed, 65 insertions, 0 deletions
diff --git a/doc/api.texi b/doc/api.texi index a158795..ef7d702 100644 --- a/doc/api.texi +++ b/doc/api.texi @@ -96,6 +96,20 @@ Return the title for @var{window}. Return the dimensions of @var{window}. @end deffn +@deffn {Procedure} window-minimum-size window +Return the minimal dimensions, that @var{window} should take. +Note, that SDL does not always enforce this restriction, so you might end up +with a window-size, that is actually smaller than the value returned by this +function. +@end deffn + +@deffn {Procedure} window-maximum-size window +Return the maximal dimensions, that @var{window} should take. +Note, that SDL does not always enforce this restriction, so you might end up +with a window-size, that is actually larger than the value returned by this +function. +@end deffn + @deffn {Procedure} window-position window Return the position of @var{window} on the display. @end deffn @@ -152,6 +166,21 @@ Set the dimensions of @var{window} to @var{size}, a two-element list of (width,height) coordinates measured in pixels. @end deffn +@deffn {Procedure} set-window-minimum-size! window width height +Set the minimum dimensions of @var{window} to @var{width} x +@var{height} pixels. +@end deffn + +@deffn {Procedure} set-window-maximum-size! window width height +Set the maximum dimensions of @var{window} to @var{width} x +@var{height} pixels. +@end deffn + +@deffn {Procedure} set-window-resizable! window resizable? +If @var{resizable} is @code{#t}, allow @var{window} to be resized, +otherwise disable resizing. +@end deffn + @deffn {Procedure} set-window-fullscreen! window fullscreen? [#:desktop?] Toggle fullscreen mode on/off for @var{window}. If @var{fullscreen?}, fullscreen mode is activated, otherwise it is deactivated. If diff --git a/sdl2/bindings.scm b/sdl2/bindings.scm index 586011e..aea12c9 100644 --- a/sdl2/bindings.scm +++ b/sdl2/bindings.scm @@ -167,6 +167,12 @@ RETURN-TYPE and accept arguments of ARG-TYPES." (define-foreign sdl-get-window-size void "SDL_GetWindowSize" '(* * *)) +(define-foreign sdl-get-window-minimum-size + void "SDL_GetWindowMinimumSize" '(* * *)) + +(define-foreign sdl-get-window-maximum-size + void "SDL_GetWindowMaximumSize" '(* * *)) + (define-foreign sdl-get-window-position void "SDL_GetWindowPosition" '(* * *)) @@ -206,6 +212,15 @@ RETURN-TYPE and accept arguments of ARG-TYPES." (define-foreign sdl-set-window-size void "SDL_SetWindowSize" (list '* int int)) +(define-foreign sdl-set-window-minimum-size + void "SDL_SetWindowMinimumSize" (list '* int int)) + +(define-foreign sdl-set-window-maximum-size + void "SDL_SetWindowMaximumSize" (list '* int int)) + +(define-foreign sdl-set-window-resizable + void "SDL_SetWindowResizable" (list '* sdl-bool)) + (define-foreign sdl-set-window-fullscreen int "SDL_SetWindowFullscreen" (list '* uint32)) diff --git a/sdl2/video.scm b/sdl2/video.scm index 187a5bc..d26eb62 100644 --- a/sdl2/video.scm +++ b/sdl2/video.scm @@ -166,6 +166,14 @@ returns or otherwise exits." "Return the dimensions of WINDOW." (%get-coords window ffi:sdl-get-window-size)) +(define (window-minimum-size window) + "Return the minimal dimensions, that WINDOW can take." + (%get-coords window ffi:sdl-get-window-minimum-size)) + +(define (window-maximum-size window) + "Return the maximal dimensions, that WINDOW can take." + (%get-coords window ffi:sdl-get-window-maximum-size)) + (define (window-position window) "Return the position of WINDOW on the display." (%get-coords window ffi:sdl-get-window-position)) @@ -231,6 +239,19 @@ of (width,height) coordinates measured in pixels." ((width height) (ffi:sdl-set-window-size (unwrap-window window) width height)))) +(define (set-window-minimum-size! window width height) + "Set the minimum dimensions of WINDOW to WIDTH x HEIGHT pixels." + (ffi:sdl-set-window-minimum-size (unwrap-window window) width height)) + +(define (set-window-maximum-size! window width height) + "Set the maximum dimensions of WINDOW to WIDTH x HEIGHT pixels." + (ffi:sdl-set-window-maximum-size (unwrap-window window) width height)) + +(define (set-window-resizable! window resizable?) + "If RESIZABLE?, make WINDOW resizable, otherwise disable resizing for WINDOW." + (ffi:sdl-set-window-resizable (unwrap-window window) + (ffi:boolean->sdl-bool resizable?))) + (define* (set-window-fullscreen! window fullscreen? #:key desktop?) "Toggle fullscreen mode on/off for WINDOW. If FULLSCREEN?, fullscreen mode is activated, otherwise it is deactivated. If |