Selaa lähdekoodia

Update Nuklear to 2.00.4

Camilla Löwy 7 vuotta sitten
vanhempi
commit
5f8431d7ca
3 muutettua tiedostoa jossa 285 lisäystä ja 230 poistoa
  1. 271 225
      deps/nuklear.h
  2. 13 4
      deps/nuklear_glfw_gl2.h
  3. 1 1
      tests/gamma.c

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 271 - 225
deps/nuklear.h


+ 13 - 4
deps/nuklear_glfw_gl2.h

@@ -75,6 +75,8 @@ static struct nk_glfw {
     int text_len;
     int text_len;
     struct nk_vec2 scroll;
     struct nk_vec2 scroll;
     double last_button_click;
     double last_button_click;
+    int is_double_click_down;
+    struct nk_vec2 double_click_pos;
 } glfw;
 } glfw;
 
 
 NK_INTERN void
 NK_INTERN void
@@ -219,10 +221,12 @@ nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int m
     glfwGetCursorPos(window, &x, &y);
     glfwGetCursorPos(window, &x, &y);
     if (action == GLFW_PRESS)  {
     if (action == GLFW_PRESS)  {
         double dt = glfwGetTime() - glfw.last_button_click;
         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();
         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
 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.paste = nk_glfw3_clipbard_paste;
     glfw.ctx.clip.userdata = nk_handle_ptr(0);
     glfw.ctx.clip.userdata = nk_handle_ptr(0);
     nk_buffer_init_default(&glfw.ogl.cmds);
     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;
     return &glfw.ctx;
 }
 }
 
 
@@ -344,7 +352,7 @@ nk_glfw3_new_frame(void)
     glfwGetCursorPos(win, &x, &y);
     glfwGetCursorPos(win, &x, &y);
     nk_input_motion(ctx, (int)x, (int)y);
     nk_input_motion(ctx, (int)x, (int)y);
     if (ctx->input.mouse.grabbed) {
     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.x = ctx->input.mouse.prev.x;
         ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
         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_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_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_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_scroll(ctx, glfw.scroll);
     nk_input_end(&glfw.ctx);
     nk_input_end(&glfw.ctx);
     glfw.text_len = 0;
     glfw.text_len = 0;

+ 1 - 1
tests/gamma.c

@@ -135,13 +135,13 @@ int main(int argc, char** argv)
 
 
         glfwGetWindowSize(window, &width, &height);
         glfwGetWindowSize(window, &width, &height);
         area = nk_rect(0.f, 0.f, (float) width, (float) height);
         area = nk_rect(0.f, 0.f, (float) width, (float) height);
+        nk_window_set_bounds(nk, "", area);
 
 
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
         nk_glfw3_new_frame();
         nk_glfw3_new_frame();
         if (nk_begin(nk, "", area, 0))
         if (nk_begin(nk, "", area, 0))
         {
         {
             const GLFWgammaramp* ramp;
             const GLFWgammaramp* ramp;
-            nk_window_set_bounds(nk, area);
 
 
             nk_layout_row_dynamic(nk, 30, 3);
             nk_layout_row_dynamic(nk, 30, 3);
             if (nk_slider_float(nk, 0.1f, &gamma_value, 5.f, 0.1f))
             if (nk_slider_float(nk, 0.1f, &gamma_value, 5.f, 0.1f))

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä