wip window title and size API

This commit is contained in:
Reuben Dunnington 2023-08-22 21:28:37 -07:00
parent 72209200b5
commit e4ac212408
Signed by: rdunnington
GPG Key ID: 3D57C8938EA08E90
4 changed files with 51 additions and 1 deletions

View File

@ -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

View File

@ -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);

View File

@ -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,

View File

@ -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"}}
]
}
]