Nuklear
This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.
 
Loading...
Searching...
No Matches
Groups

=============================================================================

                            GROUP

=============================================================================

Groups are basically windows inside windows. They allow to subdivide space in a window to layout widgets as a group. Almost all more complex widget layouting requirements can be solved using groups and basic layouting fuctionality. Groups just like windows are identified by an unique name and internally keep track of scrollbar offsets by default. However additional versions are provided to directly manage the scrollbar.

Usage

To create a group you have to call one of the three nk_group_begin_xxx functions to start group declarations and nk_group_end at the end. Furthermore it is required to check the return value of nk_group_begin_xxx and only process widgets inside the window if the value is not 0. Nesting groups is possible and even encouraged since many layouting schemes can only be achieved by nesting. Groups, unlike windows, need nk_group_end to be only called if the corresponding nk_group_begin_xxx call does not return 0:

if (nk_group_begin_xxx(ctx, ...) {
// [... widgets ...]
}
NK_API void nk_group_end(struct nk_context *)

In the grand concept groups can be called after starting a window with nk_begin_xxx and before calling nk_end:

struct nk_context ctx;
nk_init_xxx(&ctx, ...);
while (1) {
// Input
Event evt;
while (GetEvent(&evt)) {
if (evt.type == MOUSE_MOVE)
nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
else if (evt.type == [...]) {
nk_input_xxx(...);
}
}
nk_input_end(&ctx);
//
// Window
if (nk_begin_xxx(...) {
// [...widgets...]
if (nk_group_begin_xxx(ctx, ...) {
//[... widgets ...]
}
}
nk_end(ctx);
//
// Draw
const struct nk_command *cmd = 0;
nk_foreach(cmd, &ctx) {
switch (cmd->type) {
case NK_COMMAND_LINE:
your_draw_line_function(...)
break;
case NK_COMMAND_RECT
your_draw_rect_function(...)
break;
case ...:
// [...]
}
nk_clear(&ctx);
}
nk_free(&ctx);
NK_API void nk_free(struct nk_context *)
Frees all memory allocated by nuklear; Not needed if context was initialized with nk_init_fixed.
NK_API void nk_input_end(struct nk_context *)
End the input mirroring process by resetting mouse grabbing state to ensure the mouse cursor is not g...
NK_API void nk_input_begin(struct nk_context *)
Begins the input mirroring process by resetting text, scroll mouse, previous mouse position and movem...
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Sets current row layout to share horizontal space between @cols number of widgets evenly.
#define nk_foreach(c, ctx)
Iterates over each draw command inside the context draw command list.
Definition nuklear.h:1031
NK_API void nk_input_motion(struct nk_context *, int x, int y)
Mirrors current mouse position to nuklear.
NK_API void nk_clear(struct nk_context *)
Resets the context state at the end of the frame.
NK_API void nk_end(struct nk_context *ctx)
command base and header of every command inside the buffer
Definition nuklear.h:4467

Reference

Function Description
nk_group_begin Start a new group with internal scrollbar handling
nk_group_begin_titled Start a new group with separated name and title and internal scrollbar handling
nk_group_end Ends a group. Should only be called if nk_group_begin returned non-zero
nk_group_scrolled_offset_begin Start a new group with manual separated handling of scrollbar x- and y-offset
nk_group_scrolled_begin Start a new group with manual scrollbar handling
nk_group_scrolled_end Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero
nk_group_get_scroll Gets the scroll offset for the given group
nk_group_set_scroll Sets the scroll offset for the given group