|
|
|
@ -75,6 +75,8 @@ static struct nk_glfw { |
|
|
|
|
int text_len; |
|
|
|
|
struct nk_vec2 scroll; |
|
|
|
|
double last_button_click; |
|
|
|
|
int is_double_click_down; |
|
|
|
|
struct nk_vec2 double_click_pos; |
|
|
|
|
} glfw; |
|
|
|
|
|
|
|
|
|
NK_INTERN void |
|
|
|
@ -219,10 +221,12 @@ nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int m |
|
|
|
|
glfwGetCursorPos(window, &x, &y); |
|
|
|
|
if (action == GLFW_PRESS) { |
|
|
|
|
double dt = glfwGetTime() - glfw.last_button_click; |
|
|
|
|
if (dt > NK_GLFW_DOUBLE_CLICK_LO && dt < NK_GLFW_DOUBLE_CLICK_HI) |
|
|
|
|
nk_input_button(&glfw.ctx, NK_BUTTON_DOUBLE, (int)x, (int)y, nk_true); |
|
|
|
|
if (dt > NK_GLFW_DOUBLE_CLICK_LO && dt < NK_GLFW_DOUBLE_CLICK_HI) { |
|
|
|
|
glfw.is_double_click_down = nk_true; |
|
|
|
|
glfw.double_click_pos = nk_vec2((float)x, (float)y); |
|
|
|
|
} |
|
|
|
|
glfw.last_button_click = glfwGetTime(); |
|
|
|
|
} else nk_input_button(&glfw.ctx, NK_BUTTON_DOUBLE, (int)x, (int)y, nk_false); |
|
|
|
|
} else glfw.is_double_click_down = nk_false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
NK_INTERN void |
|
|
|
@ -261,6 +265,10 @@ nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state init_state) |
|
|
|
|
glfw.ctx.clip.paste = nk_glfw3_clipbard_paste; |
|
|
|
|
glfw.ctx.clip.userdata = nk_handle_ptr(0); |
|
|
|
|
nk_buffer_init_default(&glfw.ogl.cmds); |
|
|
|
|
|
|
|
|
|
glfw.is_double_click_down = nk_false; |
|
|
|
|
glfw.double_click_pos = nk_vec2(0, 0); |
|
|
|
|
|
|
|
|
|
return &glfw.ctx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -344,7 +352,7 @@ nk_glfw3_new_frame(void) |
|
|
|
|
glfwGetCursorPos(win, &x, &y); |
|
|
|
|
nk_input_motion(ctx, (int)x, (int)y); |
|
|
|
|
if (ctx->input.mouse.grabbed) { |
|
|
|
|
glfwSetCursorPos(glfw.win, ctx->input.mouse.prev.x, ctx->input.mouse.prev.y); |
|
|
|
|
glfwSetCursorPos(glfw.win, (double)ctx->input.mouse.prev.x, (double)ctx->input.mouse.prev.y); |
|
|
|
|
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x; |
|
|
|
|
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y; |
|
|
|
|
} |
|
|
|
@ -352,6 +360,7 @@ nk_glfw3_new_frame(void) |
|
|
|
|
nk_input_button(ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS); |
|
|
|
|
nk_input_button(ctx, NK_BUTTON_MIDDLE, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS); |
|
|
|
|
nk_input_button(ctx, NK_BUTTON_RIGHT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS); |
|
|
|
|
nk_input_button(ctx, NK_BUTTON_DOUBLE, (int)glfw.double_click_pos.x, (int)glfw.double_click_pos.y, glfw.is_double_click_down); |
|
|
|
|
nk_input_scroll(ctx, glfw.scroll); |
|
|
|
|
nk_input_end(&glfw.ctx); |
|
|
|
|
glfw.text_len = 0; |
|
|
|
|