diff options
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_window.c | 21 | ||||
-rw-r--r-- | src/esdl2.erl | 4 | ||||
-rw-r--r-- | src/sdl_window.erl | 4 |
4 files changed, 30 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 433b262..2a0a231 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -185,6 +185,7 @@ F(set_window_minimum_size, 3) \ F(set_window_position, 3) \ F(set_window_size, 3) \ + F(set_window_title, 2) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 5719779..065e39a 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -623,3 +623,24 @@ NIF_FUNCTION(set_window_size) return nif_thread_cast(env, thread_set_window_size, 3, NIF_RES_GET(Window, window_res), w, h); } + +// set_window_title + +NIF_CAST_HANDLER(thread_set_window_title) +{ + SDL_SetWindowTitle(args[0], args[1]); + + enif_free(args[1]); +} + +NIF_FUNCTION(set_window_title) +{ + void* window_res; + char* title = (char*)enif_alloc(255); + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + BADARG_IF(!enif_get_string(env, argv[1], title, 255, ERL_NIF_LATIN1)); + + return nif_thread_cast(env, thread_set_window_title, 2, + NIF_RES_GET(Window, window_res), title); +} diff --git a/src/esdl2.erl b/src/esdl2.erl index 31c4ce9..01969df 100644 --- a/src/esdl2.erl +++ b/src/esdl2.erl @@ -97,6 +97,7 @@ -export([set_window_minimum_size/3]). -export([set_window_position/3]). -export([set_window_size/3]). +-export([set_window_title/2]). %% @todo We probably want to accept an env variable or somthing for the location. -on_load(on_load/0). @@ -317,3 +318,6 @@ set_window_position(_, _, _) -> set_window_size(_, _, _) -> erlang:nif_error({not_loaded, ?MODULE}). + +set_window_title(_, _) -> + erlang:nif_error({not_loaded, ?MODULE}). diff --git a/src/sdl_window.erl b/src/sdl_window.erl index f44c1cd..d4f980d 100644 --- a/src/sdl_window.erl +++ b/src/sdl_window.erl @@ -40,6 +40,7 @@ -export([set_min_size/3]). -export([set_pos/3]). -export([set_size/3]). +-export([set_title/2]). create(Title, X, Y, W, H, Flags) -> esdl2:create_window(Title, X, Y, W, H, Flags), @@ -136,3 +137,6 @@ set_pos(Window, X, Y) -> set_size(Window, W, H) -> esdl2:set_window_size(Window, W, H). + +set_title(Window, Title) -> + esdl2:set_window_title(Window, Title). |