[ui] Add a function to get current mouse position

And hot/active ids.
This commit is contained in:
Bill Currie 2023-08-07 17:42:59 +09:00
parent 35e2ffb4ab
commit 95b660d7fd
2 changed files with 17 additions and 0 deletions

View file

@ -93,6 +93,12 @@ typedef struct imui_window_s {
bool no_collapse;
} imui_window_t;
typedef struct imui_io_s {
view_pos_t mouse;
uint32_t hot;
uint32_t active;
} imui_io_t;
imui_ctx_t *IMUI_NewContext (struct canvas_system_s canvas_sys,
const char *font, float fontsize);
void IMUI_DestroyContext (imui_ctx_t *ctx);
@ -100,6 +106,7 @@ void IMUI_DestroyContext (imui_ctx_t *ctx);
void IMUI_SetVisible (imui_ctx_t *ctx, bool visible);
void IMUI_SetSize (imui_ctx_t *ctx, int xlen, int ylen);
bool IMUI_ProcessEvent (imui_ctx_t *ctx, const struct IE_event_s *ie_event);
imui_io_t IMUI_GetIO (imui_ctx_t *ctx) __attribute__((pure));
void IMUI_BeginFrame (imui_ctx_t *ctx);
void IMUI_Draw (imui_ctx_t *ctx);

View file

@ -329,6 +329,16 @@ IMUI_ProcessEvent (imui_ctx_t *ctx, const IE_event_t *ie_event)
return ctx->hot != nullent || ctx->active != nullent;
}
imui_io_t
IMUI_GetIO (imui_ctx_t *ctx)
{
return (imui_io_t) {
.mouse = ctx->mouse_position,
.hot = ctx->hot,
.active = ctx->active,
};
}
void
IMUI_BeginFrame (imui_ctx_t *ctx)
{