Browse Source

Added additional comments to asserts

vurtun 9 years ago
parent
commit
3f935941f8
1 changed files with 17 additions and 12 deletions
  1. 17 12
      nuklear.h

+ 17 - 12
nuklear.h

@@ -484,7 +484,6 @@ enum nk_edit_types {
                         NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB,
                         NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB,
     NK_EDIT_EDITOR  = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|
     NK_EDIT_EDITOR  = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|
                         NK_EDIT_CLIPBOARD
                         NK_EDIT_CLIPBOARD
-
 };
 };
 enum nk_edit_events {
 enum nk_edit_events {
     NK_EDIT_ACTIVE      = NK_FLAG(0), /* edit widget is currently being modified */
     NK_EDIT_ACTIVE      = NK_FLAG(0), /* edit widget is currently being modified */
@@ -1753,6 +1752,7 @@ NK_API void nk_draw_list_stroke_triangle(struct nk_draw_list*, struct nk_vec2 a,
 NK_API void nk_draw_list_stroke_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color, unsigned int segs, float thickness);
 NK_API void nk_draw_list_stroke_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color, unsigned int segs, float thickness);
 NK_API void nk_draw_list_stroke_curve(struct nk_draw_list*, struct nk_vec2 p0, struct nk_vec2 cp0, struct nk_vec2 cp1, struct nk_vec2 p1, struct nk_color, unsigned int segments, float thickness);
 NK_API void nk_draw_list_stroke_curve(struct nk_draw_list*, struct nk_vec2 p0, struct nk_vec2 cp0, struct nk_vec2 cp1, struct nk_vec2 p1, struct nk_color, unsigned int segments, float thickness);
 NK_API void nk_draw_list_stroke_poly_line(struct nk_draw_list*, const struct nk_vec2 *pnts, const unsigned int cnt, struct nk_color, enum nk_draw_list_stroke, float thickness, enum nk_anti_aliasing);
 NK_API void nk_draw_list_stroke_poly_line(struct nk_draw_list*, const struct nk_vec2 *pnts, const unsigned int cnt, struct nk_color, enum nk_draw_list_stroke, float thickness, enum nk_anti_aliasing);
+
 /* fill */
 /* fill */
 NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
 NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
 NK_API void nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
 NK_API void nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
@@ -2373,9 +2373,8 @@ struct nk_context {
 #ifdef NK_INCLUDE_COMMAND_USERDATA
 #ifdef NK_INCLUDE_COMMAND_USERDATA
     nk_handle userdata;
     nk_handle userdata;
 #endif
 #endif
-
-    /* text editor objects are quite big because they have a internal
-     * undo/redo stack. It therefore does not make sense to have one for
+    /* text editor objects are quite big because of an internal
+     * undo/redo stack. Therefore does not make sense to have one for
      * each window for temporary use cases, so I only provide *one* instance
      * each window for temporary use cases, so I only provide *one* instance
      * for all windows. This works because the content is cleared anyway */
      * for all windows. This works because the content is cleared anyway */
     struct nk_text_edit text_edit;
     struct nk_text_edit text_edit;
@@ -5332,7 +5331,7 @@ nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
     cmd->color = col;
     cmd->color = col;
     cmd->point_count = (unsigned short)point_count;
     cmd->point_count = (unsigned short)point_count;
     for (i = 0; i < point_count; ++i) {
     for (i = 0; i < point_count; ++i) {
-        cmd->points[i].x = (short)points[i*2];
+        cmd->points[i].x = (short)points[i*2+0];
         cmd->points[i].y = (short)points[i*2+1];
         cmd->points[i].y = (short)points[i*2+1];
     }
     }
 }
 }
@@ -14915,6 +14914,7 @@ nk_begin(struct nk_context *ctx, struct nk_panel *layout, const char *title,
     int ret = 0;
     int ret = 0;
 
 
     NK_ASSERT(ctx);
     NK_ASSERT(ctx);
+    NK_ASSERT(ctx->style.font.width && "if this triggers you forgot to add a font");
     NK_ASSERT(!ctx->current && "if this triggers you missed a `nk_end` call");
     NK_ASSERT(!ctx->current && "if this triggers you missed a `nk_end` call");
     if (!ctx || ctx->current || !title)
     if (!ctx || ctx->current || !title)
         return 0;
         return 0;
@@ -15034,7 +15034,7 @@ NK_API void
 nk_end(struct nk_context *ctx)
 nk_end(struct nk_context *ctx)
 {
 {
     NK_ASSERT(ctx);
     NK_ASSERT(ctx);
-    NK_ASSERT(ctx->current);
+    NK_ASSERT(ctx->current && "if this triggers you forgot to call `nk_begin`");
     NK_ASSERT(ctx->current->layout);
     NK_ASSERT(ctx->current->layout);
     if (!ctx || !ctx->current) return;
     if (!ctx || !ctx->current) return;
     if (ctx->current->flags & NK_WINDOW_HIDDEN) {
     if (ctx->current->flags & NK_WINDOW_HIDDEN) {
@@ -15048,7 +15048,8 @@ nk_end(struct nk_context *ctx)
 NK_API struct nk_rect
 NK_API struct nk_rect
 nk_window_get_bounds(const struct nk_context *ctx)
 nk_window_get_bounds(const struct nk_context *ctx)
 {
 {
-    NK_ASSERT(ctx); NK_ASSERT(ctx->current);
+    NK_ASSERT(ctx);
+    NK_ASSERT(ctx->current);
     if (!ctx || !ctx->current) return nk_rect(0,0,0,0);
     if (!ctx || !ctx->current) return nk_rect(0,0,0,0);
     return ctx->current->bounds;
     return ctx->current->bounds;
 }
 }
@@ -15056,7 +15057,8 @@ nk_window_get_bounds(const struct nk_context *ctx)
 NK_API struct nk_vec2
 NK_API struct nk_vec2
 nk_window_get_position(const struct nk_context *ctx)
 nk_window_get_position(const struct nk_context *ctx)
 {
 {
-    NK_ASSERT(ctx); NK_ASSERT(ctx->current);
+    NK_ASSERT(ctx);
+    NK_ASSERT(ctx->current);
     if (!ctx || !ctx->current) return nk_vec2(0,0);
     if (!ctx || !ctx->current) return nk_vec2(0,0);
     return nk_vec2(ctx->current->bounds.x, ctx->current->bounds.y);
     return nk_vec2(ctx->current->bounds.x, ctx->current->bounds.y);
 }
 }
@@ -15064,7 +15066,8 @@ nk_window_get_position(const struct nk_context *ctx)
 NK_API struct nk_vec2
 NK_API struct nk_vec2
 nk_window_get_size(const struct nk_context *ctx)
 nk_window_get_size(const struct nk_context *ctx)
 {
 {
-    NK_ASSERT(ctx); NK_ASSERT(ctx->current);
+    NK_ASSERT(ctx);
+    NK_ASSERT(ctx->current);
     if (!ctx || !ctx->current) return nk_vec2(0,0);
     if (!ctx || !ctx->current) return nk_vec2(0,0);
     return nk_vec2(ctx->current->bounds.w, ctx->current->bounds.h);
     return nk_vec2(ctx->current->bounds.w, ctx->current->bounds.h);
 }
 }
@@ -15072,7 +15075,8 @@ nk_window_get_size(const struct nk_context *ctx)
 NK_API float
 NK_API float
 nk_window_get_width(const struct nk_context *ctx)
 nk_window_get_width(const struct nk_context *ctx)
 {
 {
-    NK_ASSERT(ctx); NK_ASSERT(ctx->current);
+    NK_ASSERT(ctx);
+    NK_ASSERT(ctx->current);
     if (!ctx || !ctx->current) return 0;
     if (!ctx || !ctx->current) return 0;
     return ctx->current->bounds.w;
     return ctx->current->bounds.w;
 }
 }
@@ -15080,7 +15084,8 @@ nk_window_get_width(const struct nk_context *ctx)
 NK_API float
 NK_API float
 nk_window_get_height(const struct nk_context *ctx)
 nk_window_get_height(const struct nk_context *ctx)
 {
 {
-    NK_ASSERT(ctx); NK_ASSERT(ctx->current);
+    NK_ASSERT(ctx);
+    NK_ASSERT(ctx->current);
     if (!ctx || !ctx->current) return 0;
     if (!ctx || !ctx->current) return 0;
     return ctx->current->bounds.h;
     return ctx->current->bounds.h;
 }
 }
@@ -15180,7 +15185,7 @@ nk_window_is_any_hovered(struct nk_context *ctx)
         } else if (nk_input_is_mouse_hovering_rect(&ctx->input, iter->bounds)) {
         } else if (nk_input_is_mouse_hovering_rect(&ctx->input, iter->bounds)) {
             return 1;
             return 1;
         }
         }
-        /* check if window is being hovered */
+        /* check if window popup is being hovered */
         if (iter->popup.active && nk_input_is_mouse_hovering_rect(&ctx->input, iter->popup.win->bounds))
         if (iter->popup.active && nk_input_is_mouse_hovering_rect(&ctx->input, iter->popup.win->bounds))
             return 1;
             return 1;
         iter = iter->next;
         iter = iter->next;