[wip] adding missing impl for win32 version of orca
This commit is contained in:
parent
e93bf76adc
commit
d2c4acf6e2
|
@ -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);
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,82 +1,82 @@
|
|||
/************************************************************//**
|
||||
*
|
||||
* @file: graphics_common.h
|
||||
* @author: Martin Fouilleul
|
||||
* @date: 26/04/2023
|
||||
*
|
||||
*****************************************************************/
|
||||
#ifndef __GRAPHICS_COMMON_H_
|
||||
#define __GRAPHICS_COMMON_H_
|
||||
|
||||
#include"graphics.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// canvas structs
|
||||
//------------------------------------------------------------------------
|
||||
typedef enum { MG_PATH_MOVE,
|
||||
MG_PATH_LINE,
|
||||
MG_PATH_QUADRATIC,
|
||||
MG_PATH_CUBIC } mg_path_elt_type;
|
||||
|
||||
typedef struct mg_path_elt
|
||||
{
|
||||
mg_path_elt_type type;
|
||||
vec2 p[3];
|
||||
|
||||
} mg_path_elt;
|
||||
|
||||
typedef struct mg_path_descriptor
|
||||
{
|
||||
u32 startIndex;
|
||||
u32 count;
|
||||
vec2 startPoint;
|
||||
|
||||
} mg_path_descriptor;
|
||||
|
||||
typedef struct mg_attributes
|
||||
{
|
||||
f32 width;
|
||||
f32 tolerance;
|
||||
mg_color color;
|
||||
mg_joint_type joint;
|
||||
f32 maxJointExcursion;
|
||||
mg_cap_type cap;
|
||||
|
||||
mg_font font;
|
||||
f32 fontSize;
|
||||
|
||||
mg_image image;
|
||||
mp_rect srcRegion;
|
||||
|
||||
mg_mat2x3 transform;
|
||||
mp_rect clip;
|
||||
|
||||
} mg_attributes;
|
||||
|
||||
typedef enum { MG_CMD_FILL,
|
||||
MG_CMD_STROKE,
|
||||
MG_CMD_JUMP
|
||||
} mg_primitive_cmd;
|
||||
|
||||
typedef struct mg_primitive
|
||||
{
|
||||
mg_primitive_cmd cmd;
|
||||
mg_attributes attributes;
|
||||
|
||||
union
|
||||
{
|
||||
mg_path_descriptor path;
|
||||
mp_rect rect;
|
||||
u32 jump;
|
||||
};
|
||||
|
||||
} mg_primitive;
|
||||
|
||||
void mg_surface_render_commands(mg_surface surface,
|
||||
mg_color clearColor,
|
||||
u32 primitiveCount,
|
||||
mg_primitive* primitives,
|
||||
u32 eltCount,
|
||||
mg_path_elt* elements);
|
||||
|
||||
#endif //__GRAPHICS_COMMON_H_
|
||||
/************************************************************//**
|
||||
*
|
||||
* @file: graphics_common.h
|
||||
* @author: Martin Fouilleul
|
||||
* @date: 26/04/2023
|
||||
*
|
||||
*****************************************************************/
|
||||
#ifndef __GRAPHICS_COMMON_H_
|
||||
#define __GRAPHICS_COMMON_H_
|
||||
|
||||
#include"graphics.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// canvas structs
|
||||
//------------------------------------------------------------------------
|
||||
typedef enum { MG_PATH_MOVE,
|
||||
MG_PATH_LINE,
|
||||
MG_PATH_QUADRATIC,
|
||||
MG_PATH_CUBIC } mg_path_elt_type;
|
||||
|
||||
typedef struct mg_path_elt
|
||||
{
|
||||
mg_path_elt_type type;
|
||||
vec2 p[3];
|
||||
|
||||
} mg_path_elt;
|
||||
|
||||
typedef struct mg_path_descriptor
|
||||
{
|
||||
u32 startIndex;
|
||||
u32 count;
|
||||
vec2 startPoint;
|
||||
|
||||
} mg_path_descriptor;
|
||||
|
||||
typedef struct mg_attributes
|
||||
{
|
||||
f32 width;
|
||||
f32 tolerance;
|
||||
mg_color color;
|
||||
mg_joint_type joint;
|
||||
f32 maxJointExcursion;
|
||||
mg_cap_type cap;
|
||||
|
||||
mg_font font;
|
||||
f32 fontSize;
|
||||
|
||||
mg_image image;
|
||||
mp_rect srcRegion;
|
||||
|
||||
mg_mat2x3 transform;
|
||||
mp_rect clip;
|
||||
|
||||
} mg_attributes;
|
||||
|
||||
typedef enum { MG_CMD_FILL,
|
||||
MG_CMD_STROKE,
|
||||
MG_CMD_JUMP
|
||||
} mg_primitive_cmd;
|
||||
|
||||
typedef struct mg_primitive
|
||||
{
|
||||
mg_primitive_cmd cmd;
|
||||
mg_attributes attributes;
|
||||
|
||||
union
|
||||
{
|
||||
mg_path_descriptor path;
|
||||
mp_rect rect;
|
||||
u32 jump;
|
||||
};
|
||||
|
||||
} mg_primitive;
|
||||
|
||||
MP_API void mg_surface_render_commands(mg_surface surface,
|
||||
mg_color clearColor,
|
||||
u32 primitiveCount,
|
||||
mg_primitive* primitives,
|
||||
u32 eltCount,
|
||||
mg_path_elt* elements);
|
||||
|
||||
#endif //__GRAPHICS_COMMON_H_
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
//--------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue