DeXP / nuklear_cross

Nuklear+ (read as "Nuklear cross") is a front-end overlay for Nuklear GUI library
https://nuklear-cross.dexp.in
163 stars 24 forks source link

Get Window Size #4

Open OetkenPurveyorOfCode opened 9 months ago

OetkenPurveyorOfCode commented 9 months ago

I do not like the window in a window approach that the example uses (If you get what I mean - there is a nuklear window inside a native OS window surrounded by some background color passed to nkc_render), so I disabled the nuklear window titlebar and wanted to size the nuklear window according to the native OS window around (so the background would never be seen). Does nuklear_cross provide a backend abstraction of getting the Window size? If not I might be willing to add a method to nuklear cross for getting the window size for some of the backends.

DeXP commented 9 months ago

Nope, just the function for desktop size.

NK_API int nkc_get_desktop_size(struct nkc* nkcHandle, int* width, int* height);

The idea behind this is - you are creating the window. You are passing width and height to it. So you already know the window's size.

NK_API struct nk_context *nkc_init(struct nkc* nkcHandle, const char* title, 
                            int width, int height, enum nkc_window_mode windowMode);
OetkenPurveyorOfCode commented 8 months ago

Well, the window is resizable, and to be clear, I want the window to be reiszable. So when the user resizes the window, it changes its size. Since I am on windows, I could get by with calling:

    RECT rect;
    if (GetWindowRect(myapp->nkcHandle->window, &rect)) {
        width = rect.right - rect.left;
        height = rect.bottom - rect.top;
    }

To get the window size and readjust the nk_rect in my mainloop, but I think a cross platform solution might be more desirable. (Or would you consider this outside the scope of this project, meaning you intend this project only for use in applications with non-resizable windows, (or resizable windows, but using nested nuklear's windows inside a resizable frame)).

DeXP commented 8 months ago

Aha. Thank you for the idea and Windows code. I'm not sure when I'll get back to Nuclear_cross. But I'll have the function in my TODO-list.