Giter VIP home page Giter VIP logo

Comments (6)

zoogies avatar zoogies commented on May 27, 2024 1

I think I understand what you are asking.

If you are talking about a top menu bar like this: (similar to vurtun/nuklear#308)
image
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*);

from nuklear.

altineller avatar altineller commented on May 27, 2024 1

Thank you that worked.

from nuklear.

quadroli avatar quadroli commented on May 27, 2024

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?

from nuklear.

zoogies avatar zoogies commented on May 27, 2024

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.

from nuklear.

altineller avatar altineller commented on May 27, 2024

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:

Screenshot from 2024-02-26 22-49-58

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.

from nuklear.

altineller avatar altineller commented on May 27, 2024

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.

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.

from nuklear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.