瀏覽代碼

Added assert to make sur menubar is used correctly

Since it is not as clear on how to use the menubar correctly as I
thought added an assert into `nk_menubar_begin` with explainations on
how to use it correctly and stop wrong ussage.
vurtun 9 年之前
父節點
當前提交
2a888b3098
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16 0
      nuklear.h

+ 16 - 0
nuklear.h

@@ -16997,6 +16997,22 @@ nk_menubar_begin(struct nk_context *ctx)
         return;
 
     layout = ctx->current->layout;
+    NK_ASSERT(layout->at_y == layout->bounds.y);
+    /* if this assert triggers you allocated space between nk_begin and nk_menubar_begin.
+    If you want a menubar the first nuklear function after `nk_begin` has to be a
+    `nk_menubar_begin` call. Inside the menubar you then have to allocate space for
+    widgets (also supports multiple rows).
+    Example:
+        if (nk_begin(...)) {
+            nk_menubar_begin(...);
+                nk_layout_xxxx(...);
+                nk_button(...);
+                nk_layout_xxxx(...);
+                nk_button(...);
+            nk_menubar_end(...);
+        }
+        nk_end(...);
+    */
     if (layout->flags & NK_WINDOW_HIDDEN || layout->flags & NK_WINDOW_MINIMIZED)
         return;