diff options
author | Loïc Hoguin <[email protected]> | 2014-04-03 13:57:22 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-04-03 14:37:15 +0200 |
commit | e35b49595320a4e29037b9cf3a11ff81a9984d87 (patch) | |
tree | 38fad10b173a71ae38d86cc709fb74ba5f42abc9 | |
parent | 9e38925e829fd635f6f3339770f3ebdf49ad906f (diff) | |
download | esdl2-e35b49595320a4e29037b9cf3a11ff81a9984d87.tar.gz esdl2-e35b49595320a4e29037b9cf3a11ff81a9984d87.tar.bz2 esdl2-e35b49595320a4e29037b9cf3a11ff81a9984d87.zip |
Add sdl_window:hide/1
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_window.c | 17 | ||||
-rw-r--r-- | src/esdl2.erl | 4 | ||||
-rw-r--r-- | src/sdl_window.erl | 4 |
4 files changed, 26 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index f165056..2ffed3d 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -171,6 +171,7 @@ F(get_window_position, 1) \ F(get_window_size, 1) \ F(get_window_title, 1) \ + F(hide_window, 1) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 62d6993..887d84a 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -343,3 +343,20 @@ NIF_FUNCTION(get_window_title) return nif_thread_call(env, thread_get_window_title, 1, NIF_RES_GET(Window, window_res)); } + +// hide_window + +NIF_CAST_HANDLER(thread_hide_window) +{ + SDL_HideWindow(args[0]); +} + +NIF_FUNCTION(hide_window) +{ + void* window_res; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + + return nif_thread_cast(env, thread_hide_window, 1, + NIF_RES_GET(Window, window_res)); +} diff --git a/src/esdl2.erl b/src/esdl2.erl index 9be4e55..7318945 100644 --- a/src/esdl2.erl +++ b/src/esdl2.erl @@ -83,6 +83,7 @@ -export([get_window_position/1]). -export([get_window_size/1]). -export([get_window_title/1]). +-export([hide_window/1]). %% @todo We probably want to accept an env variable or somthing for the location. -on_load(on_load/0). @@ -261,3 +262,6 @@ get_window_size(_) -> get_window_title(_) -> erlang:nif_error({not_loaded, ?MODULE}). + +hide_window(_) -> + erlang:nif_error({not_loaded, ?MODULE}). diff --git a/src/sdl_window.erl b/src/sdl_window.erl index 82e2b17..9c3fdbd 100644 --- a/src/sdl_window.erl +++ b/src/sdl_window.erl @@ -26,6 +26,7 @@ -export([get_pos/1]). -export([get_size/1]). -export([get_title/1]). +-export([hide/1]). create(Title, X, Y, W, H, Flags) -> esdl2:create_window(Title, X, Y, W, H, Flags), @@ -77,3 +78,6 @@ get_size(Window) -> get_title(Window) -> esdl2:get_window_title(Window), receive {'_nif_thread_ret_', Ret} -> Ret end. + +hide(Window) -> + esdl2:hide_window(Window). |