aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-03 13:28:10 +0200
committerLoïc Hoguin <[email protected]>2014-04-03 13:28:10 +0200
commit84b4ea732c0f2a54bbbe664e50e1af314a0bdb38 (patch)
tree79bca9e76ebf8e4e2d1d13aa8b154bbc7f940063
parentbfd03ec67be42977ce9210b1f39b59d6141a2545 (diff)
downloadesdl2-84b4ea732c0f2a54bbbe664e50e1af314a0bdb38.tar.gz
esdl2-84b4ea732c0f2a54bbbe664e50e1af314a0bdb38.tar.bz2
esdl2-84b4ea732c0f2a54bbbe664e50e1af314a0bdb38.zip
Add sdl_window:get_min_size/1
-rw-r--r--c_src/esdl2.h1
-rw-r--r--c_src/sdl_window.c24
-rw-r--r--src/esdl2.erl4
-rw-r--r--src/sdl_window.erl5
4 files changed, 34 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index 6a13a42..cab3a1a 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -167,6 +167,7 @@
F(get_window_grab, 1) \
F(get_window_id, 1) \
F(get_window_maximum_size, 1) \
+ F(get_window_minimum_size, 1) \
// Generated declarations for the NIF.
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index 0983370..242763e 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -254,3 +254,27 @@ NIF_FUNCTION(get_window_maximum_size)
return nif_thread_call(env, thread_get_window_maximum_size, 1,
NIF_RES_GET(Window, window_res));
}
+
+// get_window_minimum_size
+
+NIF_CALL_HANDLER(thread_get_window_minimum_size)
+{
+ int w, h;
+
+ SDL_GetWindowMinimumSize(args[0], &w, &h);
+
+ return enif_make_tuple2(env,
+ enif_make_int(env, w),
+ enif_make_int(env, h)
+ );
+}
+
+NIF_FUNCTION(get_window_minimum_size)
+{
+ void* window_res;
+
+ BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res));
+
+ return nif_thread_call(env, thread_get_window_minimum_size, 1,
+ NIF_RES_GET(Window, window_res));
+}
diff --git a/src/esdl2.erl b/src/esdl2.erl
index 788d5fb..0483779 100644
--- a/src/esdl2.erl
+++ b/src/esdl2.erl
@@ -79,6 +79,7 @@
-export([get_window_grab/1]).
-export([get_window_id/1]).
-export([get_window_maximum_size/1]).
+-export([get_window_minimum_size/1]).
%% @todo We probably want to accept an env variable or somthing for the location.
-on_load(on_load/0).
@@ -245,3 +246,6 @@ get_window_id(_) ->
get_window_maximum_size(_) ->
erlang:nif_error({not_loaded, ?MODULE}).
+
+get_window_minimum_size(_) ->
+ erlang:nif_error({not_loaded, ?MODULE}).
diff --git a/src/sdl_window.erl b/src/sdl_window.erl
index f3376f8..0dc0421 100644
--- a/src/sdl_window.erl
+++ b/src/sdl_window.erl
@@ -22,6 +22,7 @@
-export([is_input_grabbed/1]).
-export([get_id/1]).
-export([get_max_size/1]).
+-export([get_min_size/1]).
create(Title, X, Y, W, H, Flags) ->
esdl2:create_window(Title, X, Y, W, H, Flags),
@@ -57,3 +58,7 @@ get_id(Window) ->
get_max_size(Window) ->
esdl2:get_window_maximum_size(Window),
receive {'_nif_thread_ret_', Ret} -> Ret end.
+
+get_min_size(Window) ->
+ esdl2:get_window_minimum_size(Window),
+ receive {'_nif_thread_ret_', Ret} -> Ret end.