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
Properties

Properties are the main value modification widgets in Nuklear.

Changing a value can be achieved by dragging, adding/removing incremental steps on button click or by directly typing a number.

Usage

Each property requires a unique name for identification that is also used for displaying a label. If you want to use the same name multiple times make sure add a '#' before your name. The '#' will not be shown but will generate a unique ID. Each property also takes in a minimum and maximum value. If you want to make use of the complete number range of a type just use the provided type limits from limits.h. For example INT_MIN and INT_MAX for nk_property_int and nk_propertyi. In additional each property takes in a increment value that will be added or subtracted if either the increment decrement button is clicked. Finally there is a value for increment per pixel dragged that is added or subtracted from the value.

int value = 0;
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(...) {
// Property
nk_property_int(ctx, "ID", INT_MIN, &value, INT_MAX, 1, 1);
}
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_property_int Integer property directly modifying a passed in value
nk_property_float Float property directly modifying a passed in value
nk_property_double Double property directly modifying a passed in value
nk_propertyi Integer property returning the modified int value
nk_propertyf Float property returning the modified float value
nk_propertyd Double property returning the modified double value

# nk_property_int

Integer property directly modifying a passed in value !!!

Warning
To generate a unique property ID using the same label make sure to insert a # at the beginning. It will not be shown but guarantees correct behavior.
void nk_property_int(struct nk_context *ctx, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
Parameter Description
Parameters
[in]ctx
Must point to an previously initialized nk_context struct after calling a layouting function
Parameters
[in]name
String used both as a label as well as a unique identifier
Parameters
[in]min
Minimum value not allowed to be underflown
Parameters
[in]val
Integer pointer to be modified
Parameters
[in]max
Maximum value not allowed to be overflown
Parameters
[in]step
Increment added and subtracted on increment and decrement button
Parameters
[in]inc_per_pixel
Value per pixel added or subtracted on dragging