|
@@ -233,21 +233,25 @@ nk_sdl_font_stash_end(void)
|
|
nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
|
|
nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
|
|
}
|
|
}
|
|
|
|
|
|
-NK_API int
|
|
|
|
-nk_sdl_handle_event(SDL_Event *evt)
|
|
|
|
|
|
+NK_API void
|
|
|
|
+nk_sdl_handle_grab(void)
|
|
{
|
|
{
|
|
struct nk_context *ctx = &sdl.ctx;
|
|
struct nk_context *ctx = &sdl.ctx;
|
|
-
|
|
|
|
- /* optional grabbing behavior */
|
|
|
|
if (ctx->input.mouse.grab) {
|
|
if (ctx->input.mouse.grab) {
|
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
- ctx->input.mouse.grab = 0;
|
|
|
|
} else if (ctx->input.mouse.ungrab) {
|
|
} else if (ctx->input.mouse.ungrab) {
|
|
- int x = (int)ctx->input.mouse.prev.x, y = (int)ctx->input.mouse.prev.y;
|
|
|
|
|
|
+ SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
- SDL_WarpMouseInWindow(sdl.win, x, y);
|
|
|
|
- ctx->input.mouse.ungrab = 0;
|
|
|
|
|
|
+ } else if (ctx->input.mouse.grabbed) {
|
|
|
|
+ ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
|
|
|
+ ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+NK_API int
|
|
|
|
+nk_sdl_handle_event(SDL_Event *evt)
|
|
|
|
+{
|
|
|
|
+ struct nk_context *ctx = &sdl.ctx;
|
|
|
|
|
|
switch(evt->type)
|
|
switch(evt->type)
|
|
{
|
|
{
|