瀏覽代碼

Fixed clipped group scrollbar behavior Ro.2

While the last commit fixed some issues it still had a bug which
caused wrong scrollbar target size calculation. So this commit
hopefully fixes the problem.
vurtun 9 年之前
父節點
當前提交
be2e35e3c1
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      nuklear.h

+ 8 - 6
nuklear.h

@@ -15817,19 +15817,21 @@ nk_panel_end(struct nk_context *ctx)
             /* vertical scrollbar */
             nk_flags state = 0;
             bounds.x = layout->bounds.x + layout->width;
-            bounds.y = layout->clip.y;
+            bounds.y = layout->bounds.y + layout->header_h;
             bounds.w = scrollbar_size.y;
             bounds.h = layout->bounds.h - (layout->footer_h + layout->header_h);
             bounds.h -= (2.0f * window_padding.y);
-            if (layout->menu.h)
-                bounds.h -= layout->menu.h + layout->row.height;
             if (layout->flags & NK_WINDOW_BORDER)
                 bounds.x -= layout->border;
+            if (layout->menu.h) {
+                bounds.y += layout->menu.h;
+                bounds.h -= layout->menu.h + layout->row.height;
+            }
 
             scroll_offset = layout->offset->y;
-            scroll_step = layout->clip.h * 0.10f;
-            scroll_inc = layout->clip.h * 0.01f;
-            scroll_target = (float)(int)(layout->at_y - layout->clip.y);
+            scroll_step = bounds.h * 0.10f;
+            scroll_inc = bounds.h * 0.01f;
+            scroll_target = (float)(int)(layout->at_y - bounds.y);
             scroll_has_scrolling = (window == ctx->active);
             scroll_offset = nk_do_scrollbarv(&state, out, bounds, scroll_has_scrolling,
                     scroll_offset, scroll_target, scroll_step, scroll_inc,