aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-03 19:36:03 +0200
committerLoïc Hoguin <[email protected]>2014-04-03 19:36:03 +0200
commita538eb1deb61edd4c166dcba1dfd3dcc57663fc9 (patch)
tree6244fdfd30e881d399cc747028942f9c4358dc38
parent3026b4860fd3a1436a59bf2d26792fbbf6b60917 (diff)
downloadesdl2-a538eb1deb61edd4c166dcba1dfd3dcc57663fc9.tar.gz
esdl2-a538eb1deb61edd4c166dcba1dfd3dcc57663fc9.tar.bz2
esdl2-a538eb1deb61edd4c166dcba1dfd3dcc57663fc9.zip
Add sdl_window:set_max_size/3
-rw-r--r--c_src/esdl2.h1
-rw-r--r--c_src/sdl_window.c20
-rw-r--r--src/esdl2.erl4
-rw-r--r--src/sdl_window.erl4
4 files changed, 29 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index de6b800..9c41916 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -181,6 +181,7 @@
F(set_window_fullscreen, 2) \
F(set_window_grab, 2) \
F(set_window_icon, 2) \
+ F(set_window_maximum_size, 3) \
// Generated declarations for the NIF.
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index b79cd4f..8507234 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -543,3 +543,23 @@ NIF_FUNCTION(set_window_icon)
return nif_thread_call(env, thread_set_window_icon, 2,
NIF_RES_GET(Window, window_res), NIF_RES_GET(Surface, surface_res));
}
+
+// set_window_maximum_size
+
+NIF_CAST_HANDLER(thread_set_window_maximum_size)
+{
+ SDL_SetWindowMaximumSize(args[0], (long)args[1], (long)args[2]);
+}
+
+NIF_FUNCTION(set_window_maximum_size)
+{
+ void* window_res;
+ int w, h;
+
+ BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res));
+ BADARG_IF(!enif_get_int(env, argv[1], &w));
+ BADARG_IF(!enif_get_int(env, argv[2], &h));
+
+ return nif_thread_cast(env, thread_set_window_maximum_size, 3,
+ NIF_RES_GET(Window, window_res), w, h);
+}
diff --git a/src/esdl2.erl b/src/esdl2.erl
index e383e58..6dcd62d 100644
--- a/src/esdl2.erl
+++ b/src/esdl2.erl
@@ -93,6 +93,7 @@
-export([set_window_fullscreen/2]).
-export([set_window_grab/2]).
-export([set_window_icon/2]).
+-export([set_window_maximum_size/3]).
%% @todo We probably want to accept an env variable or somthing for the location.
-on_load(on_load/0).
@@ -301,3 +302,6 @@ set_window_grab(_, _) ->
set_window_icon(_, _) ->
erlang:nif_error({not_loaded, ?MODULE}).
+
+set_window_maximum_size(_, _, _) ->
+ erlang:nif_error({not_loaded, ?MODULE}).
diff --git a/src/sdl_window.erl b/src/sdl_window.erl
index 0232fc0..13757b1 100644
--- a/src/sdl_window.erl
+++ b/src/sdl_window.erl
@@ -36,6 +36,7 @@
-export([set_fullscreen/2]).
-export([grab_input/2]).
-export([set_icon/2]).
+-export([set_max_size/3]).
create(Title, X, Y, W, H, Flags) ->
esdl2:create_window(Title, X, Y, W, H, Flags),
@@ -120,3 +121,6 @@ grab_input(Window, Grab) ->
set_icon(Window, Surface) ->
esdl2:set_window_icon(Window, Surface),
receive {'_nif_thread_ret_', Ret} -> Ret end.
+
+set_max_size(Window, W, H) ->
+ esdl2:set_window_maximum_size(Window, W, H).