diff --git a/src/app/app.h b/src/app/app.h index 5f5b4e2..34c8699 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -323,6 +323,8 @@ ORCA_API bool oc_window_is_hidden(oc_window window); ORCA_API void oc_window_hide(oc_window window); ORCA_API void oc_window_show(oc_window window); +ORCA_API void oc_window_set_title(oc_window window, oc_str8 title); + ORCA_API bool oc_window_is_minimized(oc_window window); ORCA_API bool oc_window_is_maximized(oc_window window); ORCA_API void oc_window_minimize(oc_window window); @@ -403,6 +405,10 @@ ORCA_API int oc_directory_create(oc_str8 path); void ORCA_IMPORT(oc_request_quit)(void); +void ORCA_IMPORT(oc_runtime_window_set_title)(const char* title); + +void ORCA_IMPORT(oc_runtime_window_set_size)(f32 width, f32 height); + #endif // !defined(OC_PLATFORM_ORCA) || !(OC_PLATFORM_ORCA) #ifdef __cplusplus diff --git a/src/app/win32_app.c b/src/app/win32_app.c index 9492784..a2bb729 100644 --- a/src/app/win32_app.c +++ b/src/app/win32_app.c @@ -789,6 +789,20 @@ void oc_window_show(oc_window window) } } +void oc_window_set_title(oc_window window, oc_str8 title) +{ + oc_window_data* windowData = oc_window_ptr_from_handle(window); + if(windowData) + { + oc_arena_scope scratch = oc_scratch_begin(); + const char* titleCString = oc_str8_to_cstring(scratch.arena, title); + + SetWindowText(windowData->win32.hWnd, titleCString); + + oc_scratch_end(scratch); + } +} + bool oc_window_is_minimized(oc_window window) { oc_window_data* windowData = oc_window_ptr_from_handle(window); @@ -1252,7 +1266,7 @@ void oc_surface_init_for_window(oc_surface_data* surface, oc_window_data* window oc_log_error("couldn't enable blur behind\n"); } - //NOTE(reuben): Creating the child window takes focus away from the main window, but we want to keep + //NOTE(reuben): Creating the child window takes focus away from the main window, but we want to keep //the focus on the main window SetFocus(window->win32.hWnd); diff --git a/src/runtime.c b/src/runtime.c index 5ee8118..f47ea3f 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -66,6 +66,16 @@ oc_runtime_env* oc_runtime_env_get() return (&__orcaApp.runtime); } +void oc_runtime_window_set_title(const char* title) +{ + oc_window_set_title(__orcaApp.window, OC_STR8(title)); +} + +void oc_runtime_window_set_size(f32 width, f32 height) +{ + oc_window_set_content_size(__orcaApp.window, (oc_vec2){ .x = width, .y = height }); +} + void oc_runtime_log(oc_log_level level, int fileLen, char* file, diff --git a/src/wasmbind/core_api.json b/src/wasmbind/core_api.json index 9ffc568..15297b9 100644 --- a/src/wasmbind/core_api.json +++ b/src/wasmbind/core_api.json @@ -69,5 +69,25 @@ "cname": "oc_request_quit", "ret": {"name": "void", "tag": "v"}, "args": [] +}, +{ + "name": "oc_runtime_window_set_title", + "cname": "oc_runtime_window_set_title", + "ret": {"name": "void", "tag": "v"}, + "args": [ + { "name": "title", + "type": {"name": "const char*", "tag": "p"}} + ] +}, +{ + "name": "oc_runtime_window_set_size", + "cname": "oc_runtime_window_set_size", + "ret": {"name": "void", "tag": "v"}, + "args": [ + { "name": "width", + "type": {"name": "f32", "tag": "f"}}, + { "name": "height", + "type": {"name": "f32", "tag": "f"}} + ] } ]