Closed altineller closed 7 months ago
You can make menu's ... but what do you mean by a file menu .. ? Do you mean the actual file picker popping up or just listing the file options on your UI?
A good start would probably be to check out Nuklear/demo/common/file_browser.c
. As far as I can tell the only example that uses it is Nuklear/demo/glfw_opengl2
with INCLUDE_FILE_BROWSER
defined.
You can make menu's ... but what do you mean by a file menu .. ? Do you mean the actual file picker popping up or just listing the file options on your UI?
I am sorry, I noticed you can make menu's, nice menus indeed, but by file menu I mean something like:
I was working with imgui with some modifications for my sdl scheme, then I realized there are more modern versions, and found out about Nuklear.
So the question is: How can I put a Menu's on the top of the main window, in a menu bar.
Best Regards, C.A.
A good start would probably be to check out
Nuklear/demo/common/file_browser.c
. As far as I can tell the only example that uses it isNuklear/demo/glfw_opengl2
withINCLUDE_FILE_BROWSER
defined.
Hello, I have looked over both glfw_opengl2/demo and Nuklear/demo/common/file_browser.c and found that they include examples to browse a file system, (which will be useful later on) - but was not able to find a file menu as I described. Best regards, C.A.
I think I understand what you are asking.
If you are talking about a top menu bar like this: (similar to https://github.com/vurtun/nuklear/issues/308)
you will want to look into nk_menubar_xxx
.
Searching for nk_menubar
or nk_menubar_begin
in the Nuklear repo should return some hits in some of the examples.
For a basic example (I haven't directly tested this), you could do something like this:
if (nk_begin(ctx, "Menubar", nk_rect(0, 0, WIDTH, HEIGHT), 0))
nk_menubar_begin(ctx);
/*
25 being the width of each item, and 1 specifying 1 item in the row
*/
nk_layout_row_begin(ctx, NK_STATIC, 25, 1);
/*
push the first item (the label in the menu bar)
*/
nk_layout_row_push(ctx, 45);
if (nk_menu_begin_label(ctx, "EXAMPLE", NK_TEXT_LEFT, nk_vec2(120, 200))) {
/*
The widgets you put in here will only show when your menu is opened
*/
nk_layout_row_dynamic(ctx, 25, 1);
if (nk_menu_item_label(ctx, "EXAMPLE DROPDOWN LABEL ITEM", NK_TEXT_LEFT)) {
// do something here when this menu option is clicked
}
nk_menu_end(ctx);
}
nk_menubar_end(ctx);
nk_end(ctx);
}
This should be enough to get you started, and if you need more reference I am using nk_menubar here in my own repo.
And just for your reference, here are the definitions from nuklear.h
/* =============================================================================
*
* MENU
*
* ============================================================================= */
NK_API void nk_menubar_begin(struct nk_context*);
NK_API void nk_menubar_end(struct nk_context*);
NK_API nk_bool nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_symbol_text(struct nk_context*, const char*, int,nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
NK_API nk_bool nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
NK_API nk_bool nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
NK_API nk_bool nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
NK_API nk_bool nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
NK_API nk_bool nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
NK_API nk_bool nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
NK_API nk_bool nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
NK_API void nk_menu_close(struct nk_context*);
NK_API void nk_menu_end(struct nk_context*);
Thank you that worked.
Hello,
Is there documentation or a way so I can make a file menu, like new, open, save using nuklear?
I see there is some sort of menu functionality in the code, but I could not find an example.
Best Regards, Can