浏览代码

Fixed #442 Activation of partially visible widgets

vurtun 8 年之前
父节点
当前提交
7bd467935b
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 1 0
      CHANGELOG.txt
  2. 5 2
      nuklear.h

+ 1 - 0
CHANGELOG.txt

@@ -11,6 +11,7 @@
 
 
 Changes:
 Changes:
 --------
 --------
+- 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped
 - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries
 - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries
 - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space
 - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space
 - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size
 - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size

+ 5 - 2
nuklear.h

@@ -19936,9 +19936,10 @@ nk_widget_has_mouse_click_down(struct nk_context *ctx, enum nk_buttons btn, int
 NK_API enum nk_widget_layout_states
 NK_API enum nk_widget_layout_states
 nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
 nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
 {
 {
-    struct nk_rect c;
+    struct nk_rect c, v;
     struct nk_window *win;
     struct nk_window *win;
     struct nk_panel *layout;
     struct nk_panel *layout;
+    const struct nk_input *in;
 
 
     NK_ASSERT(ctx);
     NK_ASSERT(ctx);
     NK_ASSERT(ctx->current);
     NK_ASSERT(ctx->current);
@@ -19950,6 +19951,7 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
     nk_panel_alloc_space(bounds, ctx);
     nk_panel_alloc_space(bounds, ctx);
     win = ctx->current;
     win = ctx->current;
     layout = win->layout;
     layout = win->layout;
+    in = &ctx->input;
     c = layout->clip;
     c = layout->clip;
 
 
     /*  if one of these triggers you forgot to add an `if` condition around either
     /*  if one of these triggers you forgot to add an `if` condition around either
@@ -19972,9 +19974,10 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
     c.w = (float)((int)c.w);
     c.w = (float)((int)c.w);
     c.h = (float)((int)c.h);
     c.h = (float)((int)c.h);
 
 
+    nk_unify(&v, &c, bounds->x, bounds->y, bounds->x + bounds->w, bounds->y + bounds->h);
     if (!NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->x, bounds->y, bounds->w, bounds->h))
     if (!NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->x, bounds->y, bounds->w, bounds->h))
         return NK_WIDGET_INVALID;
         return NK_WIDGET_INVALID;
-    if (!NK_CONTAINS(bounds->x, bounds->y, bounds->w, bounds->h, c.x, c.y, c.w, c.h))
+    if (!NK_INBOX(in->mouse.pos.x, in->mouse.pos.y, v.x, v.y, v.w, v.h))
         return NK_WIDGET_ROM;
         return NK_WIDGET_ROM;
     return NK_WIDGET_VALID;
     return NK_WIDGET_VALID;
 }
 }