[wip] adding missing impl for win32 version of orca

This commit is contained in:
martinfouilleul 2023-06-17 20:09:25 +02:00
parent e93bf76adc
commit d2c4acf6e2
4 changed files with 110 additions and 84 deletions

View File

@ -180,7 +180,7 @@ MP_API bool mg_canvas_is_nil(mg_canvas canvas);
MP_API mg_canvas mg_canvas_create(void);
MP_API void mg_canvas_destroy(mg_canvas canvas);
mg_canvas mg_canvas_set_current(mg_canvas canvas);
MP_API mg_canvas mg_canvas_set_current(mg_canvas canvas);
MP_API void mg_render(mg_surface surface, mg_canvas canvas);
//------------------------------------------------------------------------------------------

View File

@ -72,7 +72,7 @@ typedef struct mg_primitive
} mg_primitive;
void mg_surface_render_commands(mg_surface surface,
MP_API void mg_surface_render_commands(mg_surface surface,
mg_color clearColor,
u32 primitiveCount,
mg_primitive* primitives,

View File

@ -51,7 +51,7 @@ void file_slot_recycle(file_table* table, file_slot* slot);
file_handle file_handle_from_slot(file_table* table, file_slot* slot);
file_slot* file_slot_from_handle(file_table* table, file_handle handle);
io_cmp io_wait_single_req_with_table(io_req* req, file_table* table);
MP_API io_cmp io_wait_single_req_with_table(io_req* req, file_table* table);
//-----------------------------------------------------------------------

View File

@ -771,6 +771,32 @@ mp_rect mp_window_get_content_rect(mp_window window)
return(rect);
}
//TODO: set content rect, center
void mp_window_center(mp_window window)
{
mp_window_data* windowData = mp_window_ptr_from_handle(window);
if(windowData)
{
RECT winRect;
GetWindowRect(windowData->win32.hWnd, &winRect);
HMONITOR monitor = MonitorFromPoint((POINT){winRect.left, winRect.top}, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO monitorInfo = {.cbSize = sizeof(MONITORINFO)};
GetMonitorInfoW(monitor, &monitorInfo);
int monW = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
int monH = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
int winW = winRect.right - winRect.left;
int winH = winRect.bottom - winRect.top;
int winX = 0.5*(monW-winW);
int winY = 0.5*(monW-winW);
SetWindowPos(windowData->win32.hWnd, NULL, winX, winY, winW, winH, SWP_NOZORDER|SWP_NOACTIVATE);
}
}
//--------------------------------------------------------------------------------
// clipboard functions
//--------------------------------------------------------------------------------