Browse Source

Fixed scaler dragging behavior #432

vurtun 8 năm trước cách đây
mục cha
commit
9ed3eeec8d
2 tập tin đã thay đổi với 16 bổ sung8 xóa
  1. 1 0
      CHANGELOG.md
  2. 15 8
      nuklear.h

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@
 
 
 Changes:
 Changes:
 --------
 --------
+- 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size
 - 2017/05/06 (1.38.0) - Added platform double-click support
 - 2017/05/06 (1.38.0) - Added platform double-click support
 - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends
 - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends
 - 2017/04/20 (1.37.0) - Extended properties with selection and clipbard support
 - 2017/04/20 (1.37.0) - Extended properties with selection and clipbard support

+ 15 - 8
nuklear.h

@@ -17939,20 +17939,27 @@ nk_panel_end(struct nk_context *ctx)
             int left_mouse_click_in_scaler = nk_input_has_mouse_click_down_in_rect(in,
             int left_mouse_click_in_scaler = nk_input_has_mouse_click_down_in_rect(in,
                     NK_BUTTON_LEFT, scaler, nk_true);
                     NK_BUTTON_LEFT, scaler, nk_true);
 
 
-            if (nk_input_is_mouse_down(in, NK_BUTTON_LEFT) && left_mouse_down && left_mouse_click_in_scaler) {
+            if (left_mouse_down && left_mouse_click_in_scaler) {
                 float delta_x = in->mouse.delta.x;
                 float delta_x = in->mouse.delta.x;
                 if (layout->flags & NK_WINDOW_SCALE_LEFT) {
                 if (layout->flags & NK_WINDOW_SCALE_LEFT) {
                     delta_x = -delta_x;
                     delta_x = -delta_x;
                     window->bounds.x += in->mouse.delta.x;
                     window->bounds.x += in->mouse.delta.x;
                 }
                 }
-                window->bounds.w = NK_MAX(window_size.x, window->bounds.w + delta_x);
-
-                /* dragging in y-direction is only possible if static window */
-                if (!(layout->flags & NK_WINDOW_DYNAMIC))
-                    window->bounds.h = NK_MAX(window_size.y, window->bounds.h + in->mouse.delta.y);
+                /* dragging in x-direction  */
+                if (window_size.x < window->bounds.w + delta_x) {
+                    window->bounds.w = window->bounds.w + delta_x;
+                    scaler.x += in->mouse.delta.x;
+                }
+                /* dragging in y-direction (only possible if static window) */
+                if (!(layout->flags & NK_WINDOW_DYNAMIC)) {
+                    if (window_size.y < window->bounds.h + in->mouse.delta.y) {
+                        window->bounds.h = window->bounds.h + in->mouse.delta.y;
+                        scaler.y += in->mouse.delta.y;
+                    }
+                }
                 ctx->style.cursor_active = ctx->style.cursors[NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT];
                 ctx->style.cursor_active = ctx->style.cursors[NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT];
-                in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.x = scaler.x + in->mouse.delta.x + scaler.w/2.0f;
-                in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.y = scaler.y + in->mouse.delta.y + scaler.h/2.0f;
+                in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.x = scaler.x + scaler.w/2.0f;
+                in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos.y = scaler.y + scaler.h/2.0f;
             }
             }
         }
         }
     }
     }