瀏覽代碼

Version 1.04 with seperated window name and title

Added `nk_begin_titled` for seperated window name and title or cases
you need to keep persistent state between frames while changing
the window title.
vurtun 9 年之前
父節點
當前提交
c87a55cf56
共有 1 個文件被更改,包括 12 次插入3 次删除
  1. 12 3
      nuklear.h

+ 12 - 3
nuklear.h

@@ -1,5 +1,5 @@
 /*
 /*
- Nuklear - v1.03 - public domain
+ Nuklear - v1.031 - public domain
  no warrenty implied; use at your own risk.
  no warrenty implied; use at your own risk.
  authored from 2015-2016 by Micha Mettke
  authored from 2015-2016 by Micha Mettke
 
 
@@ -183,6 +183,7 @@ LICENSE:
     publish and distribute this file as you see fit.
     publish and distribute this file as you see fit.
 
 
 CHANGELOG:
 CHANGELOG:
+    - 2016/07/29 (1.031)- Added helper macros into header include guard
     - 2016/07/29 (1.03) - Moved the window/table pool into the header part to
     - 2016/07/29 (1.03) - Moved the window/table pool into the header part to
                             simplify memory management by removing the need to
                             simplify memory management by removing the need to
                             allocate the pool.
                             allocate the pool.
@@ -560,6 +561,7 @@ NK_API void                     nk_set_user_data(struct nk_context*, nk_handle h
 
 
 /* window */
 /* window */
 NK_API int                      nk_begin(struct nk_context*, struct nk_panel*, const char *title, struct nk_rect bounds, nk_flags flags);
 NK_API int                      nk_begin(struct nk_context*, struct nk_panel*, const char *title, struct nk_rect bounds, nk_flags flags);
+NK_API int                      nk_begin_titled(struct nk_context*, struct nk_panel*, const char *name, const char *id, struct nk_rect bounds, nk_flags flags);
 NK_API void                     nk_end(struct nk_context*);
 NK_API void                     nk_end(struct nk_context*);
 
 
 NK_API struct nk_window*        nk_window_find(struct nk_context *ctx, const char *name);
 NK_API struct nk_window*        nk_window_find(struct nk_context *ctx, const char *name);
@@ -15205,6 +15207,13 @@ nk_remove_window(struct nk_context *ctx, struct nk_window *win)
 NK_API int
 NK_API int
 nk_begin(struct nk_context *ctx, struct nk_panel *layout, const char *title,
 nk_begin(struct nk_context *ctx, struct nk_panel *layout, const char *title,
     struct nk_rect bounds, nk_flags flags)
     struct nk_rect bounds, nk_flags flags)
+{
+    return nk_begin_titled(ctx, layout, title, title, bounds, flags);
+}
+
+NK_API int
+nk_begin_titled(struct nk_context *ctx, struct nk_panel *layout,
+    const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
 {
 {
     struct nk_window *win;
     struct nk_window *win;
     struct nk_style *style;
     struct nk_style *style;
@@ -15220,8 +15229,8 @@ nk_begin(struct nk_context *ctx, struct nk_panel *layout, const char *title,
 
 
     /* find or create window */
     /* find or create window */
     style = &ctx->style;
     style = &ctx->style;
-    title_len = (int)nk_strlen(title);
-    title_hash = nk_murmur_hash(title, (int)title_len, NK_WINDOW_TITLE);
+    title_len = (int)nk_strlen(name);
+    title_hash = nk_murmur_hash(name, (int)title_len, NK_WINDOW_TITLE);
     win = nk_find_window(ctx, title_hash);
     win = nk_find_window(ctx, title_hash);
     if (!win) {
     if (!win) {
         /* create new window */
         /* create new window */