|
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.
|
The input API is responsible for holding the current input state composed of mouse, key and text input states.
It is worth noting that no direct OS or window handling is done in nuklear. Instead all input state has to be provided by platform specific code. This on one hand expects more work from the user and complicates usage but on the other hand provides simple abstraction over a big number of platforms, libraries and other already provided functionality.
Input state needs to be provided to nuklear by first calling nk_input_begin which resets internal state like delta mouse position and button transitions. After nk_input_begin all current input state needs to be provided. This includes mouse motion, button and key pressed and released, text input and scrolling. Both event- or state-based input handling are supported by this API and should work without problems. Finally after all input state has been mirrored nk_input_end needs to be called to finish input process.
| Function | Description |
|---|---|
| nk_input_begin | Begins the input mirroring process. Needs to be called before all other nk_input_xxx calls |
| nk_input_motion | Mirrors mouse cursor position |
| nk_input_key | Mirrors key state with either pressed or released |
| nk_input_button | Mirrors mouse button state with either pressed or released |
| nk_input_scroll | Mirrors mouse scroll values |
| nk_input_char | Adds a single ASCII text character into an internal text buffer |
| nk_input_glyph | Adds a single multi-byte UTF-8 character into an internal text buffer |
| nk_input_unicode | Adds a single unicode rune into an internal text buffer |
| nk_input_end | Ends the input mirroring process by calculating state changes. Don't call any nk_input_xxx function referenced above after this call |