Przeglądaj źródła

Fixed scrollbar drawing bug if not enough space

vurtun 8 lat temu
rodzic
commit
70d9de10c9
2 zmienionych plików z 6 dodań i 6 usunięć
  1. 1 0
      CHANGELOG.md
  2. 5 6
      nuklear.h

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@
 
 Changes:
 --------
+- 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/06 (1.38.0) - Added platform double-click support
 - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends

+ 5 - 6
nuklear.h

@@ -14936,7 +14936,7 @@ nk_do_scrollbarv(nk_flags *state,
     if (!out || !style) return 0;
 
     scroll.w = NK_MAX(scroll.w, 1);
-    scroll.h = NK_MAX(scroll.h, 2 * scroll.w);
+    scroll.h = NK_MAX(scroll.h, 0);
     if (target <= scroll.h) return 0;
 
     /* optional scrollbar buttons */
@@ -14949,7 +14949,7 @@ nk_do_scrollbarv(nk_flags *state,
         button.w = scroll.w;
         button.h = scroll.w;
 
-        scroll_h = scroll.h - 2 * button.h;
+        scroll_h = NK_MAX(scroll.h - 2 * button.h,0);
         scroll_step = NK_MIN(step, button_pixel_inc);
 
         /* decrement button */
@@ -14975,7 +14975,7 @@ nk_do_scrollbarv(nk_flags *state,
     scroll_off = scroll_offset / target;
 
     /* calculate scrollbar cursor bounds */
-    cursor.h = (scroll_ratio * scroll.h) - (2*style->border + 2*style->padding.y);
+    cursor.h = NK_MAX((scroll_ratio * scroll.h) - (2*style->border + 2*style->padding.y), 0);
     cursor.y = scroll.y + (scroll_off * scroll.h) + style->border + style->padding.y;
     cursor.w = scroll.w - (2 * style->border + 2 * style->padding.x);
     cursor.x = scroll.x + style->border + style->padding.x;
@@ -14984,12 +14984,12 @@ nk_do_scrollbarv(nk_flags *state,
     empty_north.x = scroll.x;
     empty_north.y = scroll.y;
     empty_north.w = scroll.w;
-    empty_north.h = cursor.y - scroll.y;
+    empty_north.h = NK_MAX(cursor.y - scroll.y, 0);
 
     empty_south.x = scroll.x;
     empty_south.y = cursor.y + cursor.h;
     empty_south.w = scroll.w;
-    empty_south.h = (scroll.y + scroll.h) - (cursor.y + cursor.h);
+    empty_south.h = NK_MAX((scroll.y + scroll.h) - (cursor.y + cursor.h), 0);
 
     /* update scrollbar */
     scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
@@ -18006,7 +18006,6 @@ nk_panel_end(struct nk_context *ctx)
         window->popup.con_count = 0;
     }
     window->popup.combo_count = 0;
-
     /* helper to make sure you have a 'nk_tree_push' for every 'nk_tree_pop' */
     NK_ASSERT(!layout->row.tree_depth);
 }