implement our own gui module, drop microui
This commit is contained in:
parent
2555bec8eb
commit
8baf5f06ea
25 changed files with 495 additions and 507 deletions
|
|
@ -367,11 +367,45 @@ static void sdl3_set_relative_mouse_mode(void* platform_data, bool enabled) {
|
|||
}
|
||||
}
|
||||
|
||||
static void sdl3_set_cursor(void* platform_data, pxl8_cursor cursor) {
|
||||
if (!platform_data) return;
|
||||
|
||||
SDL_SystemCursor sdl_cursor;
|
||||
switch (cursor) {
|
||||
case PXL8_CURSOR_ARROW:
|
||||
sdl_cursor = SDL_SYSTEM_CURSOR_DEFAULT;
|
||||
break;
|
||||
case PXL8_CURSOR_HAND:
|
||||
sdl_cursor = SDL_SYSTEM_CURSOR_POINTER;
|
||||
break;
|
||||
default:
|
||||
sdl_cursor = SDL_SYSTEM_CURSOR_DEFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_Cursor* cursor_obj = SDL_CreateSystemCursor(sdl_cursor);
|
||||
if (cursor_obj) {
|
||||
SDL_SetCursor(cursor_obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void sdl3_center_cursor(void* platform_data) {
|
||||
if (!platform_data) return;
|
||||
|
||||
pxl8_sdl3_context* ctx = (pxl8_sdl3_context*)platform_data;
|
||||
i32 w, h;
|
||||
if (SDL_GetWindowSize(ctx->window, &w, &h)) {
|
||||
SDL_WarpMouseInWindow(ctx->window, w / 2, h / 2);
|
||||
}
|
||||
}
|
||||
|
||||
const pxl8_hal pxl8_hal_sdl3 = {
|
||||
.create = sdl3_create,
|
||||
.destroy = sdl3_destroy,
|
||||
.get_ticks = sdl3_get_ticks,
|
||||
.center_cursor = sdl3_center_cursor,
|
||||
.present = sdl3_present,
|
||||
.set_cursor = sdl3_set_cursor,
|
||||
.upload_atlas = sdl3_upload_atlas,
|
||||
.upload_framebuffer = sdl3_upload_framebuffer,
|
||||
.set_relative_mouse_mode = sdl3_set_relative_mouse_mode,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue