Make a window appear using Nuklear GUI library?

169 views Asked by At

Can someone help me make a Window appear using Nuklear GUI Library In C++ and on the window I want 2 buttons in the center one above another, and above the buttons I want an Image, and I want the background to be black. I also want it to have it's own custom title bar.

Here is an example on how I want it to look:

How UI Looks

I want the first button to open a new file

and I want the second one to also open a new file

here is my code:

/*Importing Packages*/
#include <stdio.h>
#include "Nuklear/src/nuklear.h"

int main() {

}
1

There are 1 answers

0
Joshk326 On

To create a custom window, you will need to init the nuklear GUI state.

struct nk_content ctx;
//Create a fixed window
nk_init_fixed(&ctx, calloc(1,MAX_MEMORY), MAX_MEMORY, &font);

Once your GUI state is initiated, you must create the window rect. To do so, you will have to begin the nuklear GUI and use nk_rect to draw a rectangle.

if(nk_begin(&ctx, "Title", nk_rect(x,y, width, height), NK_WINDOW_BORDER|NK_WINDOW_MOVEABLE|NK_WINDOW_CLOSABLE)){
   //This is where you will put the content in your window
}
nk_end(&ctx)

To create buttons, you must use the nk_button_label method, which will draw a button in your nk_content.

To view more information I recommend checking out the Nuklear GitHub page as it has plenty of examples that will help you create the design you want.