diff options
author | Loïc Hoguin <[email protected]> | 2014-04-03 19:50:59 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-04-03 19:50:59 +0200 |
commit | a1afe564f1b5a3e8b91e3f706fbd5d7d66a9978c (patch) | |
tree | 1b1e0e8662ab8fe8b8ad20b2ef456a0f71292483 | |
parent | 89b594e3a86da6cc6d08009bfe0fb26a18ce8365 (diff) | |
download | esdl2-a1afe564f1b5a3e8b91e3f706fbd5d7d66a9978c.tar.gz esdl2-a1afe564f1b5a3e8b91e3f706fbd5d7d66a9978c.tar.bz2 esdl2-a1afe564f1b5a3e8b91e3f706fbd5d7d66a9978c.zip |
Add sdl_window:set_pos/3
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_window.c | 20 | ||||
-rw-r--r-- | src/esdl2.erl | 4 | ||||
-rw-r--r-- | src/sdl_window.erl | 4 |
4 files changed, 29 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 3b69a87..c7817b2 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -183,6 +183,7 @@ F(set_window_icon, 2) \ F(set_window_maximum_size, 3) \ F(set_window_minimum_size, 3) \ + F(set_window_position, 3) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 7fe4198..fea00cc 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -583,3 +583,23 @@ NIF_FUNCTION(set_window_minimum_size) return nif_thread_cast(env, thread_set_window_minimum_size, 3, NIF_RES_GET(Window, window_res), w, h); } + +// set_window_position + +NIF_CAST_HANDLER(thread_set_window_position) +{ + SDL_SetWindowPosition(args[0], (long)args[1], (long)args[2]); +} + +NIF_FUNCTION(set_window_position) +{ + void* window_res; + int x, y; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + BADARG_IF(!enif_get_int(env, argv[1], &x)); + BADARG_IF(!enif_get_int(env, argv[2], &y)); + + return nif_thread_cast(env, thread_set_window_position, 3, + NIF_RES_GET(Window, window_res), x, y); +} diff --git a/src/esdl2.erl b/src/esdl2.erl index 8067c5f..c1e7651 100644 --- a/src/esdl2.erl +++ b/src/esdl2.erl @@ -95,6 +95,7 @@ -export([set_window_icon/2]). -export([set_window_maximum_size/3]). -export([set_window_minimum_size/3]). +-export([set_window_position/3]). %% @todo We probably want to accept an env variable or somthing for the location. -on_load(on_load/0). @@ -309,3 +310,6 @@ set_window_maximum_size(_, _, _) -> set_window_minimum_size(_, _, _) -> erlang:nif_error({not_loaded, ?MODULE}). + +set_window_position(_, _, _) -> + erlang:nif_error({not_loaded, ?MODULE}). diff --git a/src/sdl_window.erl b/src/sdl_window.erl index f3bdcf7..80e5376 100644 --- a/src/sdl_window.erl +++ b/src/sdl_window.erl @@ -38,6 +38,7 @@ -export([set_icon/2]). -export([set_max_size/3]). -export([set_min_size/3]). +-export([set_pos/3]). create(Title, X, Y, W, H, Flags) -> esdl2:create_window(Title, X, Y, W, H, Flags), @@ -128,3 +129,6 @@ set_max_size(Window, W, H) -> set_min_size(Window, W, H) -> esdl2:set_window_minimum_size(Window, W, H). + +set_pos(Window, X, Y) -> + esdl2:set_window_position(Window, X, Y). |