Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
8.86k stars 535 forks source link

How to make own title bar, without using the operating systems #616

Closed altineller closed 3 months ago

altineller commented 4 months ago

Hello,

I would like to make a title bar such as:

Screenshot from 2024-02-28 18-26-39

The title bar is avoidable with glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); but then one would need to handle dragging and the minimize/maximize/close buttons on their own.

My question is: The menu bar being a nk_rect at top of the window created with:

nk_begin(ctx, "Menubar", nk_rect(0, 0, display_width, 40), 0);
nk_menubar_begin(ctx);

It has flags 0, so it is not moveable, and it contains the menubar_begin.

How can I make it that so when the user clicks and drags, the rectangle part will move the outer window, such as an operating system generated title bar would?

Best Regards, C.

RobLoach commented 4 months ago

While I haven't used it before, I heard that can be done with slice https://github.com/Immediate-Mode-UI/Nuklear/blob/8e5c9f7f345c7a7560f4538ffc42e7f1baff0f10/src/nuklear_9slice.c#L6

Axle-Ozz-i-sofT commented 4 months ago

Hi altineller If you are meaning the main rendering window with title bar and borders hidden... I am looking into this too (as well as transparency for the window canvas) on Allegro and SDL2. One option I am thinking about is to capture capture MOUSE_DOWN x.y over the NK title bar bounds (header) and use the x.y up, down. left, right to move the rendering window (Allegro) by the same amount obtained from the title bar. For this I would have to send the modified +/-x,+/-y to al_set_window_position(x, y); in Allegro during the drag.

There may be an easier way to do it but I can't see it in Alegro5 at the moment.

Best regards Axle

RobLoach commented 3 months ago

Depends on your platform. In SDL, I believe you can use SDL_NOFRAME, but I haven't tried it before. This is likely out of scope for the Nuklear renderers themselves though. More a renderer/platform thing.