aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ext/CMakeLists.txt4
-rw-r--r--tests/ext/nuklear.c1
-rw-r--r--tests/ext/nuklear.h9513
3 files changed, 5555 insertions, 3963 deletions
diff --git a/tests/ext/CMakeLists.txt b/tests/ext/CMakeLists.txt
index 501d9665..6a2dede1 100644
--- a/tests/ext/CMakeLists.txt
+++ b/tests/ext/CMakeLists.txt
@@ -89,3 +89,7 @@ file(COPY ${spineruntimes_dir}/examples/spineboy/export/spineboy.atlas DESTINATI
file(COPY ${spineruntimes_dir}/examples/spineboy/export/spineboy.png DESTINATION ${CMAKE_BINARY_DIR}/Debug)
add_library(nuklear nuklear.c)
+if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ # NOTE: must propagate to upstream includers
+ target_compile_options(nuklear PUBLIC /wd5287)
+endif()
diff --git a/tests/ext/nuklear.c b/tests/ext/nuklear.c
index 52712f32..431bc596 100644
--- a/tests/ext/nuklear.c
+++ b/tests/ext/nuklear.c
@@ -26,6 +26,7 @@
#pragma warning(disable:4127) // conditional expression is constant
#pragma warning(disable:4100) // unreferenced formal parameter
#pragma warning(disable:4701) // potentially uninitialized local variable used
+#pragma warning(disable:4116) // unnamed type definition in parentheses`
#endif
#include "nuklear.h"
#if defined(_MSC_VER)
diff --git a/tests/ext/nuklear.h b/tests/ext/nuklear.h
index 6855f6fa..71b55a24 100644
--- a/tests/ext/nuklear.h
+++ b/tests/ext/nuklear.h
@@ -1,224 +1,231 @@
/*
-/// # Nuklear
-/// ![](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif)
-///
-/// ## Contents
-/// 1. About section
-/// 2. Highlights section
-/// 3. Features section
-/// 4. Usage section
-/// 1. Flags section
-/// 2. Constants section
-/// 3. Dependencies section
-/// 5. Example section
-/// 6. API section
-/// 1. Context section
-/// 2. Input section
-/// 3. Drawing section
-/// 4. Window section
-/// 5. Layouting section
-/// 6. Groups section
-/// 7. Tree section
-/// 8. Properties section
-/// 7. License section
-/// 8. Changelog section
-/// 9. Gallery section
-/// 10. Credits section
-///
-/// ## About
-/// 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 renderbackend or OS window and input handling but instead provides a very modular
-/// library approach by using 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 only focuses on the actual UI.
-///
-/// ## Highlights
-/// - Graphical user interface toolkit
-/// - Single header library
-/// - Written in C89 (a.k.a. ANSI C or ISO C90)
-/// - Small codebase (~18kLOC)
-/// - Focus on portability, efficiency and simplicity
-/// - No dependencies (not even the standard library if not wanted)
-/// - Fully skinnable and customizable
-/// - Low memory footprint with total memory control if needed or wanted
-/// - UTF-8 support
-/// - No global or hidden state
-/// - Customizable library modules (you can compile and use only what you need)
-/// - Optional font baker and vertex buffer output
-///
-/// ## Features
-/// - Absolutely no platform dependent code
-/// - Memory management control ranging from/to
-/// - Ease of use by allocating everything from standard library
-/// - Control every byte of memory inside the library
-/// - Font handling control ranging from/to
-/// - Use your own font implementation for everything
-/// - Use this libraries internal font baking and handling API
-/// - Drawing output control ranging from/to
-/// - Simple shapes for more high level APIs which already have drawing capabilities
-/// - Hardware accessible anti-aliased vertex buffer output
-/// - Customizable colors and properties ranging from/to
-/// - Simple changes to color by filling a simple color table
-/// - Complete control with ability to use skinning to decorate widgets
-/// - Bendable UI library with widget ranging from/to
-/// - Basic widgets like buttons, checkboxes, slider, ...
-/// - Advanced widget like abstract comboboxes, contextual menus,...
-/// - Compile time configuration to only compile what you need
-/// - Subset which can be used if you do not want to link or use the standard library
-/// - Can be easily modified to only update on user input instead of frame updates
-///
-/// ## Usage
-/// This library is self contained in one single header file and can be used either
-/// in header only mode or in implementation mode. The header only mode is used
-/// by default when included and allows including this header in other headers
-/// and does not contain the actual implementation. <br /><br />
-///
-/// The implementation mode requires to define the preprocessor macro
-/// NK_IMPLEMENTATION in *one* .c/.cpp file before #includeing this file, e.g.:
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C
-/// #define NK_IMPLEMENTATION
-/// #include "nuklear.h"
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Also optionally define the symbols listed in the section "OPTIONAL DEFINES"
-/// below in header and implementation mode if you want to use additional functionality
-/// or need more control over the library.
-///
-/// !!! WARNING
-/// Every time nuklear is included define the same compiler flags. This very important not doing so could lead to compiler errors or even worse stack corruptions.
-///
-/// ### Flags
-/// Flag | Description
-/// --------------------------------|------------------------------------------
-/// NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation
-/// NK_INCLUDE_FIXED_TYPES | If defined it will include header `<stdint.h>` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself.
-/// NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `<stdlib.h>` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management.
-/// NK_INCLUDE_STANDARD_IO | If defined it will include header `<stdio.h>` and provide additional functions depending on file loading.
-/// NK_INCLUDE_STANDARD_VARARGS | If defined it will include header <stdarg.h> and provide additional functions depending on file loading.
-/// NK_INCLUDE_STANDARD_BOOL | If defined it will include header `<stdbool.h>` for nk_bool otherwise nuklear defines nk_bool as int.
-/// NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,...
-/// NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it.
-/// NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font
-/// NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
-/// NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
-/// NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
-/// NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit
-/// NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
-///
-/// !!! WARNING
-/// The following flags will pull in the standard C library:
-/// - NK_INCLUDE_DEFAULT_ALLOCATOR
-/// - NK_INCLUDE_STANDARD_IO
-/// - NK_INCLUDE_STANDARD_VARARGS
-///
-/// !!! WARNING
-/// The following flags if defined need to be defined for both header and implementation:
-/// - NK_INCLUDE_FIXED_TYPES
-/// - NK_INCLUDE_DEFAULT_ALLOCATOR
-/// - NK_INCLUDE_STANDARD_VARARGS
-/// - NK_INCLUDE_STANDARD_BOOL
-/// - NK_INCLUDE_VERTEX_BUFFER_OUTPUT
-/// - NK_INCLUDE_FONT_BAKING
-/// - NK_INCLUDE_DEFAULT_FONT
-/// - NK_INCLUDE_STANDARD_VARARGS
-/// - NK_INCLUDE_COMMAND_USERDATA
-/// - NK_UINT_DRAW_INDEX
-///
-/// ### Constants
-/// Define | Description
-/// --------------------------------|---------------------------------------
-/// NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it.
-/// NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string Under normal circumstances this should be more than sufficient.
-/// NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient.
-///
-/// !!! WARNING
-/// The following constants if defined need to be defined for both header and implementation:
-/// - NK_MAX_NUMBER_BUFFER
-/// - NK_BUFFER_DEFAULT_INITIAL_SIZE
-/// - NK_INPUT_MAX
-///
-/// ### Dependencies
-/// Function | Description
-/// ------------|---------------------------------------------------------------
-/// NK_ASSERT | If you don't define this, nuklear will use <assert.h> with assert().
-/// NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version.
-/// NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version.
-/// NK_SQRT | You can define this to 'sqrt' or your own sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version.
-/// NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation.
-/// NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation.
-/// NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
-/// NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
-/// NK_VSNPRINTF| If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe.
-///
-/// !!! WARNING
-/// The following dependencies will pull in the standard C library if not redefined:
-/// - NK_ASSERT
-///
-/// !!! WARNING
-/// The following dependencies if defined need to be defined for both header and implementation:
-/// - NK_ASSERT
-///
-/// !!! WARNING
-/// The following dependencies if defined need to be defined only for the implementation part:
-/// - NK_MEMSET
-/// - NK_MEMCPY
-/// - NK_SQRT
-/// - NK_SIN
-/// - NK_COS
-/// - NK_STRTOD
-/// - NK_DTOA
-/// - NK_VSNPRINTF
-///
-/// ## Example
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// // init gui state
-/// enum {EASY, HARD};
-/// static int op = EASY;
-/// static float value = 0.6f;
-/// static int i = 20;
-/// struct nk_context ctx;
-///
-/// nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
-/// if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
-/// NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
-/// // fixed widget pixel width
-/// nk_layout_row_static(&ctx, 30, 80, 1);
-/// if (nk_button_label(&ctx, "button")) {
-/// // event handling
-/// }
-///
-/// // fixed widget window ratio width
-/// nk_layout_row_dynamic(&ctx, 30, 2);
-/// if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
-/// if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
-///
-/// // custom widget pixel width
-/// nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
-/// {
-/// nk_layout_row_push(&ctx, 50);
-/// nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
-/// nk_layout_row_push(&ctx, 110);
-/// nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
-/// }
-/// nk_layout_row_end(&ctx);
-/// }
-/// nk_end(&ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// ![](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
-///
-/// ## API
-///
+# Nuklear
+![](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif)
+
+## Contents
+1. About section
+2. Highlights section
+3. Features section
+4. Usage section
+ 1. Flags section
+ 2. Constants section
+ 3. Dependencies section
+5. Example section
+6. API section
+ 1. Context section
+ 2. Input section
+ 3. Drawing section
+ 4. Window section
+ 5. Layouting section
+ 6. Groups section
+ 7. Tree section
+ 8. Properties section
+7. License section
+8. Changelog section
+9. Gallery section
+10. Credits section
+
+## About
+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 renderbackend or OS window and input handling but instead provides a very modular
+library approach by using 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 only focuses on the actual UI.
+
+## Highlights
+- Graphical user interface toolkit
+- Single header library
+- Written in C89 (a.k.a. ANSI C or ISO C90)
+- Small codebase (~18kLOC)
+- Focus on portability, efficiency and simplicity
+- No dependencies (not even the standard library if not wanted)
+- Fully skinnable and customizable
+- Low memory footprint with total memory control if needed or wanted
+- UTF-8 support
+- No global or hidden state
+- Customizable library modules (you can compile and use only what you need)
+- Optional font baker and vertex buffer output
+- [Code available on github](https://github.com/Immediate-Mode-UI/Nuklear/)
+
+## Features
+- Absolutely no platform dependent code
+- Memory management control ranging from/to
+ - Ease of use by allocating everything from standard library
+ - Control every byte of memory inside the library
+- Font handling control ranging from/to
+ - Use your own font implementation for everything
+ - Use this libraries internal font baking and handling API
+- Drawing output control ranging from/to
+ - Simple shapes for more high level APIs which already have drawing capabilities
+ - Hardware accessible anti-aliased vertex buffer output
+- Customizable colors and properties ranging from/to
+ - Simple changes to color by filling a simple color table
+ - Complete control with ability to use skinning to decorate widgets
+- Bendable UI library with widget ranging from/to
+ - Basic widgets like buttons, checkboxes, slider, ...
+ - Advanced widget like abstract comboboxes, contextual menus,...
+- Compile time configuration to only compile what you need
+ - Subset which can be used if you do not want to link or use the standard library
+- Can be easily modified to only update on user input instead of frame updates
+
+## Usage
+This library is self contained in one single header file and can be used either
+in header only mode or in implementation mode. The header only mode is used
+by default when included and allows including this header in other headers
+and does not contain the actual implementation. <br /><br />
+
+The implementation mode requires to define the preprocessor macro
+NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.:
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C
+ #define NK_IMPLEMENTATION
+ #include "nuklear.h"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Also optionally define the symbols listed in the section "OPTIONAL DEFINES"
+below in header and implementation mode if you want to use additional functionality
+or need more control over the library.
+
+!!! WARNING
+ Every time nuklear is included define the same compiler flags. This very important not doing so could lead to compiler errors or even worse stack corruptions.
+
+### Flags
+Flag | Description
+--------------------------------|------------------------------------------
+NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation
+NK_INCLUDE_FIXED_TYPES | If defined it will include header `<stdint.h>` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself.
+NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `<stdlib.h>` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management.
+NK_INCLUDE_STANDARD_IO | If defined it will include header `<stdio.h>` and provide additional functions depending on file loading.
+NK_INCLUDE_STANDARD_VARARGS | If defined it will include header <stdarg.h> and provide additional functions depending on file loading.
+NK_INCLUDE_STANDARD_BOOL | If defined it will include header `<stdbool.h>` for nk_bool otherwise nuklear defines nk_bool as int.
+NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,...
+NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it.
+NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font
+NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
+NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
+NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
+NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit
+NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
+NK_IS_WORD_BOUNDARY(c) | Define this to a function macro that takes a single nk_rune (nk_uint) and returns true if it's a word separator. If not defined, uses the default definition (see nk_is_word_boundary())
+
+!!! WARNING
+ The following flags will pull in the standard C library:
+ - NK_INCLUDE_DEFAULT_ALLOCATOR
+ - NK_INCLUDE_STANDARD_IO
+ - NK_INCLUDE_STANDARD_VARARGS
+
+!!! WARNING
+ The following flags if defined need to be defined for both header and implementation:
+ - NK_INCLUDE_FIXED_TYPES
+ - NK_INCLUDE_DEFAULT_ALLOCATOR
+ - NK_INCLUDE_STANDARD_VARARGS
+ - NK_INCLUDE_STANDARD_BOOL
+ - NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+ - NK_INCLUDE_FONT_BAKING
+ - NK_INCLUDE_DEFAULT_FONT
+ - NK_INCLUDE_STANDARD_VARARGS
+ - NK_INCLUDE_COMMAND_USERDATA
+ - NK_UINT_DRAW_INDEX
+
+### Constants
+Define | Description
+--------------------------------|---------------------------------------
+NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it.
+NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string Under normal circumstances this should be more than sufficient.
+NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient.
+
+!!! WARNING
+ The following constants if defined need to be defined for both header and implementation:
+ - NK_MAX_NUMBER_BUFFER
+ - NK_BUFFER_DEFAULT_INITIAL_SIZE
+ - NK_INPUT_MAX
+
+### Dependencies
+Function | Description
+------------|---------------------------------------------------------------
+NK_ASSERT | If you don't define this, nuklear will use <assert.h> with assert().
+NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version.
+NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version.
+NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version.
+NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation.
+NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation.
+NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
+NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
+NK_VSNPRINTF| If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe.
+
+!!! WARNING
+ The following dependencies will pull in the standard C library if not redefined:
+ - NK_ASSERT
+
+!!! WARNING
+ The following dependencies if defined need to be defined for both header and implementation:
+ - NK_ASSERT
+
+!!! WARNING
+ The following dependencies if defined need to be defined only for the implementation part:
+ - NK_MEMSET
+ - NK_MEMCPY
+ - NK_SQRT
+ - NK_SIN
+ - NK_COS
+ - NK_STRTOD
+ - NK_DTOA
+ - NK_VSNPRINTF
+
+## Example
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
+// init gui state
+enum {EASY, HARD};
+static int op = EASY;
+static float value = 0.6f;
+static int i = 20;
+struct nk_context ctx;
+
+nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
+if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
+ NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
+ // fixed widget pixel width
+ nk_layout_row_static(&ctx, 30, 80, 1);
+ if (nk_button_label(&ctx, "button")) {
+ // event handling
+ }
+
+ // fixed widget window ratio width
+ nk_layout_row_dynamic(&ctx, 30, 2);
+ if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
+ if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
+
+ // custom widget pixel width
+ nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
+ {
+ nk_layout_row_push(&ctx, 50);
+ nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
+ nk_layout_row_push(&ctx, 110);
+ nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
+ }
+ nk_layout_row_end(&ctx);
+}
+nk_end(&ctx);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+![](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
+
+## API
+
*/
#ifndef NK_SINGLE_FILE
#define NK_SINGLE_FILE
#endif
+/** \file nuklear.h
+ * \brief main API and documentation file
+ *
+ * \details
+ */
#ifndef NK_NUKLEAR_H_
#define NK_NUKLEAR_H_
@@ -232,9 +239,10 @@ extern "C" {
*
* ===============================================================
*/
+
#define NK_UNDEFINED (-1.0f)
-#define NK_UTF_INVALID 0xFFFD /* internal invalid utf8 rune */
-#define NK_UTF_SIZE 4 /* describes the number of bytes a glyph consists of*/
+#define NK_UTF_INVALID 0xFFFD /**< internal invalid utf8 rune */
+#define NK_UTF_SIZE 4 /**< describes the number of bytes a glyph consists of*/
#ifndef NK_INPUT_MAX
#define NK_INPUT_MAX 16
#endif
@@ -251,6 +259,7 @@ extern "C" {
*
* ===============================================================
*/
+
#ifndef NK_API
#ifdef NK_PRIVATE
#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
@@ -329,7 +338,7 @@ extern "C" {
*
* ===============================================================
*/
-#ifdef NK_INCLUDE_FIXED_TYPES
+ #ifdef NK_INCLUDE_FIXED_TYPES
#include <stdint.h>
#define NK_INT8 int8_t
#define NK_UINT8 uint8_t
@@ -372,7 +381,7 @@ extern "C" {
#elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
#define NK_SIZE_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
- #if defined(__x86_64__) || defined(__ppc64__)
+ #if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_SIZE_TYPE unsigned long
#else
#define NK_SIZE_TYPE unsigned int
@@ -387,7 +396,7 @@ extern "C" {
#elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
#define NK_POINTER_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
- #if defined(__x86_64__) || defined(__ppc64__)
+ #if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_POINTER_TYPE unsigned long
#else
#define NK_POINTER_TYPE unsigned int
@@ -403,7 +412,7 @@ extern "C" {
#include <stdbool.h>
#define NK_BOOL bool
#else
- #define NK_BOOL int /* could be char, use int for drop-in replacement backwards compatibility */
+ #define NK_BOOL int /**< could be char, use int for drop-in replacement backwards compatibility */
#endif
#endif
@@ -480,7 +489,8 @@ struct nk_rect {float x,y,w,h;};
struct nk_recti {short x,y,w,h;};
typedef char nk_glyph[NK_UTF_SIZE];
typedef union {void *ptr; int id;} nk_handle;
-struct nk_image {nk_handle handle;unsigned short w,h;unsigned short region[4];};
+struct nk_image {nk_handle handle; nk_ushort w, h; nk_ushort region[4];};
+struct nk_nine_slice {struct nk_image img; nk_ushort l, t, r, b;};
struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
struct nk_scroll {nk_uint x, y;};
@@ -522,6 +532,10 @@ enum nk_symbol_type {
NK_SYMBOL_TRIANGLE_RIGHT,
NK_SYMBOL_PLUS,
NK_SYMBOL_MINUS,
+ NK_SYMBOL_TRIANGLE_UP_OUTLINE,
+ NK_SYMBOL_TRIANGLE_DOWN_OUTLINE,
+ NK_SYMBOL_TRIANGLE_LEFT_OUTLINE,
+ NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE,
NK_SYMBOL_MAX
};
/* =============================================================================
@@ -529,159 +543,166 @@ enum nk_symbol_type {
* CONTEXT
*
* =============================================================================*/
-/*/// ### Context
-/// Contexts are the main entry point and the majestro of nuklear and contain all required state.
-/// They are used for window, memory, input, style, stack, commands and time management and need
-/// to be passed into all nuklear GUI specific functions.
-///
-/// #### Usage
-/// To use a context it first has to be initialized which can be achieved by calling
-/// one of either `nk_init_default`, `nk_init_fixed`, `nk_init`, `nk_init_custom`.
-/// Each takes in a font handle and a specific way of handling memory. Memory control
-/// hereby ranges from standard library to just specifying a fixed sized block of memory
-/// which nuklear has to manage itself from.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// // [...]
-/// nk_clear(&ctx);
-/// }
-/// nk_free(&ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// Function | Description
-/// --------------------|-------------------------------------------------------
-/// __nk_init_default__ | Initializes context with standard library memory allocation (malloc,free)
-/// __nk_init_fixed__ | Initializes context from single fixed size memory block
-/// __nk_init__ | Initializes context with memory allocator callbacks for alloc and free
-/// __nk_init_custom__ | Initializes context from two buffers. One for draw commands the other for window/panel/table allocations
-/// __nk_clear__ | Called at the end of the frame to reset and prepare the context for the next frame
-/// __nk_free__ | Shutdown and free all memory allocated inside the context
-/// __nk_set_user_data__| Utility function to pass user data to draw command
+/**
+ * \page Context
+ * Contexts are the main entry point and the majestro of nuklear and contain all required state.
+ * They are used for window, memory, input, style, stack, commands and time management and need
+ * to be passed into all nuklear GUI specific functions.
+ *
+ * # Usage
+ * To use a context it first has to be initialized which can be achieved by calling
+ * one of either `nk_init_default`, `nk_init_fixed`, `nk_init`, `nk_init_custom`.
+ * Each takes in a font handle and a specific way of handling memory. Memory control
+ * hereby ranges from standard library to just specifying a fixed sized block of memory
+ * which nuklear has to manage itself from.
+ *
+ * ```c
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * // [...]
+ * nk_clear(&ctx);
+ * }
+ * nk_free(&ctx);
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * --------------------|-------------------------------------------------------
+ * \ref nk_init_default | Initializes context with standard library memory allocation (malloc,free)
+ * \ref nk_init_fixed | Initializes context from single fixed size memory block
+ * \ref nk_init | Initializes context with memory allocator callbacks for alloc and free
+ * \ref nk_init_custom | Initializes context from two buffers. One for draw commands the other for window/panel/table allocations
+ * \ref nk_clear | Called at the end of the frame to reset and prepare the context for the next frame
+ * \ref nk_free | Shutdown and free all memory allocated inside the context
+ * \ref nk_set_user_data| Utility function to pass user data to draw command
*/
+
#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
-/*/// #### nk_init_default
-/// Initializes a `nk_context` struct with a default standard library allocator.
-/// Should be used if you don't want to be bothered with memory management in nuklear.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_init_default(struct nk_context *ctx, const struct nk_user_font *font);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|---------------------------------------------------------------
-/// __ctx__ | Must point to an either stack or heap allocated `nk_context` struct
-/// __font__ | Must point to a previously initialized font handle for more info look at font documentation
-///
-/// Returns either `false(0)` on failure or `true(1)` on success.
-///
-*/
+
+/**
+ * # nk_init_default
+ * Initializes a `nk_context` struct with a default standard library allocator.
+ * Should be used if you don't want to be bothered with memory management in nuklear.
+ *
+ * ```c
+ * nk_bool nk_init_default(struct nk_context *ctx, const struct nk_user_font *font);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|---------------------------------------------------------------
+ * \param[in] ctx | Must point to an either stack or heap allocated `nk_context` struct
+ * \param[in] font | Must point to a previously initialized font handle for more info look at font documentation
+ *
+ * \returns either `false(0)` on failure or `true(1)` on success.
+ */
NK_API nk_bool nk_init_default(struct nk_context*, const struct nk_user_font*);
#endif
-/*/// #### nk_init_fixed
-/// Initializes a `nk_context` struct from single fixed size memory block
-/// Should be used if you want complete control over nuklear's memory management.
-/// Especially recommended for system with little memory or systems with virtual memory.
-/// For the later case you can just allocate for example 16MB of virtual memory
-/// and only the required amount of memory will actually be committed.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_init_fixed(struct nk_context *ctx, void *memory, nk_size size, const struct nk_user_font *font);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// !!! Warning
-/// make sure the passed memory block is aligned correctly for `nk_draw_commands`.
-///
-/// Parameter | Description
-/// ------------|--------------------------------------------------------------
-/// __ctx__ | Must point to an either stack or heap allocated `nk_context` struct
-/// __memory__ | Must point to a previously allocated memory block
-/// __size__ | Must contain the total size of __memory__
-/// __font__ | Must point to a previously initialized font handle for more info look at font documentation
-///
-/// Returns either `false(0)` on failure or `true(1)` on success.
-*/
+/**
+ * # nk_init_fixed
+ * Initializes a `nk_context` struct from single fixed size memory block
+ * Should be used if you want complete control over nuklear's memory management.
+ * Especially recommended for system with little memory or systems with virtual memory.
+ * For the later case you can just allocate for example 16MB of virtual memory
+ * and only the required amount of memory will actually be committed.
+ *
+ * ```c
+ * nk_bool nk_init_fixed(struct nk_context *ctx, void *memory, nk_size size, const struct nk_user_font *font);
+ * ```
+ *
+ * !!! Warning
+ * make sure the passed memory block is aligned correctly for `nk_draw_commands`.
+ *
+ * Parameter | Description
+ * ------------|--------------------------------------------------------------
+ * \param[in] ctx | Must point to an either stack or heap allocated `nk_context` struct
+ * \param[in] memory | Must point to a previously allocated memory block
+ * \param[in] size | Must contain the total size of memory
+ * \param[in] font | Must point to a previously initialized font handle for more info look at font documentation
+ *
+ * \returns either `false(0)` on failure or `true(1)` on success.
+ */
NK_API nk_bool nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
-/*/// #### nk_init
-/// Initializes a `nk_context` struct with memory allocation callbacks for nuklear to allocate
-/// memory from. Used internally for `nk_init_default` and provides a kitchen sink allocation
-/// interface to nuklear. Can be useful for cases like monitoring memory consumption.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_init(struct nk_context *ctx, struct nk_allocator *alloc, const struct nk_user_font *font);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|---------------------------------------------------------------
-/// __ctx__ | Must point to an either stack or heap allocated `nk_context` struct
-/// __alloc__ | Must point to a previously allocated memory allocator
-/// __font__ | Must point to a previously initialized font handle for more info look at font documentation
-///
-/// Returns either `false(0)` on failure or `true(1)` on success.
-*/
-NK_API nk_bool nk_init(struct nk_context*, struct nk_allocator*, const struct nk_user_font*);
-/*/// #### nk_init_custom
-/// Initializes a `nk_context` struct from two different either fixed or growing
-/// buffers. The first buffer is for allocating draw commands while the second buffer is
-/// used for allocating windows, panels and state tables.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_init_custom(struct nk_context *ctx, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *font);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|---------------------------------------------------------------
-/// __ctx__ | Must point to an either stack or heap allocated `nk_context` struct
-/// __cmds__ | Must point to a previously initialized memory buffer either fixed or dynamic to store draw commands into
-/// __pool__ | Must point to a previously initialized memory buffer either fixed or dynamic to store windows, panels and tables
-/// __font__ | Must point to a previously initialized font handle for more info look at font documentation
-///
-/// Returns either `false(0)` on failure or `true(1)` on success.
-*/
+
+/**
+ * # nk_init
+ * Initializes a `nk_context` struct with memory allocation callbacks for nuklear to allocate
+ * memory from. Used internally for `nk_init_default` and provides a kitchen sink allocation
+ * interface to nuklear. Can be useful for cases like monitoring memory consumption.
+ *
+ * ```c
+ * nk_bool nk_init(struct nk_context *ctx, const struct nk_allocator *alloc, const struct nk_user_font *font);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|---------------------------------------------------------------
+ * \param[in] ctx | Must point to an either stack or heap allocated `nk_context` struct
+ * \param[in] alloc | Must point to a previously allocated memory allocator
+ * \param[in] font | Must point to a previously initialized font handle for more info look at font documentation
+ *
+ * \returns either `false(0)` on failure or `true(1)` on success.
+ */
+NK_API nk_bool nk_init(struct nk_context*, const struct nk_allocator*, const struct nk_user_font*);
+
+/**
+ * \brief Initializes a `nk_context` struct from two different either fixed or growing buffers.
+ *
+ * \details
+ * The first buffer is for allocating draw commands while the second buffer is
+ * used for allocating windows, panels and state tables.
+ *
+ * ```c
+ * nk_bool nk_init_custom(struct nk_context *ctx, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *font);
+ * ```
+ *
+ * \param[in] ctx Must point to an either stack or heap allocated `nk_context` struct
+ * \param[in] cmds Must point to a previously initialized memory buffer either fixed or dynamic to store draw commands into
+ * \param[in] pool Must point to a previously initialized memory buffer either fixed or dynamic to store windows, panels and tables
+ * \param[in] font Must point to a previously initialized font handle for more info look at font documentation
+ *
+ * \returns either `false(0)` on failure or `true(1)` on success.
+ */
NK_API nk_bool nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
-/*/// #### nk_clear
-/// Resets the context state at the end of the frame. This includes mostly
-/// garbage collector tasks like removing windows or table not called and therefore
-/// used anymore.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_clear(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-*/
+
+/**
+ * \brief Resets the context state at the end of the frame.
+ *
+ * \details
+ * This includes mostly garbage collector tasks like removing windows or table
+ * not called and therefore used anymore.
+ *
+ * ```c
+ * void nk_clear(struct nk_context *ctx);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ */
NK_API void nk_clear(struct nk_context*);
-/*/// #### nk_free
-/// Frees all memory allocated by nuklear. Not needed if context was
-/// initialized with `nk_init_fixed`.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_free(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-*/
+
+/**
+ * \brief Frees all memory allocated by nuklear; Not needed if context was initialized with `nk_init_fixed`.
+ *
+ * \details
+ * ```c
+ * void nk_free(struct nk_context *ctx);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ */
NK_API void nk_free(struct nk_context*);
+
#ifdef NK_INCLUDE_COMMAND_USERDATA
-/*/// #### nk_set_user_data
-/// Sets the currently passed userdata passed down into each draw command.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_set_user_data(struct nk_context *ctx, nk_handle data);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|--------------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __data__ | Handle with either pointer or index to be passed into every draw commands
-*/
+/**
+ * \brief Sets the currently passed userdata passed down into each draw command.
+ *
+ * \details
+ * ```c
+ * void nk_set_user_data(struct nk_context *ctx, nk_handle data);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ * \param[in] data Handle with either pointer or index to be passed into every draw commands
+ */
NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
#endif
/* =============================================================================
@@ -689,67 +710,70 @@ NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
* INPUT
*
* =============================================================================*/
-/*/// ### Input
-/// 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// nk_input_begin(&ctx);
-/// while (GetEvent(&evt)) {
-/// if (evt.type == MOUSE_MOVE)
-/// nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
-/// else if (evt.type == [...]) {
-/// // [...]
-/// }
-/// } nk_input_end(&ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Usage
-/// Input state needs to be provided to nuklear by first calling `nk_input_begin`
-/// which resets internal state like delta mouse position and button transistions.
-/// 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// Event evt;
-/// nk_input_begin(&ctx);
-/// while (GetEvent(&evt)) {
-/// if (evt.type == MOUSE_MOVE)
-/// nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
-/// else if (evt.type == [...]) {
-/// // [...]
-/// }
-/// }
-/// nk_input_end(&ctx);
-/// // [...]
-/// nk_clear(&ctx);
-/// } nk_free(&ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// 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
-*/
+/**
+ * \page Input
+ *
+ * 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.
+ *
+ * ```c
+ * nk_input_begin(&ctx);
+ * while (GetEvent(&evt)) {
+ * if (evt.type == MOUSE_MOVE)
+ * nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
+ * else if (evt.type == [...]) {
+ * // [...]
+ * }
+ * } nk_input_end(&ctx);
+ * ```
+ *
+ * # Usage
+ * 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.
+ *
+ * ```c
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * Event evt;
+ * nk_input_begin(&ctx);
+ * while (GetEvent(&evt)) {
+ * if (evt.type == MOUSE_MOVE)
+ * nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
+ * else if (evt.type == [...]) {
+ * // [...]
+ * }
+ * }
+ * nk_input_end(&ctx);
+ * // [...]
+ * nk_clear(&ctx);
+ * } nk_free(&ctx);
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * --------------------|-------------------------------------------------------
+ * \ref nk_input_begin | Begins the input mirroring process. Needs to be called before all other `nk_input_xxx` calls
+ * \ref nk_input_motion | Mirrors mouse cursor position
+ * \ref nk_input_key | Mirrors key state with either pressed or released
+ * \ref nk_input_button | Mirrors mouse button state with either pressed or released
+ * \ref nk_input_scroll | Mirrors mouse scroll values
+ * \ref nk_input_char | Adds a single ASCII text character into an internal text buffer
+ * \ref nk_input_glyph | Adds a single multi-byte UTF-8 character into an internal text buffer
+ * \ref nk_input_unicode| Adds a single unicode rune into an internal text buffer
+ * \ref 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
+ */
+
enum nk_keys {
NK_KEY_NONE,
NK_KEY_SHIFT,
@@ -792,371 +816,376 @@ enum nk_buttons {
NK_BUTTON_DOUBLE,
NK_BUTTON_MAX
};
-/*/// #### nk_input_begin
-/// Begins the input mirroring process by resetting text, scroll
-/// mouse, previous mouse position and movement as well as key state transitions,
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_begin(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-*/
+
+/**
+ * \brief Begins the input mirroring process by resetting text, scroll
+ * mouse, previous mouse position and movement as well as key state transitions.
+ *
+ * \details
+ * ```c
+ * void nk_input_begin(struct nk_context*);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ */
NK_API void nk_input_begin(struct nk_context*);
-/*/// #### nk_input_motion
-/// Mirrors current mouse position to nuklear
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_motion(struct nk_context *ctx, int x, int y);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __x__ | Must hold an integer describing the current mouse cursor x-position
-/// __y__ | Must hold an integer describing the current mouse cursor y-position
-*/
+
+/**
+ * \brief Mirrors current mouse position to nuklear
+ *
+ * \details
+ * ```c
+ * void nk_input_motion(struct nk_context *ctx, int x, int y);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ * \param[in] x Must hold an integer describing the current mouse cursor x-position
+ * \param[in] y Must hold an integer describing the current mouse cursor y-position
+ */
NK_API void nk_input_motion(struct nk_context*, int x, int y);
-/*/// #### nk_input_key
-/// Mirrors the state of a specific key to nuklear
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_key(struct nk_context*, enum nk_keys key, nk_bool down);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __key__ | Must be any value specified in enum `nk_keys` that needs to be mirrored
-/// __down__ | Must be 0 for key is up and 1 for key is down
-*/
+
+/**
+ * \brief Mirrors the state of a specific key to nuklear
+ *
+ * \details
+ * ```c
+ * void nk_input_key(struct nk_context*, enum nk_keys key, nk_bool down);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ * \param[in] key Must be any value specified in enum `nk_keys` that needs to be mirrored
+ * \param[in] down Must be 0 for key is up and 1 for key is down
+ */
NK_API void nk_input_key(struct nk_context*, enum nk_keys, nk_bool down);
-/*/// #### nk_input_button
-/// Mirrors the state of a specific mouse button to nuklear
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_button(struct nk_context *ctx, enum nk_buttons btn, int x, int y, nk_bool down);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __btn__ | Must be any value specified in enum `nk_buttons` that needs to be mirrored
-/// __x__ | Must contain an integer describing mouse cursor x-position on click up/down
-/// __y__ | Must contain an integer describing mouse cursor y-position on click up/down
-/// __down__ | Must be 0 for key is up and 1 for key is down
-*/
+
+/**
+ * \brief Mirrors the state of a specific mouse button to nuklear
+ *
+ * \details
+ * ```c
+ * void nk_input_button(struct nk_context *ctx, enum nk_buttons btn, int x, int y, nk_bool down);
+ * ```
+ *
+ * \param[in] ctx Must point to a previously initialized `nk_context` struct
+ * \param[in] btn Must be any value specified in enum `nk_buttons` that needs to be mirrored
+ * \param[in] x Must contain an integer describing mouse cursor x-position on click up/down
+ * \param[in] y Must contain an integer describing mouse cursor y-position on click up/down
+ * \param[in] down Must be 0 for key is up and 1 for key is down
+ */
NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, nk_bool down);
-/*/// #### nk_input_scroll
-/// Copies the last mouse scroll value to nuklear. Is generally
-/// a scroll value. So does not have to come from mouse and could also originate
-/// TODO finish this sentence
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_scroll(struct nk_context *ctx, struct nk_vec2 val);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __val__ | vector with both X- as well as Y-scroll value
-*/
+
+/**
+ * \brief Copies the last mouse scroll value to nuklear.
+ *
+ * \details
+ * Is generally a scroll value. So does not have to come from mouse and could
+ * also originate from balls, tracks, linear guide rails, or other programs.
+ *
+ * ```c
+ * void nk_input_scroll(struct nk_context *ctx, struct nk_vec2 val);
+ * ```
+ *
+ * \param[in] ctx | Must point to a previously initialized `nk_context` struct
+ * \param[in] val | vector with both X- as well as Y-scroll value
+ */
NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
-/*/// #### nk_input_char
-/// Copies a single ASCII character into an internal text buffer
-/// This is basically a helper function to quickly push ASCII characters into
-/// nuklear.
-///
-/// !!! Note
-/// Stores up to NK_INPUT_MAX bytes between `nk_input_begin` and `nk_input_end`.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_char(struct nk_context *ctx, char c);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __c__ | Must be a single ASCII character preferable one that can be printed
-*/
+
+/**
+ * \brief Copies a single ASCII character into an internal text buffer
+ *
+ * \details
+ * This is basically a helper function to quickly push ASCII characters into
+ * nuklear.
+ *
+ * \note
+ * Stores up to NK_INPUT_MAX bytes between `nk_input_begin` and `nk_input_end`.
+ *
+ * ```c
+ * void nk_input_char(struct nk_context *ctx, char c);
+ * ```
+ *
+ * \param[in] ctx | Must point to a previously initialized `nk_context` struct
+ * \param[in] c | Must be a single ASCII character preferable one that can be printed
+ */
NK_API void nk_input_char(struct nk_context*, char);
-/*/// #### nk_input_glyph
-/// Converts an encoded unicode rune into UTF-8 and copies the result into an
-/// internal text buffer.
-///
-/// !!! Note
-/// Stores up to NK_INPUT_MAX bytes between `nk_input_begin` and `nk_input_end`.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_glyph(struct nk_context *ctx, const nk_glyph g);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __g__ | UTF-32 unicode codepoint
-*/
+
+/**
+ * \brief Converts an encoded unicode rune into UTF-8 and copies the result into an
+ * internal text buffer.
+ *
+ * \note
+ * Stores up to NK_INPUT_MAX bytes between `nk_input_begin` and `nk_input_end`.
+ *
+ * ```c
+ * void nk_input_glyph(struct nk_context *ctx, const nk_glyph g);
+ * ```
+ *
+ * \param[in] ctx | Must point to a previously initialized `nk_context` struct
+ * \param[in] g | UTF-32 unicode codepoint
+ */
NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
-/*/// #### nk_input_unicode
-/// Converts a unicode rune into UTF-8 and copies the result
-/// into an internal text buffer.
-/// !!! Note
-/// Stores up to NK_INPUT_MAX bytes between `nk_input_begin` and `nk_input_end`.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_unicode(struct nk_context*, nk_rune rune);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-/// __rune__ | UTF-32 unicode codepoint
-*/
+
+/**
+ * \brief Converts a unicode rune into UTF-8 and copies the result
+ * into an internal text buffer.
+ *
+ * \details
+ * \note
+ * Stores up to NK_INPUT_MAX bytes between `nk_input_begin` and `nk_input_end`.
+ *
+ * ```c
+ * void nk_input_unicode(struct nk_context*, nk_rune rune);
+ * ```
+ *
+ * \param[in] ctx | Must point to a previously initialized `nk_context` struct
+ * \param[in] rune | UTF-32 unicode codepoint
+ */
NK_API void nk_input_unicode(struct nk_context*, nk_rune);
-/*/// #### nk_input_end
-/// End the input mirroring process by resetting mouse grabbing
-/// state to ensure the mouse cursor is not grabbed indefinitely.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_input_end(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to a previously initialized `nk_context` struct
-*/
+
+/**
+ * \brief End the input mirroring process by resetting mouse grabbing
+ * state to ensure the mouse cursor is not grabbed indefinitely.
+ *
+ * \details
+ * ```c
+ * void nk_input_end(struct nk_context *ctx);
+ * ```
+ *
+ * \param[in] ctx | Must point to a previously initialized `nk_context` struct
+ */
NK_API void nk_input_end(struct nk_context*);
-/* =============================================================================
+
+/** =============================================================================
*
* DRAWING
*
* =============================================================================*/
-/*/// ### Drawing
-/// This library was designed to be render backend agnostic so it does
-/// not draw anything to screen directly. Instead all drawn shapes, widgets
-/// are made of, are buffered into memory and make up a command queue.
-/// Each frame therefore fills the command buffer with draw commands
-/// that then need to be executed by the user and his own render backend.
-/// After that the command buffer needs to be cleared and a new frame can be
-/// started. It is probably important to note that the command buffer is the main
-/// drawing API and the optional vertex buffer API only takes this format and
-/// converts it into a hardware accessible format.
-///
-/// #### Usage
-/// To draw all draw commands accumulated over a frame you need your own render
-/// backend able to draw a number of 2D primitives. This includes at least
-/// filled and stroked rectangles, circles, text, lines, triangles and scissors.
-/// As soon as this criterion is met you can iterate over each draw command
-/// and execute each draw command in a interpreter like fashion:
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// 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 //...:
-/// //[...]
-/// }
-/// }
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// In program flow context draw commands need to be executed after input has been
-/// gathered and the complete UI with windows and their contained widgets have
-/// been executed and before calling `nk_clear` which frees all previously
-/// allocated draw commands.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// Event evt;
-/// nk_input_begin(&ctx);
-/// while (GetEvent(&evt)) {
-/// if (evt.type == MOUSE_MOVE)
-/// nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
-/// else if (evt.type == [...]) {
-/// [...]
-/// }
-/// }
-/// nk_input_end(&ctx);
-/// //
-/// // [...]
-/// //
-/// 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);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// You probably noticed that you have to draw all of the UI each frame which is
-/// quite wasteful. While the actual UI updating loop is quite fast rendering
-/// without actually needing it is not. So there are multiple things you could do.
-///
-/// First is only update on input. This of course is only an option if your
-/// application only depends on the UI and does not require any outside calculations.
-/// If you actually only update on input make sure to update the UI two times each
-/// frame and call `nk_clear` directly after the first pass and only draw in
-/// the second pass. In addition it is recommended to also add additional timers
-/// to make sure the UI is not drawn more than a fixed number of frames per second.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// // [...wait for input ]
-/// // [...do two UI passes ...]
-/// do_ui(...)
-/// nk_clear(&ctx);
-/// do_ui(...)
-/// //
-/// // 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);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// The second probably more applicable trick is to only draw if anything changed.
-/// It is not really useful for applications with continuous draw loop but
-/// quite useful for desktop applications. To actually get nuklear to only
-/// draw on changes you first have to define `NK_ZERO_COMMAND_MEMORY` and
-/// allocate a memory buffer that will store each unique drawing output.
-/// After each frame you compare the draw command memory inside the library
-/// with your allocated buffer by memcmp. If memcmp detects differences
-/// you have to copy the command buffer into the allocated buffer
-/// and then draw like usual (this example uses fixed memory but you could
-/// use dynamically allocated memory).
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// //[... other defines ...]
-/// #define NK_ZERO_COMMAND_MEMORY
-/// #include "nuklear.h"
-/// //
-/// // setup context
-/// struct nk_context ctx;
-/// void *last = calloc(1,64*1024);
-/// void *buf = calloc(1,64*1024);
-/// nk_init_fixed(&ctx, buf, 64*1024);
-/// //
-/// // loop
-/// while (1) {
-/// // [...input...]
-/// // [...ui...]
-/// void *cmds = nk_buffer_memory(&ctx.memory);
-/// if (memcmp(cmds, last, ctx.memory.allocated)) {
-/// memcpy(last,cmds,ctx.memory.allocated);
-/// 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);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Finally while using draw commands makes sense for higher abstracted platforms like
-/// X11 and Win32 or drawing libraries it is often desirable to use graphics
-/// hardware directly. Therefore it is possible to just define
-/// `NK_INCLUDE_VERTEX_BUFFER_OUTPUT` which includes optional vertex output.
-/// To access the vertex output you first have to convert all draw commands into
-/// vertexes by calling `nk_convert` which takes in your preferred vertex format.
-/// After successfully converting all draw commands just iterate over and execute all
-/// vertex draw commands:
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// // fill configuration
-/// struct your_vertex
-/// {
-/// float pos[2]; // important to keep it to 2 floats
-/// float uv[2];
-/// unsigned char col[4];
-/// };
-/// struct nk_convert_config cfg = {};
-/// static const struct nk_draw_vertex_layout_element vertex_layout[] = {
-/// {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)},
-/// {NK_VERTEX_TEXCOORD, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, uv)},
-/// {NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct your_vertex, col)},
-/// {NK_VERTEX_LAYOUT_END}
-/// };
-/// cfg.shape_AA = NK_ANTI_ALIASING_ON;
-/// cfg.line_AA = NK_ANTI_ALIASING_ON;
-/// cfg.vertex_layout = vertex_layout;
-/// cfg.vertex_size = sizeof(struct your_vertex);
-/// cfg.vertex_alignment = NK_ALIGNOF(struct your_vertex);
-/// cfg.circle_segment_count = 22;
-/// cfg.curve_segment_count = 22;
-/// cfg.arc_segment_count = 22;
-/// cfg.global_alpha = 1.0f;
-/// cfg.null = dev->null;
-/// //
-/// // setup buffers and convert
-/// struct nk_buffer cmds, verts, idx;
-/// nk_buffer_init_default(&cmds);
-/// nk_buffer_init_default(&verts);
-/// nk_buffer_init_default(&idx);
-/// nk_convert(&ctx, &cmds, &verts, &idx, &cfg);
-/// //
-/// // draw
-/// nk_draw_foreach(cmd, &ctx, &cmds) {
-/// if (!cmd->elem_count) continue;
-/// //[...]
-/// }
-/// nk_buffer_free(&cms);
-/// nk_buffer_free(&verts);
-/// nk_buffer_free(&idx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// Function | Description
-/// --------------------|-------------------------------------------------------
-/// __nk__begin__ | Returns the first draw command in the context draw command list to be drawn
-/// __nk__next__ | Increments the draw command iterator to the next command inside the context draw command list
-/// __nk_foreach__ | Iterates over each draw command inside the context draw command list
-/// __nk_convert__ | Converts from the abstract draw commands list into a hardware accessible vertex format
-/// __nk_draw_begin__ | Returns the first vertex command in the context vertex draw list to be executed
-/// __nk__draw_next__ | Increments the vertex command iterator to the next command inside the context vertex command list
-/// __nk__draw_end__ | Returns the end of the vertex draw list
-/// __nk_draw_foreach__ | Iterates over each vertex draw command inside the vertex draw list
-*/
+/**
+ * \page Drawing
+ * This library was designed to be render backend agnostic so it does
+ * not draw anything to screen directly. Instead all drawn shapes, widgets
+ * are made of, are buffered into memory and make up a command queue.
+ * Each frame therefore fills the command buffer with draw commands
+ * that then need to be executed by the user and his own render backend.
+ * After that the command buffer needs to be cleared and a new frame can be
+ * started. It is probably important to note that the command buffer is the main
+ * drawing API and the optional vertex buffer API only takes this format and
+ * converts it into a hardware accessible format.
+ *
+ * # Usage
+ * To draw all draw commands accumulated over a frame you need your own render
+ * backend able to draw a number of 2D primitives. This includes at least
+ * filled and stroked rectangles, circles, text, lines, triangles and scissors.
+ * As soon as this criterion is met you can iterate over each draw command
+ * and execute each draw command in a interpreter like fashion:
+ *
+ * ```c
+ * 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 //...:
+ * //[...]
+ * }
+ * }
+ * ```
+ *
+ * In program flow context draw commands need to be executed after input has been
+ * gathered and the complete UI with windows and their contained widgets have
+ * been executed and before calling `nk_clear` which frees all previously
+ * allocated draw commands.
+ *
+ * ```c
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * Event evt;
+ * nk_input_begin(&ctx);
+ * while (GetEvent(&evt)) {
+ * if (evt.type == MOUSE_MOVE)
+ * nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
+ * else if (evt.type == [...]) {
+ * [...]
+ * }
+ * }
+ * nk_input_end(&ctx);
+ * //
+ * // [...]
+ * //
+ * 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);
+ * ```
+ *
+ * You probably noticed that you have to draw all of the UI each frame which is
+ * quite wasteful. While the actual UI updating loop is quite fast rendering
+ * without actually needing it is not. So there are multiple things you could do.
+ *
+ * First is only update on input. This of course is only an option if your
+ * application only depends on the UI and does not require any outside calculations.
+ * If you actually only update on input make sure to update the UI two times each
+ * frame and call `nk_clear` directly after the first pass and only draw in
+ * the second pass. In addition it is recommended to also add additional timers
+ * to make sure the UI is not drawn more than a fixed number of frames per second.
+ *
+ * ```c
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * // [...wait for input ]
+ * // [...do two UI passes ...]
+ * do_ui(...)
+ * nk_clear(&ctx);
+ * do_ui(...)
+ * //
+ * // 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);
+ * ```
+ *
+ * The second probably more applicable trick is to only draw if anything changed.
+ * It is not really useful for applications with continuous draw loop but
+ * quite useful for desktop applications. To actually get nuklear to only
+ * draw on changes you first have to define `NK_ZERO_COMMAND_MEMORY` and
+ * allocate a memory buffer that will store each unique drawing output.
+ * After each frame you compare the draw command memory inside the library
+ * with your allocated buffer by memcmp. If memcmp detects differences
+ * you have to copy the command buffer into the allocated buffer
+ * and then draw like usual (this example uses fixed memory but you could
+ * use dynamically allocated memory).
+ *
+ * ```c
+ * //[... other defines ...]
+ * #define NK_ZERO_COMMAND_MEMORY
+ * #include "nuklear.h"
+ * //
+ * // setup context
+ * struct nk_context ctx;
+ * void *last = calloc(1,64*1024);
+ * void *buf = calloc(1,64*1024);
+ * nk_init_fixed(&ctx, buf, 64*1024);
+ * //
+ * // loop
+ * while (1) {
+ * // [...input...]
+ * // [...ui...]
+ * void *cmds = nk_buffer_memory(&ctx.memory);
+ * if (memcmp(cmds, last, ctx.memory.allocated)) {
+ * memcpy(last,cmds,ctx.memory.allocated);
+ * 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);
+ * ```
+ *
+ * Finally while using draw commands makes sense for higher abstracted platforms like
+ * X11 and Win32 or drawing libraries it is often desirable to use graphics
+ * hardware directly. Therefore it is possible to just define
+ * `NK_INCLUDE_VERTEX_BUFFER_OUTPUT` which includes optional vertex output.
+ * To access the vertex output you first have to convert all draw commands into
+ * vertexes by calling `nk_convert` which takes in your preferred vertex format.
+ * After successfully converting all draw commands just iterate over and execute all
+ * vertex draw commands:
+ *
+ * ```c
+ * // fill configuration
+ * struct your_vertex
+ * {
+ * float pos[2]; // important to keep it to 2 floats
+ * float uv[2];
+ * unsigned char col[4];
+ * };
+ * struct nk_convert_config cfg = {};
+ * static const struct nk_draw_vertex_layout_element vertex_layout[] = {
+ * {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)},
+ * {NK_VERTEX_TEXCOORD, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, uv)},
+ * {NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct your_vertex, col)},
+ * {NK_VERTEX_LAYOUT_END}
+ * };
+ * cfg.shape_AA = NK_ANTI_ALIASING_ON;
+ * cfg.line_AA = NK_ANTI_ALIASING_ON;
+ * cfg.vertex_layout = vertex_layout;
+ * cfg.vertex_size = sizeof(struct your_vertex);
+ * cfg.vertex_alignment = NK_ALIGNOF(struct your_vertex);
+ * cfg.circle_segment_count = 22;
+ * cfg.curve_segment_count = 22;
+ * cfg.arc_segment_count = 22;
+ * cfg.global_alpha = 1.0f;
+ * cfg.tex_null = dev->tex_null;
+ * //
+ * // setup buffers and convert
+ * struct nk_buffer cmds, verts, idx;
+ * nk_buffer_init_default(&cmds);
+ * nk_buffer_init_default(&verts);
+ * nk_buffer_init_default(&idx);
+ * nk_convert(&ctx, &cmds, &verts, &idx, &cfg);
+ * //
+ * // draw
+ * nk_draw_foreach(cmd, &ctx, &cmds) {
+ * if (!cmd->elem_count) continue;
+ * //[...]
+ * }
+ * nk_buffer_free(&cms);
+ * nk_buffer_free(&verts);
+ * nk_buffer_free(&idx);
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * --------------------|-------------------------------------------------------
+ * \ref nk__begin | Returns the first draw command in the context draw command list to be drawn
+ * \ref nk__next | Increments the draw command iterator to the next command inside the context draw command list
+ * \ref nk_foreach | Iterates over each draw command inside the context draw command list
+ * \ref nk_convert | Converts from the abstract draw commands list into a hardware accessible vertex format
+ * \ref nk_draw_begin | Returns the first vertex command in the context vertex draw list to be executed
+ * \ref nk__draw_next | Increments the vertex command iterator to the next command inside the context vertex command list
+ * \ref nk__draw_end | Returns the end of the vertex draw list
+ * \ref nk_draw_foreach | Iterates over each vertex draw command inside the vertex draw list
+ */
+
enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
enum nk_convert_result {
NK_CONVERT_SUCCESS = 0,
@@ -1166,305 +1195,315 @@ enum nk_convert_result {
NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
};
struct nk_draw_null_texture {
- nk_handle texture; /* texture handle to a texture with a white pixel */
- struct nk_vec2 uv; /* coordinates to a white pixel in the texture */
+ nk_handle texture; /**!< texture handle to a texture with a white pixel */
+ struct nk_vec2 uv; /**!< coordinates to a white pixel in the texture */
};
struct nk_convert_config {
- float global_alpha; /* global alpha value */
- enum nk_anti_aliasing line_AA; /* line anti-aliasing flag can be turned off if you are tight on memory */
- enum nk_anti_aliasing shape_AA; /* shape anti-aliasing flag can be turned off if you are tight on memory */
- unsigned circle_segment_count; /* number of segments used for circles: default to 22 */
- unsigned arc_segment_count; /* number of segments used for arcs: default to 22 */
- unsigned curve_segment_count; /* number of segments used for curves: default to 22 */
- struct nk_draw_null_texture null; /* handle to texture with a white pixel for shape drawing */
- const struct nk_draw_vertex_layout_element *vertex_layout; /* describes the vertex output format and packing */
- nk_size vertex_size; /* sizeof one vertex for vertex packing */
- nk_size vertex_alignment; /* vertex alignment: Can be obtained by NK_ALIGNOF */
+ float global_alpha; /**!< global alpha value */
+ enum nk_anti_aliasing line_AA; /**!< line anti-aliasing flag can be turned off if you are tight on memory */
+ enum nk_anti_aliasing shape_AA; /**!< shape anti-aliasing flag can be turned off if you are tight on memory */
+ unsigned circle_segment_count; /**!< number of segments used for circles: default to 22 */
+ unsigned arc_segment_count; /**!< number of segments used for arcs: default to 22 */
+ unsigned curve_segment_count; /**!< number of segments used for curves: default to 22 */
+ struct nk_draw_null_texture tex_null; /**!< handle to texture with a white pixel for shape drawing */
+ const struct nk_draw_vertex_layout_element *vertex_layout; /**!< describes the vertex output format and packing */
+ nk_size vertex_size; /**!< sizeof one vertex for vertex packing */
+ nk_size vertex_alignment; /**!< vertex alignment: Can be obtained by NK_ALIGNOF */
};
-/*/// #### nk__begin
-/// Returns a draw command list iterator to iterate all draw
-/// commands accumulated over one frame.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// const struct nk_command* nk__begin(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | must point to an previously initialized `nk_context` struct at the end of a frame
-///
-/// Returns draw command pointer pointing to the first command inside the draw command list
-*/
+
+/**
+ * \brief Returns a draw command list iterator to iterate all draw
+ * commands accumulated over one frame.
+ *
+ * \details
+ * ```c
+ * const struct nk_command* nk__begin(struct nk_context*);
+ * ```
+ *
+ * \param[in] ctx | must point to an previously initialized `nk_context` struct at the end of a frame
+ *
+ * \returns draw command pointer pointing to the first command inside the draw command list
+ */
NK_API const struct nk_command* nk__begin(struct nk_context*);
-/*/// #### nk__next
-/// Returns draw command pointer pointing to the next command inside the draw command list
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-/// __cmd__ | Must point to an previously a draw command either returned by `nk__begin` or `nk__next`
-///
-/// Returns draw command pointer pointing to the next command inside the draw command list
-*/
+
+/**
+ * \brief Returns draw command pointer pointing to the next command inside the draw command list
+ *
+ * \details
+ * ```c
+ * const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct at the end of a frame
+ * \param[in] cmd | Must point to an previously a draw command either returned by `nk__begin` or `nk__next`
+ *
+ * \returns draw command pointer pointing to the next command inside the draw command list
+ */
NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
-/*/// #### nk_foreach
-/// Iterates over each draw command inside the context draw command list
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// #define nk_foreach(c, ctx)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-/// __cmd__ | Command pointer initialized to NULL
-///
-/// Iterates over each draw command inside the context draw command list
-*/
+
+/**
+ * \brief Iterates over each draw command inside the context draw command list
+ *
+ * ```c
+ * #define nk_foreach(c, ctx)
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct at the end of a frame
+ * \param[in] cmd | Command pointer initialized to NULL
+ */
#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
+
#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
-/*/// #### nk_convert
-/// Converts all internal draw commands into vertex draw commands and fills
-/// three buffers with vertexes, vertex draw commands and vertex indices. The vertex format
-/// as well as some other configuration values have to be configured by filling out a
-/// `nk_convert_config` struct.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// nk_flags nk_convert(struct nk_context *ctx, struct nk_buffer *cmds,
-/// struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-/// __cmds__ | Must point to a previously initialized buffer to hold converted vertex draw commands
-/// __vertices__| Must point to a previously initialized buffer to hold all produced vertices
-/// __elements__| Must point to a previously initialized buffer to hold all produced vertex indices
-/// __config__ | Must point to a filled out `nk_config` struct to configure the conversion process
-///
-/// Returns one of enum nk_convert_result error codes
-///
-/// Parameter | Description
-/// --------------------------------|-----------------------------------------------------------
-/// NK_CONVERT_SUCCESS | Signals a successful draw command to vertex buffer conversion
-/// NK_CONVERT_INVALID_PARAM | An invalid argument was passed in the function call
-/// NK_CONVERT_COMMAND_BUFFER_FULL | The provided buffer for storing draw commands is full or failed to allocate more memory
-/// NK_CONVERT_VERTEX_BUFFER_FULL | The provided buffer for storing vertices is full or failed to allocate more memory
-/// NK_CONVERT_ELEMENT_BUFFER_FULL | The provided buffer for storing indicies is full or failed to allocate more memory
-*/
+
+/**
+ * \brief Converts all internal draw commands into vertex draw commands and fills
+ * three buffers with vertexes, vertex draw commands and vertex indices.
+ *
+ * \details
+ * The vertex format as well as some other configuration values have to be
+ * configured by filling out a `nk_convert_config` struct.
+ *
+ * ```c
+ * nk_flags nk_convert(struct nk_context *ctx, struct nk_buffer *cmds,
+ * struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
+ * ```
+ *
+ * \param[in] ctx Must point to an previously initialized `nk_context` struct at the end of a frame
+ * \param[out] cmds Must point to a previously initialized buffer to hold converted vertex draw commands
+ * \param[out] vertices Must point to a previously initialized buffer to hold all produced vertices
+ * \param[out] elements Must point to a previously initialized buffer to hold all produced vertex indices
+ * \param[in] config Must point to a filled out `nk_config` struct to configure the conversion process
+ *
+ * \returns one of enum nk_convert_result error codes
+ *
+ * Parameter | Description
+ * --------------------------------|-----------------------------------------------------------
+ * NK_CONVERT_SUCCESS | Signals a successful draw command to vertex buffer conversion
+ * NK_CONVERT_INVALID_PARAM | An invalid argument was passed in the function call
+ * NK_CONVERT_COMMAND_BUFFER_FULL | The provided buffer for storing draw commands is full or failed to allocate more memory
+ * NK_CONVERT_VERTEX_BUFFER_FULL | The provided buffer for storing vertices is full or failed to allocate more memory
+ * NK_CONVERT_ELEMENT_BUFFER_FULL | The provided buffer for storing indices is full or failed to allocate more memory
+ */
NK_API nk_flags nk_convert(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
-/*/// #### nk__draw_begin
-/// Returns a draw vertex command buffer iterator to iterate over the vertex draw command buffer
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-/// __buf__ | Must point to an previously by `nk_convert` filled out vertex draw command buffer
-///
-/// Returns vertex draw command pointer pointing to the first command inside the vertex draw command buffer
-*/
+
+/**
+ * \brief Returns a draw vertex command buffer iterator to iterate over the vertex draw command buffer
+ *
+ * \details
+ * ```c
+ * const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct at the end of a frame
+ * \param[in] buf | Must point to an previously by `nk_convert` filled out vertex draw command buffer
+ *
+ * \returns vertex draw command pointer pointing to the first command inside the vertex draw command buffer
+ */
NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
-/*/// #### nk__draw_end
-/// Returns the vertex draw command at the end of the vertex draw command buffer
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// const struct nk_draw_command* nk__draw_end(const struct nk_context *ctx, const struct nk_buffer *buf);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-/// __buf__ | Must point to an previously by `nk_convert` filled out vertex draw command buffer
-///
-/// Returns vertex draw command pointer pointing to the end of the last vertex draw command inside the vertex draw command buffer
-*/
+
+/**
+
+ * # # nk__draw_end
+ * \returns the vertex draw command at the end of the vertex draw command buffer
+ *
+ * ```c
+ * const struct nk_draw_command* nk__draw_end(const struct nk_context *ctx, const struct nk_buffer *buf);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct at the end of a frame
+ * \param[in] buf | Must point to an previously by `nk_convert` filled out vertex draw command buffer
+ *
+ * \returns vertex draw command pointer pointing to the end of the last vertex draw command inside the vertex draw command buffer
+
+ */
NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
-/*/// #### nk__draw_next
-/// Increments the vertex draw command buffer iterator
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __cmd__ | Must point to an previously either by `nk__draw_begin` or `nk__draw_next` returned vertex draw command
-/// __buf__ | Must point to an previously by `nk_convert` filled out vertex draw command buffer
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-///
-/// Returns vertex draw command pointer pointing to the end of the last vertex draw command inside the vertex draw command buffer
-*/
+
+/**
+ * # # nk__draw_next
+ * Increments the vertex draw command buffer iterator
+ *
+ * ```c
+ * const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] cmd | Must point to an previously either by `nk__draw_begin` or `nk__draw_next` returned vertex draw command
+ * \param[in] buf | Must point to an previously by `nk_convert` filled out vertex draw command buffer
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct at the end of a frame
+ *
+ * \returns vertex draw command pointer pointing to the end of the last vertex draw command inside the vertex draw command buffer
+
+ */
NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
-/*/// #### nk_draw_foreach
-/// Iterates over each vertex draw command inside a vertex draw command buffer
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// #define nk_draw_foreach(cmd,ctx, b)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __cmd__ | `nk_draw_command`iterator set to NULL
-/// __buf__ | Must point to an previously by `nk_convert` filled out vertex draw command buffer
-/// __ctx__ | Must point to an previously initialized `nk_context` struct at the end of a frame
-*/
+
+/**
+ * # # nk_draw_foreach
+ * Iterates over each vertex draw command inside a vertex draw command buffer
+ *
+ * ```c
+ * #define nk_draw_foreach(cmd,ctx, b)
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] cmd | `nk_draw_command`iterator set to NULL
+ * \param[in] buf | Must point to an previously by `nk_convert` filled out vertex draw command buffer
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct at the end of a frame
+ */
+
#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
#endif
-/* =============================================================================
+
+/** =============================================================================
*
* WINDOW
*
- * =============================================================================
-/// ### Window
-/// Windows are the main persistent state used inside nuklear and are life time
-/// controlled by simply "retouching" (i.e. calling) each window each frame.
-/// All widgets inside nuklear can only be added inside the function pair `nk_begin_xxx`
-/// and `nk_end`. Calling any widgets outside these two functions will result in an
-/// assert in debug or no state change in release mode.<br /><br />
-///
-/// Each window holds frame persistent state like position, size, flags, state tables,
-/// and some garbage collected internal persistent widget state. Each window
-/// is linked into a window stack list which determines the drawing and overlapping
-/// order. The topmost window thereby is the currently active window.<br /><br />
-///
-/// To change window position inside the stack occurs either automatically by
-/// user input by being clicked on or programmatically by calling `nk_window_focus`.
-/// Windows by default are visible unless explicitly being defined with flag
-/// `NK_WINDOW_HIDDEN`, the user clicked the close button on windows with flag
-/// `NK_WINDOW_CLOSABLE` or if a window was explicitly hidden by calling
-/// `nk_window_show`. To explicitly close and destroy a window call `nk_window_close`.<br /><br />
-///
-/// #### Usage
-/// To create and keep a window you have to call one of the two `nk_begin_xxx`
-/// functions to start window declarations and `nk_end` at the end. Furthermore it
-/// is recommended to check the return value of `nk_begin_xxx` and only process
-/// widgets inside the window if the value is not 0. Either way you have to call
-/// `nk_end` at the end of window declarations. Furthermore, do not attempt to
-/// nest `nk_begin_xxx` calls which will hopefully result in an assert or if not
-/// in a segmentation fault.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // [... widgets ...]
-/// }
-/// nk_end(ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// In the grand concept window and widget declarations need to occur after input
-/// handling and before drawing to screen. Not doing so can result in higher
-/// latency or at worst invalid behavior. Furthermore make sure that `nk_clear`
-/// is called at the end of the frame. While nuklear's default platform backends
-/// already call `nk_clear` for you if you write your own backend not calling
-/// `nk_clear` can cause asserts or even worse undefined behavior.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// Event evt;
-/// nk_input_begin(&ctx);
-/// 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);
-///
-/// if (nk_begin_xxx(...) {
-/// //[...]
-/// }
-/// nk_end(ctx);
-///
-/// const struct nk_command *cmd = 0;
-/// nk_foreach(cmd, &ctx) {
-/// 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);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// Function | Description
-/// ------------------------------------|----------------------------------------
-/// nk_begin | Starts a new window; needs to be called every frame for every window (unless hidden) or otherwise the window gets removed
-/// nk_begin_titled | Extended window start with separated title and identifier to allow multiple windows with same name but not title
-/// nk_end | Needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup
-//
-/// nk_window_find | Finds and returns the window with give name
-/// nk_window_get_bounds | Returns a rectangle with screen position and size of the currently processed window.
-/// nk_window_get_position | Returns the position of the currently processed window
-/// nk_window_get_size | Returns the size with width and height of the currently processed window
-/// nk_window_get_width | Returns the width of the currently processed window
-/// nk_window_get_height | Returns the height of the currently processed window
-/// nk_window_get_panel | Returns the underlying panel which contains all processing state of the current window
-/// nk_window_get_content_region | Returns the position and size of the currently visible and non-clipped space inside the currently processed window
-/// nk_window_get_content_region_min | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
-/// nk_window_get_content_region_max | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
-/// nk_window_get_content_region_size | Returns the size of the currently visible and non-clipped space inside the currently processed window
-/// nk_window_get_canvas | Returns the draw command buffer. Can be used to draw custom widgets
-/// nk_window_get_scroll | Gets the scroll offset of the current window
-/// nk_window_has_focus | Returns if the currently processed window is currently active
-/// nk_window_is_collapsed | Returns if the window with given name is currently minimized/collapsed
-/// nk_window_is_closed | Returns if the currently processed window was closed
-/// nk_window_is_hidden | Returns if the currently processed window was hidden
-/// nk_window_is_active | Same as nk_window_has_focus for some reason
-/// nk_window_is_hovered | Returns if the currently processed window is currently being hovered by mouse
-/// nk_window_is_any_hovered | Return if any window currently hovered
-/// nk_item_is_any_active | Returns if any window or widgets is currently hovered or active
+ * =============================================================================*/
+/**
+ * \page Window
+ * Windows are the main persistent state used inside nuklear and are life time
+ * controlled by simply "retouching" (i.e. calling) each window each frame.
+ * All widgets inside nuklear can only be added inside the function pair `nk_begin_xxx`
+ * and `nk_end`. Calling any widgets outside these two functions will result in an
+ * assert in debug or no state change in release mode.<br /><br />
+ *
+ * Each window holds frame persistent state like position, size, flags, state tables,
+ * and some garbage collected internal persistent widget state. Each window
+ * is linked into a window stack list which determines the drawing and overlapping
+ * order. The topmost window thereby is the currently active window.<br /><br />
+ *
+ * To change window position inside the stack occurs either automatically by
+ * user input by being clicked on or programmatically by calling `nk_window_focus`.
+ * Windows by default are visible unless explicitly being defined with flag
+ * `NK_WINDOW_HIDDEN`, the user clicked the close button on windows with flag
+ * `NK_WINDOW_CLOSABLE` or if a window was explicitly hidden by calling
+ * `nk_window_show`. To explicitly close and destroy a window call `nk_window_close`.<br /><br />
+ *
+ * # Usage
+ * To create and keep a window you have to call one of the two `nk_begin_xxx`
+ * functions to start window declarations and `nk_end` at the end. Furthermore it
+ * is recommended to check the return value of `nk_begin_xxx` and only process
+ * widgets inside the window if the value is not 0. Either way you have to call
+ * `nk_end` at the end of window declarations. Furthermore, do not attempt to
+ * nest `nk_begin_xxx` calls which will hopefully result in an assert or if not
+ * in a segmentation fault.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // [... widgets ...]
+ * }
+ * nk_end(ctx);
+ * ```
+ *
+ * In the grand concept window and widget declarations need to occur after input
+ * handling and before drawing to screen. Not doing so can result in higher
+ * latency or at worst invalid behavior. Furthermore make sure that `nk_clear`
+ * is called at the end of the frame. While nuklear's default platform backends
+ * already call `nk_clear` for you if you write your own backend not calling
+ * `nk_clear` can cause asserts or even worse undefined behavior.
+ *
+ * ```c
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * Event evt;
+ * nk_input_begin(&ctx);
+ * 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);
+ *
+ * if (nk_begin_xxx(...) {
+ * //[...]
+ * }
+ * nk_end(ctx);
+ *
+ * const struct nk_command *cmd = 0;
+ * nk_foreach(cmd, &ctx) {
+ * 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);
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * ------------------------------------|----------------------------------------
+ * \ref nk_begin | Starts a new window; needs to be called every frame for every window (unless hidden) or otherwise the window gets removed
+ * \ref nk_begin_titled | Extended window start with separated title and identifier to allow multiple windows with same name but not title
+ * \ref nk_end | Needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup
+ *
+ * \ref nk_window_find | Finds and returns the window with give name
+ * \ref nk_window_get_bounds | Returns a rectangle with screen position and size of the currently processed window.
+ * \ref nk_window_get_position | Returns the position of the currently processed window
+ * \ref nk_window_get_size | Returns the size with width and height of the currently processed window
+ * \ref nk_window_get_width | Returns the width of the currently processed window
+ * \ref nk_window_get_height | Returns the height of the currently processed window
+ * \ref nk_window_get_panel | Returns the underlying panel which contains all processing state of the current window
+ * \ref nk_window_get_content_region | Returns the position and size of the currently visible and non-clipped space inside the currently processed window
+ * \ref nk_window_get_content_region_min | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
+ * \ref nk_window_get_content_region_max | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
+ * \ref nk_window_get_content_region_size | Returns the size of the currently visible and non-clipped space inside the currently processed window
+ * \ref nk_window_get_canvas | Returns the draw command buffer. Can be used to draw custom widgets
+ * \ref nk_window_get_scroll | Gets the scroll offset of the current window
+ * \ref nk_window_has_focus | Returns if the currently processed window is currently active
+ * \ref nk_window_is_collapsed | Returns if the window with given name is currently minimized/collapsed
+ * \ref nk_window_is_closed | Returns if the currently processed window was closed
+ * \ref nk_window_is_hidden | Returns if the currently processed window was hidden
+ * \ref nk_window_is_active | Same as nk_window_has_focus for some reason
+ * \ref nk_window_is_hovered | Returns if the currently processed window is currently being hovered by mouse
+ * \ref nk_window_is_any_hovered | Return if any window currently hovered
+ * \ref nk_item_is_any_active | Returns if any window or widgets is currently hovered or active
//
-/// nk_window_set_bounds | Updates position and size of the currently processed window
-/// nk_window_set_position | Updates position of the currently process window
-/// nk_window_set_size | Updates the size of the currently processed window
-/// nk_window_set_focus | Set the currently processed window as active window
-/// nk_window_set_scroll | Sets the scroll offset of the current window
+ * \ref nk_window_set_bounds | Updates position and size of the currently processed window
+ * \ref nk_window_set_position | Updates position of the currently process window
+ * \ref nk_window_set_size | Updates the size of the currently processed window
+ * \ref nk_window_set_focus | Set the currently processed window as active window
+ * \ref nk_window_set_scroll | Sets the scroll offset of the current window
//
-/// nk_window_close | Closes the window with given window name which deletes the window at the end of the frame
-/// nk_window_collapse | Collapses the window with given window name
-/// nk_window_collapse_if | Collapses the window with given window name if the given condition was met
-/// nk_window_show | Hides a visible or reshows a hidden window
-/// nk_window_show_if | Hides/shows a window depending on condition
-*/
-/*
-/// #### nk_panel_flags
-/// Flag | Description
-/// ----------------------------|----------------------------------------
-/// NK_WINDOW_BORDER | Draws a border around the window to visually separate window from the background
-/// NK_WINDOW_MOVABLE | The movable flag indicates that a window can be moved by user input or by dragging the window header
-/// NK_WINDOW_SCALABLE | The scalable flag indicates that a window can be scaled by user input by dragging a scaler icon at the button of the window
-/// NK_WINDOW_CLOSABLE | Adds a closable icon into the header
-/// NK_WINDOW_MINIMIZABLE | Adds a minimize icon into the header
-/// NK_WINDOW_NO_SCROLLBAR | Removes the scrollbar from the window
-/// NK_WINDOW_TITLE | Forces a header at the top at the window showing the title
-/// NK_WINDOW_SCROLL_AUTO_HIDE | Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame
-/// NK_WINDOW_BACKGROUND | Always keep window in the background
-/// NK_WINDOW_SCALE_LEFT | Puts window scaler in the left-bottom corner instead right-bottom
-/// NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focus
-///
-/// #### nk_collapse_states
-/// State | Description
-/// ----------------|-----------------------------------------------------------
-/// __NK_MINIMIZED__| UI section is collased and not visibile until maximized
-/// __NK_MAXIMIZED__| UI section is extended and visibile until minimized
-/// <br /><br />
-*/
+ * \ref nk_window_close | Closes the window with given window name which deletes the window at the end of the frame
+ * \ref nk_window_collapse | Collapses the window with given window name
+ * \ref nk_window_collapse_if | Collapses the window with given window name if the given condition was met
+ * \ref nk_window_show | Hides a visible or reshows a hidden window
+ * \ref nk_window_show_if | Hides/shows a window depending on condition
+
+ * # nk_panel_flags
+ * Flag | Description
+ * ----------------------------|----------------------------------------
+ * NK_WINDOW_BORDER | Draws a border around the window to visually separate window from the background
+ * NK_WINDOW_MOVABLE | The movable flag indicates that a window can be moved by user input or by dragging the window header
+ * NK_WINDOW_SCALABLE | The scalable flag indicates that a window can be scaled by user input by dragging a scaler icon at the button of the window
+ * NK_WINDOW_CLOSABLE | Adds a closable icon into the header
+ * NK_WINDOW_MINIMIZABLE | Adds a minimize icon into the header
+ * NK_WINDOW_NO_SCROLLBAR | Removes the scrollbar from the window
+ * NK_WINDOW_TITLE | Forces a header at the top at the window showing the title
+ * NK_WINDOW_SCROLL_AUTO_HIDE | Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame
+ * NK_WINDOW_BACKGROUND | Always keep window in the background
+ * NK_WINDOW_SCALE_LEFT | Puts window scaler in the left-bottom corner instead right-bottom
+ * NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focus
+ *
+ * # nk_collapse_states
+ * State | Description
+ * ----------------|-----------------------------------------------------------
+ * NK_MINIMIZED| UI section is collapsed and not visible until maximized
+ * NK_MAXIMIZED| UI section is extended and visible until minimized
+ */
+
enum nk_panel_flags {
NK_WINDOW_BORDER = NK_FLAG(0),
NK_WINDOW_MOVABLE = NK_FLAG(1),
@@ -1478,1555 +1517,1761 @@ enum nk_panel_flags {
NK_WINDOW_SCALE_LEFT = NK_FLAG(9),
NK_WINDOW_NO_INPUT = NK_FLAG(10)
};
-/*/// #### nk_begin
-/// Starts a new window; needs to be called every frame for every
-/// window (unless hidden) or otherwise the window gets removed
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __title__ | Window title and identifier. Needs to be persistent over frames to identify the window
-/// __bounds__ | Initial position and window size. However if you do not define `NK_WINDOW_SCALABLE` or `NK_WINDOW_MOVABLE` you can set window position and size every frame
-/// __flags__ | Window flags defined in the nk_panel_flags section with a number of different window behaviors
-///
-/// Returns `true(1)` if the window can be filled up with widgets from this point
-/// until `nk_end` or `false(0)` otherwise for example if minimized
-*/
+
+/**
+ * # # nk_begin
+ * Starts a new window; needs to be called every frame for every
+ * window (unless hidden) or otherwise the window gets removed
+ *
+ * ```c
+ * nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] title | Window title and identifier. Needs to be persistent over frames to identify the window
+ * \param[in] bounds | Initial position and window size. However if you do not define `NK_WINDOW_SCALABLE` or `NK_WINDOW_MOVABLE` you can set window position and size every frame
+ * \param[in] flags | Window flags defined in the nk_panel_flags section with a number of different window behaviors
+ *
+ * \returns `true(1)` if the window can be filled up with widgets from this point
+ * until `nk_end` or `false(0)` otherwise for example if minimized
+
+ */
NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
-/*/// #### nk_begin_titled
-/// Extended window start with separated title and identifier to allow multiple
-/// windows with same title but not name
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Window identifier. Needs to be persistent over frames to identify the window
-/// __title__ | Window title displayed inside header if flag `NK_WINDOW_TITLE` or either `NK_WINDOW_CLOSABLE` or `NK_WINDOW_MINIMIZED` was set
-/// __bounds__ | Initial position and window size. However if you do not define `NK_WINDOW_SCALABLE` or `NK_WINDOW_MOVABLE` you can set window position and size every frame
-/// __flags__ | Window flags defined in the nk_panel_flags section with a number of different window behaviors
-///
-/// Returns `true(1)` if the window can be filled up with widgets from this point
-/// until `nk_end` or `false(0)` otherwise for example if minimized
-*/
+
+/**
+ * # # nk_begin_titled
+ * Extended window start with separated title and identifier to allow multiple
+ * windows with same title but not name
+ *
+ * ```c
+ * nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Window identifier. Needs to be persistent over frames to identify the window
+ * \param[in] title | Window title displayed inside header if flag `NK_WINDOW_TITLE` or either `NK_WINDOW_CLOSABLE` or `NK_WINDOW_MINIMIZED` was set
+ * \param[in] bounds | Initial position and window size. However if you do not define `NK_WINDOW_SCALABLE` or `NK_WINDOW_MOVABLE` you can set window position and size every frame
+ * \param[in] flags | Window flags defined in the nk_panel_flags section with a number of different window behaviors
+ *
+ * \returns `true(1)` if the window can be filled up with widgets from this point
+ * until `nk_end` or `false(0)` otherwise for example if minimized
+
+ */
NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
-/*/// #### nk_end
-/// Needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup.
-/// All widget calls after this functions will result in asserts or no state changes
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_end(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-*/
+
+/**
+ * # # nk_end
+ * Needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup.
+ * All widget calls after this functions will result in asserts or no state changes
+ *
+ * ```c
+ * void nk_end(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+
+ */
NK_API void nk_end(struct nk_context *ctx);
-/*/// #### nk_window_find
-/// Finds and returns a window from passed name
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_window *nk_window_find(struct nk_context *ctx, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Window identifier
-///
-/// Returns a `nk_window` struct pointing to the identified window or NULL if
-/// no window with the given name was found
-*/
-NK_API struct nk_window *nk_window_find(struct nk_context *ctx, const char *name);
-/*/// #### nk_window_get_bounds
-/// Returns a rectangle with screen position and size of the currently processed window
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns a `nk_rect` struct with window upper left window position and size
-*/
+
+/**
+ * # # nk_window_find
+ * Finds and returns a window from passed name
+ *
+ * ```c
+ * struct nk_window *nk_window_find(struct nk_context *ctx, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Window identifier
+ *
+ * \returns a `nk_window` struct pointing to the identified window or NULL if
+ * no window with the given name was found
+ */
+NK_API struct nk_window *nk_window_find(const struct nk_context *ctx, const char *name);
+
+/**
+ * # # nk_window_get_bounds
+ * \returns a rectangle with screen position and size of the currently processed window
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns a `nk_rect` struct with window upper left window position and size
+
+ */
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
-/*/// #### nk_window_get_position
-/// Returns the position of the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns a `nk_vec2` struct with window upper left position
-*/
+
+/**
+ * # # nk_window_get_position
+ * \returns the position of the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns a `nk_vec2` struct with window upper left position
+
+ */
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
-/*/// #### nk_window_get_size
-/// Returns the size with width and height of the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns a `nk_vec2` struct with window width and height
-*/
-NK_API struct nk_vec2 nk_window_get_size(const struct nk_context*);
-/*/// #### nk_window_get_width
-/// Returns the width of the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// float nk_window_get_width(const struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns the current window width
-*/
-NK_API float nk_window_get_width(const struct nk_context*);
-/*/// #### nk_window_get_height
-/// Returns the height of the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// float nk_window_get_height(const struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns the current window height
-*/
-NK_API float nk_window_get_height(const struct nk_context*);
-/*/// #### nk_window_get_panel
-/// Returns the underlying panel which contains all processing state of the current window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// !!! WARNING
-/// Do not keep the returned panel pointer around, it is only valid until `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_panel* nk_window_get_panel(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns a pointer to window internal `nk_panel` state.
-*/
-NK_API struct nk_panel* nk_window_get_panel(struct nk_context*);
-/*/// #### nk_window_get_content_region
-/// Returns the position and size of the currently visible and non-clipped space
-/// inside the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_rect nk_window_get_content_region(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `nk_rect` struct with screen position and size (no scrollbar offset)
-/// of the visible space inside the current window
-*/
-NK_API struct nk_rect nk_window_get_content_region(struct nk_context*);
-/*/// #### nk_window_get_content_region_min
-/// Returns the upper left position of the currently visible and non-clipped
-/// space inside the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_window_get_content_region_min(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// returns `nk_vec2` struct with upper left screen position (no scrollbar offset)
-/// of the visible space inside the current window
-*/
-NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context*);
-/*/// #### nk_window_get_content_region_max
-/// Returns the lower right screen position of the currently visible and
-/// non-clipped space inside the currently processed window.
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_window_get_content_region_max(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `nk_vec2` struct with lower right screen position (no scrollbar offset)
-/// of the visible space inside the current window
-*/
-NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context*);
-/*/// #### nk_window_get_content_region_size
-/// Returns the size of the currently visible and non-clipped space inside the
-/// currently processed window
-///
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_window_get_content_region_size(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `nk_vec2` struct with size the visible space inside the current window
-*/
-NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context*);
-/*/// #### nk_window_get_canvas
-/// Returns the draw command buffer. Can be used to draw custom widgets
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// !!! WARNING
-/// Do not keep the returned command buffer pointer around it is only valid until `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_command_buffer* nk_window_get_canvas(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns a pointer to window internal `nk_command_buffer` struct used as
-/// drawing canvas. Can be used to do custom drawing.
-*/
-NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
-/*/// #### nk_window_get_scroll
-/// Gets the scroll offset for the current window
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// -------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __offset_x__ | A pointer to the x offset output (or NULL to ignore)
-/// __offset_y__ | A pointer to the y offset output (or NULL to ignore)
-*/
-NK_API void nk_window_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
-/*/// #### nk_window_has_focus
-/// Returns if the currently processed window is currently active
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_has_focus(const struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `false(0)` if current window is not active or `true(1)` if it is
-*/
-NK_API nk_bool nk_window_has_focus(const struct nk_context*);
-/*/// #### nk_window_is_hovered
-/// Return if the current window is being hovered
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_is_hovered(struct nk_context *ctx);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `true(1)` if current window is hovered or `false(0)` otherwise
-*/
-NK_API nk_bool nk_window_is_hovered(struct nk_context*);
-/*/// #### nk_window_is_collapsed
-/// Returns if the window with given name is currently minimized/collapsed
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_is_collapsed(struct nk_context *ctx, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of window you want to check if it is collapsed
-///
-/// Returns `true(1)` if current window is minimized and `false(0)` if window not
-/// found or is not minimized
-*/
-NK_API nk_bool nk_window_is_collapsed(struct nk_context *ctx, const char *name);
-/*/// #### nk_window_is_closed
-/// Returns if the window with given name was closed by calling `nk_close`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_is_closed(struct nk_context *ctx, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of window you want to check if it is closed
-///
-/// Returns `true(1)` if current window was closed or `false(0)` window not found or not closed
-*/
-NK_API nk_bool nk_window_is_closed(struct nk_context*, const char*);
-/*/// #### nk_window_is_hidden
-/// Returns if the window with given name is hidden
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_is_hidden(struct nk_context *ctx, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of window you want to check if it is hidden
-///
-/// Returns `true(1)` if current window is hidden or `false(0)` window not found or visible
-*/
-NK_API nk_bool nk_window_is_hidden(struct nk_context*, const char*);
-/*/// #### nk_window_is_active
-/// Same as nk_window_has_focus for some reason
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_is_active(struct nk_context *ctx, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of window you want to check if it is active
-///
-/// Returns `true(1)` if current window is active or `false(0)` window not found or not active
-*/
-NK_API nk_bool nk_window_is_active(struct nk_context*, const char*);
-/*/// #### nk_window_is_any_hovered
-/// Returns if the any window is being hovered
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_window_is_any_hovered(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `true(1)` if any window is hovered or `false(0)` otherwise
-*/
-NK_API nk_bool nk_window_is_any_hovered(struct nk_context*);
-/*/// #### nk_item_is_any_active
-/// Returns if the any window is being hovered or any widget is currently active.
-/// Can be used to decide if input should be processed by UI or your specific input handling.
-/// Example could be UI and 3D camera to move inside a 3D space.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_item_is_any_active(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-///
-/// Returns `true(1)` if any window is hovered or any item is active or `false(0)` otherwise
-*/
-NK_API nk_bool nk_item_is_any_active(struct nk_context*);
-/*/// #### nk_window_set_bounds
-/// Updates position and size of window with passed in name
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_set_bounds(struct nk_context*, const char *name, struct nk_rect bounds);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to modify both position and size
-/// __bounds__ | Must point to a `nk_rect` struct with the new position and size
-*/
-NK_API void nk_window_set_bounds(struct nk_context*, const char *name, struct nk_rect bounds);
-/*/// #### nk_window_set_position
-/// Updates position of window with passed name
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_set_position(struct nk_context*, const char *name, struct nk_vec2 pos);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to modify both position
-/// __pos__ | Must point to a `nk_vec2` struct with the new position
-*/
-NK_API void nk_window_set_position(struct nk_context*, const char *name, struct nk_vec2 pos);
-/*/// #### nk_window_set_size
-/// Updates size of window with passed in name
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_set_size(struct nk_context*, const char *name, struct nk_vec2);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to modify both window size
-/// __size__ | Must point to a `nk_vec2` struct with new window size
-*/
-NK_API void nk_window_set_size(struct nk_context*, const char *name, struct nk_vec2);
-/*/// #### nk_window_set_focus
-/// Sets the window with given name as active
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_set_focus(struct nk_context*, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to set focus on
-*/
-NK_API void nk_window_set_focus(struct nk_context*, const char *name);
-/*/// #### nk_window_set_scroll
-/// Sets the scroll offset for the current window
-/// !!! WARNING
-/// Only call this function between calls `nk_begin_xxx` and `nk_end`
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// -------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __offset_x__ | The x offset to scroll to
-/// __offset_y__ | The y offset to scroll to
-*/
-NK_API void nk_window_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
-/*/// #### nk_window_close
-/// Closes a window and marks it for being freed at the end of the frame
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_close(struct nk_context *ctx, const char *name);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to close
-*/
+
+/**
+ * # # nk_window_get_size
+ * \returns the size with width and height of the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns a `nk_vec2` struct with window width and height
+
+ */
+NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
+
+/**
+ * nk_window_get_width
+ * \returns the width of the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * float nk_window_get_width(const struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns the current window width
+ */
+NK_API float nk_window_get_width(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_get_height
+ * \returns the height of the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * float nk_window_get_height(const struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns the current window height
+
+ */
+NK_API float nk_window_get_height(const struct nk_context* ctx);
+
+/**
+ * # # nk_window_get_panel
+ * \returns the underlying panel which contains all processing state of the current window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * !!! \warning
+ * Do not keep the returned panel pointer around, it is only valid until `nk_end`
+ * ```c
+ * struct nk_panel* nk_window_get_panel(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns a pointer to window internal `nk_panel` state.
+
+ */
+NK_API struct nk_panel* nk_window_get_panel(const struct nk_context* ctx);
+
+/**
+ * # # nk_window_get_content_region
+ * \returns the position and size of the currently visible and non-clipped space
+ * inside the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ *
+ * ```c
+ * struct nk_rect nk_window_get_content_region(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `nk_rect` struct with screen position and size (no scrollbar offset)
+ * of the visible space inside the current window
+
+ */
+NK_API struct nk_rect nk_window_get_content_region(const struct nk_context* ctx);
+
+/**
+ * # # nk_window_get_content_region_min
+ * \returns the upper left position of the currently visible and non-clipped
+ * space inside the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ *
+ * ```c
+ * struct nk_vec2 nk_window_get_content_region_min(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * returns `nk_vec2` struct with upper left screen position (no scrollbar offset)
+ * of the visible space inside the current window
+
+ */
+NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_get_content_region_max
+ * \returns the lower right screen position of the currently visible and
+ * non-clipped space inside the currently processed window.
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ *
+ * ```c
+ * struct nk_vec2 nk_window_get_content_region_max(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `nk_vec2` struct with lower right screen position (no scrollbar offset)
+ * of the visible space inside the current window
+
+ */
+NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_get_content_region_size
+ * \returns the size of the currently visible and non-clipped space inside the
+ * currently processed window
+ *
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ *
+ * ```c
+ * struct nk_vec2 nk_window_get_content_region_size(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `nk_vec2` struct with size the visible space inside the current window
+
+ */
+NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_get_canvas
+ * \returns the draw command buffer. Can be used to draw custom widgets
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * !!! \warning
+ * Do not keep the returned command buffer pointer around it is only valid until `nk_end`
+ *
+ * ```c
+ * struct nk_command_buffer* nk_window_get_canvas(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns a pointer to window internal `nk_command_buffer` struct used as
+ * drawing canvas. Can be used to do custom drawing.
+ */
+NK_API struct nk_command_buffer* nk_window_get_canvas(const struct nk_context* ctx);
+
+/**
+ * # # nk_window_get_scroll
+ * Gets the scroll offset for the current window
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ *
+ * ```c
+ * void nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
+ * ```
+ *
+ * Parameter | Description
+ * -------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] offset_x | A pointer to the x offset output (or NULL to ignore)
+ * \param[in] offset_y | A pointer to the y offset output (or NULL to ignore)
+
+ */
+NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
+
+/**
+ * # # nk_window_has_focus
+ * \returns if the currently processed window is currently active
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * nk_bool nk_window_has_focus(const struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `false(0)` if current window is not active or `true(1)` if it is
+
+ */
+NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_is_hovered
+ * Return if the current window is being hovered
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ * ```c
+ * nk_bool nk_window_is_hovered(struct nk_context *ctx);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `true(1)` if current window is hovered or `false(0)` otherwise
+
+ */
+NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_is_collapsed
+ * \returns if the window with given name is currently minimized/collapsed
+ * ```c
+ * nk_bool nk_window_is_collapsed(struct nk_context *ctx, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of window you want to check if it is collapsed
+ *
+ * \returns `true(1)` if current window is minimized and `false(0)` if window not
+ * found or is not minimized
+
+ */
+NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name);
+
+/**
+ * # # nk_window_is_closed
+ * \returns if the window with given name was closed by calling `nk_close`
+ * ```c
+ * nk_bool nk_window_is_closed(struct nk_context *ctx, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of window you want to check if it is closed
+ *
+ * \returns `true(1)` if current window was closed or `false(0)` window not found or not closed
+
+ */
+NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char* name);
+
+/**
+ * # # nk_window_is_hidden
+ * \returns if the window with given name is hidden
+ * ```c
+ * nk_bool nk_window_is_hidden(struct nk_context *ctx, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of window you want to check if it is hidden
+ *
+ * \returns `true(1)` if current window is hidden or `false(0)` window not found or visible
+
+ */
+NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char* name);
+
+/**
+ * # # nk_window_is_active
+ * Same as nk_window_has_focus for some reason
+ * ```c
+ * nk_bool nk_window_is_active(struct nk_context *ctx, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of window you want to check if it is active
+ *
+ * \returns `true(1)` if current window is active or `false(0)` window not found or not active
+ */
+NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char* name);
+
+/**
+ * # # nk_window_is_any_hovered
+ * \returns if the any window is being hovered
+ * ```c
+ * nk_bool nk_window_is_any_hovered(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `true(1)` if any window is hovered or `false(0)` otherwise
+ */
+NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx);
+
+/**
+ * # # nk_item_is_any_active
+ * \returns if the any window is being hovered or any widget is currently active.
+ * Can be used to decide if input should be processed by UI or your specific input handling.
+ * Example could be UI and 3D camera to move inside a 3D space.
+ * ```c
+ * nk_bool nk_item_is_any_active(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ *
+ * \returns `true(1)` if any window is hovered or any item is active or `false(0)` otherwise
+
+ */
+NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx);
+
+/**
+ * # # nk_window_set_bounds
+ * Updates position and size of window with passed in name
+ * ```c
+ * void nk_window_set_bounds(struct nk_context*, const char *name, struct nk_rect bounds);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to modify both position and size
+ * \param[in] bounds | Must point to a `nk_rect` struct with the new position and size
+
+ */
+NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds);
+
+/**
+ * # # nk_window_set_position
+ * Updates position of window with passed name
+ * ```c
+ * void nk_window_set_position(struct nk_context*, const char *name, struct nk_vec2 pos);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to modify both position
+ * \param[in] pos | Must point to a `nk_vec2` struct with the new position
+
+ */
+NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos);
+
+/**
+ * # # nk_window_set_size
+ * Updates size of window with passed in name
+ * ```c
+ * void nk_window_set_size(struct nk_context*, const char *name, struct nk_vec2);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to modify both window size
+ * \param[in] size | Must point to a `nk_vec2` struct with new window size
+
+ */
+NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size);
+
+/**
+ * # # nk_window_set_focus
+ * Sets the window with given name as active
+ * ```c
+ * void nk_window_set_focus(struct nk_context*, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to set focus on
+
+ */
+NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name);
+
+/**
+ * # # nk_window_set_scroll
+ * Sets the scroll offset for the current window
+ * !!! \warning
+ * Only call this function between calls `nk_begin_xxx` and `nk_end`
+ *
+ * ```c
+ * void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
+ * ```
+ *
+ * Parameter | Description
+ * -------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] offset_x | The x offset to scroll to
+ * \param[in] offset_y | The y offset to scroll to
+
+ */
+NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
+
+/**
+ * # # nk_window_close
+ * Closes a window and marks it for being freed at the end of the frame
+ * ```c
+ * void nk_window_close(struct nk_context *ctx, const char *name);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to close
+
+ */
NK_API void nk_window_close(struct nk_context *ctx, const char *name);
-/*/// #### nk_window_collapse
-/// Updates collapse state of a window with given name
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to close
-/// __state__ | value out of nk_collapse_states section
-*/
-NK_API void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
-/*/// #### nk_window_collapse_if
-/// Updates collapse state of a window with given name if given condition is met
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_collapse_if(struct nk_context*, const char *name, enum nk_collapse_states, int cond);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to either collapse or maximize
-/// __state__ | value out of nk_collapse_states section the window should be put into
-/// __cond__ | condition that has to be met to actually commit the collapse state change
-*/
-NK_API void nk_window_collapse_if(struct nk_context*, const char *name, enum nk_collapse_states, int cond);
-/*/// #### nk_window_show
-/// updates visibility state of a window with given name
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_show(struct nk_context*, const char *name, enum nk_show_states);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to either collapse or maximize
-/// __state__ | state with either visible or hidden to modify the window with
-*/
-NK_API void nk_window_show(struct nk_context*, const char *name, enum nk_show_states);
-/*/// #### nk_window_show_if
-/// Updates visibility state of a window with given name if a given condition is met
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __name__ | Identifier of the window to either hide or show
-/// __state__ | state with either visible or hidden to modify the window with
-/// __cond__ | condition that has to be met to actually commit the visbility state change
-*/
-NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
+
+/**
+ * # # nk_window_collapse
+ * Updates collapse state of a window with given name
+ * ```c
+ * void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to close
+ * \param[in] state | value out of nk_collapse_states section
+
+ */
+NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state);
+
+/**
+ * # # nk_window_collapse_if
+ * Updates collapse state of a window with given name if given condition is met
+ * ```c
+ * void nk_window_collapse_if(struct nk_context*, const char *name, enum nk_collapse_states, int cond);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to either collapse or maximize
+ * \param[in] state | value out of nk_collapse_states section the window should be put into
+ * \param[in] cond | condition that has to be met to actually commit the collapse state change
+
+ */
+NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond);
+
+/**
+ * # # nk_window_show
+ * updates visibility state of a window with given name
+ * ```c
+ * void nk_window_show(struct nk_context*, const char *name, enum nk_show_states);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to either collapse or maximize
+ * \param[in] state | state with either visible or hidden to modify the window with
+ */
+NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state);
+
+/**
+ * # # nk_window_show_if
+ * Updates visibility state of a window with given name if a given condition is met
+ * ```c
+ * void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] name | Identifier of the window to either hide or show
+ * \param[in] state | state with either visible or hidden to modify the window with
+ * \param[in] cond | condition that has to be met to actually commit the visibility state change
+
+ */
+NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond);
+
+/**
+ * # # nk_window_show_if
+ * Line for visual separation. Draws a line with thickness determined by the current row height.
+ * ```c
+ * void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, NK_BOOL rounding)
+ * ```
+ *
+ * Parameter | Description
+ * ----------------|-------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] color | Color of the horizontal line
+ * \param[in] rounding | Whether or not to make the line round
+ */
+NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
+
/* =============================================================================
*
* LAYOUT
*
- * =============================================================================
-/// ### Layouting
-/// Layouting in general describes placing widget inside a window with position and size.
-/// While in this particular implementation there are five different APIs for layouting
-/// each with different trade offs between control and ease of use. <br /><br />
-///
-/// All layouting methods in this library are based around the concept of a row.
-/// A row has a height the window content grows by and a number of columns and each
-/// layouting method specifies how each widget is placed inside the row.
-/// After a row has been allocated by calling a layouting functions and then
-/// filled with widgets will advance an internal pointer over the allocated row. <br /><br />
-///
-/// To actually define a layout you just call the appropriate layouting function
-/// and each subsequent widget call will place the widget as specified. Important
-/// here is that if you define more widgets then columns defined inside the layout
-/// functions it will allocate the next row without you having to make another layouting <br /><br />
-/// call.
-///
-/// Biggest limitation with using all these APIs outside the `nk_layout_space_xxx` API
-/// is that you have to define the row height for each. However the row height
-/// often depends on the height of the font. <br /><br />
-///
-/// To fix that internally nuklear uses a minimum row height that is set to the
-/// height plus padding of currently active font and overwrites the row height
-/// value if zero. <br /><br />
-///
-/// If you manually want to change the minimum row height then
-/// use nk_layout_set_min_row_height, and use nk_layout_reset_min_row_height to
-/// reset it back to be derived from font height. <br /><br />
-///
-/// Also if you change the font in nuklear it will automatically change the minimum
-/// row height for you and. This means if you change the font but still want
-/// a minimum row height smaller than the font you have to repush your value. <br /><br />
-///
-/// For actually more advanced UI I would even recommend using the `nk_layout_space_xxx`
-/// layouting method in combination with a cassowary constraint solver (there are
-/// some versions on github with permissive license model) to take over all control over widget
-/// layouting yourself. However for quick and dirty layouting using all the other layouting
-/// functions should be fine.
-///
-/// #### Usage
-/// 1. __nk_layout_row_dynamic__<br /><br />
-/// The easiest layouting function is `nk_layout_row_dynamic`. It provides each
-/// widgets with same horizontal space inside the row and dynamically grows
-/// if the owning window grows in width. So the number of columns dictates
-/// the size of each widget dynamically by formula:
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// widget_width = (window_width - padding - spacing) * (1/colum_count)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Just like all other layouting APIs if you define more widget than columns this
-/// library will allocate a new row and keep all layouting parameters previously
-/// defined.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // first row with height: 30 composed of two widgets
-/// nk_layout_row_dynamic(&ctx, 30, 2);
-/// nk_widget(...);
-/// nk_widget(...);
-/// //
-/// // second row with same parameter as defined above
-/// nk_widget(...);
-/// nk_widget(...);
-/// //
-/// // third row uses 0 for height which will use auto layouting
-/// nk_layout_row_dynamic(&ctx, 0, 2);
-/// nk_widget(...);
-/// nk_widget(...);
-/// }
-/// nk_end(...);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// 2. __nk_layout_row_static__<br /><br />
-/// Another easy layouting function is `nk_layout_row_static`. It provides each
-/// widget with same horizontal pixel width inside the row and does not grow
-/// if the owning window scales smaller or bigger.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // first row with height: 30 composed of two widgets with width: 80
-/// nk_layout_row_static(&ctx, 30, 80, 2);
-/// nk_widget(...);
-/// nk_widget(...);
-/// //
-/// // second row with same parameter as defined above
-/// nk_widget(...);
-/// nk_widget(...);
-/// //
-/// // third row uses 0 for height which will use auto layouting
-/// nk_layout_row_static(&ctx, 0, 80, 2);
-/// nk_widget(...);
-/// nk_widget(...);
-/// }
-/// nk_end(...);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// 3. __nk_layout_row_xxx__<br /><br />
-/// A little bit more advanced layouting API are functions `nk_layout_row_begin`,
-/// `nk_layout_row_push` and `nk_layout_row_end`. They allow to directly
-/// specify each column pixel or window ratio in a row. It supports either
-/// directly setting per column pixel width or widget window ratio but not
-/// both. Furthermore it is a immediate mode API so each value is directly
-/// pushed before calling a widget. Therefore the layout is not automatically
-/// repeating like the last two layouting functions.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // first row with height: 25 composed of two widgets with width 60 and 40
-/// nk_layout_row_begin(ctx, NK_STATIC, 25, 2);
-/// nk_layout_row_push(ctx, 60);
-/// nk_widget(...);
-/// nk_layout_row_push(ctx, 40);
-/// nk_widget(...);
-/// nk_layout_row_end(ctx);
-/// //
-/// // second row with height: 25 composed of two widgets with window ratio 0.25 and 0.75
-/// nk_layout_row_begin(ctx, NK_DYNAMIC, 25, 2);
-/// nk_layout_row_push(ctx, 0.25f);
-/// nk_widget(...);
-/// nk_layout_row_push(ctx, 0.75f);
-/// nk_widget(...);
-/// nk_layout_row_end(ctx);
-/// //
-/// // third row with auto generated height: composed of two widgets with window ratio 0.25 and 0.75
-/// nk_layout_row_begin(ctx, NK_DYNAMIC, 0, 2);
-/// nk_layout_row_push(ctx, 0.25f);
-/// nk_widget(...);
-/// nk_layout_row_push(ctx, 0.75f);
-/// nk_widget(...);
-/// nk_layout_row_end(ctx);
-/// }
-/// nk_end(...);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// 4. __nk_layout_row__<br /><br />
-/// The array counterpart to API nk_layout_row_xxx is the single nk_layout_row
-/// functions. Instead of pushing either pixel or window ratio for every widget
-/// it allows to define it by array. The trade of for less control is that
-/// `nk_layout_row` is automatically repeating. Otherwise the behavior is the
-/// same.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // two rows with height: 30 composed of two widgets with width 60 and 40
-/// const float size[] = {60,40};
-/// nk_layout_row(ctx, NK_STATIC, 30, 2, ratio);
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// //
-/// // two rows with height: 30 composed of two widgets with window ratio 0.25 and 0.75
-/// const float ratio[] = {0.25, 0.75};
-/// nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratio);
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// //
-/// // two rows with auto generated height composed of two widgets with window ratio 0.25 and 0.75
-/// const float ratio[] = {0.25, 0.75};
-/// nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratio);
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// }
-/// nk_end(...);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// 5. __nk_layout_row_template_xxx__<br /><br />
-/// The most complex and second most flexible API is a simplified flexbox version without
-/// line wrapping and weights for dynamic widgets. It is an immediate mode API but
-/// unlike `nk_layout_row_xxx` it has auto repeat behavior and needs to be called
-/// before calling the templated widgets.
-/// The row template layout has three different per widget size specifier. The first
-/// one is the `nk_layout_row_template_push_static` with fixed widget pixel width.
-/// They do not grow if the row grows and will always stay the same.
-/// The second size specifier is `nk_layout_row_template_push_variable`
-/// which defines a minimum widget size but it also can grow if more space is available
-/// not taken by other widgets.
-/// Finally there are dynamic widgets with `nk_layout_row_template_push_dynamic`
-/// which are completely flexible and unlike variable widgets can even shrink
-/// to zero if not enough space is provided.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // two rows with height: 30 composed of three widgets
-/// nk_layout_row_template_begin(ctx, 30);
-/// nk_layout_row_template_push_dynamic(ctx);
-/// nk_layout_row_template_push_variable(ctx, 80);
-/// nk_layout_row_template_push_static(ctx, 80);
-/// nk_layout_row_template_end(ctx);
-/// //
-/// // first row
-/// nk_widget(...); // dynamic widget can go to zero if not enough space
-/// nk_widget(...); // variable widget with min 80 pixel but can grow bigger if enough space
-/// nk_widget(...); // static widget with fixed 80 pixel width
-/// //
-/// // second row same layout
-/// nk_widget(...);
-/// nk_widget(...);
-/// nk_widget(...);
-/// }
-/// nk_end(...);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// 6. __nk_layout_space_xxx__<br /><br />
-/// Finally the most flexible API directly allows you to place widgets inside the
-/// window. The space layout API is an immediate mode API which does not support
-/// row auto repeat and directly sets position and size of a widget. Position
-/// and size hereby can be either specified as ratio of allocated space or
-/// allocated space local position and pixel size. Since this API is quite
-/// powerful there are a number of utility functions to get the available space
-/// and convert between local allocated space and screen space.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_begin_xxx(...) {
-/// // static row with height: 500 (you can set column count to INT_MAX if you don't want to be bothered)
-/// nk_layout_space_begin(ctx, NK_STATIC, 500, INT_MAX);
-/// nk_layout_space_push(ctx, nk_rect(0,0,150,200));
-/// nk_widget(...);
-/// nk_layout_space_push(ctx, nk_rect(200,200,100,200));
-/// nk_widget(...);
-/// nk_layout_space_end(ctx);
-/// //
-/// // dynamic row with height: 500 (you can set column count to INT_MAX if you don't want to be bothered)
-/// nk_layout_space_begin(ctx, NK_DYNAMIC, 500, INT_MAX);
-/// nk_layout_space_push(ctx, nk_rect(0.5,0.5,0.1,0.1));
-/// nk_widget(...);
-/// nk_layout_space_push(ctx, nk_rect(0.7,0.6,0.1,0.1));
-/// nk_widget(...);
-/// }
-/// nk_end(...);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// Function | Description
-/// ----------------------------------------|------------------------------------
-/// nk_layout_set_min_row_height | Set the currently used minimum row height to a specified value
-/// nk_layout_reset_min_row_height | Resets the currently used minimum row height to font height
-/// nk_layout_widget_bounds | Calculates current width a static layout row can fit inside a window
-/// nk_layout_ratio_from_pixel | Utility functions to calculate window ratio from pixel size
-//
-/// nk_layout_row_dynamic | Current layout is divided into n same sized growing columns
-/// nk_layout_row_static | Current layout is divided into n same fixed sized columns
-/// nk_layout_row_begin | Starts a new row with given height and number of columns
-/// nk_layout_row_push | Pushes another column with given size or window ratio
-/// nk_layout_row_end | Finished previously started row
-/// nk_layout_row | Specifies row columns in array as either window ratio or size
-//
-/// nk_layout_row_template_begin | Begins the row template declaration
-/// nk_layout_row_template_push_dynamic | Adds a dynamic column that dynamically grows and can go to zero if not enough space
-/// nk_layout_row_template_push_variable | Adds a variable column that dynamically grows but does not shrink below specified pixel width
-/// nk_layout_row_template_push_static | Adds a static column that does not grow and will always have the same size
-/// nk_layout_row_template_end | Marks the end of the row template
-//
-/// nk_layout_space_begin | Begins a new layouting space that allows to specify each widgets position and size
-/// nk_layout_space_push | Pushes position and size of the next widget in own coordinate space either as pixel or ratio
-/// nk_layout_space_end | Marks the end of the layouting space
-//
-/// nk_layout_space_bounds | Callable after nk_layout_space_begin and returns total space allocated
-/// nk_layout_space_to_screen | Converts vector from nk_layout_space coordinate space into screen space
-/// nk_layout_space_to_local | Converts vector from screen space into nk_layout_space coordinates
-/// nk_layout_space_rect_to_screen | Converts rectangle from nk_layout_space coordinate space into screen space
-/// nk_layout_space_rect_to_local | Converts rectangle from screen space into nk_layout_space coordinates
-*/
-/*/// #### nk_layout_set_min_row_height
-/// Sets the currently used minimum row height.
-/// !!! WARNING
-/// The passed height needs to include both your preferred row height
-/// as well as padding. No internal padding is added.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_set_min_row_height(struct nk_context*, float height);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __height__ | New minimum row height to be used for auto generating the row height
-*/
+ * =============================================================================*/
+/**
+ * \page Layouting
+ * Layouting in general describes placing widget inside a window with position and size.
+ * While in this particular implementation there are five different APIs for layouting
+ * each with different trade offs between control and ease of use. <br /><br />
+ *
+ * All layouting methods in this library are based around the concept of a row.
+ * A row has a height the window content grows by and a number of columns and each
+ * layouting method specifies how each widget is placed inside the row.
+ * After a row has been allocated by calling a layouting functions and then
+ * filled with widgets will advance an internal pointer over the allocated row. <br /><br />
+ *
+ * To actually define a layout you just call the appropriate layouting function
+ * and each subsequent widget call will place the widget as specified. Important
+ * here is that if you define more widgets then columns defined inside the layout
+ * functions it will allocate the next row without you having to make another layouting <br /><br />
+ * call.
+ *
+ * Biggest limitation with using all these APIs outside the `nk_layout_space_xxx` API
+ * is that you have to define the row height for each. However the row height
+ * often depends on the height of the font. <br /><br />
+ *
+ * To fix that internally nuklear uses a minimum row height that is set to the
+ * height plus padding of currently active font and overwrites the row height
+ * value if zero. <br /><br />
+ *
+ * If you manually want to change the minimum row height then
+ * use nk_layout_set_min_row_height, and use nk_layout_reset_min_row_height to
+ * reset it back to be derived from font height. <br /><br />
+ *
+ * Also if you change the font in nuklear it will automatically change the minimum
+ * row height for you and. This means if you change the font but still want
+ * a minimum row height smaller than the font you have to repush your value. <br /><br />
+ *
+ * For actually more advanced UI I would even recommend using the `nk_layout_space_xxx`
+ * layouting method in combination with a cassowary constraint solver (there are
+ * some versions on github with permissive license model) to take over all control over widget
+ * layouting yourself. However for quick and dirty layouting using all the other layouting
+ * functions should be fine.
+ *
+ * # Usage
+ * 1. __nk_layout_row_dynamic__<br /><br />
+ * The easiest layouting function is `nk_layout_row_dynamic`. It provides each
+ * widgets with same horizontal space inside the row and dynamically grows
+ * if the owning window grows in width. So the number of columns dictates
+ * the size of each widget dynamically by formula:
+ *
+ * ```c
+ * widget_width = (window_width - padding - spacing) * (1/column_count)
+ * ```
+ *
+ * Just like all other layouting APIs if you define more widget than columns this
+ * library will allocate a new row and keep all layouting parameters previously
+ * defined.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // first row with height: 30 composed of two widgets
+ * nk_layout_row_dynamic(&ctx, 30, 2);
+ * nk_widget(...);
+ * nk_widget(...);
+ * //
+ * // second row with same parameter as defined above
+ * nk_widget(...);
+ * nk_widget(...);
+ * //
+ * // third row uses 0 for height which will use auto layouting
+ * nk_layout_row_dynamic(&ctx, 0, 2);
+ * nk_widget(...);
+ * nk_widget(...);
+ * }
+ * nk_end(...);
+ * ```
+ *
+ * 2. __nk_layout_row_static__<br /><br />
+ * Another easy layouting function is `nk_layout_row_static`. It provides each
+ * widget with same horizontal pixel width inside the row and does not grow
+ * if the owning window scales smaller or bigger.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // first row with height: 30 composed of two widgets with width: 80
+ * nk_layout_row_static(&ctx, 30, 80, 2);
+ * nk_widget(...);
+ * nk_widget(...);
+ * //
+ * // second row with same parameter as defined above
+ * nk_widget(...);
+ * nk_widget(...);
+ * //
+ * // third row uses 0 for height which will use auto layouting
+ * nk_layout_row_static(&ctx, 0, 80, 2);
+ * nk_widget(...);
+ * nk_widget(...);
+ * }
+ * nk_end(...);
+ * ```
+ *
+ * 3. __nk_layout_row_xxx__<br /><br />
+ * A little bit more advanced layouting API are functions `nk_layout_row_begin`,
+ * `nk_layout_row_push` and `nk_layout_row_end`. They allow to directly
+ * specify each column pixel or window ratio in a row. It supports either
+ * directly setting per column pixel width or widget window ratio but not
+ * both. Furthermore it is a immediate mode API so each value is directly
+ * pushed before calling a widget. Therefore the layout is not automatically
+ * repeating like the last two layouting functions.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // first row with height: 25 composed of two widgets with width 60 and 40
+ * nk_layout_row_begin(ctx, NK_STATIC, 25, 2);
+ * nk_layout_row_push(ctx, 60);
+ * nk_widget(...);
+ * nk_layout_row_push(ctx, 40);
+ * nk_widget(...);
+ * nk_layout_row_end(ctx);
+ * //
+ * // second row with height: 25 composed of two widgets with window ratio 0.25 and 0.75
+ * nk_layout_row_begin(ctx, NK_DYNAMIC, 25, 2);
+ * nk_layout_row_push(ctx, 0.25f);
+ * nk_widget(...);
+ * nk_layout_row_push(ctx, 0.75f);
+ * nk_widget(...);
+ * nk_layout_row_end(ctx);
+ * //
+ * // third row with auto generated height: composed of two widgets with window ratio 0.25 and 0.75
+ * nk_layout_row_begin(ctx, NK_DYNAMIC, 0, 2);
+ * nk_layout_row_push(ctx, 0.25f);
+ * nk_widget(...);
+ * nk_layout_row_push(ctx, 0.75f);
+ * nk_widget(...);
+ * nk_layout_row_end(ctx);
+ * }
+ * nk_end(...);
+ * ```
+ *
+ * 4. __nk_layout_row__<br /><br />
+ * The array counterpart to API nk_layout_row_xxx is the single nk_layout_row
+ * functions. Instead of pushing either pixel or window ratio for every widget
+ * it allows to define it by array. The trade of for less control is that
+ * `nk_layout_row` is automatically repeating. Otherwise the behavior is the
+ * same.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // two rows with height: 30 composed of two widgets with width 60 and 40
+ * const float ratio[] = {60,40};
+ * nk_layout_row(ctx, NK_STATIC, 30, 2, ratio);
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * //
+ * // two rows with height: 30 composed of two widgets with window ratio 0.25 and 0.75
+ * const float ratio[] = {0.25, 0.75};
+ * nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratio);
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * //
+ * // two rows with auto generated height composed of two widgets with window ratio 0.25 and 0.75
+ * const float ratio[] = {0.25, 0.75};
+ * nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratio);
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * }
+ * nk_end(...);
+ * ```
+ *
+ * 5. __nk_layout_row_template_xxx__<br /><br />
+ * The most complex and second most flexible API is a simplified flexbox version without
+ * line wrapping and weights for dynamic widgets. It is an immediate mode API but
+ * unlike `nk_layout_row_xxx` it has auto repeat behavior and needs to be called
+ * before calling the templated widgets.
+ * The row template layout has three different per widget size specifier. The first
+ * one is the `nk_layout_row_template_push_static` with fixed widget pixel width.
+ * They do not grow if the row grows and will always stay the same.
+ * The second size specifier is `nk_layout_row_template_push_variable`
+ * which defines a minimum widget size but it also can grow if more space is available
+ * not taken by other widgets.
+ * Finally there are dynamic widgets with `nk_layout_row_template_push_dynamic`
+ * which are completely flexible and unlike variable widgets can even shrink
+ * to zero if not enough space is provided.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // two rows with height: 30 composed of three widgets
+ * nk_layout_row_template_begin(ctx, 30);
+ * nk_layout_row_template_push_dynamic(ctx);
+ * nk_layout_row_template_push_variable(ctx, 80);
+ * nk_layout_row_template_push_static(ctx, 80);
+ * nk_layout_row_template_end(ctx);
+ * //
+ * // first row
+ * nk_widget(...); // dynamic widget can go to zero if not enough space
+ * nk_widget(...); // variable widget with min 80 pixel but can grow bigger if enough space
+ * nk_widget(...); // static widget with fixed 80 pixel width
+ * //
+ * // second row same layout
+ * nk_widget(...);
+ * nk_widget(...);
+ * nk_widget(...);
+ * }
+ * nk_end(...);
+ * ```
+ *
+ * 6. __nk_layout_space_xxx__<br /><br />
+ * Finally the most flexible API directly allows you to place widgets inside the
+ * window. The space layout API is an immediate mode API which does not support
+ * row auto repeat and directly sets position and size of a widget. Position
+ * and size hereby can be either specified as ratio of allocated space or
+ * allocated space local position and pixel size. Since this API is quite
+ * powerful there are a number of utility functions to get the available space
+ * and convert between local allocated space and screen space.
+ *
+ * ```c
+ * if (nk_begin_xxx(...) {
+ * // static row with height: 500 (you can set column count to INT_MAX if you don't want to be bothered)
+ * nk_layout_space_begin(ctx, NK_STATIC, 500, INT_MAX);
+ * nk_layout_space_push(ctx, nk_rect(0,0,150,200));
+ * nk_widget(...);
+ * nk_layout_space_push(ctx, nk_rect(200,200,100,200));
+ * nk_widget(...);
+ * nk_layout_space_end(ctx);
+ * //
+ * // dynamic row with height: 500 (you can set column count to INT_MAX if you don't want to be bothered)
+ * nk_layout_space_begin(ctx, NK_DYNAMIC, 500, INT_MAX);
+ * nk_layout_space_push(ctx, nk_rect(0.5,0.5,0.1,0.1));
+ * nk_widget(...);
+ * nk_layout_space_push(ctx, nk_rect(0.7,0.6,0.1,0.1));
+ * nk_widget(...);
+ * }
+ * nk_end(...);
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * ---------------------------------------------|------------------------------------
+ * \ref nk_layout_set_min_row_height | Set the currently used minimum row height to a specified value
+ * \ref nk_layout_reset_min_row_height | Resets the currently used minimum row height to font height
+ * \ref nk_layout_widget_bounds | Calculates current width a static layout row can fit inside a window
+ * \ref nk_layout_ratio_from_pixel | Utility functions to calculate window ratio from pixel size
+ * \ref nk_layout_row_dynamic | Current layout is divided into n same sized growing columns
+ * \ref nk_layout_row_static | Current layout is divided into n same fixed sized columns
+ * \ref nk_layout_row_begin | Starts a new row with given height and number of columns
+ * \ref nk_layout_row_push | Pushes another column with given size or window ratio
+ * \ref nk_layout_row_end | Finished previously started row
+ * \ref nk_layout_row | Specifies row columns in array as either window ratio or size
+ * \ref nk_layout_row_template_begin | Begins the row template declaration
+ * \ref nk_layout_row_template_push_dynamic | Adds a dynamic column that dynamically grows and can go to zero if not enough space
+ * \ref nk_layout_row_template_push_variable | Adds a variable column that dynamically grows but does not shrink below specified pixel width
+ * \ref nk_layout_row_template_push_static | Adds a static column that does not grow and will always have the same size
+ * \ref nk_layout_row_template_end | Marks the end of the row template
+ * \ref nk_layout_space_begin | Begins a new layouting space that allows to specify each widgets position and size
+ * \ref nk_layout_space_push | Pushes position and size of the next widget in own coordinate space either as pixel or ratio
+ * \ref nk_layout_space_end | Marks the end of the layouting space
+ * \ref nk_layout_space_bounds | Callable after nk_layout_space_begin and returns total space allocated
+ * \ref nk_layout_space_to_screen | Converts vector from nk_layout_space coordinate space into screen space
+ * \ref nk_layout_space_to_local | Converts vector from screen space into nk_layout_space coordinates
+ * \ref nk_layout_space_rect_to_screen | Converts rectangle from nk_layout_space coordinate space into screen space
+ * \ref nk_layout_space_rect_to_local | Converts rectangle from screen space into nk_layout_space coordinates
+ */
+
+
+
+enum nk_widget_align {
+ NK_WIDGET_ALIGN_LEFT = 0x01,
+ NK_WIDGET_ALIGN_CENTERED = 0x02,
+ NK_WIDGET_ALIGN_RIGHT = 0x04,
+ NK_WIDGET_ALIGN_TOP = 0x08,
+ NK_WIDGET_ALIGN_MIDDLE = 0x10,
+ NK_WIDGET_ALIGN_BOTTOM = 0x20
+};
+enum nk_widget_alignment {
+ NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
+ NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
+ NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
+};
+
+/**
+ * Sets the currently used minimum row height.
+ * !!! \warning
+ * The passed height needs to include both your preferred row height
+ * as well as padding. No internal padding is added.
+ *
+ * ```c
+ * void nk_layout_set_min_row_height(struct nk_context*, float height);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] height | New minimum row height to be used for auto generating the row height
+ */
NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
-/*/// #### nk_layout_reset_min_row_height
-/// Reset the currently used minimum row height back to `font_height + text_padding + padding`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_reset_min_row_height(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-*/
+
+/**
+ * Reset the currently used minimum row height back to `font_height + text_padding + padding`
+ * ```c
+ * void nk_layout_reset_min_row_height(struct nk_context*);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ */
NK_API void nk_layout_reset_min_row_height(struct nk_context*);
-/*/// #### nk_layout_widget_bounds
-/// Returns the width of the next row allocate by one of the layouting functions
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_rect nk_layout_widget_bounds(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-///
-/// Return `nk_rect` with both position and size of the next row
-*/
-NK_API struct nk_rect nk_layout_widget_bounds(struct nk_context*);
-/*/// #### nk_layout_ratio_from_pixel
-/// Utility functions to calculate window ratio from pixel size
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// float nk_layout_ratio_from_pixel(struct nk_context*, float pixel_width);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __pixel__ | Pixel_width to convert to window ratio
-///
-/// Returns `nk_rect` with both position and size of the next row
-*/
-NK_API float nk_layout_ratio_from_pixel(struct nk_context*, float pixel_width);
-/*/// #### nk_layout_row_dynamic
-/// Sets current row layout to share horizontal space
-/// between @cols number of widgets evenly. Once called all subsequent widget
-/// calls greater than @cols will allocate a new row with same layout.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __height__ | Holds height of each widget in row or zero for auto layouting
-/// __columns__ | Number of widget inside row
-*/
+
+/**
+ * \brief Returns the width of the next row allocate by one of the layouting functions
+ *
+ * \details
+ * ```c
+ * struct nk_rect nk_layout_widget_bounds(struct nk_context*);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ *
+ * \return `nk_rect` with both position and size of the next row
+ */
+NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx);
+
+/**
+ * \brief Utility functions to calculate window ratio from pixel size
+ *
+ * \details
+ * ```c
+ * float nk_layout_ratio_from_pixel(struct nk_context*, float pixel_width);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] pixel | Pixel_width to convert to window ratio
+ *
+ * \returns `nk_rect` with both position and size of the next row
+ */
+NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width);
+
+/**
+ * \brief Sets current row layout to share horizontal space
+ * between @cols number of widgets evenly. Once called all subsequent widget
+ * calls greater than @cols will allocate a new row with same layout.
+ *
+ * \details
+ * ```c
+ * void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] height | Holds height of each widget in row or zero for auto layouting
+ * \param[in] columns | Number of widget inside row
+ */
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
-/*/// #### nk_layout_row_static
-/// Sets current row layout to fill @cols number of widgets
-/// in row with same @item_width horizontal size. Once called all subsequent widget
-/// calls greater than @cols will allocate a new row with same layout.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __height__ | Holds height of each widget in row or zero for auto layouting
-/// __width__ | Holds pixel width of each widget in the row
-/// __columns__ | Number of widget inside row
-*/
+
+/**
+ * \brief Sets current row layout to fill @cols number of widgets
+ * in row with same @item_width horizontal size. Once called all subsequent widget
+ * calls greater than @cols will allocate a new row with same layout.
+ *
+ * \details
+ * ```c
+ * void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] height | Holds height of each widget in row or zero for auto layouting
+ * \param[in] width | Holds pixel width of each widget in the row
+ * \param[in] columns | Number of widget inside row
+ */
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
-/*/// #### nk_layout_row_begin
-/// Starts a new dynamic or fixed row with given height and columns.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __fmt__ | either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
-/// __height__ | holds height of each widget in row or zero for auto layouting
-/// __columns__ | Number of widget inside row
-*/
+
+/**
+ * \brief Starts a new dynamic or fixed row with given height and columns.
+ *
+ * \details
+ * ```c
+ * void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] fmt | either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
+ * \param[in] height | holds height of each widget in row or zero for auto layouting
+ * \param[in] columns | Number of widget inside row
+ */
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
-/*/// #### nk_layout_row_push
-/// Specifies either window ratio or width of a single column
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_push(struct nk_context*, float value);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __value__ | either a window ratio or fixed width depending on @fmt in previous `nk_layout_row_begin` call
-*/
+
+/**
+ * \breif Specifies either window ratio or width of a single column
+ *
+ * \details
+ * ```c
+ * void nk_layout_row_push(struct nk_context*, float value);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] value | either a window ratio or fixed width depending on @fmt in previous `nk_layout_row_begin` call
+ */
NK_API void nk_layout_row_push(struct nk_context*, float value);
-/*/// #### nk_layout_row_end
-/// Finished previously started row
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_end(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-*/
+
+/**
+ * \brief Finished previously started row
+ *
+ * \details
+ * ```c
+ * void nk_layout_row_end(struct nk_context*);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ */
NK_API void nk_layout_row_end(struct nk_context*);
-/*/// #### nk_layout_row
-/// Specifies row columns in array as either window ratio or size
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __fmt__ | Either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
-/// __height__ | Holds height of each widget in row or zero for auto layouting
-/// __columns__ | Number of widget inside row
-*/
+
+/**
+ * \brief Specifies row columns in array as either window ratio or size
+ *
+ * \details
+ * ```c
+ * void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] fmt | Either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
+ * \param[in] height | Holds height of each widget in row or zero for auto layouting
+ * \param[in] columns | Number of widget inside row
+ */
NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
-/*/// #### nk_layout_row_template_begin
-/// Begins the row template declaration
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_template_begin(struct nk_context*, float row_height);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __height__ | Holds height of each widget in row or zero for auto layouting
-*/
+
+/**
+ * # # nk_layout_row_template_begin
+ * Begins the row template declaration
+ * ```c
+ * void nk_layout_row_template_begin(struct nk_context*, float row_height);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] height | Holds height of each widget in row or zero for auto layouting
+ */
NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
-/*/// #### nk_layout_row_template_push_dynamic
-/// Adds a dynamic column that dynamically grows and can go to zero if not enough space
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_template_push_dynamic(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __height__ | Holds height of each widget in row or zero for auto layouting
-*/
+
+/**
+ * # # nk_layout_row_template_push_dynamic
+ * Adds a dynamic column that dynamically grows and can go to zero if not enough space
+ * ```c
+ * void nk_layout_row_template_push_dynamic(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] height | Holds height of each widget in row or zero for auto layouting
+ */
NK_API void nk_layout_row_template_push_dynamic(struct nk_context*);
-/*/// #### nk_layout_row_template_push_variable
-/// Adds a variable column that dynamically grows but does not shrink below specified pixel width
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __width__ | Holds the minimum pixel width the next column must always be
-*/
+
+/**
+ * # # nk_layout_row_template_push_variable
+ * Adds a variable column that dynamically grows but does not shrink below specified pixel width
+ * ```c
+ * void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] width | Holds the minimum pixel width the next column must always be
+ */
NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
-/*/// #### nk_layout_row_template_push_static
-/// Adds a static column that does not grow and will always have the same size
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_template_push_static(struct nk_context*, float width);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __width__ | Holds the absolute pixel width value the next column must be
-*/
+
+/**
+ * # # nk_layout_row_template_push_static
+ * Adds a static column that does not grow and will always have the same size
+ * ```c
+ * void nk_layout_row_template_push_static(struct nk_context*, float width);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] width | Holds the absolute pixel width value the next column must be
+ */
NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
-/*/// #### nk_layout_row_template_end
-/// Marks the end of the row template
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_row_template_end(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-*/
+
+/**
+ * # # nk_layout_row_template_end
+ * Marks the end of the row template
+ * ```c
+ * void nk_layout_row_template_end(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ */
NK_API void nk_layout_row_template_end(struct nk_context*);
-/*/// #### nk_layout_space_begin
-/// Begins a new layouting space that allows to specify each widgets position and size.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
-/// __fmt__ | Either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
-/// __height__ | Holds height of each widget in row or zero for auto layouting
-/// __columns__ | Number of widgets inside row
-*/
+
+/**
+ * # # nk_layout_space_begin
+ * Begins a new layouting space that allows to specify each widgets position and size.
+ * ```c
+ * void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ * \param[in] fmt | Either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
+ * \param[in] height | Holds height of each widget in row or zero for auto layouting
+ * \param[in] columns | Number of widgets inside row
+ */
NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
-/*/// #### nk_layout_space_push
-/// Pushes position and size of the next widget in own coordinate space either as pixel or ratio
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_space_push(struct nk_context *ctx, struct nk_rect bounds);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-/// __bounds__ | Position and size in laoyut space local coordinates
-*/
+
+/**
+ * # # nk_layout_space_push
+ * Pushes position and size of the next widget in own coordinate space either as pixel or ratio
+ * ```c
+ * void nk_layout_space_push(struct nk_context *ctx, struct nk_rect bounds);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ * \param[in] bounds | Position and size in laoyut space local coordinates
+ */
NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
-/*/// #### nk_layout_space_end
-/// Marks the end of the layout space
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_layout_space_end(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-*/
+
+/**
+ * # # nk_layout_space_end
+ * Marks the end of the layout space
+ * ```c
+ * void nk_layout_space_end(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ */
NK_API void nk_layout_space_end(struct nk_context*);
-/*/// #### nk_layout_space_bounds
-/// Utility function to calculate total space allocated for `nk_layout_space`
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_rect nk_layout_space_bounds(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-///
-/// Returns `nk_rect` holding the total space allocated
-*/
-NK_API struct nk_rect nk_layout_space_bounds(struct nk_context*);
-/*/// #### nk_layout_space_to_screen
-/// Converts vector from nk_layout_space coordinate space into screen space
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_layout_space_to_screen(struct nk_context*, struct nk_vec2);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-/// __vec__ | Position to convert from layout space into screen coordinate space
-///
-/// Returns transformed `nk_vec2` in screen space coordinates
-*/
-NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context*, struct nk_vec2);
-/*/// #### nk_layout_space_to_local
-/// Converts vector from layout space into screen space
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_vec2 nk_layout_space_to_local(struct nk_context*, struct nk_vec2);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-/// __vec__ | Position to convert from screen space into layout coordinate space
-///
-/// Returns transformed `nk_vec2` in layout space coordinates
-*/
-NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context*, struct nk_vec2);
-/*/// #### nk_layout_space_rect_to_screen
-/// Converts rectangle from screen space into layout space
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_rect nk_layout_space_rect_to_screen(struct nk_context*, struct nk_rect);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-/// __bounds__ | Rectangle to convert from layout space into screen space
-///
-/// Returns transformed `nk_rect` in screen space coordinates
-*/
-NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context*, struct nk_rect);
-/*/// #### nk_layout_space_rect_to_local
-/// Converts rectangle from layout space into screen space
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct nk_rect);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
-/// __bounds__ | Rectangle to convert from layout space into screen space
-///
-/// Returns transformed `nk_rect` in layout space coordinates
-*/
-NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct nk_rect);
-/* =============================================================================
+
+/**
+ * # # nk_layout_space_bounds
+ * Utility function to calculate total space allocated for `nk_layout_space`
+ * ```c
+ * struct nk_rect nk_layout_space_bounds(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *
+ * \returns `nk_rect` holding the total space allocated
+ */
+NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx);
+
+/**
+ * # # nk_layout_space_to_screen
+ * Converts vector from nk_layout_space coordinate space into screen space
+ * ```c
+ * struct nk_vec2 nk_layout_space_to_screen(struct nk_context*, struct nk_vec2);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ * \param[in] vec | Position to convert from layout space into screen coordinate space
+ *
+ * \returns transformed `nk_vec2` in screen space coordinates
+ */
+NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context* ctx, struct nk_vec2 vec);
+
+/**
+ * # # nk_layout_space_to_local
+ * Converts vector from layout space into screen space
+ * ```c
+ * struct nk_vec2 nk_layout_space_to_local(struct nk_context*, struct nk_vec2);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ * \param[in] vec | Position to convert from screen space into layout coordinate space
+ *
+ * \returns transformed `nk_vec2` in layout space coordinates
+ */
+NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec);
+
+/**
+ * # # nk_layout_space_rect_to_screen
+ * Converts rectangle from screen space into layout space
+ * ```c
+ * struct nk_rect nk_layout_space_rect_to_screen(struct nk_context*, struct nk_rect);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ * \param[in] bounds | Rectangle to convert from layout space into screen space
+ *
+ * \returns transformed `nk_rect` in screen space coordinates
+ */
+NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds);
+
+/**
+ * # # nk_layout_space_rect_to_local
+ * Converts rectangle from layout space into screen space
+ * ```c
+ * struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct nk_rect);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ * \param[in] bounds | Rectangle to convert from layout space into screen space
+ *
+ * \returns transformed `nk_rect` in layout space coordinates
+ */
+NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds);
+
+/**
+ * # # nk_spacer
+ * Spacer is a dummy widget that consumes space as usual but doesn't draw anything
+ * ```c
+ * void nk_spacer(struct nk_context* );
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *
+ */
+NK_API void nk_spacer(struct nk_context *ctx);
+
+
+/** =============================================================================
*
* GROUP
*
- * =============================================================================
-/// ### Groups
-/// 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 corosponding `nk_group_begin_xxx` call does not return 0:
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_group_begin_xxx(ctx, ...) {
-/// // [... widgets ...]
-/// nk_group_end(ctx);
-/// }
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// In the grand concept groups can be called after starting a window
-/// with `nk_begin_xxx` and before calling `nk_end`:
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// // Input
-/// Event evt;
-/// nk_input_begin(&ctx);
-/// 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...]
-/// nk_layout_row_dynamic(...);
-/// if (nk_group_begin_xxx(ctx, ...) {
-/// //[... widgets ...]
-/// nk_group_end(ctx);
-/// }
-/// }
-/// 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);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-/// #### Reference
-/// Function | Description
-/// --------------------------------|-------------------------------------------
-/// nk_group_begin | Start a new group with internal scrollbar handling
-/// nk_group_begin_titled | Start a new group with separeted 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
-*/
-/*/// #### nk_group_begin
-/// Starts a new widget group. Requires a previous layouting function to specify a pos/size.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_group_begin(struct nk_context*, const char *title, nk_flags);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __title__ | Must be an unique identifier for this group that is also used for the group header
-/// __flags__ | Window flags defined in the nk_panel_flags section with a number of different group behaviors
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+ * =============================================================================*/
+/**
+ * \page Groups
+ * 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:
+ *
+ * ```c
+ * if (nk_group_begin_xxx(ctx, ...) {
+ * // [... widgets ...]
+ * nk_group_end(ctx);
+ * }
+ * ```
+ *
+ * In the grand concept groups can be called after starting a window
+ * with `nk_begin_xxx` and before calling `nk_end`:
+ *
+ * ```c
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * // Input
+ * Event evt;
+ * nk_input_begin(&ctx);
+ * 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...]
+ * nk_layout_row_dynamic(...);
+ * if (nk_group_begin_xxx(ctx, ...) {
+ * //[... widgets ...]
+ * nk_group_end(ctx);
+ * }
+ * }
+ * 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);
+ * ```
+ * # Reference
+ * Function | Description
+ * --------------------------------|-------------------------------------------
+ * \ref nk_group_begin | Start a new group with internal scrollbar handling
+ * \ref nk_group_begin_titled | Start a new group with separated name and title and internal scrollbar handling
+ * \ref nk_group_end | Ends a group. Should only be called if nk_group_begin returned non-zero
+ * \ref nk_group_scrolled_offset_begin | Start a new group with manual separated handling of scrollbar x- and y-offset
+ * \ref nk_group_scrolled_begin | Start a new group with manual scrollbar handling
+ * \ref nk_group_scrolled_end | Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero
+ * \ref nk_group_get_scroll | Gets the scroll offset for the given group
+ * \ref nk_group_set_scroll | Sets the scroll offset for the given group
+ */
+
+ /**
+ * \brief Starts a new widget group. Requires a previous layouting function to specify a pos/size.
+ * ```c
+ * nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] title | Must be an unique identifier for this group that is also used for the group header
+ * \param[in] flags | Window flags defined in the nk_panel_flags section with a number of different group behaviors
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
-/*/// #### nk_group_begin_titled
-/// Starts a new widget group. Requires a previous layouting function to specify a pos/size.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __id__ | Must be an unique identifier for this group
-/// __title__ | Group header title
-/// __flags__ | Window flags defined in the nk_panel_flags section with a number of different group behaviors
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+ /**
+ * \brief Starts a new widget group. Requires a previous layouting function to specify a pos/size.
+ * ```c
+ * nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
+ * ```
+ *
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] id | Must be an unique identifier for this group
+ * \param[in] title | Group header title
+ * \param[in] flags | Window flags defined in the nk_panel_flags section with a number of different group behaviors
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
-/*/// #### nk_group_end
-/// Ends a widget group
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_group_end(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-*/
+
+/**
+ * # # nk_group_end
+ * Ends a widget group
+ * ```c
+ * void nk_group_end(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ */
NK_API void nk_group_end(struct nk_context*);
-/*/// #### nk_group_scrolled_offset_begin
-/// starts a new widget group. requires a previous layouting function to specify
-/// a size. Does not keep track of scrollbar.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __x_offset__| Scrollbar x-offset to offset all widgets inside the group horizontally.
-/// __y_offset__| Scrollbar y-offset to offset all widgets inside the group vertically
-/// __title__ | Window unique group title used to both identify and display in the group header
-/// __flags__ | Window flags from the nk_panel_flags section
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_group_scrolled_offset_begin
+ * starts a new widget group. requires a previous layouting function to specify
+ * a size. Does not keep track of scrollbar.
+ * ```c
+ * nk_bool nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] x_offset| Scrollbar x-offset to offset all widgets inside the group horizontally.
+ * \param[in] y_offset| Scrollbar y-offset to offset all widgets inside the group vertically
+ * \param[in] title | Window unique group title used to both identify and display in the group header
+ * \param[in] flags | Window flags from the nk_panel_flags section
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags);
-/*/// #### nk_group_scrolled_begin
-/// Starts a new widget group. requires a previous
-/// layouting function to specify a size. Does not keep track of scrollbar.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __off__ | Both x- and y- scroll offset. Allows for manual scrollbar control
-/// __title__ | Window unique group title used to both identify and display in the group header
-/// __flags__ | Window flags from nk_panel_flags section
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_group_scrolled_begin
+ * Starts a new widget group. requires a previous
+ * layouting function to specify a size. Does not keep track of scrollbar.
+ * ```c
+ * nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] off | Both x- and y- scroll offset. Allows for manual scrollbar control
+ * \param[in] title | Window unique group title used to both identify and display in the group header
+ * \param[in] flags | Window flags from nk_panel_flags section
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
-/*/// #### nk_group_scrolled_end
-/// Ends a widget group after calling nk_group_scrolled_offset_begin or nk_group_scrolled_begin.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_group_scrolled_end(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-*/
+
+/**
+ * # # nk_group_scrolled_end
+ * Ends a widget group after calling nk_group_scrolled_offset_begin or nk_group_scrolled_begin.
+ * ```c
+ * void nk_group_scrolled_end(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ */
NK_API void nk_group_scrolled_end(struct nk_context*);
-/*/// #### nk_group_get_scroll
-/// Gets the scroll position of the given group.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// -------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __id__ | The id of the group to get the scroll position of
-/// __x_offset__ | A pointer to the x offset output (or NULL to ignore)
-/// __y_offset__ | A pointer to the y offset output (or NULL to ignore)
-*/
+
+/**
+ * # # nk_group_get_scroll
+ * Gets the scroll position of the given group.
+ * ```c
+ * void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
+ * ```
+ *
+ * Parameter | Description
+ * -------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] id | The id of the group to get the scroll position of
+ * \param[in] x_offset | A pointer to the x offset output (or NULL to ignore)
+ * \param[in] y_offset | A pointer to the y offset output (or NULL to ignore)
+ */
NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
-/*/// #### nk_group_set_scroll
-/// Sets the scroll position of the given group.
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// -------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __id__ | The id of the group to scroll
-/// __x_offset__ | The x offset to scroll to
-/// __y_offset__ | The y offset to scroll to
-*/
+
+/**
+ * # # nk_group_set_scroll
+ * Sets the scroll position of the given group.
+ * ```c
+ * void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
+ * ```
+ *
+ * Parameter | Description
+ * -------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] id | The id of the group to scroll
+ * \param[in] x_offset | The x offset to scroll to
+ * \param[in] y_offset | The y offset to scroll to
+ */
NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
-/* =============================================================================
+
+/** =============================================================================
*
* TREE
*
- * =============================================================================
-/// ### Tree
-/// Trees represent two different concept. First the concept of a collapsable
-/// UI section that can be either in a hidden or visibile state. They allow the UI
-/// user to selectively minimize the current set of visible UI to comprehend.
-/// The second concept are tree widgets for visual UI representation of trees.<br /><br />
-///
-/// Trees thereby can be nested for tree representations and multiple nested
-/// collapsable UI sections. All trees are started by calling of the
-/// `nk_tree_xxx_push_tree` functions and ended by calling one of the
-/// `nk_tree_xxx_pop_xxx()` functions. Each starting functions takes a title label
-/// and optionally an image to be displayed and the initial collapse state from
-/// the nk_collapse_states section.<br /><br />
-///
-/// The runtime state of the tree is either stored outside the library by the caller
-/// or inside which requires a unique ID. The unique ID can either be generated
-/// automatically from `__FILE__` and `__LINE__` with function `nk_tree_push`,
-/// by `__FILE__` and a user provided ID generated for example by loop index with
-/// function `nk_tree_push_id` or completely provided from outside by user with
-/// function `nk_tree_push_hashed`.
-///
-/// #### Usage
-/// To create a tree you have to call one of the seven `nk_tree_xxx_push_xxx`
-/// functions to start a collapsable UI section and `nk_tree_xxx_pop` to mark the
-/// end.
-/// Each starting function will either return `false(0)` if the tree is collapsed
-/// or hidden and therefore does not need to be filled with content or `true(1)`
-/// if visible and required to be filled.
-///
-/// !!! Note
-/// The tree header does not require and layouting function and instead
-/// calculates a auto height based on the currently used font size
-///
-/// The tree ending functions only need to be called if the tree content is
-/// actually visible. So make sure the tree push function is guarded by `if`
-/// and the pop call is only taken if the tree is visible.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// if (nk_tree_push(ctx, NK_TREE_TAB, "Tree", NK_MINIMIZED)) {
-/// nk_layout_row_dynamic(...);
-/// nk_widget(...);
-/// nk_tree_pop(ctx);
-/// }
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// Function | Description
-/// ----------------------------|-------------------------------------------
-/// nk_tree_push | Start a collapsable UI section with internal state management
-/// nk_tree_push_id | Start a collapsable UI section with internal state management callable in a look
-/// nk_tree_push_hashed | Start a collapsable UI section with internal state management with full control over internal unique ID use to store state
-/// nk_tree_image_push | Start a collapsable UI section with image and label header
-/// nk_tree_image_push_id | Start a collapsable UI section with image and label header and internal state management callable in a look
-/// nk_tree_image_push_hashed | Start a collapsable UI section with image and label header and internal state management with full control over internal unique ID use to store state
-/// nk_tree_pop | Ends a collapsable UI section
-//
-/// nk_tree_state_push | Start a collapsable UI section with external state management
-/// nk_tree_state_image_push | Start a collapsable UI section with image and label header and external state management
-/// nk_tree_state_pop | Ends a collapsabale UI section
-///
-/// #### nk_tree_type
-/// Flag | Description
-/// ----------------|----------------------------------------
-/// NK_TREE_NODE | Highlighted tree header to mark a collapsable UI section
-/// NK_TREE_TAB | Non-highighted tree header closer to tree representations
-*/
-/*/// #### nk_tree_push
-/// Starts a collapsable UI section with internal state management
-/// !!! WARNING
-/// To keep track of the runtime tree collapsable state this function uses
-/// defines `__FILE__` and `__LINE__` to generate a unique ID. If you want
-/// to call this function in a loop please use `nk_tree_push_id` or
-/// `nk_tree_push_hashed` instead.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// #define nk_tree_push(ctx, type, title, state)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __title__ | Label printed in the tree header
-/// __state__ | Initial tree state value out of nk_collapse_states
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+ * =============================================================================*/
+/**
+ * \page Tree
+ * Trees represent two different concept. First the concept of a collapsible
+ * UI section that can be either in a hidden or visible state. They allow the UI
+ * user to selectively minimize the current set of visible UI to comprehend.
+ * The second concept are tree widgets for visual UI representation of trees.<br /><br />
+ *
+ * Trees thereby can be nested for tree representations and multiple nested
+ * collapsible UI sections. All trees are started by calling of the
+ * `nk_tree_xxx_push_tree` functions and ended by calling one of the
+ * `nk_tree_xxx_pop_xxx()` functions. Each starting functions takes a title label
+ * and optionally an image to be displayed and the initial collapse state from
+ * the nk_collapse_states section.<br /><br />
+ *
+ * The runtime state of the tree is either stored outside the library by the caller
+ * or inside which requires a unique ID. The unique ID can either be generated
+ * automatically from `__FILE__` and `__LINE__` with function `nk_tree_push`,
+ * by `__FILE__` and a user provided ID generated for example by loop index with
+ * function `nk_tree_push_id` or completely provided from outside by user with
+ * function `nk_tree_push_hashed`.
+ *
+ * # Usage
+ * To create a tree you have to call one of the seven `nk_tree_xxx_push_xxx`
+ * functions to start a collapsible UI section and `nk_tree_xxx_pop` to mark the
+ * end.
+ * Each starting function will either return `false(0)` if the tree is collapsed
+ * or hidden and therefore does not need to be filled with content or `true(1)`
+ * if visible and required to be filled.
+ *
+ * !!! Note
+ * The tree header does not require and layouting function and instead
+ * calculates a auto height based on the currently used font size
+ *
+ * The tree ending functions only need to be called if the tree content is
+ * actually visible. So make sure the tree push function is guarded by `if`
+ * and the pop call is only taken if the tree is visible.
+ *
+ * ```c
+ * if (nk_tree_push(ctx, NK_TREE_TAB, "Tree", NK_MINIMIZED)) {
+ * nk_layout_row_dynamic(...);
+ * nk_widget(...);
+ * nk_tree_pop(ctx);
+ * }
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * ----------------------------|-------------------------------------------
+ * nk_tree_push | Start a collapsible UI section with internal state management
+ * nk_tree_push_id | Start a collapsible UI section with internal state management callable in a look
+ * nk_tree_push_hashed | Start a collapsible UI section with internal state management with full control over internal unique ID use to store state
+ * nk_tree_image_push | Start a collapsible UI section with image and label header
+ * nk_tree_image_push_id | Start a collapsible UI section with image and label header and internal state management callable in a look
+ * nk_tree_image_push_hashed | Start a collapsible UI section with image and label header and internal state management with full control over internal unique ID use to store state
+ * nk_tree_pop | Ends a collapsible UI section
+ * nk_tree_state_push | Start a collapsible UI section with external state management
+ * nk_tree_state_image_push | Start a collapsible UI section with image and label header and external state management
+ * nk_tree_state_pop | Ends a collapsabale UI section
+ *
+ * # nk_tree_type
+ * Flag | Description
+ * ----------------|----------------------------------------
+ * NK_TREE_NODE | Highlighted tree header to mark a collapsible UI section
+ * NK_TREE_TAB | Non-highlighted tree header closer to tree representations
+ */
+
+/**
+ * # # nk_tree_push
+ * Starts a collapsible UI section with internal state management
+ * !!! \warning
+ * To keep track of the runtime tree collapsible state this function uses
+ * defines `__FILE__` and `__LINE__` to generate a unique ID. If you want
+ * to call this function in a loop please use `nk_tree_push_id` or
+ * `nk_tree_push_hashed` instead.
+ *
+ * ```c
+ * #define nk_tree_push(ctx, type, title, state)
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Initial tree state value out of nk_collapse_states
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
#define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
-/*/// #### nk_tree_push_id
-/// Starts a collapsable UI section with internal state management callable in a look
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// #define nk_tree_push_id(ctx, type, title, state, id)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __title__ | Label printed in the tree header
-/// __state__ | Initial tree state value out of nk_collapse_states
-/// __id__ | Loop counter index if this function is called in a loop
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_push_id
+ * Starts a collapsible UI section with internal state management callable in a look
+ * ```c
+ * #define nk_tree_push_id(ctx, type, title, state, id)
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Initial tree state value out of nk_collapse_states
+ * \param[in] id | Loop counter index if this function is called in a loop
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
#define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
-/*/// #### nk_tree_push_hashed
-/// Start a collapsable UI section with internal state management with full
-/// control over internal unique ID used to store state
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __title__ | Label printed in the tree header
-/// __state__ | Initial tree state value out of nk_collapse_states
-/// __hash__ | Memory block or string to generate the ID from
-/// __len__ | Size of passed memory block or string in __hash__
-/// __seed__ | Seeding value if this function is called in a loop or default to `0`
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_push_hashed
+ * Start a collapsible UI section with internal state management with full
+ * control over internal unique ID used to store state
+ * ```c
+ * nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Initial tree state value out of nk_collapse_states
+ * \param[in] hash | Memory block or string to generate the ID from
+ * \param[in] len | Size of passed memory block or string in __hash__
+ * \param[in] seed | Seeding value if this function is called in a loop or default to `0`
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
-/*/// #### nk_tree_image_push
-/// Start a collapsable UI section with image and label header
-/// !!! WARNING
-/// To keep track of the runtime tree collapsable state this function uses
-/// defines `__FILE__` and `__LINE__` to generate a unique ID. If you want
-/// to call this function in a loop please use `nk_tree_image_push_id` or
-/// `nk_tree_image_push_hashed` instead.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// #define nk_tree_image_push(ctx, type, img, title, state)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-//
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __img__ | Image to display inside the header on the left of the label
-/// __title__ | Label printed in the tree header
-/// __state__ | Initial tree state value out of nk_collapse_states
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_image_push
+ * Start a collapsible UI section with image and label header
+ * !!! \warning
+ * To keep track of the runtime tree collapsible state this function uses
+ * defines `__FILE__` and `__LINE__` to generate a unique ID. If you want
+ * to call this function in a loop please use `nk_tree_image_push_id` or
+ * `nk_tree_image_push_hashed` instead.
+ *
+ * ```c
+ * #define nk_tree_image_push(ctx, type, img, title, state)
+ * ```
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] img | Image to display inside the header on the left of the label
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Initial tree state value out of nk_collapse_states
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
#define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
-/*/// #### nk_tree_image_push_id
-/// Start a collapsable UI section with image and label header and internal state
-/// management callable in a look
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// #define nk_tree_image_push_id(ctx, type, img, title, state, id)
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __img__ | Image to display inside the header on the left of the label
-/// __title__ | Label printed in the tree header
-/// __state__ | Initial tree state value out of nk_collapse_states
-/// __id__ | Loop counter index if this function is called in a loop
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_image_push_id
+ * Start a collapsible UI section with image and label header and internal state
+ * management callable in a look
+ *
+ * ```c
+ * #define nk_tree_image_push_id(ctx, type, img, title, state, id)
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] img | Image to display inside the header on the left of the label
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Initial tree state value out of nk_collapse_states
+ * \param[in] id | Loop counter index if this function is called in a loop
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
-/*/// #### nk_tree_image_push_hashed
-/// Start a collapsable UI section with internal state management with full
-/// control over internal unique ID used to store state
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __img__ | Image to display inside the header on the left of the label
-/// __title__ | Label printed in the tree header
-/// __state__ | Initial tree state value out of nk_collapse_states
-/// __hash__ | Memory block or string to generate the ID from
-/// __len__ | Size of passed memory block or string in __hash__
-/// __seed__ | Seeding value if this function is called in a loop or default to `0`
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_image_push_hashed
+ * Start a collapsible UI section with internal state management with full
+ * control over internal unique ID used to store state
+ * ```c
+ * nk_bool nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] img | Image to display inside the header on the left of the label
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Initial tree state value out of nk_collapse_states
+ * \param[in] hash | Memory block or string to generate the ID from
+ * \param[in] len | Size of passed memory block or string in __hash__
+ * \param[in] seed | Seeding value if this function is called in a loop or default to `0`
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
-/*/// #### nk_tree_pop
-/// Ends a collapsabale UI section
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_tree_pop(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
-*/
+
+/**
+ * # # nk_tree_pop
+ * Ends a collapsabale UI section
+ * ```c
+ * void nk_tree_pop(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
+ */
NK_API void nk_tree_pop(struct nk_context*);
-/*/// #### nk_tree_state_push
-/// Start a collapsable UI section with external state management
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __title__ | Label printed in the tree header
-/// __state__ | Persistent state to update
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_state_push
+ * Start a collapsible UI section with external state management
+ * ```c
+ * nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Persistent state to update
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
-/*/// #### nk_tree_state_image_push
-/// Start a collapsable UI section with image and label header and external state management
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
-/// __img__ | Image to display inside the header on the left of the label
-/// __type__ | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
-/// __title__ | Label printed in the tree header
-/// __state__ | Persistent state to update
-///
-/// Returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
-*/
+
+/**
+ * # # nk_tree_state_image_push
+ * Start a collapsible UI section with image and label header and external state management
+ * ```c
+ * nk_bool nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
+ * \param[in] img | Image to display inside the header on the left of the label
+ * \param[in] type | Value from the nk_tree_type section to visually mark a tree node header as either a collapseable UI section or tree node
+ * \param[in] title | Label printed in the tree header
+ * \param[in] state | Persistent state to update
+ *
+ * \returns `true(1)` if visible and fillable with widgets or `false(0)` otherwise
+ */
NK_API nk_bool nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
-/*/// #### nk_tree_state_pop
-/// Ends a collapsabale UI section
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_tree_state_pop(struct nk_context*);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// ------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
-*/
+
+/**
+ * # # nk_tree_state_pop
+ * Ends a collapsabale UI section
+ * ```c
+ * void nk_tree_state_pop(struct nk_context*);
+ * ```
+ *
+ * Parameter | Description
+ * ------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling `nk_tree_xxx_push_xxx`
+ */
NK_API void nk_tree_state_pop(struct nk_context*);
#define nk_tree_element_push(ctx, type, title, state, sel) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
@@ -3057,31 +3302,34 @@ NK_API void nk_list_view_end(struct nk_list_view*);
*
* ============================================================================= */
enum nk_widget_layout_states {
- NK_WIDGET_INVALID, /* The widget cannot be seen and is completely out of view */
- NK_WIDGET_VALID, /* The widget is completely inside the window and can be updated and drawn */
- NK_WIDGET_ROM /* The widget is partially visible and cannot be updated */
+ NK_WIDGET_INVALID, /**< The widget cannot be seen and is completely out of view */
+ NK_WIDGET_VALID, /**< The widget is completely inside the window and can be updated and drawn */
+ NK_WIDGET_ROM, /**< The widget is partially visible and cannot be updated */
+ NK_WIDGET_DISABLED /**< The widget is manually disabled and acts like NK_WIDGET_ROM */
};
enum nk_widget_states {
NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
- NK_WIDGET_STATE_INACTIVE = NK_FLAG(2), /* widget is neither active nor hovered */
- NK_WIDGET_STATE_ENTERED = NK_FLAG(3), /* widget has been hovered on the current frame */
- NK_WIDGET_STATE_HOVER = NK_FLAG(4), /* widget is being hovered */
- NK_WIDGET_STATE_ACTIVED = NK_FLAG(5),/* widget is currently activated */
- NK_WIDGET_STATE_LEFT = NK_FLAG(6), /* widget is from this frame on not hovered anymore */
- NK_WIDGET_STATE_HOVERED = NK_WIDGET_STATE_HOVER|NK_WIDGET_STATE_MODIFIED, /* widget is being hovered */
- NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED /* widget is currently activated */
+ NK_WIDGET_STATE_INACTIVE = NK_FLAG(2), /**!< widget is neither active nor hovered */
+ NK_WIDGET_STATE_ENTERED = NK_FLAG(3), /**!< widget has been hovered on the current frame */
+ NK_WIDGET_STATE_HOVER = NK_FLAG(4), /**!< widget is being hovered */
+ NK_WIDGET_STATE_ACTIVED = NK_FLAG(5),/**!< widget is currently activated */
+ NK_WIDGET_STATE_LEFT = NK_FLAG(6), /**!< widget is from this frame on not hovered anymore */
+ NK_WIDGET_STATE_HOVERED = NK_WIDGET_STATE_HOVER|NK_WIDGET_STATE_MODIFIED, /**!< widget is being hovered */
+ NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED /**!< widget is currently activated */
};
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
-NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, struct nk_context*, struct nk_vec2);
-NK_API struct nk_rect nk_widget_bounds(struct nk_context*);
-NK_API struct nk_vec2 nk_widget_position(struct nk_context*);
-NK_API struct nk_vec2 nk_widget_size(struct nk_context*);
-NK_API float nk_widget_width(struct nk_context*);
-NK_API float nk_widget_height(struct nk_context*);
-NK_API nk_bool nk_widget_is_hovered(struct nk_context*);
-NK_API nk_bool nk_widget_is_mouse_clicked(struct nk_context*, enum nk_buttons);
-NK_API nk_bool nk_widget_has_mouse_click_down(struct nk_context*, enum nk_buttons, nk_bool down);
+NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, const struct nk_context*, struct nk_vec2);
+NK_API struct nk_rect nk_widget_bounds(const struct nk_context*);
+NK_API struct nk_vec2 nk_widget_position(const struct nk_context*);
+NK_API struct nk_vec2 nk_widget_size(const struct nk_context*);
+NK_API float nk_widget_width(const struct nk_context*);
+NK_API float nk_widget_height(const struct nk_context*);
+NK_API nk_bool nk_widget_is_hovered(const struct nk_context*);
+NK_API nk_bool nk_widget_is_mouse_clicked(const struct nk_context*, enum nk_buttons);
+NK_API nk_bool nk_widget_has_mouse_click_down(const struct nk_context*, enum nk_buttons, nk_bool down);
NK_API void nk_spacing(struct nk_context*, int cols);
+NK_API void nk_widget_disable_begin(struct nk_context* ctx);
+NK_API void nk_widget_disable_end(struct nk_context* ctx);
/* =============================================================================
*
* TEXT
@@ -3159,10 +3407,13 @@ NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
* ============================================================================= */
NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
+NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
+NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
+NK_API nk_bool nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
/* =============================================================================
@@ -3171,9 +3422,13 @@ NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsi
*
* ============================================================================= */
NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
+NK_API nk_bool nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
+NK_API nk_bool nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
+NK_API nk_bool nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
+NK_API nk_bool nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment);
/* =============================================================================
*
* SELECTABLE
@@ -3202,6 +3457,15 @@ NK_API float nk_slide_float(struct nk_context*, float min, float val, float max,
NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
NK_API nk_bool nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
NK_API nk_bool nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
+
+/* =============================================================================
+ *
+ * KNOB
+ *
+ * ============================================================================= */
+NK_API nk_bool nk_knob_float(struct nk_context*, float min, float *val, float max, float step, enum nk_heading zero_direction, float dead_zone_degrees);
+NK_API nk_bool nk_knob_int(struct nk_context*, int min, int *val, int max, int step, enum nk_heading zero_direction, float dead_zone_degrees);
+
/* =============================================================================
*
* PROGRESSBAR
@@ -3221,210 +3485,216 @@ NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_colo
*
* PROPERTIES
*
- * =============================================================================
-/// ### 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 identifaction 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 propery 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int value = 0;
-/// struct nk_context ctx;
-/// nk_init_xxx(&ctx, ...);
-/// while (1) {
-/// // Input
-/// Event evt;
-/// nk_input_begin(&ctx);
-/// 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_layout_row_dynamic(...);
-/// 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);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// #### Reference
-/// Function | Description
-/// --------------------|-------------------------------------------
-/// nk_property_int | Integer property directly modifing a passed in value
-/// nk_property_float | Float property directly modifing a passed in value
-/// nk_property_double | Double property directly modifing 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 modifing 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// 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
-/// --------------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function
-/// __name__ | String used both as a label as well as a unique identifier
-/// __min__ | Minimum value not allowed to be underflown
-/// __val__ | Integer pointer to be modified
-/// __max__ | Maximum value not allowed to be overflown
-/// __step__ | Increment added and subtracted on increment and decrement button
-/// __inc_per_pixel__ | Value per pixel added or subtracted on dragging
-*/
+ * =============================================================================*/
+/**
+ * \page 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.
+ *
+ * ```c
+ * int value = 0;
+ * struct nk_context ctx;
+ * nk_init_xxx(&ctx, ...);
+ * while (1) {
+ * // Input
+ * Event evt;
+ * nk_input_begin(&ctx);
+ * 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_layout_row_dynamic(...);
+ * 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);
+ * ```
+ *
+ * # Reference
+ * Function | Description
+ * --------------------|-------------------------------------------
+ * \ref nk_property_int | Integer property directly modifying a passed in value
+ * \ref nk_property_float | Float property directly modifying a passed in value
+ * \ref nk_property_double | Double property directly modifying a passed in value
+ * \ref nk_propertyi | Integer property returning the modified int value
+ * \ref nk_propertyf | Float property returning the modified float value
+ * \ref 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.
+ *
+ * ```c
+ * 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
+ * --------------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling a layouting function
+ * \param[in] name | String used both as a label as well as a unique identifier
+ * \param[in] min | Minimum value not allowed to be underflown
+ * \param[in] val | Integer pointer to be modified
+ * \param[in] max | Maximum value not allowed to be overflown
+ * \param[in] step | Increment added and subtracted on increment and decrement button
+ * \param[in] inc_per_pixel | Value per pixel added or subtracted on dragging
+ */
NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
-/*/// #### nk_property_float
-/// Float property directly modifing 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_property_float(struct nk_context *ctx, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// --------------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function
-/// __name__ | String used both as a label as well as a unique identifier
-/// __min__ | Minimum value not allowed to be underflown
-/// __val__ | Float pointer to be modified
-/// __max__ | Maximum value not allowed to be overflown
-/// __step__ | Increment added and subtracted on increment and decrement button
-/// __inc_per_pixel__ | Value per pixel added or subtracted on dragging
-*/
+
+/**
+ * # # nk_property_float
+ * Float 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.
+ *
+ * ```c
+ * void nk_property_float(struct nk_context *ctx, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
+ * ```
+ *
+ * Parameter | Description
+ * --------------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling a layouting function
+ * \param[in] name | String used both as a label as well as a unique identifier
+ * \param[in] min | Minimum value not allowed to be underflown
+ * \param[in] val | Float pointer to be modified
+ * \param[in] max | Maximum value not allowed to be overflown
+ * \param[in] step | Increment added and subtracted on increment and decrement button
+ * \param[in] inc_per_pixel | Value per pixel added or subtracted on dragging
+ */
NK_API void nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
-/*/// #### nk_property_double
-/// Double property directly modifing 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// void nk_property_double(struct nk_context *ctx, const char *name, double min, double *val, double max, double step, double inc_per_pixel);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// --------------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function
-/// __name__ | String used both as a label as well as a unique identifier
-/// __min__ | Minimum value not allowed to be underflown
-/// __val__ | Double pointer to be modified
-/// __max__ | Maximum value not allowed to be overflown
-/// __step__ | Increment added and subtracted on increment and decrement button
-/// __inc_per_pixel__ | Value per pixel added or subtracted on dragging
-*/
+
+/**
+ * # # nk_property_double
+ * Double 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.
+ *
+ * ```c
+ * void nk_property_double(struct nk_context *ctx, const char *name, double min, double *val, double max, double step, double inc_per_pixel);
+ * ```
+ *
+ * Parameter | Description
+ * --------------------|-----------------------------------------------------------
+ * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling a layouting function
+ * \param[in] name | String used both as a label as well as a unique identifier
+ * \param[in] min | Minimum value not allowed to be underflown
+ * \param[in] val | Double pointer to be modified
+ * \param[in] max | Maximum value not allowed to be overflown
+ * \param[in] step | Increment added and subtracted on increment and decrement button
+ * \param[in] inc_per_pixel | Value per pixel added or subtracted on dragging
+ */
NK_API void nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
-/*/// #### nk_propertyi
-/// Integer property modifing a passed in value and returning the new 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// int nk_propertyi(struct nk_context *ctx, const char *name, int min, int val, int max, int step, float inc_per_pixel);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// --------------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function
-/// __name__ | String used both as a label as well as a unique identifier
-/// __min__ | Minimum value not allowed to be underflown
-/// __val__ | Current integer value to be modified and returned
-/// __max__ | Maximum value not allowed to be overflown
-/// __step__ | Increment added and subtracted on increment and decrement button
-/// __inc_per_pixel__ | Value per pixel added or subtracted on dragging
-///
-/// Returns the new modified integer value
-*/
-NK_API nk_bool nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
-/*/// #### nk_propertyf
-/// Float property modifing a passed in value and returning the new 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// float nk_propertyf(struct nk_context *ctx, const char *name, float min, float val, float max, float step, float inc_per_pixel);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// --------------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function
-/// __name__ | String used both as a label as well as a unique identifier
-/// __min__ | Minimum value not allowed to be underflown
-/// __val__ | Current float value to be modified and returned
-/// __max__ | Maximum value not allowed to be overflown
-/// __step__ | Increment added and subtracted on increment and decrement button
-/// __inc_per_pixel__ | Value per pixel added or subtracted on dragging
-///
-/// Returns the new modified float value
-*/
+
+/**
+ * # # nk_propertyi
+ * Integer property modifying a passed in value and returning the new 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.
+ *
+ * ```c
+ * int nk_propertyi(struct nk_context *ctx, const char *name, int min, int val, int max, int step, float inc_per_pixel);
+ * ```
+ *
+ * \param[in] ctx Must point to an previously initialized `nk_context` struct after calling a layouting function
+ * \param[in] name String used both as a label as well as a unique identifier
+ * \param[in] min Minimum value not allowed to be underflown
+ * \param[in] val Current integer value to be modified and returned
+ * \param[in] max Maximum value not allowed to be overflown
+ * \param[in] step Increment added and subtracted on increment and decrement button
+ * \param[in] inc_per_pixel Value per pixel added or subtracted on dragging
+ *
+ * \returns the new modified integer value
+ */
+NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
+
+/**
+ * # # nk_propertyf
+ * Float property modifying a passed in value and returning the new 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.
+ *
+ * ```c
+ * float nk_propertyf(struct nk_context *ctx, const char *name, float min, float val, float max, float step, float inc_per_pixel);
+ * ```
+ *
+ * \param[in] ctx Must point to an previously initialized `nk_context` struct after calling a layouting function
+ * \param[in] name String used both as a label as well as a unique identifier
+ * \param[in] min Minimum value not allowed to be underflown
+ * \param[in] val Current float value to be modified and returned
+ * \param[in] max Maximum value not allowed to be overflown
+ * \param[in] step Increment added and subtracted on increment and decrement button
+ * \param[in] inc_per_pixel Value per pixel added or subtracted on dragging
+ *
+ * \returns the new modified float value
+ */
NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
-/*/// #### nk_propertyd
-/// Float property modifing a passed in value and returning the new 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.
-///
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
-/// float nk_propertyd(struct nk_context *ctx, const char *name, double min, double val, double max, double step, double inc_per_pixel);
-/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///
-/// Parameter | Description
-/// --------------------|-----------------------------------------------------------
-/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function
-/// __name__ | String used both as a label as well as a unique identifier
-/// __min__ | Minimum value not allowed to be underflown
-/// __val__ | Current double value to be modified and returned
-/// __max__ | Maximum value not allowed to be overflown
-/// __step__ | Increment added and subtracted on increment and decrement button
-/// __inc_per_pixel__ | Value per pixel added or subtracted on dragging
-///
-/// Returns the new modified double value
-*/
+
+/**
+ * # # nk_propertyd
+ * Float property modifying a passed in value and returning the new 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.
+ *
+ * ```c
+ * float nk_propertyd(struct nk_context *ctx, const char *name, double min, double val, double max, double step, double inc_per_pixel);
+ * ```
+ *
+ * \param[in] ctx Must point to an previously initialized `nk_context` struct after calling a layouting function
+ * \param[in] name String used both as a label as well as a unique identifier
+ * \param[in] min Minimum value not allowed to be underflown
+ * \param[in] val Current double value to be modified and returned
+ * \param[in] max Maximum value not allowed to be overflown
+ * \param[in] step Increment added and subtracted on increment and decrement button
+ * \param[in] inc_per_pixel Value per pixel added or subtracted on dragging
+ *
+ * \returns the new modified double value
+ */
NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
+
/* =============================================================================
*
* TEXT EDIT
@@ -3452,11 +3722,11 @@ enum nk_edit_types {
NK_EDIT_EDITOR = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
};
enum nk_edit_events {
- NK_EDIT_ACTIVE = NK_FLAG(0), /* edit widget is currently being modified */
- NK_EDIT_INACTIVE = NK_FLAG(1), /* edit widget is not active and is not being modified */
- NK_EDIT_ACTIVATED = NK_FLAG(2), /* edit widget went from state inactive to state active */
- NK_EDIT_DEACTIVATED = NK_FLAG(3), /* edit widget went from state active to state inactive */
- NK_EDIT_COMMITED = NK_FLAG(4) /* edit widget has received an enter and lost focus */
+ NK_EDIT_ACTIVE = NK_FLAG(0), /**!< edit widget is currently being modified */
+ NK_EDIT_INACTIVE = NK_FLAG(1), /**!< edit widget is not active and is not being modified */
+ NK_EDIT_ACTIVATED = NK_FLAG(2), /**!< edit widget went from state inactive to state active */
+ NK_EDIT_DEACTIVATED = NK_FLAG(3), /**!< edit widget went from state active to state inactive */
+ NK_EDIT_COMMITED = NK_FLAG(4) /**!< edit widget has received an enter and lost focus */
};
NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
@@ -3485,18 +3755,18 @@ NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userd
NK_API nk_bool nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
NK_API void nk_popup_close(struct nk_context*);
NK_API void nk_popup_end(struct nk_context*);
-NK_API void nk_popup_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
+NK_API void nk_popup_get_scroll(const struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
/* =============================================================================
*
* COMBOBOX
*
* ============================================================================= */
-NK_API int nk_combo(struct nk_context*, const char **items, int count, int selected, int item_height, struct nk_vec2 size);
+NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int selected, int item_height, struct nk_vec2 size);
NK_API int nk_combo_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size);
NK_API int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size);
NK_API int nk_combo_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void *userdata, int selected, int count, int item_height, struct nk_vec2 size);
-NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size);
+NK_API void nk_combobox(struct nk_context*, const char *const *items, int count, int *selected, int item_height, struct nk_vec2 size);
NK_API void nk_combobox_string(struct nk_context*, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size);
NK_API void nk_combobox_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size);
NK_API void nk_combobox_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void*, int *selected, int count, int item_height, struct nk_vec2 size);
@@ -3576,6 +3846,9 @@ NK_API void nk_menu_end(struct nk_context*);
* STYLE
*
* ============================================================================= */
+
+#define NK_WIDGET_DISABLED_FACTOR 0.5f
+
enum nk_style_colors {
NK_COLOR_TEXT,
NK_COLOR_WINDOW,
@@ -3605,6 +3878,10 @@ enum nk_style_colors {
NK_COLOR_SCROLLBAR_CURSOR_HOVER,
NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
NK_COLOR_TAB_HEADER,
+ NK_COLOR_KNOB,
+ NK_COLOR_KNOB_CURSOR,
+ NK_COLOR_KNOB_CURSOR_HOVER,
+ NK_COLOR_KNOB_CURSOR_ACTIVE,
NK_COLOR_COUNT
};
enum nk_style_cursor {
@@ -3620,7 +3897,7 @@ enum nk_style_cursor {
NK_API void nk_style_default(struct nk_context*);
NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
-NK_API void nk_style_load_all_cursors(struct nk_context*, struct nk_cursor*);
+NK_API void nk_style_load_all_cursors(struct nk_context*, const struct nk_cursor*);
NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
NK_API nk_bool nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
@@ -3652,6 +3929,7 @@ NK_API struct nk_color nk_rgb_f(float r, float g, float b);
NK_API struct nk_color nk_rgb_fv(const float *rgb);
NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
NK_API struct nk_color nk_rgb_hex(const char *rgb);
+NK_API struct nk_color nk_rgb_factor(struct nk_color col, float factor);
NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
NK_API struct nk_color nk_rgba_u32(nk_uint);
@@ -3663,7 +3941,7 @@ NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
NK_API struct nk_color nk_rgba_hex(const char *rgb);
NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
-NK_API struct nk_colorf nk_hsva_colorfv(float *c);
+NK_API struct nk_colorf nk_hsva_colorfv(const float *c);
NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
@@ -3714,9 +3992,21 @@ NK_API struct nk_image nk_image_handle(nk_handle);
NK_API struct nk_image nk_image_ptr(void*);
NK_API struct nk_image nk_image_id(int);
NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
-NK_API struct nk_image nk_subimage_ptr(void*, unsigned short w, unsigned short h, struct nk_rect sub_region);
-NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region);
-NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region);
+NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
+NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
+NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
+/* =============================================================================
+ *
+ * 9-SLICE
+ *
+ * ============================================================================= */
+NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
+NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
+NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
+NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
+NK_API struct nk_nine_slice nk_sub9slice_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
+NK_API struct nk_nine_slice nk_sub9slice_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
+NK_API struct nk_nine_slice nk_sub9slice_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
/* =============================================================================
*
* MATH
@@ -3746,11 +4036,11 @@ NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
NK_API int nk_strlen(const char *str);
NK_API int nk_stricmp(const char *s1, const char *s2);
NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
-NK_API int nk_strtoi(const char *str, const char **endptr);
-NK_API float nk_strtof(const char *str, const char **endptr);
+NK_API int nk_strtoi(const char *str, char **endptr);
+NK_API float nk_strtof(const char *str, char **endptr);
#ifndef NK_STRTOD
#define NK_STRTOD nk_strtod
-NK_API double nk_strtod(const char *str, const char **endptr);
+NK_API double nk_strtod(const char *str, char **endptr);
#endif
NK_API int nk_strfilter(const char *text, const char *regexp);
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
@@ -3769,150 +4059,158 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
* FONT
*
* ===============================================================*/
-/* Font handling in this library was designed to be quite customizable and lets
- you decide what you want to use and what you want to provide. There are three
- different ways to use the font atlas. The first two will use your font
- handling scheme and only requires essential data to run nuklear. The next
- slightly more advanced features is font handling with vertex buffer output.
- Finally the most complex API wise is using nuklear's font baking API.
-
- 1.) Using your own implementation without vertex buffer output
- --------------------------------------------------------------
- So first up the easiest way to do font handling is by just providing a
- `nk_user_font` struct which only requires the height in pixel of the used
- font and a callback to calculate the width of a string. This way of handling
- fonts is best fitted for using the normal draw shape command API where you
- do all the text drawing yourself and the library does not require any kind
- of deeper knowledge about which font handling mechanism you use.
- IMPORTANT: the `nk_user_font` pointer provided to nuklear has to persist
- over the complete life time! I know this sucks but it is currently the only
- way to switch between fonts.
-
- float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
- {
- your_font_type *type = handle.ptr;
- float text_width = ...;
- return text_width;
- }
-
- struct nk_user_font font;
- font.userdata.ptr = &your_font_class_or_struct;
- font.height = your_font_height;
- font.width = your_text_width_calculation;
-
- struct nk_context ctx;
- nk_init_default(&ctx, &font);
-
- 2.) Using your own implementation with vertex buffer output
- --------------------------------------------------------------
- While the first approach works fine if you don't want to use the optional
- vertex buffer output it is not enough if you do. To get font handling working
- for these cases you have to provide two additional parameters inside the
- `nk_user_font`. First a texture atlas handle used to draw text as subimages
- of a bigger font atlas texture and a callback to query a character's glyph
- information (offset, size, ...). So it is still possible to provide your own
- font and use the vertex buffer output.
-
- float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
- {
- your_font_type *type = handle.ptr;
- float text_width = ...;
- return text_width;
- }
- void query_your_font_glyph(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
- {
- your_font_type *type = handle.ptr;
- glyph.width = ...;
- glyph.height = ...;
- glyph.xadvance = ...;
- glyph.uv[0].x = ...;
- glyph.uv[0].y = ...;
- glyph.uv[1].x = ...;
- glyph.uv[1].y = ...;
- glyph.offset.x = ...;
- glyph.offset.y = ...;
- }
-
- struct nk_user_font font;
- font.userdata.ptr = &your_font_class_or_struct;
- font.height = your_font_height;
- font.width = your_text_width_calculation;
- font.query = query_your_font_glyph;
- font.texture.id = your_font_texture;
-
- struct nk_context ctx;
- nk_init_default(&ctx, &font);
-
- 3.) Nuklear font baker
- ------------------------------------
- The final approach if you do not have a font handling functionality or don't
- want to use it in this library is by using the optional font baker.
- The font baker APIs can be used to create a font plus font atlas texture
- and can be used with or without the vertex buffer output.
-
- It still uses the `nk_user_font` struct and the two different approaches
- previously stated still work. The font baker is not located inside
- `nk_context` like all other systems since it can be understood as more of
- an extension to nuklear and does not really depend on any `nk_context` state.
-
- Font baker need to be initialized first by one of the nk_font_atlas_init_xxx
- functions. If you don't care about memory just call the default version
- `nk_font_atlas_init_default` which will allocate all memory from the standard library.
- If you want to control memory allocation but you don't care if the allocated
- memory is temporary and therefore can be freed directly after the baking process
- is over or permanent you can call `nk_font_atlas_init`.
-
- After successfully initializing the font baker you can add Truetype(.ttf) fonts from
- different sources like memory or from file by calling one of the `nk_font_atlas_add_xxx`.
- functions. Adding font will permanently store each font, font config and ttf memory block(!)
- inside the font atlas and allows to reuse the font atlas. If you don't want to reuse
- the font baker by for example adding additional fonts you can call
- `nk_font_atlas_cleanup` after the baking process is over (after calling nk_font_atlas_end).
-
- As soon as you added all fonts you wanted you can now start the baking process
- for every selected glyph to image by calling `nk_font_atlas_bake`.
- The baking process returns image memory, width and height which can be used to
- either create your own image object or upload it to any graphics library.
- No matter which case you finally have to call `nk_font_atlas_end` which
- will free all temporary memory including the font atlas image so make sure
- you created our texture beforehand. `nk_font_atlas_end` requires a handle
- to your font texture or object and optionally fills a `struct nk_draw_null_texture`
- which can be used for the optional vertex output. If you don't want it just
- set the argument to `NULL`.
-
- At this point you are done and if you don't want to reuse the font atlas you
- can call `nk_font_atlas_cleanup` to free all truetype blobs and configuration
- memory. Finally if you don't use the font atlas and any of it's fonts anymore
- you need to call `nk_font_atlas_clear` to free all memory still being used.
-
- struct nk_font_atlas atlas;
- nk_font_atlas_init_default(&atlas);
- nk_font_atlas_begin(&atlas);
- nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, 0);
- nk_font *font2 = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font2.ttf", 16, 0);
- const void* img = nk_font_atlas_bake(&atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
- nk_font_atlas_end(&atlas, nk_handle_id(texture), 0);
-
- struct nk_context ctx;
- nk_init_default(&ctx, &font->handle);
- while (1) {
-
- }
- nk_font_atlas_clear(&atlas);
-
- The font baker API is probably the most complex API inside this library and
- I would suggest reading some of my examples `example/` to get a grip on how
- to use the font atlas. There are a number of details I left out. For example
- how to merge fonts, configure a font with `nk_font_config` to use other languages,
- use another texture coordinate format and a lot more:
-
- struct nk_font_config cfg = nk_font_config(font_pixel_height);
- cfg.merge_mode = nk_false or nk_true;
- cfg.range = nk_font_korean_glyph_ranges();
- cfg.coord_type = NK_COORD_PIXEL;
- nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, &cfg);
+/**
+ * \page Font
+ * Font handling in this library was designed to be quite customizable and lets
+ * you decide what you want to use and what you want to provide. There are three
+ * different ways to use the font atlas. The first two will use your font
+ * handling scheme and only requires essential data to run nuklear. The next
+ * slightly more advanced features is font handling with vertex buffer output.
+ * Finally the most complex API wise is using nuklear's font baking API.
+ *
+ * # Using your own implementation without vertex buffer output
+ *
+ * So first up the easiest way to do font handling is by just providing a
+ * `nk_user_font` struct which only requires the height in pixel of the used
+ * font and a callback to calculate the width of a string. This way of handling
+ * fonts is best fitted for using the normal draw shape command API where you
+ * do all the text drawing yourself and the library does not require any kind
+ * of deeper knowledge about which font handling mechanism you use.
+ * IMPORTANT: the `nk_user_font` pointer provided to nuklear has to persist
+ * over the complete life time! I know this sucks but it is currently the only
+ * way to switch between fonts.
+ *
+ * ```c
+ * float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
+ * {
+ * your_font_type *type = handle.ptr;
+ * float text_width = ...;
+ * return text_width;
+ * }
+ *
+ * struct nk_user_font font;
+ * font.userdata.ptr = &your_font_class_or_struct;
+ * font.height = your_font_height;
+ * font.width = your_text_width_calculation;
+ *
+ * struct nk_context ctx;
+ * nk_init_default(&ctx, &font);
+ * ```
+ * # Using your own implementation with vertex buffer output
+ *
+ * While the first approach works fine if you don't want to use the optional
+ * vertex buffer output it is not enough if you do. To get font handling working
+ * for these cases you have to provide two additional parameters inside the
+ * `nk_user_font`. First a texture atlas handle used to draw text as subimages
+ * of a bigger font atlas texture and a callback to query a character's glyph
+ * information (offset, size, ...). So it is still possible to provide your own
+ * font and use the vertex buffer output.
+ *
+ * ```c
+ * float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
+ * {
+ * your_font_type *type = handle.ptr;
+ * float text_width = ...;
+ * return text_width;
+ * }
+ * void query_your_font_glyph(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
+ * {
+ * your_font_type *type = handle.ptr;
+ * glyph.width = ...;
+ * glyph.height = ...;
+ * glyph.xadvance = ...;
+ * glyph.uv[0].x = ...;
+ * glyph.uv[0].y = ...;
+ * glyph.uv[1].x = ...;
+ * glyph.uv[1].y = ...;
+ * glyph.offset.x = ...;
+ * glyph.offset.y = ...;
+ * }
+ *
+ * struct nk_user_font font;
+ * font.userdata.ptr = &your_font_class_or_struct;
+ * font.height = your_font_height;
+ * font.width = your_text_width_calculation;
+ * font.query = query_your_font_glyph;
+ * font.texture.id = your_font_texture;
+ *
+ * struct nk_context ctx;
+ * nk_init_default(&ctx, &font);
+ * ```
+ *
+ * # Nuklear font baker
+ *
+ * The final approach if you do not have a font handling functionality or don't
+ * want to use it in this library is by using the optional font baker.
+ * The font baker APIs can be used to create a font plus font atlas texture
+ * and can be used with or without the vertex buffer output.
+ *
+ * It still uses the `nk_user_font` struct and the two different approaches
+ * previously stated still work. The font baker is not located inside
+ * `nk_context` like all other systems since it can be understood as more of
+ * an extension to nuklear and does not really depend on any `nk_context` state.
+ *
+ * Font baker need to be initialized first by one of the nk_font_atlas_init_xxx
+ * functions. If you don't care about memory just call the default version
+ * `nk_font_atlas_init_default` which will allocate all memory from the standard library.
+ * If you want to control memory allocation but you don't care if the allocated
+ * memory is temporary and therefore can be freed directly after the baking process
+ * is over or permanent you can call `nk_font_atlas_init`.
+ *
+ * After successfully initializing the font baker you can add Truetype(.ttf) fonts from
+ * different sources like memory or from file by calling one of the `nk_font_atlas_add_xxx`.
+ * functions. Adding font will permanently store each font, font config and ttf memory block(!)
+ * inside the font atlas and allows to reuse the font atlas. If you don't want to reuse
+ * the font baker by for example adding additional fonts you can call
+ * `nk_font_atlas_cleanup` after the baking process is over (after calling nk_font_atlas_end).
+ *
+ * As soon as you added all fonts you wanted you can now start the baking process
+ * for every selected glyph to image by calling `nk_font_atlas_bake`.
+ * The baking process returns image memory, width and height which can be used to
+ * either create your own image object or upload it to any graphics library.
+ * No matter which case you finally have to call `nk_font_atlas_end` which
+ * will free all temporary memory including the font atlas image so make sure
+ * you created our texture beforehand. `nk_font_atlas_end` requires a handle
+ * to your font texture or object and optionally fills a `struct nk_draw_null_texture`
+ * which can be used for the optional vertex output. If you don't want it just
+ * set the argument to `NULL`.
+ *
+ * At this point you are done and if you don't want to reuse the font atlas you
+ * can call `nk_font_atlas_cleanup` to free all truetype blobs and configuration
+ * memory. Finally if you don't use the font atlas and any of it's fonts anymore
+ * you need to call `nk_font_atlas_clear` to free all memory still being used.
+ *
+ * ```c
+ * struct nk_font_atlas atlas;
+ * nk_font_atlas_init_default(&atlas);
+ * nk_font_atlas_begin(&atlas);
+ * nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, 0);
+ * nk_font *font2 = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font2.ttf", 16, 0);
+ * const void* img = nk_font_atlas_bake(&atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
+ * nk_font_atlas_end(&atlas, nk_handle_id(texture), 0);
+ *
+ * struct nk_context ctx;
+ * nk_init_default(&ctx, &font->handle);
+ * while (1) {
+ *
+ * }
+ * nk_font_atlas_clear(&atlas);
+ * ```
+ * The font baker API is probably the most complex API inside this library and
+ * I would suggest reading some of my examples `example/` to get a grip on how
+ * to use the font atlas. There are a number of details I left out. For example
+ * how to merge fonts, configure a font with `nk_font_config` to use other languages,
+ * use another texture coordinate format and a lot more:
+ *
+ * ```c
+ * struct nk_font_config cfg = nk_font_config(font_pixel_height);
+ * cfg.merge_mode = nk_false or nk_true;
+ * cfg.range = nk_font_korean_glyph_ranges();
+ * cfg.coord_type = NK_COORD_PIXEL;
+ * nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, &cfg);
+ * ```
+ */
-*/
struct nk_user_font_glyph;
typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
@@ -3921,84 +4219,56 @@ typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
struct nk_user_font_glyph {
- struct nk_vec2 uv[2];
- /* texture coordinates */
- struct nk_vec2 offset;
- /* offset between top left and glyph */
- float width, height;
- /* size of the glyph */
- float xadvance;
- /* offset to the next glyph */
+ struct nk_vec2 uv[2]; /**!< texture coordinates */
+ struct nk_vec2 offset; /**!< offset between top left and glyph */
+ float width, height; /**!< size of the glyph */
+ float xadvance; /**!< offset to the next glyph */
};
#endif
struct nk_user_font {
- nk_handle userdata;
- /* user provided font handle */
- float height;
- /* max height of the font */
- nk_text_width_f width;
- /* font string width in pixel callback */
+ nk_handle userdata; /**!< user provided font handle */
+ float height; /**!< max height of the font */
+ nk_text_width_f width; /**!< font string width in pixel callback */
#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
- nk_query_font_glyph_f query;
- /* font glyph callback to query drawing info */
- nk_handle texture;
- /* texture handle to the used font atlas or texture */
+ nk_query_font_glyph_f query; /**!< font glyph callback to query drawing info */
+ nk_handle texture; /**!< texture handle to the used font atlas or texture */
#endif
};
#ifdef NK_INCLUDE_FONT_BAKING
enum nk_font_coord_type {
- NK_COORD_UV, /* texture coordinates inside font glyphs are clamped between 0-1 */
- NK_COORD_PIXEL /* texture coordinates inside font glyphs are in absolute pixel */
+ NK_COORD_UV, /**!< texture coordinates inside font glyphs are clamped between 0-1 */
+ NK_COORD_PIXEL /**!< texture coordinates inside font glyphs are in absolute pixel */
};
struct nk_font;
struct nk_baked_font {
- float height;
- /* height of the font */
- float ascent, descent;
- /* font glyphs ascent and descent */
- nk_rune glyph_offset;
- /* glyph array offset inside the font glyph baking output array */
- nk_rune glyph_count;
- /* number of glyphs of this font inside the glyph baking array output */
- const nk_rune *ranges;
- /* font codepoint ranges as pairs of (from/to) and 0 as last element */
+ float height; /**!< height of the font */
+ float ascent; /**!< font glyphs ascent and descent */
+ float descent; /**!< font glyphs ascent and descent */
+ nk_rune glyph_offset; /**!< glyph array offset inside the font glyph baking output array */
+ nk_rune glyph_count; /**!< number of glyphs of this font inside the glyph baking array output */
+ const nk_rune *ranges; /**!< font codepoint ranges as pairs of (from/to) and 0 as last element */
};
struct nk_font_config {
- struct nk_font_config *next;
- /* NOTE: only used internally */
- void *ttf_blob;
- /* pointer to loaded TTF file memory block.
- * NOTE: not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
- nk_size ttf_size;
- /* size of the loaded TTF file memory block
- * NOTE: not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
-
- unsigned char ttf_data_owned_by_atlas;
- /* used inside font atlas: default to: 0*/
- unsigned char merge_mode;
- /* merges this font into the last font */
- unsigned char pixel_snap;
- /* align every character to pixel boundary (if true set oversample (1,1)) */
- unsigned char oversample_v, oversample_h;
- /* rasterize at hight quality for sub-pixel position */
+ struct nk_font_config *next; /**!< NOTE: only used internally */
+ void *ttf_blob; /**!< pointer to loaded TTF file memory block. * \note not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
+ nk_size ttf_size; /**!< size of the loaded TTF file memory block * \note not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
+
+ unsigned char ttf_data_owned_by_atlas; /**!< used inside font atlas: default to: 0*/
+ unsigned char merge_mode; /**!< merges this font into the last font */
+ unsigned char pixel_snap; /**!< align every character to pixel boundary (if true set oversample (1,1)) */
+ unsigned char oversample_v, oversample_h; /**!< rasterize at high quality for sub-pixel position */
unsigned char padding[3];
- float size;
- /* baked pixel height of the font */
- enum nk_font_coord_type coord_type;
- /* texture coordinate format with either pixel or UV coordinates */
- struct nk_vec2 spacing;
- /* extra pixel spacing between glyphs */
- const nk_rune *range;
- /* list of unicode ranges (2 values per range, zero terminated) */
- struct nk_baked_font *font;
- /* font to setup in the baking process: NOTE: not needed for font atlas */
- nk_rune fallback_glyph;
- /* fallback glyph to use if a given rune is not found */
+ float size; /**!< baked pixel height of the font */
+ enum nk_font_coord_type coord_type; /**!< texture coordinate format with either pixel or UV coordinates */
+ struct nk_vec2 spacing; /**!< extra pixel spacing between glyphs */
+ const nk_rune *range; /**!< list of unicode ranges (2 values per range, zero terminated) */
+ struct nk_baked_font *font; /**!< font to setup in the baking process: NOTE: not needed for font atlas */
+ nk_rune fallback_glyph; /**!< fallback glyph to use if a given rune is not found */
struct nk_font_config *n;
struct nk_font_config *p;
};
@@ -4046,7 +4316,7 @@ struct nk_font_atlas {
int font_num;
};
-/* some language glyph codepoint ranges */
+/** some language glyph codepoint ranges */
NK_API const nk_rune *nk_font_default_glyph_ranges(void);
NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
@@ -4055,8 +4325,8 @@ NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
#endif
-NK_API void nk_font_atlas_init(struct nk_font_atlas*, struct nk_allocator*);
-NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, struct nk_allocator *persistent, struct nk_allocator *transient);
+NK_API void nk_font_atlas_init(struct nk_font_atlas*, const struct nk_allocator*);
+NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, const struct nk_allocator *persistent, const struct nk_allocator *transient);
NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
NK_API struct nk_font_config nk_font_config(float pixel_height);
NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
@@ -4071,45 +4341,48 @@ NK_API struct nk_font *nk_font_atlas_add_compressed(struct nk_font_atlas*, void
NK_API struct nk_font* nk_font_atlas_add_compressed_base85(struct nk_font_atlas*, const char *data, float height, const struct nk_font_config *config);
NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
-NK_API const struct nk_font_glyph* nk_font_find_glyph(struct nk_font*, nk_rune unicode);
+NK_API const struct nk_font_glyph* nk_font_find_glyph(const struct nk_font*, nk_rune unicode);
NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
#endif
-/* ==============================================================
+/** ==============================================================
*
* MEMORY BUFFER
*
* ===============================================================*/
-/* A basic (double)-buffer with linear allocation and resetting as only
- freeing policy. The buffer's main purpose is to control all memory management
- inside the GUI toolkit and still leave memory control as much as possible in
- the hand of the user while also making sure the library is easy to use if
- not as much control is needed.
- In general all memory inside this library can be provided from the user in
- three different ways.
-
- The first way and the one providing most control is by just passing a fixed
- size memory block. In this case all control lies in the hand of the user
- since he can exactly control where the memory comes from and how much memory
- the library should consume. Of course using the fixed size API removes the
- ability to automatically resize a buffer if not enough memory is provided so
- you have to take over the resizing. While being a fixed sized buffer sounds
- quite limiting, it is very effective in this library since the actual memory
- consumption is quite stable and has a fixed upper bound for a lot of cases.
-
- If you don't want to think about how much memory the library should allocate
- at all time or have a very dynamic UI with unpredictable memory consumption
- habits but still want control over memory allocation you can use the dynamic
- allocator based API. The allocator consists of two callbacks for allocating
- and freeing memory and optional userdata so you can plugin your own allocator.
-
- The final and easiest way can be used by defining
- NK_INCLUDE_DEFAULT_ALLOCATOR which uses the standard library memory
- allocation functions malloc and free and takes over complete control over
- memory in this library.
-*/
+/**
+ * \page Memory Buffer
+ * A basic (double)-buffer with linear allocation and resetting as only
+ * freeing policy. The buffer's main purpose is to control all memory management
+ * inside the GUI toolkit and still leave memory control as much as possible in
+ * the hand of the user while also making sure the library is easy to use if
+ * not as much control is needed.
+ * In general all memory inside this library can be provided from the user in
+ * three different ways.
+ *
+ * The first way and the one providing most control is by just passing a fixed
+ * size memory block. In this case all control lies in the hand of the user
+ * since he can exactly control where the memory comes from and how much memory
+ * the library should consume. Of course using the fixed size API removes the
+ * ability to automatically resize a buffer if not enough memory is provided so
+ * you have to take over the resizing. While being a fixed sized buffer sounds
+ * quite limiting, it is very effective in this library since the actual memory
+ * consumption is quite stable and has a fixed upper bound for a lot of cases.
+ *
+ * If you don't want to think about how much memory the library should allocate
+ * at all time or have a very dynamic UI with unpredictable memory consumption
+ * habits but still want control over memory allocation you can use the dynamic
+ * allocator based API. The allocator consists of two callbacks for allocating
+ * and freeing memory and optional userdata so you can plugin your own allocator.
+ *
+ * The final and easiest way can be used by defining
+ * NK_INCLUDE_DEFAULT_ALLOCATOR which uses the standard library memory
+ * allocation functions malloc and free and takes over complete control over
+ * memory in this library.
+ */
+
struct nk_memory_status {
void *memory;
unsigned int type;
@@ -4137,24 +4410,15 @@ struct nk_buffer_marker {
struct nk_memory {void *ptr;nk_size size;};
struct nk_buffer {
- struct nk_buffer_marker marker[NK_BUFFER_MAX];
- /* buffer marker to free a buffer to a certain offset */
- struct nk_allocator pool;
- /* allocator callback for dynamic buffers */
- enum nk_allocation_type type;
- /* memory management type */
- struct nk_memory memory;
- /* memory and size of the current memory block */
- float grow_factor;
- /* growing factor for dynamic memory management */
- nk_size allocated;
- /* total amount of memory allocated */
- nk_size needed;
- /* totally consumed memory given that enough memory is present */
- nk_size calls;
- /* number of allocation calls */
- nk_size size;
- /* current size of the buffer */
+ struct nk_buffer_marker marker[NK_BUFFER_MAX]; /**!< buffer marker to free a buffer to a certain offset */
+ struct nk_allocator pool; /**!< allocator callback for dynamic buffers */
+ enum nk_allocation_type type; /**!< memory management type */
+ struct nk_memory memory; /**!< memory and size of the current memory block */
+ float grow_factor; /**!< growing factor for dynamic memory management */
+ nk_size allocated; /**!< total amount of memory allocated */
+ nk_size needed; /**!< totally consumed memory given that enough memory is present */
+ nk_size calls; /**!< number of allocation calls */
+ nk_size size; /**!< current size of the buffer */
};
#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
@@ -4162,7 +4426,7 @@ NK_API void nk_buffer_init_default(struct nk_buffer*);
#endif
NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
-NK_API void nk_buffer_info(struct nk_memory_status*, struct nk_buffer*);
+NK_API void nk_buffer_info(struct nk_memory_status*, const struct nk_buffer*);
NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
@@ -4170,21 +4434,21 @@ NK_API void nk_buffer_clear(struct nk_buffer*);
NK_API void nk_buffer_free(struct nk_buffer*);
NK_API void *nk_buffer_memory(struct nk_buffer*);
NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
-NK_API nk_size nk_buffer_total(struct nk_buffer*);
+NK_API nk_size nk_buffer_total(const struct nk_buffer*);
-/* ==============================================================
+/** ==============================================================
*
* STRING
*
* ===============================================================*/
-/* Basic string buffer which is only used in context with the text editor
+/** Basic string buffer which is only used in context with the text editor
* to manage and manipulate dynamic or fixed size string content. This is _NOT_
* the default string handling method. The only instance you should have any contact
* with this API is if you interact with an `nk_text_edit` object inside one of the
* copy and paste functions and even there only for more advanced cases. */
struct nk_str {
struct nk_buffer buffer;
- int len; /* in codepoints/runes/glyphs */
+ int len; /**!< in codepoints/runes/glyphs */
};
#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
@@ -4225,15 +4489,17 @@ NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unico
NK_API char *nk_str_get(struct nk_str*);
NK_API const char *nk_str_get_const(const struct nk_str*);
-NK_API int nk_str_len(struct nk_str*);
-NK_API int nk_str_len_char(struct nk_str*);
+NK_API int nk_str_len(const struct nk_str*);
+NK_API int nk_str_len_char(const struct nk_str*);
-/*===============================================================
+/**===============================================================
*
* TEXT EDITOR
*
* ===============================================================*/
-/* Editing text in this library is handled by either `nk_edit_string` or
+/**
+ * \page Text Editor
+ * Editing text in this library is handled by either `nk_edit_string` or
* `nk_edit_buffer`. But like almost everything in this library there are multiple
* ways of doing it and a balance between control and ease of use with memory
* as well as functionality controlled by flags.
@@ -4256,6 +4522,7 @@ NK_API int nk_str_len_char(struct nk_str*);
* It is rather designed for uses cases which make sense for a GUI library not for
* an full blown text editor.
*/
+
#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
#define NK_TEXTEDIT_UNDOSTATECOUNT 99
#endif
@@ -4318,7 +4585,7 @@ struct nk_text_edit {
struct nk_text_undo_state undo;
};
-/* filter function */
+/** filter function */
NK_API nk_bool nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
NK_API nk_bool nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
NK_API nk_bool nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
@@ -4327,11 +4594,11 @@ NK_API nk_bool nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
NK_API nk_bool nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
NK_API nk_bool nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
-/* text editor */
+/** text editor */
#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
NK_API void nk_textedit_init_default(struct nk_text_edit*);
#endif
-NK_API void nk_textedit_init(struct nk_text_edit*, struct nk_allocator*, nk_size size);
+NK_API void nk_textedit_init(struct nk_text_edit*, const struct nk_allocator*, nk_size size);
NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
NK_API void nk_textedit_free(struct nk_text_edit*);
NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
@@ -4348,50 +4615,55 @@ NK_API void nk_textedit_redo(struct nk_text_edit*);
* DRAWING
*
* ===============================================================*/
-/* This library was designed to be render backend agnostic so it does
- not draw anything to screen. Instead all drawn shapes, widgets
- are made of, are buffered into memory and make up a command queue.
- Each frame therefore fills the command buffer with draw commands
- that then need to be executed by the user and his own render backend.
- After that the command buffer needs to be cleared and a new frame can be
- started. It is probably important to note that the command buffer is the main
- drawing API and the optional vertex buffer API only takes this format and
- converts it into a hardware accessible format.
-
- To use the command queue to draw your own widgets you can access the
- command buffer of each window by calling `nk_window_get_canvas` after
- previously having called `nk_begin`:
-
- void draw_red_rectangle_widget(struct nk_context *ctx)
- {
- struct nk_command_buffer *canvas;
- struct nk_input *input = &ctx->input;
- canvas = nk_window_get_canvas(ctx);
-
- struct nk_rect space;
- enum nk_widget_layout_states state;
- state = nk_widget(&space, ctx);
- if (!state) return;
-
- if (state != NK_WIDGET_ROM)
- update_your_widget_by_user_input(...);
- nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0));
- }
+/**
+ * \page Drawing
+ * This library was designed to be render backend agnostic so it does
+ * not draw anything to screen. Instead all drawn shapes, widgets
+ * are made of, are buffered into memory and make up a command queue.
+ * Each frame therefore fills the command buffer with draw commands
+ * that then need to be executed by the user and his own render backend.
+ * After that the command buffer needs to be cleared and a new frame can be
+ * started. It is probably important to note that the command buffer is the main
+ * drawing API and the optional vertex buffer API only takes this format and
+ * converts it into a hardware accessible format.
+ *
+ * To use the command queue to draw your own widgets you can access the
+ * command buffer of each window by calling `nk_window_get_canvas` after
+ * previously having called `nk_begin`:
+ *
+ * ```c
+ * void draw_red_rectangle_widget(struct nk_context *ctx)
+ * {
+ * struct nk_command_buffer *canvas;
+ * struct nk_input *input = &ctx->input;
+ * canvas = nk_window_get_canvas(ctx);
+ *
+ * struct nk_rect space;
+ * enum nk_widget_layout_states state;
+ * state = nk_widget(&space, ctx);
+ * if (!state) return;
+ *
+ * if (state != NK_WIDGET_ROM)
+ * update_your_widget_by_user_input(...);
+ * nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0));
+ * }
+ *
+ * if (nk_begin(...)) {
+ * nk_layout_row_dynamic(ctx, 25, 1);
+ * draw_red_rectangle_widget(ctx);
+ * }
+ * nk_end(..)
+ *
+ * ```
+ * Important to know if you want to create your own widgets is the `nk_widget`
+ * call. It allocates space on the panel reserved for this widget to be used,
+ * but also returns the state of the widget space. If your widget is not seen and does
+ * not have to be updated it is '0' and you can just return. If it only has
+ * to be drawn the state will be `NK_WIDGET_ROM` otherwise you can do both
+ * update and draw your widget. The reason for separating is to only draw and
+ * update what is actually necessary which is crucial for performance.
+ */
- if (nk_begin(...)) {
- nk_layout_row_dynamic(ctx, 25, 1);
- draw_red_rectangle_widget(ctx);
- }
- nk_end(..)
-
- Important to know if you want to create your own widgets is the `nk_widget`
- call. It allocates space on the panel reserved for this widget to be used,
- but also returns the state of the widget space. If your widget is not seen and does
- not have to be updated it is '0' and you can just return. If it only has
- to be drawn the state will be `NK_WIDGET_ROM` otherwise you can do both
- update and draw your widget. The reason for separating is to only draw and
- update what is actually necessary which is crucial for performance.
-*/
enum nk_command_type {
NK_COMMAND_NOP,
NK_COMMAND_SCISSOR,
@@ -4414,7 +4686,7 @@ enum nk_command_type {
NK_COMMAND_CUSTOM
};
-/* command base and header of every command inside the buffer */
+ /** command base and header of every command inside the buffer */
struct nk_command {
enum nk_command_type type;
nk_size next;
@@ -4572,7 +4844,7 @@ struct nk_command_text {
unsigned short w, h;
float height;
int length;
- char string[1];
+ char string[2];
};
enum nk_command_clipping {
@@ -4588,26 +4860,27 @@ struct nk_command_buffer {
nk_size begin, end, last;
};
-/* shape outlines */
+/** shape outlines */
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
NK_API void nk_stroke_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color);
NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
-NK_API void nk_stroke_polyline(struct nk_command_buffer*, float *points, int point_count, float line_thickness, struct nk_color col);
-NK_API void nk_stroke_polygon(struct nk_command_buffer*, float*, int point_count, float line_thickness, struct nk_color);
+NK_API void nk_stroke_polyline(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color col);
+NK_API void nk_stroke_polygon(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color);
-/* filled shades */
+/** filled shades */
NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
NK_API void nk_fill_rect_multi_color(struct nk_command_buffer*, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
-NK_API void nk_fill_polygon(struct nk_command_buffer*, float*, int point_count, struct nk_color);
+NK_API void nk_fill_polygon(struct nk_command_buffer*, const float *points, int point_count, struct nk_color);
-/* misc */
+/** misc */
NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
+NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
NK_API void nk_draw_text(struct nk_command_buffer*, struct nk_rect, const char *text, int len, const struct nk_user_font*, struct nk_color, struct nk_color);
NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
@@ -4625,6 +4898,9 @@ struct nk_mouse_button {
struct nk_mouse {
struct nk_mouse_button buttons[NK_BUTTON_MAX];
struct nk_vec2 pos;
+#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
+ struct nk_vec2 down_pos;
+#endif
struct nk_vec2 prev;
struct nk_vec2 delta;
struct nk_vec2 scroll_delta;
@@ -4650,6 +4926,7 @@ struct nk_input {
NK_API nk_bool nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
NK_API nk_bool nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
+NK_API nk_bool nk_input_has_mouse_click_in_button_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
NK_API nk_bool nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, nk_bool down);
NK_API nk_bool nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, nk_bool down);
@@ -4670,29 +4947,30 @@ NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
*
* ===============================================================*/
#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
-/* The optional vertex buffer draw list provides a 2D drawing context
- with antialiasing functionality which takes basic filled or outlined shapes
- or a path and outputs vertexes, elements and draw commands.
- The actual draw list API is not required to be used directly while using this
- library since converting the default library draw command output is done by
- just calling `nk_convert` but I decided to still make this library accessible
- since it can be useful.
-
- The draw list is based on a path buffering and polygon and polyline
- rendering API which allows a lot of ways to draw 2D content to screen.
- In fact it is probably more powerful than needed but allows even more crazy
- things than this library provides by default.
-*/
+/**
+ * \page "Draw List"
+ * The optional vertex buffer draw list provides a 2D drawing context
+ * with antialiasing functionality which takes basic filled or outlined shapes
+ * or a path and outputs vertexes, elements and draw commands.
+ * The actual draw list API is not required to be used directly while using this
+ * library since converting the default library draw command output is done by
+ * just calling `nk_convert` but I decided to still make this library accessible
+ * since it can be useful.
+ *
+ * The draw list is based on a path buffering and polygon and polyline
+ * rendering API which allows a lot of ways to draw 2D content to screen.
+ * In fact it is probably more powerful than needed but allows even more crazy
+ * things than this library provides by default.
+ */
+
#ifdef NK_UINT_DRAW_INDEX
typedef nk_uint nk_draw_index;
#else
typedef nk_ushort nk_draw_index;
#endif
enum nk_draw_list_stroke {
- NK_STROKE_OPEN = nk_false,
- /* build up path has no connection back to the beginning */
- NK_STROKE_CLOSED = nk_true
- /* build up path has a connection back to the beginning */
+ NK_STROKE_OPEN = nk_false, /***< build up path has no connection back to the beginning */
+ NK_STROKE_CLOSED = nk_true /***< build up path has a connection back to the beginning */
};
enum nk_draw_vertex_layout_attribute {
@@ -4738,12 +5016,9 @@ struct nk_draw_vertex_layout_element {
};
struct nk_draw_command {
- unsigned int elem_count;
- /* number of elements in the current draw batch */
- struct nk_rect clip_rect;
- /* current screen clipping rectangle */
- nk_handle texture;
- /* current texture to set */
+ unsigned int elem_count; /**< number of elements in the current draw batch */
+ struct nk_rect clip_rect; /**< current screen clipping rectangle */
+ nk_handle texture; /**< current texture to set */
#ifdef NK_INCLUDE_COMMAND_USERDATA
nk_handle userdata;
#endif
@@ -4825,12 +5100,14 @@ NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata)
* ===============================================================*/
enum nk_style_item_type {
NK_STYLE_ITEM_COLOR,
- NK_STYLE_ITEM_IMAGE
+ NK_STYLE_ITEM_IMAGE,
+ NK_STYLE_ITEM_NINE_SLICE
};
union nk_style_item_data {
- struct nk_image image;
struct nk_color color;
+ struct nk_image image;
+ struct nk_nine_slice slice;
};
struct nk_style_item {
@@ -4841,6 +5118,8 @@ struct nk_style_item {
struct nk_style_text {
struct nk_color color;
struct nk_vec2 padding;
+ float color_factor;
+ float disabled_factor;
};
struct nk_style_button {
@@ -4849,6 +5128,7 @@ struct nk_style_button {
struct nk_style_item hover;
struct nk_style_item active;
struct nk_color border_color;
+ float color_factor_background;
/* text */
struct nk_color text_background;
@@ -4856,6 +5136,7 @@ struct nk_style_button {
struct nk_color text_hover;
struct nk_color text_active;
nk_flags text_alignment;
+ float color_factor_text;
/* properties */
float border;
@@ -4863,6 +5144,7 @@ struct nk_style_button {
struct nk_vec2 padding;
struct nk_vec2 image_padding;
struct nk_vec2 touch_padding;
+ float disabled_factor;
/* optional user callbacks */
nk_handle userdata;
@@ -4893,6 +5175,8 @@ struct nk_style_toggle {
struct nk_vec2 touch_padding;
float spacing;
float border;
+ float color_factor;
+ float disabled_factor;
/* optional user callbacks */
nk_handle userdata;
@@ -4928,6 +5212,8 @@ struct nk_style_selectable {
struct nk_vec2 padding;
struct nk_vec2 touch_padding;
struct nk_vec2 image_padding;
+ float color_factor;
+ float disabled_factor;
/* optional user callbacks */
nk_handle userdata;
@@ -4960,6 +5246,8 @@ struct nk_style_slider {
struct nk_vec2 padding;
struct nk_vec2 spacing;
struct nk_vec2 cursor_size;
+ float color_factor;
+ float disabled_factor;
/* optional buttons */
int show_buttons;
@@ -4974,6 +5262,39 @@ struct nk_style_slider {
void(*draw_end)(struct nk_command_buffer*, nk_handle);
};
+struct nk_style_knob {
+ /* background */
+ struct nk_style_item normal;
+ struct nk_style_item hover;
+ struct nk_style_item active;
+ struct nk_color border_color;
+
+ /* knob */
+ struct nk_color knob_normal;
+ struct nk_color knob_hover;
+ struct nk_color knob_active;
+ struct nk_color knob_border_color;
+
+ /* cursor */
+ struct nk_color cursor_normal;
+ struct nk_color cursor_hover;
+ struct nk_color cursor_active;
+
+ /* properties */
+ float border;
+ float knob_border;
+ struct nk_vec2 padding;
+ struct nk_vec2 spacing;
+ float cursor_width;
+ float color_factor;
+ float disabled_factor;
+
+ /* optional user callbacks */
+ nk_handle userdata;
+ void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+ void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
struct nk_style_progress {
/* background */
struct nk_style_item normal;
@@ -4993,6 +5314,8 @@ struct nk_style_progress {
float cursor_border;
float cursor_rounding;
struct nk_vec2 padding;
+ float color_factor;
+ float disabled_factor;
/* optional user callbacks */
nk_handle userdata;
@@ -5019,6 +5342,8 @@ struct nk_style_scrollbar {
float border_cursor;
float rounding_cursor;
struct nk_vec2 padding;
+ float color_factor;
+ float disabled_factor;
/* optional buttons */
int show_buttons;
@@ -5065,6 +5390,8 @@ struct nk_style_edit {
struct nk_vec2 scrollbar_size;
struct nk_vec2 padding;
float row_padding;
+ float color_factor;
+ float disabled_factor;
};
struct nk_style_property {
@@ -5087,6 +5414,8 @@ struct nk_style_property {
float border;
float rounding;
struct nk_vec2 padding;
+ float color_factor;
+ float disabled_factor;
struct nk_style_edit edit;
struct nk_style_button inc_button;
@@ -5109,6 +5438,9 @@ struct nk_style_chart {
float border;
float rounding;
struct nk_vec2 padding;
+ float color_factor;
+ float disabled_factor;
+ nk_bool show_markers;
};
struct nk_style_combo {
@@ -5140,6 +5472,8 @@ struct nk_style_combo {
struct nk_vec2 content_padding;
struct nk_vec2 button_padding;
struct nk_vec2 spacing;
+ float color_factor;
+ float disabled_factor;
};
struct nk_style_tab {
@@ -5162,6 +5496,8 @@ struct nk_style_tab {
float indent;
struct nk_vec2 padding;
struct nk_vec2 spacing;
+ float color_factor;
+ float disabled_factor;
};
enum nk_style_header_align {
@@ -5245,6 +5581,7 @@ struct nk_style {
struct nk_style_toggle checkbox;
struct nk_style_selectable selectable;
struct nk_style_slider slider;
+ struct nk_style_knob knob;
struct nk_style_progress progress;
struct nk_style_property property;
struct nk_style_edit edit;
@@ -5256,8 +5593,9 @@ struct nk_style {
struct nk_style_window window;
};
-NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
NK_API struct nk_style_item nk_style_item_color(struct nk_color);
+NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
+NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
NK_API struct nk_style_item nk_style_item_hide(void);
/*==============================================================
@@ -5294,6 +5632,7 @@ struct nk_chart_slot {
int count;
struct nk_vec2 last;
int index;
+ nk_bool show_markers;
};
struct nk_chart {
@@ -5372,20 +5711,13 @@ struct nk_panel {
struct nk_table;
enum nk_window_flags {
NK_WINDOW_PRIVATE = NK_FLAG(11),
- NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE,
- /* special window type growing up in height while being filled to a certain maximum height */
- NK_WINDOW_ROM = NK_FLAG(12),
- /* sets window widgets into a read only mode and does not allow input changes */
- NK_WINDOW_NOT_INTERACTIVE = NK_WINDOW_ROM|NK_WINDOW_NO_INPUT,
- /* prevents all interaction caused by input to either window or widgets inside */
- NK_WINDOW_HIDDEN = NK_FLAG(13),
- /* Hides window and stops any window interaction and drawing */
- NK_WINDOW_CLOSED = NK_FLAG(14),
- /* Directly closes and frees the window at the end of the frame */
- NK_WINDOW_MINIMIZED = NK_FLAG(15),
- /* marks the window as minimized */
- NK_WINDOW_REMOVE_ROM = NK_FLAG(16)
- /* Removes read only mode at the end of the window */
+ NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE, /**< special window type growing up in height while being filled to a certain maximum height */
+ NK_WINDOW_ROM = NK_FLAG(12), /**< sets window widgets into a read only mode and does not allow input changes */
+ NK_WINDOW_NOT_INTERACTIVE = NK_WINDOW_ROM|NK_WINDOW_NO_INPUT, /**< prevents all interaction caused by input to either window or widgets inside */
+ NK_WINDOW_HIDDEN = NK_FLAG(13), /**< Hides window and stops any window interaction and drawing */
+ NK_WINDOW_CLOSED = NK_FLAG(14), /**< Directly closes and frees the window at the end of the frame */
+ NK_WINDOW_MINIMIZED = NK_FLAG(15), /**< marks the window as minimized */
+ NK_WINDOW_REMOVE_ROM = NK_FLAG(16) /**< Removes read only mode at the end of the window */
};
struct nk_popup_state {
@@ -5443,6 +5775,7 @@ struct nk_window {
struct nk_popup_state popup;
struct nk_edit_state edit;
unsigned int scrolled;
+ nk_bool widgets_disabled;
struct nk_table *tables;
unsigned int table_count;
@@ -5456,28 +5789,32 @@ struct nk_window {
/*==============================================================
* STACK
* =============================================================*/
-/* The style modifier stack can be used to temporarily change a
+/**
+ * \page Stack
+ * # Stack
+ * The style modifier stack can be used to temporarily change a
* property inside `nk_style`. For example if you want a special
* red button you can temporarily push the old button color onto a stack
* draw the button with a red color and then you just pop the old color
* back from the stack:
*
- * nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(nk_rgb(255,0,0)));
- * nk_style_push_style_item(ctx, &ctx->style.button.hover, nk_style_item_color(nk_rgb(255,0,0)));
- * nk_style_push_style_item(ctx, &ctx->style.button.active, nk_style_item_color(nk_rgb(255,0,0)));
- * nk_style_push_vec2(ctx, &cx->style.button.padding, nk_vec2(2,2));
+ * nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(nk_rgb(255,0,0)));
+ * nk_style_push_style_item(ctx, &ctx->style.button.hover, nk_style_item_color(nk_rgb(255,0,0)));
+ * nk_style_push_style_item(ctx, &ctx->style.button.active, nk_style_item_color(nk_rgb(255,0,0)));
+ * nk_style_push_vec2(ctx, &cx->style.button.padding, nk_vec2(2,2));
*
- * nk_button(...);
+ * nk_button(...);
*
- * nk_style_pop_style_item(ctx);
- * nk_style_pop_style_item(ctx);
- * nk_style_pop_style_item(ctx);
- * nk_style_pop_vec2(ctx);
+ * nk_style_pop_style_item(ctx);
+ * nk_style_pop_style_item(ctx);
+ * nk_style_pop_style_item(ctx);
+ * nk_style_pop_vec2(ctx);
*
* Nuklear has a stack for style_items, float properties, vector properties,
* flags, colors, fonts and for button_behavior. Each has it's own fixed size stack
* which can be changed at compile time.
*/
+
#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
#endif
@@ -5607,15 +5944,15 @@ struct nk_context {
#ifdef NK_INCLUDE_COMMAND_USERDATA
nk_handle userdata;
#endif
- /* text editor objects are quite big because of an internal
+ /** text editor objects are quite big because of an internal
* undo/redo stack. Therefore it does not make sense to have one for
* each window for temporary use cases, so I only provide *one* instance
* for all windows. This works because the content is cleared anyway */
struct nk_text_edit text_edit;
- /* draw buffer used for overlay drawing operation like cursor */
+ /** draw buffer used for overlay drawing operation like cursor */
struct nk_command_buffer overlay;
- /* windows */
+ /** windows */
int build;
int use_pool;
struct nk_pool pool;
@@ -5632,6 +5969,7 @@ struct nk_context {
* MATH
* =============================================================== */
#define NK_PI 3.141592654f
+#define NK_PI_HALF 1.570796326f
#define NK_UTF_INVALID 0xFFFD
#define NK_MAX_FLOAT_PRECISION 2
@@ -5680,9 +6018,11 @@ struct nk_context {
#define NK_ALIGN_PTR_BACK(x, mask)\
(NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
+#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(EMSCRIPTEN)
+#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
+#else
#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
-#define NK_CONTAINER_OF(ptr,type,member)\
- (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
+#endif
#ifdef __cplusplus
}
@@ -5695,12 +6035,15 @@ template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};}
template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
#define NK_ALIGNOF(t) (nk_alignof<t>::value)
-#elif defined(_MSC_VER)
-#define NK_ALIGNOF(t) (__alignof(t))
#else
-#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
+#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
#endif
+#define NK_CONTAINER_OF(ptr,type,member)\
+ (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
+
+
+
#endif /* NK_NUKLEAR_H_ */
#ifdef NK_IMPLEMENTATION
@@ -5801,13 +6144,21 @@ NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
else (*(s)) = NK_WIDGET_STATE_INACTIVE;
/* math */
+#ifndef NK_INV_SQRT
NK_LIB float nk_inv_sqrt(float n);
+#endif
#ifndef NK_SIN
NK_LIB float nk_sin(float x);
#endif
#ifndef NK_COS
NK_LIB float nk_cos(float x);
#endif
+#ifndef NK_ATAN
+NK_LIB float nk_atan(float x);
+#endif
+#ifndef NK_ATAN2
+NK_LIB float nk_atan2(float y, float x);
+#endif
NK_LIB nk_uint nk_round_up_pow2(nk_uint v);
NK_LIB struct nk_rect nk_shrink_rect(struct nk_rect r, float amount);
NK_LIB struct nk_rect nk_pad_rect(struct nk_rect r, struct nk_vec2 pad);
@@ -5817,6 +6168,7 @@ NK_LIB int nk_ifloord(double x);
NK_LIB int nk_ifloorf(float x);
NK_LIB int nk_iceilf(float x);
NK_LIB int nk_log10(double n);
+NK_LIB float nk_roundf(float x);
/* util */
enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
@@ -5843,7 +6195,7 @@ NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct nk_user_font *f
NK_LIB int nk_strfmt(char *buf, int buf_size, const char *fmt, va_list args);
#endif
#ifdef NK_INCLUDE_STANDARD_IO
-NK_LIB char *nk_file_load(const char* path, nk_size* siz, struct nk_allocator *alloc);
+NK_LIB char *nk_file_load(const char* path, nk_size* siz, const struct nk_allocator *alloc);
#endif
/* buffer */
@@ -5884,11 +6236,11 @@ enum nk_window_insert_location {
NK_LIB void *nk_create_window(struct nk_context *ctx);
NK_LIB void nk_remove_window(struct nk_context*, struct nk_window*);
NK_LIB void nk_free_window(struct nk_context *ctx, struct nk_window *win);
-NK_LIB struct nk_window *nk_find_window(struct nk_context *ctx, nk_hash hash, const char *name);
+NK_LIB struct nk_window *nk_find_window(const struct nk_context *ctx, nk_hash hash, const char *name);
NK_LIB void nk_insert_window(struct nk_context *ctx, struct nk_window *win, enum nk_window_insert_location loc);
/* pool */
-NK_LIB void nk_pool_init(struct nk_pool *pool, struct nk_allocator *alloc, unsigned int capacity);
+NK_LIB void nk_pool_init(struct nk_pool *pool, const struct nk_allocator *alloc, unsigned int capacity);
NK_LIB void nk_pool_free(struct nk_pool *pool);
NK_LIB void nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size);
NK_LIB struct nk_page_element *nk_pool_alloc(struct nk_pool *pool);
@@ -5904,7 +6256,7 @@ NK_LIB void nk_remove_table(struct nk_window *win, struct nk_table *tbl);
NK_LIB void nk_free_table(struct nk_context *ctx, struct nk_table *tbl);
NK_LIB void nk_push_table(struct nk_window *win, struct nk_table *tbl);
NK_LIB nk_uint *nk_add_value(struct nk_context *ctx, struct nk_window *win, nk_hash name, nk_uint value);
-NK_LIB nk_uint *nk_find_value(struct nk_window *win, nk_hash name);
+NK_LIB nk_uint *nk_find_value(const struct nk_window *win, nk_hash name);
/* panel */
NK_LIB void *nk_create_panel(struct nk_context *ctx);
@@ -5925,7 +6277,7 @@ NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, flo
NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
NK_LIB void nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx, struct nk_window *win, int modify);
NK_LIB void nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx);
-NK_LIB void nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx);
+NK_LIB void nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx);
/* popup */
NK_LIB nk_bool nk_nonblock_begin(struct nk_context *ctx, nk_flags flags, struct nk_rect body, struct nk_rect header, enum nk_panel_type panel_type);
@@ -5960,9 +6312,9 @@ enum nk_toggle_type {
NK_TOGGLE_OPTION
};
NK_LIB nk_bool nk_toggle_behavior(const struct nk_input *in, struct nk_rect select, nk_flags *state, nk_bool active);
-NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
-NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
-NK_LIB nk_bool nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, nk_bool *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font);
+NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font, nk_flags text_alignment);
+NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font, nk_flags text_alignment);
+NK_LIB nk_bool nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, nk_bool *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font, nk_flags widget_alignment, nk_flags text_alignment);
/* progress */
NK_LIB nk_size nk_progress_behavior(nk_flags *state, struct nk_input *in, struct nk_rect r, struct nk_rect cursor, nk_size max, nk_size value, nk_bool modifiable);
@@ -6033,21 +6385,36 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop
#ifdef NK_INCLUDE_FONT_BAKING
+/**
+ * @def NK_NO_STB_RECT_PACK_IMPLEMENTATION
+ *
+ * When defined, will avoid enabling STB_RECT_PACK_IMPLEMENTATION for when stb_rect_pack.h is already implemented elsewhere.
+ */
+#ifndef NK_NO_STB_RECT_PACK_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
+#endif /* NK_NO_STB_RECT_PACK_IMPLEMENTATION */
+
+/**
+ * @def NK_NO_STB_TRUETYPE_IMPLEMENTATION
+ *
+ * When defined, will avoid enabling STB_TRUETYPE_IMPLEMENTATION for when stb_truetype.h is already implemented elsewhere.
+ */
+#ifndef NK_NO_STB_TRUETYPE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
+#endif /* NK_NO_STB_TRUETYPE_IMPLEMENTATION */
/* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */
#ifndef STBTT_malloc
static void*
nk_stbtt_malloc(nk_size size, void *user_data) {
- struct nk_allocator *alloc = (struct nk_allocator *) user_data;
- return alloc->alloc(alloc->userdata, 0, size);
+ struct nk_allocator *alloc = (struct nk_allocator *) user_data;
+ return alloc->alloc(alloc->userdata, 0, size);
}
static void
nk_stbtt_free(void *ptr, void *user_data) {
- struct nk_allocator *alloc = (struct nk_allocator *) user_data;
- alloc->free(alloc->userdata, ptr);
+ struct nk_allocator *alloc = (struct nk_allocator *) user_data;
+ alloc->free(alloc->userdata, ptr);
}
#define STBTT_malloc(x,u) nk_stbtt_malloc(x,u)
@@ -6062,39 +6429,41 @@ nk_stbtt_free(void *ptr, void *user_data) {
-
/* ===============================================================
*
* MATH
*
* ===============================================================*/
-/* Since nuklear is supposed to work on all systems providing floating point
- math without any dependencies I also had to implement my own math functions
- for sqrt, sin and cos. Since the actual highly accurate implementations for
- the standard library functions are quite complex and I do not need high
- precision for my use cases I use approximations.
-
- Sqrt
- ----
- For square root nuklear uses the famous fast inverse square root:
- https://en.wikipedia.org/wiki/Fast_inverse_square_root with
- slightly tweaked magic constant. While on today's hardware it is
- probably not faster it is still fast and accurate enough for
- nuklear's use cases. IMPORTANT: this requires float format IEEE 754
-
- Sine/Cosine
- -----------
- All constants inside both function are generated Remez's minimax
- approximations for value range 0...2*PI. The reason why I decided to
- approximate exactly that range is that nuklear only needs sine and
- cosine to generate circles which only requires that exact range.
- In addition I used Remez instead of Taylor for additional precision:
- www.lolengine.net/blog/2011/12/21/better-function-approximations.
-
- The tool I used to generate constants for both sine and cosine
- (it can actually approximate a lot more functions) can be
- found here: www.lolengine.net/wiki/oss/lolremez
+/*/// ### Math
+/// Since nuklear is supposed to work on all systems providing floating point
+/// math without any dependencies I also had to implement my own math functions
+/// for sqrt, sin and cos. Since the actual highly accurate implementations for
+/// the standard library functions are quite complex and I do not need high
+/// precision for my use cases I use approximations.
+///
+/// Sqrt
+/// ----
+/// For square root nuklear uses the famous fast inverse square root:
+/// https://en.wikipedia.org/wiki/Fast_inverse_square_root with
+/// slightly tweaked magic constant. While on today's hardware it is
+/// probably not faster it is still fast and accurate enough for
+/// nuklear's use cases. IMPORTANT: this requires float format IEEE 754
+///
+/// Sine/Cosine
+/// -----------
+/// All constants inside both function are generated Remez's minimax
+/// approximations for value range 0...2*PI. The reason why I decided to
+/// approximate exactly that range is that nuklear only needs sine and
+/// cosine to generate circles which only requires that exact range.
+/// In addition I used Remez instead of Taylor for additional precision:
+/// www.lolengine.net/blog/2011/12/21/better-function-approximations.
+///
+/// The tool I used to generate constants for both sine and cosine
+/// (it can actually approximate a lot more functions) can be
+/// found here: www.lolengine.net/wiki/oss/lolremez
*/
+#ifndef NK_INV_SQRT
+#define NK_INV_SQRT nk_inv_sqrt
NK_LIB float
nk_inv_sqrt(float n)
{
@@ -6107,6 +6476,7 @@ nk_inv_sqrt(float n)
conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
return conv.f;
}
+#endif
#ifndef NK_SIN
#define NK_SIN nk_sin
NK_LIB float
@@ -6142,6 +6512,52 @@ nk_cos(float x)
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
}
#endif
+#ifndef NK_ATAN
+#define NK_ATAN nk_atan
+NK_LIB float
+nk_atan(float x)
+{
+ /* ./lolremez --progress --float -d 9 -r "0:pi*2" "atan(x)" */
+ float u = -1.0989005e-05f;
+ NK_ASSERT(x >= 0.0f && "TODO support negative floats");
+ u = u * x + 0.00034117949f;
+ u = u * x + -0.0044932296f;
+ u = u * x + 0.032596264f;
+ u = u * x + -0.14088021f;
+ u = u * x + 0.36040401f;
+ u = u * x + -0.47017866f;
+ u = u * x + 0.00050198776f;
+ u = u * x + 1.0077682f;
+ u = u * x + -0.0004765437f;
+ return u;
+}
+#endif
+#ifndef NK_ATAN2
+#define NK_ATAN2 nk_atan2
+NK_LIB float
+nk_atan2(float y, float x)
+{
+ float ax = NK_ABS(x),
+ ay = NK_ABS(y);
+ /* 0 = +y +x 1 = -y +x
+ 2 = +y -x 3 = -y -x */
+ nk_uint signs = (y < 0) | ((x < 0) << 1);
+
+ float a;
+ if(y == 0.0 && x == 0.0) return 0.0f;
+ a = (ay > ax)
+ ? NK_PI_HALF - NK_ATAN(ax / ay)
+ : NK_ATAN(ay / ax);
+
+ switch(signs){
+ case 0: return a;
+ case 1: return -a;
+ case 2: return -a + NK_PI;
+ case 3: return a - NK_PI;
+ }
+ return 0.0f; /* prevents warning */
+}
+#endif
NK_LIB nk_uint
nk_round_up_pow2(nk_uint v)
{
@@ -6209,6 +6625,11 @@ nk_log10(double n)
if (neg) exp = -exp;
return exp;
}
+NK_LIB float
+nk_roundf(float x)
+{
+ return (x >= 0.0f) ? (float)nk_ifloorf(x + 0.5f) : (float)nk_iceilf(x - 0.5f);
+}
NK_API struct nk_rect
nk_get_null_rect(void)
{
@@ -6503,7 +6924,7 @@ nk_strlen(const char *str)
return siz;
}
NK_API int
-nk_strtoi(const char *str, const char **endptr)
+nk_strtoi(const char *str, char **endptr)
{
int neg = 1;
const char *p = str;
@@ -6523,15 +6944,15 @@ nk_strtoi(const char *str, const char **endptr)
p++;
}
if (endptr)
- *endptr = p;
+ *endptr = (char *)p;
return neg*value;
}
NK_API double
-nk_strtod(const char *str, const char **endptr)
+nk_strtod(const char *str, char **endptr)
{
double m;
double neg = 1.0;
- const char *p = str;
+ char *p = (char *)str;
double value = 0;
double number = 0;
@@ -6584,7 +7005,7 @@ nk_strtod(const char *str, const char **endptr)
return number;
}
NK_API float
-nk_strtof(const char *str, const char **endptr)
+nk_strtof(const char *str, char **endptr)
{
float float_value;
double double_value;
@@ -6995,7 +7416,7 @@ nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args)
/* width argument */
width = NK_DEFAULT;
if (*iter >= '1' && *iter <= '9') {
- const char *end;
+ char *end;
width = nk_strtoi(iter, &end);
if (end == iter)
width = -1;
@@ -7013,7 +7434,7 @@ nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args)
precision = va_arg(args, int);
iter++;
} else {
- const char *end;
+ char *end;
precision = nk_strtoi(iter, &end);
if (end == iter)
precision = -1;
@@ -7346,7 +7767,7 @@ nk_murmur_hash(const void * key, int len, nk_hash seed)
}
#ifdef NK_INCLUDE_STANDARD_IO
NK_LIB char*
-nk_file_load(const char* path, nk_size* siz, struct nk_allocator *alloc)
+nk_file_load(const char* path, nk_size* siz, const struct nk_allocator *alloc)
{
char *buf;
FILE *fd;
@@ -7514,6 +7935,16 @@ nk_parse_hex(const char *p, int length)
return i;
}
NK_API struct nk_color
+nk_rgb_factor(struct nk_color col, float factor)
+{
+ if (factor == 1.0f)
+ return col;
+ col.r = (nk_byte)(col.r * factor);
+ col.g = (nk_byte)(col.g * factor);
+ col.b = (nk_byte)(col.b * factor);
+ return col;
+}
+NK_API struct nk_color
nk_rgba(int r, int g, int b, int a)
{
struct nk_color ret;
@@ -7727,7 +8158,7 @@ nk_hsva_colorf(float h, float s, float v, float a)
return out;
}
NK_API struct nk_colorf
-nk_hsva_colorfv(float *c)
+nk_hsva_colorfv(const float *c)
{
return nk_hsva_colorf(c[0], c[1], c[2], c[3]);
}
@@ -7906,7 +8337,6 @@ nk_color_hsv_bv(nk_byte *out, struct nk_color in)
-
/* ===============================================================
*
* UTF-8
@@ -8293,7 +8723,7 @@ nk_buffer_free(struct nk_buffer *b)
b->pool.free(b->pool.userdata, b->memory.ptr);
}
NK_API void
-nk_buffer_info(struct nk_memory_status *s, struct nk_buffer *b)
+nk_buffer_info(struct nk_memory_status *s, const struct nk_buffer *b)
{
NK_ASSERT(b);
NK_ASSERT(s);
@@ -8319,7 +8749,7 @@ nk_buffer_memory_const(const struct nk_buffer *buffer)
return buffer->memory.ptr;
}
NK_API nk_size
-nk_buffer_total(struct nk_buffer *buffer)
+nk_buffer_total(const struct nk_buffer *buffer)
{
NK_ASSERT(buffer);
if (!buffer) return 0;
@@ -8329,7 +8759,6 @@ nk_buffer_total(struct nk_buffer *buffer)
-
/* ===============================================================
*
* STRING
@@ -8393,7 +8822,6 @@ nk_str_append_text_utf8(struct nk_str *str, const char *text, int len)
NK_API int
nk_str_append_str_utf8(struct nk_str *str, const char *text)
{
- int runes = 0;
int byte_len = 0;
int num_runes = 0;
int glyph_len = 0;
@@ -8407,7 +8835,7 @@ nk_str_append_str_utf8(struct nk_str *str, const char *text)
num_runes++;
}
nk_str_append_text_char(str, text, byte_len);
- return runes;
+ return num_runes;
}
NK_API int
nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len)
@@ -8522,7 +8950,6 @@ nk_str_insert_text_utf8(struct nk_str *str, int pos, const char *text, int len)
NK_API int
nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
{
- int runes = 0;
int byte_len = 0;
int num_runes = 0;
int glyph_len = 0;
@@ -8536,7 +8963,7 @@ nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
num_runes++;
}
nk_str_insert_at_rune(str, pos, text, byte_len);
- return runes;
+ return num_runes;
}
NK_API int
nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len)
@@ -8750,14 +9177,14 @@ nk_str_get_const(const struct nk_str *s)
return (const char*)s->buffer.memory.ptr;
}
NK_API int
-nk_str_len(struct nk_str *s)
+nk_str_len(const struct nk_str *s)
{
NK_ASSERT(s);
if (!s || !s->len || !s->buffer.allocated) return 0;
return s->len;
}
NK_API int
-nk_str_len_char(struct nk_str *s)
+nk_str_len_char(const struct nk_str *s)
{
NK_ASSERT(s);
if (!s || !s->len || !s->buffer.allocated) return 0;
@@ -8781,7 +9208,6 @@ nk_str_free(struct nk_str *str)
-
/* ==============================================================
*
* DRAW
@@ -9110,7 +9536,7 @@ nk_fill_triangle(struct nk_command_buffer *b, float x0, float y0, float x1,
cmd->color = c;
}
NK_API void
-nk_stroke_polygon(struct nk_command_buffer *b, float *points, int point_count,
+nk_stroke_polygon(struct nk_command_buffer *b, const float *points, int point_count,
float line_thickness, struct nk_color col)
{
int i;
@@ -9131,7 +9557,7 @@ nk_stroke_polygon(struct nk_command_buffer *b, float *points, int point_count,
}
}
NK_API void
-nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
+nk_fill_polygon(struct nk_command_buffer *b, const float *points, int point_count,
struct nk_color col)
{
int i;
@@ -9152,7 +9578,7 @@ nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
}
}
NK_API void
-nk_stroke_polyline(struct nk_command_buffer *b, float *points, int point_count,
+nk_stroke_polyline(struct nk_command_buffer *b, const float *points, int point_count,
float line_thickness, struct nk_color col)
{
int i;
@@ -9196,6 +9622,83 @@ nk_draw_image(struct nk_command_buffer *b, struct nk_rect r,
cmd->col = col;
}
NK_API void
+nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
+ const struct nk_nine_slice *slc, struct nk_color col)
+{
+ struct nk_image img;
+ const struct nk_image *slcimg = (const struct nk_image*)slc;
+ nk_ushort rgnX, rgnY, rgnW, rgnH;
+ rgnX = slcimg->region[0];
+ rgnY = slcimg->region[1];
+ rgnW = slcimg->region[2];
+ rgnH = slcimg->region[3];
+
+ /* top-left */
+ img.handle = slcimg->handle;
+ img.w = slcimg->w;
+ img.h = slcimg->h;
+ img.region[0] = rgnX;
+ img.region[1] = rgnY;
+ img.region[2] = slc->l;
+ img.region[3] = slc->t;
+
+ nk_draw_image(b,
+ nk_rect(r.x, r.y, (float)slc->l, (float)slc->t),
+ &img, col);
+
+#define IMG_RGN(x, y, w, h) img.region[0] = (nk_ushort)(x); img.region[1] = (nk_ushort)(y); img.region[2] = (nk_ushort)(w); img.region[3] = (nk_ushort)(h);
+
+ /* top-center */
+ IMG_RGN(rgnX + slc->l, rgnY, rgnW - slc->l - slc->r, slc->t);
+ nk_draw_image(b,
+ nk_rect(r.x + (float)slc->l, r.y, (float)(r.w - slc->l - slc->r), (float)slc->t),
+ &img, col);
+
+ /* top-right */
+ IMG_RGN(rgnX + rgnW - slc->r, rgnY, slc->r, slc->t);
+ nk_draw_image(b,
+ nk_rect(r.x + r.w - (float)slc->r, r.y, (float)slc->r, (float)slc->t),
+ &img, col);
+
+ /* center-left */
+ IMG_RGN(rgnX, rgnY + slc->t, slc->l, rgnH - slc->t - slc->b);
+ nk_draw_image(b,
+ nk_rect(r.x, r.y + (float)slc->t, (float)slc->l, (float)(r.h - slc->t - slc->b)),
+ &img, col);
+
+ /* center */
+ IMG_RGN(rgnX + slc->l, rgnY + slc->t, rgnW - slc->l - slc->r, rgnH - slc->t - slc->b);
+ nk_draw_image(b,
+ nk_rect(r.x + (float)slc->l, r.y + (float)slc->t, (float)(r.w - slc->l - slc->r), (float)(r.h - slc->t - slc->b)),
+ &img, col);
+
+ /* center-right */
+ IMG_RGN(rgnX + rgnW - slc->r, rgnY + slc->t, slc->r, rgnH - slc->t - slc->b);
+ nk_draw_image(b,
+ nk_rect(r.x + r.w - (float)slc->r, r.y + (float)slc->t, (float)slc->r, (float)(r.h - slc->t - slc->b)),
+ &img, col);
+
+ /* bottom-left */
+ IMG_RGN(rgnX, rgnY + rgnH - slc->b, slc->l, slc->b);
+ nk_draw_image(b,
+ nk_rect(r.x, r.y + r.h - (float)slc->b, (float)slc->l, (float)slc->b),
+ &img, col);
+
+ /* bottom-center */
+ IMG_RGN(rgnX + slc->l, rgnY + rgnH - slc->b, rgnW - slc->l - slc->r, slc->b);
+ nk_draw_image(b,
+ nk_rect(r.x + (float)slc->l, r.y + r.h - (float)slc->b, (float)(r.w - slc->l - slc->r), (float)slc->b),
+ &img, col);
+
+ /* bottom-right */
+ IMG_RGN(rgnX + rgnW - slc->r, rgnY + rgnH - slc->b, slc->r, slc->b);
+ nk_draw_image(b,
+ nk_rect(r.x + r.w - (float)slc->r, r.y + r.h - (float)slc->b, (float)slc->r, (float)slc->b),
+ &img, col);
+
+#undef IMG_RGN
+}
+NK_API void
nk_push_custom(struct nk_command_buffer *b, struct nk_rect r,
nk_command_custom_callback cb, nk_handle usr)
{
@@ -9263,7 +9766,6 @@ nk_draw_text(struct nk_command_buffer *b, struct nk_rect r,
-
/* ===============================================================
*
* VERTEX
@@ -9440,7 +9942,7 @@ nk_draw_list_add_clip(struct nk_draw_list *list, struct nk_rect rect)
NK_ASSERT(list);
if (!list) return;
if (!list->cmd_count) {
- nk_draw_list_push_command(list, rect, list->config.null.texture);
+ nk_draw_list_push_command(list, rect, list->config.tex_null.texture);
} else {
struct nk_draw_command *prev = nk_draw_list_command_last(list);
if (prev->elem_count == 0)
@@ -9459,14 +9961,16 @@ nk_draw_list_push_image(struct nk_draw_list *list, nk_handle texture)
struct nk_draw_command *prev = nk_draw_list_command_last(list);
if (prev->elem_count == 0) {
prev->texture = texture;
- #ifdef NK_INCLUDE_COMMAND_USERDATA
+ #ifdef NK_INCLUDE_COMMAND_USERDATA
prev->userdata = list->userdata;
- #endif
- } else if (prev->texture.id != texture.id
- #ifdef NK_INCLUDE_COMMAND_USERDATA
- || prev->userdata.id != list->userdata.id
- #endif
- ) nk_draw_list_push_command(list, prev->clip_rect, texture);
+ #endif
+ } else if (prev->texture.id != texture.id
+ #ifdef NK_INCLUDE_COMMAND_USERDATA
+ || prev->userdata.id != list->userdata.id
+ #endif
+ ) {
+ nk_draw_list_push_command(list, prev->clip_rect, texture);
+ }
}
}
#ifdef NK_INCLUDE_COMMAND_USERDATA
@@ -9490,14 +9994,14 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
/* This assert triggers because your are drawing a lot of stuff and nuklear
* defined `nk_draw_index` as `nk_ushort` to safe space be default.
*
- * So you reached the maximum number of indicies or rather vertexes.
- * To solve this issue please change typdef `nk_draw_index` to `nk_uint`
+ * So you reached the maximum number of indices or rather vertexes.
+ * To solve this issue please change typedef `nk_draw_index` to `nk_uint`
* and don't forget to specify the new element size in your drawing
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
- * instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
+ * instead of specifying `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
* Sorry for the inconvenience. */
if(sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
- "To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
+ "To many vertices for 16-bit vertex indices. Please read comment above on how to solve this problem"));
return vtx;
}
NK_INTERN nk_draw_index*
@@ -9740,7 +10244,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p
/* vec2 inverted length */
len = nk_vec2_len_sqr(diff);
if (len != 0.0f)
- len = nk_inv_sqrt(len);
+ len = NK_INV_SQRT(len);
else len = 1.0f;
diff = nk_vec2_muls(diff, len);
@@ -9795,7 +10299,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p
/* fill vertices */
for (i = 0; i < points_count; ++i) {
- const struct nk_vec2 uv = list->config.null.uv;
+ const struct nk_vec2 uv = list->config.tex_null.uv;
vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
@@ -9860,7 +10364,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p
/* add vertices */
for (i = 0; i < points_count; ++i) {
- const struct nk_vec2 uv = list->config.null.uv;
+ const struct nk_vec2 uv = list->config.tex_null.uv;
vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
@@ -9881,7 +10385,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p
for (i1 = 0; i1 < count; ++i1) {
float dx, dy;
- const struct nk_vec2 uv = list->config.null.uv;
+ const struct nk_vec2 uv = list->config.tex_null.uv;
const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
const struct nk_vec2 p1 = points[i1];
const struct nk_vec2 p2 = points[i2];
@@ -9891,7 +10395,7 @@ nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *p
/* vec2 inverted length */
len = nk_vec2_len_sqr(diff);
if (len != 0.0f)
- len = nk_inv_sqrt(len);
+ len = NK_INV_SQRT(len);
else len = 1.0f;
diff = nk_vec2_muls(diff, len);
@@ -9981,7 +10485,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list,
/* vec2 inverted length */
float len = nk_vec2_len_sqr(diff);
if (len != 0.0f)
- len = nk_inv_sqrt(len);
+ len = NK_INV_SQRT(len);
else len = 1.0f;
diff = nk_vec2_muls(diff, len);
@@ -9991,7 +10495,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list,
/* add vertices + indexes */
for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
- const struct nk_vec2 uv = list->config.null.uv;
+ const struct nk_vec2 uv = list->config.tex_null.uv;
struct nk_vec2 n0 = normals[i0];
struct nk_vec2 n1 = normals[i1];
struct nk_vec2 dm = nk_vec2_muls(nk_vec2_add(n0, n1), 0.5f);
@@ -10028,7 +10532,7 @@ nk_draw_list_fill_poly_convex(struct nk_draw_list *list,
if (!vtx || !ids) return;
for (i = 0; i < vtx_count; ++i)
- vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
+ vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.tex_null.uv, col);
for (i = 2; i < points_count; ++i) {
ids[0] = (nk_draw_index)index;
ids[1] = (nk_draw_index)(index+ i - 1);
@@ -10057,8 +10561,8 @@ nk_draw_list_path_line_to(struct nk_draw_list *list, struct nk_vec2 pos)
nk_draw_list_add_clip(list, nk_null_rect);
cmd = nk_draw_list_command_last(list);
- if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
- nk_draw_list_push_image(list, list->config.null.texture);
+ if (cmd && cmd->texture.ptr != list->config.tex_null.texture.ptr)
+ nk_draw_list_push_image(list, list->config.tex_null.texture);
points = nk_draw_list_alloc_path(list, 1);
if (!points) return;
@@ -10260,7 +10764,7 @@ nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rec
NK_ASSERT(list);
if (!list) return;
- nk_draw_list_push_image(list, list->config.null.texture);
+ nk_draw_list_push_image(list, list->config.tex_null.texture);
index = (nk_draw_index)list->vertex_count;
vtx = nk_draw_list_alloc_vertices(list, 4);
idx = nk_draw_list_alloc_elements(list, 6);
@@ -10270,10 +10774,10 @@ nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rec
idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
- vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y), list->config.null.uv, col_left);
- vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y), list->config.null.uv, col_top);
- vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y + rect.h), list->config.null.uv, col_right);
- vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y + rect.h), list->config.null.uv, col_bottom);
+ vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y), list->config.tex_null.uv, col_left);
+ vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y), list->config.tex_null.uv, col_top);
+ vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y + rect.h), list->config.tex_null.uv, col_right);
+ vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y + rect.h), list->config.tex_null.uv, col_bottom);
}
NK_API void
nk_draw_list_fill_triangle(struct nk_draw_list *list, struct nk_vec2 a,
@@ -10600,12 +11104,18 @@ nk__draw_next(const struct nk_draw_command *cmd,
#endif
-/* stb_rect_pack.h - v1.00 - public domain - rectangle packing */
+/* stb_rect_pack.h - v1.01 - public domain - rectangle packing */
/* Sean Barrett 2014 */
/* */
/* Useful for e.g. packing rectangular textures into an atlas. */
/* Does not do rotation. */
/* */
+/* Before #including, */
+/* */
+/* #define STB_RECT_PACK_IMPLEMENTATION */
+/* */
+/* in the file that you want to have the implementation. */
+/* */
/* Not necessarily the awesomest packing method, but better than */
/* the totally naive one in stb_truetype (which is primarily what */
/* this is meant to replace). */
@@ -10637,6 +11147,7 @@ nk__draw_next(const struct nk_draw_command *cmd,
/* */
/* Version history: */
/* */
+/* 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section */
/* 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles */
/* 0.99 (2019-02-07) warning fixes */
/* 0.11 (2017-03-03) return packing success/fail result */
@@ -10677,11 +11188,10 @@ typedef struct stbrp_context stbrp_context;
typedef struct stbrp_node stbrp_node;
typedef struct stbrp_rect stbrp_rect;
-#ifdef STBRP_LARGE_RECTS
typedef int stbrp_coord;
-#else
-typedef unsigned short stbrp_coord;
-#endif
+
+#define STBRP__MAXVAL 0x7fffffff
+/* Mostly for internal use, but this is the maximum supported coordinate value. */
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
/* Assign packed locations to rectangles. The rectangles are of type */
@@ -10811,8 +11321,10 @@ struct stbrp_context
#ifdef _MSC_VER
#define STBRP__NOTUSED(v) (void)(v)
+#define STBRP__CDECL __cdecl
#else
#define STBRP__NOTUSED(v) (void)sizeof(v)
+#define STBRP__CDECL
#endif
enum
@@ -10855,9 +11367,6 @@ STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_ou
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
{
int i;
-#ifndef STBRP_LARGE_RECTS
- STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
-#endif
for (i=0; i < num_nodes-1; ++i)
nodes[i].next = &nodes[i+1];
@@ -10876,11 +11385,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
context->extra[0].y = 0;
context->extra[0].next = &context->extra[1];
context->extra[1].x = (stbrp_coord) width;
-#ifdef STBRP_LARGE_RECTS
context->extra[1].y = (1<<30);
-#else
- context->extra[1].y = 65535;
-#endif
context->extra[1].next = NULL;
}
@@ -10912,7 +11417,7 @@ static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0
if (node->y > min_y) {
/* raise min_y higher. */
/* we've accounted for all waste up to min_y, */
- /* but we'll now add more waste for everything we've visted */
+ /* but we'll now add more waste for everything we've visited */
waste_area += visited_width * (node->y - min_y);
min_y = node->y;
/* the first time through, visited_width might be reduced */
@@ -11067,7 +11572,7 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
/* insert the new node into the right starting point, and */
/* let 'cur' point to the remaining nodes needing to be */
- /* stiched back in */
+ /* stitched back in */
cur = *res.prev_link;
if (cur->x < res.x) {
@@ -11122,7 +11627,7 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
return res;
}
-static int rect_height_compare(const void *a, const void *b)
+static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
@@ -11133,19 +11638,13 @@ static int rect_height_compare(const void *a, const void *b)
return (p->w > q->w) ? -1 : (p->w < q->w);
}
-static int rect_original_order(const void *a, const void *b)
+static int STBRP__CDECL rect_original_order(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
}
-#ifdef STBRP_LARGE_RECTS
-#define STBRP__MAXVAL 0xffffffff
-#else
-#define STBRP__MAXVAL 0xffff
-#endif
-
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
{
int i, all_rects_packed = 1;
@@ -11229,8 +11728,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/
-/* stb_truetype.h - v1.24 - public domain */
-/* authored from 2009-2020 by Sean Barrett / RAD Game Tools */
+/* stb_truetype.h - v1.26 - public domain */
+/* authored from 2009-2021 by Sean Barrett / RAD Game Tools */
/* */
/* ======================================================================= */
/* */
@@ -11284,11 +11783,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Johan Duparc Thomas Fields */
/* Hou Qiming Derek Vinyard */
/* Rob Loach Cort Stratton */
-/* Kenney Phillis Jr. Brian Costabile */
-/* Ken Voskuil (kaesve) */
+/* Kenney Phillis Jr. Brian Costabile */
+/* Ken Voskuil (kaesve) */
/* */
/* VERSION HISTORY */
/* */
+/* 1.26 (2021-08-28) fix broken rasterizer */
+/* 1.25 (2021-07-11) many fixes */
/* 1.24 (2020-02-05) fix warning */
/* 1.23 (2020-02-02) query SVG data for glyphs; query whole kerning table (but only kern not GPOS) */
/* 1.22 (2019-08-11) minimize missing-glyph duplication; fix kerning if both 'GPOS' and 'kern' are defined */
@@ -11501,8 +12002,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* // SAMPLE PROGRAMS */
/* // */
/* */
-/* Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless */
-/* */
+/* Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless. */
+/* See "tests/truetype_demo_win32.c" for a complete version. */
#if 0
#define STB_TRUETYPE_IMPLEMENTATION /* force following include to generate implementation */
#include "stb_truetype.h"
@@ -11528,6 +12029,8 @@ void my_stbtt_initfont(void)
void my_stbtt_print(float x, float y, char *text)
{
/* assume orthographic projection with units = screen pixels, origin at top left */
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ftex);
glBegin(GL_QUADS);
@@ -11535,10 +12038,10 @@ void my_stbtt_print(float x, float y, char *text)
if (*text >= 32 && *text < 128) {
stbtt_aligned_quad q;
stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);/* 1=opengl & d3d10+,0=d3d9 */
- glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0);
- glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0);
- glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1);
- glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1);
+ glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y0);
+ glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y0);
+ glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y1);
+ glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y1);
}
++text;
}
@@ -12084,6 +12587,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s
STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
/* frees the data allocated above */
+STBTT_DEF unsigned char *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl);
STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg);
STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg);
/* fills svg with the character's SVG data. */
@@ -12770,12 +13274,12 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
search += 2;
{
- stbtt_uint16 offset, start;
+ stbtt_uint16 offset, start, last;
stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1);
- STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item));
start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
- if (unicode_codepoint < start)
+ last = ttUSHORT(data + endCount + 2*item);
+ if (unicode_codepoint < start || unicode_codepoint > last)
return 0;
offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
@@ -13102,7 +13606,7 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s
if (comp_verts) STBTT_free(comp_verts, info->userdata);
return 0;
}
- if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex));
+ if (num_vertices > 0 && vertices) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex));
STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex));
if (vertices) STBTT_free(vertices, info->userdata);
vertices = tmp;
@@ -13365,7 +13869,7 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st
subrs = stbtt__cid_get_glyph_subrs(info, glyph_index);
has_subrs = 1;
}
- /* fallthrough */
+ /* FALLTHROUGH */
case 0x1D: /* callgsubr */
if (sp < 1) return STBTT__CSERR("call(g|)subr stack");
v = (int) s[--sp];
@@ -13470,7 +13974,7 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st
} break;
default:
- if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254))
+ if (b0 != 255 && b0 != 28 && b0 < 32)
return STBTT__CSERR("reserved operator");
/* push immediate */
@@ -13582,7 +14086,7 @@ STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningent
return length;
}
-static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
+static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
{
stbtt_uint8 *data = info->data + info->kern;
stbtt_uint32 needle, straw;
@@ -13612,243 +14116,225 @@ static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph
return 0;
}
-static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
-{
- stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
- switch(coverageFormat) {
- case 1: {
- stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2);
-
- /* Binary search. */
- stbtt_int32 l=0, r=glyphCount-1, m;
- int straw, needle=glyph;
- while (l <= r) {
- stbtt_uint8 *glyphArray = coverageTable + 4;
- stbtt_uint16 glyphID;
- m = (l + r) >> 1;
- glyphID = ttUSHORT(glyphArray + 2 * m);
- straw = glyphID;
- if (needle < straw)
- r = m - 1;
- else if (needle > straw)
- l = m + 1;
- else {
- return m;
- }
+static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
+{
+ stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
+ switch (coverageFormat) {
+ case 1: {
+ stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2);
+
+ /* Binary search. */
+ stbtt_int32 l=0, r=glyphCount-1, m;
+ int straw, needle=glyph;
+ while (l <= r) {
+ stbtt_uint8 *glyphArray = coverageTable + 4;
+ stbtt_uint16 glyphID;
+ m = (l + r) >> 1;
+ glyphID = ttUSHORT(glyphArray + 2 * m);
+ straw = glyphID;
+ if (needle < straw)
+ r = m - 1;
+ else if (needle > straw)
+ l = m + 1;
+ else {
+ return m;
}
- } break;
+ }
+ break;
+ }
- case 2: {
- stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2);
- stbtt_uint8 *rangeArray = coverageTable + 4;
-
- /* Binary search. */
- stbtt_int32 l=0, r=rangeCount-1, m;
- int strawStart, strawEnd, needle=glyph;
- while (l <= r) {
- stbtt_uint8 *rangeRecord;
- m = (l + r) >> 1;
- rangeRecord = rangeArray + 6 * m;
- strawStart = ttUSHORT(rangeRecord);
- strawEnd = ttUSHORT(rangeRecord + 2);
- if (needle < strawStart)
- r = m - 1;
- else if (needle > strawEnd)
- l = m + 1;
- else {
- stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4);
- return startCoverageIndex + glyph - strawStart;
- }
+ case 2: {
+ stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2);
+ stbtt_uint8 *rangeArray = coverageTable + 4;
+
+ /* Binary search. */
+ stbtt_int32 l=0, r=rangeCount-1, m;
+ int strawStart, strawEnd, needle=glyph;
+ while (l <= r) {
+ stbtt_uint8 *rangeRecord;
+ m = (l + r) >> 1;
+ rangeRecord = rangeArray + 6 * m;
+ strawStart = ttUSHORT(rangeRecord);
+ strawEnd = ttUSHORT(rangeRecord + 2);
+ if (needle < strawStart)
+ r = m - 1;
+ else if (needle > strawEnd)
+ l = m + 1;
+ else {
+ stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4);
+ return startCoverageIndex + glyph - strawStart;
}
- } break;
+ }
+ break;
+ }
- default: {
- /* There are no other cases. */
- STBTT_assert(0);
- } break;
- }
+ default: return -1; /* unsupported */
+ }
- return -1;
+ return -1;
}
static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
{
- stbtt_uint16 classDefFormat = ttUSHORT(classDefTable);
- switch(classDefFormat)
- {
- case 1: {
- stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2);
- stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4);
- stbtt_uint8 *classDef1ValueArray = classDefTable + 6;
-
- if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
- return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
-
- classDefTable = classDef1ValueArray + 2 * glyphCount;
- } break;
+ stbtt_uint16 classDefFormat = ttUSHORT(classDefTable);
+ switch (classDefFormat)
+ {
+ case 1: {
+ stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2);
+ stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4);
+ stbtt_uint8 *classDef1ValueArray = classDefTable + 6;
- case 2: {
- stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2);
- stbtt_uint8 *classRangeRecords = classDefTable + 4;
-
- /* Binary search. */
- stbtt_int32 l=0, r=classRangeCount-1, m;
- int strawStart, strawEnd, needle=glyph;
- while (l <= r) {
- stbtt_uint8 *classRangeRecord;
- m = (l + r) >> 1;
- classRangeRecord = classRangeRecords + 6 * m;
- strawStart = ttUSHORT(classRangeRecord);
- strawEnd = ttUSHORT(classRangeRecord + 2);
- if (needle < strawStart)
- r = m - 1;
- else if (needle > strawEnd)
- l = m + 1;
- else
- return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
- }
+ if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
+ return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
+ break;
+ }
- classDefTable = classRangeRecords + 6 * classRangeCount;
- } break;
+ case 2: {
+ stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2);
+ stbtt_uint8 *classRangeRecords = classDefTable + 4;
+
+ /* Binary search. */
+ stbtt_int32 l=0, r=classRangeCount-1, m;
+ int strawStart, strawEnd, needle=glyph;
+ while (l <= r) {
+ stbtt_uint8 *classRangeRecord;
+ m = (l + r) >> 1;
+ classRangeRecord = classRangeRecords + 6 * m;
+ strawStart = ttUSHORT(classRangeRecord);
+ strawEnd = ttUSHORT(classRangeRecord + 2);
+ if (needle < strawStart)
+ r = m - 1;
+ else if (needle > strawEnd)
+ l = m + 1;
+ else
+ return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
+ }
+ break;
+ }
- default: {
- /* There are no other cases. */
- STBTT_assert(0);
- } break;
- }
+ default:
+ return -1; /* Unsupported definition type, return an error. */
+ }
- return -1;
+ /* "All glyphs not assigned to a class fall into class 0". (OpenType spec) */
+ return 0;
}
/* Define to STBTT_assert(x) if you want to break on unimplemented formats. */
#define STBTT_GPOS_TODO_assert(x)
-static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
-{
- stbtt_uint16 lookupListOffset;
- stbtt_uint8 *lookupList;
- stbtt_uint16 lookupCount;
- stbtt_uint8 *data;
- stbtt_int32 i;
-
- if (!info->gpos) return 0;
-
- data = info->data + info->gpos;
-
- if (ttUSHORT(data+0) != 1) return 0; /* Major version 1 */
- if (ttUSHORT(data+2) != 0) return 0; /* Minor version 0 */
-
- lookupListOffset = ttUSHORT(data+8);
- lookupList = data + lookupListOffset;
- lookupCount = ttUSHORT(lookupList);
-
- for (i=0; i<lookupCount; ++i) {
- stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i);
- stbtt_uint8 *lookupTable = lookupList + lookupOffset;
-
- stbtt_uint16 lookupType = ttUSHORT(lookupTable);
- stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
- stbtt_uint8 *subTableOffsets = lookupTable + 6;
- switch(lookupType) {
- case 2: { /* Pair Adjustment Positioning Subtable */
- stbtt_int32 sti;
- for (sti=0; sti<subTableCount; sti++) {
- stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
- stbtt_uint8 *table = lookupTable + subtableOffset;
- stbtt_uint16 posFormat = ttUSHORT(table);
- stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
- stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
- if (coverageIndex == -1) continue;
-
- switch (posFormat) {
- case 1: {
- stbtt_int32 l, r, m;
- int straw, needle;
- stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
- stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
- stbtt_int32 valueRecordPairSizeInBytes = 2;
- stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
- stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
- stbtt_uint8 *pairValueTable = table + pairPosOffset;
- stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable);
- stbtt_uint8 *pairValueArray = pairValueTable + 2;
- /* TODO: Support more formats. */
- STBTT_GPOS_TODO_assert(valueFormat1 == 4);
- if (valueFormat1 != 4) return 0;
- STBTT_GPOS_TODO_assert(valueFormat2 == 0);
- if (valueFormat2 != 0) return 0;
-
- STBTT_assert(coverageIndex < pairSetCount);
- STBTT__NOTUSED(pairSetCount);
-
- needle=glyph2;
- r=pairValueCount-1;
- l=0;
-
- /* Binary search. */
- while (l <= r) {
- stbtt_uint16 secondGlyph;
- stbtt_uint8 *pairValue;
- m = (l + r) >> 1;
- pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m;
- secondGlyph = ttUSHORT(pairValue);
- straw = secondGlyph;
- if (needle < straw)
- r = m - 1;
- else if (needle > straw)
- l = m + 1;
- else {
- stbtt_int16 xAdvance = ttSHORT(pairValue + 2);
- return xAdvance;
- }
- }
- } break;
-
- case 2: {
- stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
- stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
-
- stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
- stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
- int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
- int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2);
-
- stbtt_uint16 class1Count = ttUSHORT(table + 12);
- stbtt_uint16 class2Count = ttUSHORT(table + 14);
- STBTT_assert(glyph1class < class1Count);
- STBTT_assert(glyph2class < class2Count);
-
- /* TODO: Support more formats. */
- STBTT_GPOS_TODO_assert(valueFormat1 == 4);
- if (valueFormat1 != 4) return 0;
- STBTT_GPOS_TODO_assert(valueFormat2 == 0);
- if (valueFormat2 != 0) return 0;
-
- if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) {
- stbtt_uint8 *class1Records = table + 16;
- stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count);
- stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class);
- return xAdvance;
- }
- } break;
-
- default: {
- /* There are no other cases. */
- STBTT_assert(0);
- break;
- };
- }
- }
- break;
- };
+static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
+{
+ stbtt_uint16 lookupListOffset;
+ stbtt_uint8 *lookupList;
+ stbtt_uint16 lookupCount;
+ stbtt_uint8 *data;
+ stbtt_int32 i, sti;
+
+ if (!info->gpos) return 0;
+
+ data = info->data + info->gpos;
+
+ if (ttUSHORT(data+0) != 1) return 0; /* Major version 1 */
+ if (ttUSHORT(data+2) != 0) return 0; /* Minor version 0 */
+
+ lookupListOffset = ttUSHORT(data+8);
+ lookupList = data + lookupListOffset;
+ lookupCount = ttUSHORT(lookupList);
+
+ for (i=0; i<lookupCount; ++i) {
+ stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i);
+ stbtt_uint8 *lookupTable = lookupList + lookupOffset;
+
+ stbtt_uint16 lookupType = ttUSHORT(lookupTable);
+ stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
+ stbtt_uint8 *subTableOffsets = lookupTable + 6;
+ if (lookupType != 2) /* Pair Adjustment Positioning Subtable */
+ continue;
+
+ for (sti=0; sti<subTableCount; sti++) {
+ stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
+ stbtt_uint8 *table = lookupTable + subtableOffset;
+ stbtt_uint16 posFormat = ttUSHORT(table);
+ stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
+ stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
+ if (coverageIndex == -1) continue;
+
+ switch (posFormat) {
+ case 1: {
+ stbtt_int32 l, r, m;
+ int straw, needle;
+ stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
+ stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
+ if (valueFormat1 == 4 && valueFormat2 == 0) { /* Support more formats? */
+ stbtt_int32 valueRecordPairSizeInBytes = 2;
+ stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
+ stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
+ stbtt_uint8 *pairValueTable = table + pairPosOffset;
+ stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable);
+ stbtt_uint8 *pairValueArray = pairValueTable + 2;
+
+ if (coverageIndex >= pairSetCount) return 0;
+
+ needle=glyph2;
+ r=pairValueCount-1;
+ l=0;
+
+ /* Binary search. */
+ while (l <= r) {
+ stbtt_uint16 secondGlyph;
+ stbtt_uint8 *pairValue;
+ m = (l + r) >> 1;
+ pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m;
+ secondGlyph = ttUSHORT(pairValue);
+ straw = secondGlyph;
+ if (needle < straw)
+ r = m - 1;
+ else if (needle > straw)
+ l = m + 1;
+ else {
+ stbtt_int16 xAdvance = ttSHORT(pairValue + 2);
+ return xAdvance;
+ }
+ }
+ } else
+ return 0;
+ break;
+ }
+
+ case 2: {
+ stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
+ stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
+ if (valueFormat1 == 4 && valueFormat2 == 0) { /* Support more formats? */
+ stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
+ stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
+ int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
+ int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2);
+
+ stbtt_uint16 class1Count = ttUSHORT(table + 12);
+ stbtt_uint16 class2Count = ttUSHORT(table + 14);
+ stbtt_uint8 *class1Records, *class2Records;
+ stbtt_int16 xAdvance;
+
+ if (glyph1class < 0 || glyph1class >= class1Count) return 0; /* malformed */
+ if (glyph2class < 0 || glyph2class >= class2Count) return 0; /* malformed */
+
+ class1Records = table + 16;
+ class2Records = class1Records + 2 * (glyph1class * class2Count);
+ xAdvance = ttSHORT(class2Records + 2 * glyph2class);
+ return xAdvance;
+ } else
+ return 0;
+ break;
+ }
default:
- /* TODO: Implement other stuff. */
- break;
- }
- }
+ return 0; /* Unsupported position format */
+ }
+ }
+ }
- return 0;
+ return 0;
}
STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2)
@@ -14306,6 +14792,23 @@ static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edg
}
}
+static float stbtt__sized_trapezoid_area(float height, float top_width, float bottom_width)
+{
+ STBTT_assert(top_width >= 0);
+ STBTT_assert(bottom_width >= 0);
+ return (top_width + bottom_width) / 2.0f * height;
+}
+
+static float stbtt__position_trapezoid_area(float height, float tx0, float tx1, float bx0, float bx1)
+{
+ return stbtt__sized_trapezoid_area(height, tx1 - tx0, bx1 - bx0);
+}
+
+static float stbtt__sized_triangle_area(float height, float width)
+{
+ return height * width / 2;
+}
+
static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top)
{
float y_bottom = y_top+1;
@@ -14360,13 +14863,13 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
float height;
/* simple case, only spans one pixel */
int x = (int) x_top;
- height = sy1 - sy0;
+ height = (sy1 - sy0) * e->direction;
STBTT_assert(x >= 0 && x < len);
- scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height;
- scanline_fill[x] += e->direction * height; /* everything right of this pixel is filled */
+ scanline[x] += stbtt__position_trapezoid_area(height, x_top, x+1.0f, x_bottom, x+1.0f);
+ scanline_fill[x] += height; /* everything right of this pixel is filled */
} else {
int x,x1,x2;
- float y_crossing, step, sign, area;
+ float y_crossing, y_final, step, sign, area;
/* covers 2+ pixels */
if (x_top > x_bottom) {
/* flip scanline vertically; signed area is the same */
@@ -14379,29 +14882,79 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
dy = -dy;
t = x0, x0 = xb, xb = t;
}
+ STBTT_assert(dy >= 0);
+ STBTT_assert(dx >= 0);
x1 = (int) x_top;
x2 = (int) x_bottom;
/* compute intersection with y axis at x1+1 */
- y_crossing = (x1+1 - x0) * dy + y_top;
+ y_crossing = y_top + dy * (x1+1 - x0);
+
+ /* compute intersection with y axis at x2 */
+ y_final = y_top + dy * (x2 - x0);
+
+ /* x1 x_top x2 x_bottom */
+ /* y_top +------|-----+------------+------------+--------|---+------------+ */
+ /* | | | | | | */
+ /* | | | | | | */
+ /* sy0 | Txxxxx|............|............|............|............| */
+ /* y_crossing | *xxxxx.......|............|............|............| */
+ /* | | xxxxx..|............|............|............| */
+ /* | | /- xx*xxxx........|............|............| */
+ /* | | dy < | xxxxxx..|............|............| */
+ /* y_final | | \- | xx*xxx.........|............| */
+ /* sy1 | | | | xxxxxB...|............| */
+ /* | | | | | | */
+ /* | | | | | | */
+ /* y_bottom +------------+------------+------------+------------+------------+ */
+ /* */
+ /* goal is to measure the area covered by '.' in each pixel */
+
+ /* if x2 is right at the right edge of x1, y_crossing can blow up, github #1057 */
+ /* @TODO: maybe test against sy1 rather than y_bottom? */
+ if (y_crossing > y_bottom)
+ y_crossing = y_bottom;
sign = e->direction;
- /* area of the rectangle covered from y0..y_crossing */
+
+ /* area of the rectangle covered from sy0..y_crossing */
area = sign * (y_crossing-sy0);
- /* area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) */
- scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2);
- step = sign * dy;
+ /* area of the triangle (x_top,sy0), (x1+1,sy0), (x1+1,y_crossing) */
+ scanline[x1] += stbtt__sized_triangle_area(area, x1+1 - x_top);
+
+ /* check if final y_crossing is blown up; no test case for this */
+ if (y_final > y_bottom) {
+ y_final = y_bottom;
+ dy = (y_final - y_crossing ) / (x2 - (x1+1)); /* if denom=0, y_final = y_crossing, so y_final <= y_bottom */
+ }
+
+ /* in second pixel, area covered by line segment found in first pixel */
+ /* is always a rectangle 1 wide * the height of that line segment; this */
+ /* is exactly what the variable 'area' stores. it also gets a contribution */
+ /* from the line segment within it. the THIRD pixel will get the first */
+ /* pixel's rectangle contribution, the second pixel's rectangle contribution, */
+ /* and its own contribution. the 'own contribution' is the same in every pixel except */
+ /* the leftmost and rightmost, a trapezoid that slides down in each pixel. */
+ /* the second pixel's contribution to the third pixel will be the */
+ /* rectangle 1 wide times the height change in the second pixel, which is dy. */
+
+ step = sign * dy * 1; /* dy is dy/dx, change in y for every 1 change in x, */
+ /* which multiplied by 1-pixel-width is how much pixel area changes for each step in x */
+ /* so the area advances by 'step' every time */
+
for (x = x1+1; x < x2; ++x) {
- scanline[x] += area + step/2;
+ scanline[x] += area + step/2; /* area of trapezoid is 1*step/2 */
area += step;
}
- y_crossing += dy * (x2 - (x1+1));
+ STBTT_assert(STBTT_fabs(area) <= 1.01f); /* accumulated error from area += step unless we round step down */
+ STBTT_assert(sy1 > y_final-0.01f);
- STBTT_assert(STBTT_fabs(area) <= 1.01f);
-
- scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing);
+ /* area covered in the last pixel is the rectangle from all the pixels to the left, */
+ /* plus the trapezoid filled by the line segment in this pixel all the way to the right edge */
+ scanline[x2] += area + sign * stbtt__position_trapezoid_area(sy1-y_final, (float) x2, x2+1.0f, x_bottom, x2+1.0f);
+ /* the rest of the line is filled based on the total height of the line segment in this pixel */
scanline_fill[x2] += sign * (sy1-sy0);
}
} else {
@@ -14409,6 +14962,9 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
/* clipping logic. since this does not match the intended use */
/* of this library, we use a different, very slow brute */
/* force implementation */
+ /* note though that this does happen some of the time because */
+ /* x_top and x_bottom can be extrapolated at the top & bottom of */
+ /* the shape and actually lie outside the bounding box */
int x;
for (x=0; x < len; ++x) {
/* cases: */
@@ -15645,15 +16201,14 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
float y_frac;
int winding = 0;
- orig[0] = x;
- orig[1] = y;
-
/* make sure y never passes through a vertex of the shape */
y_frac = (float) STBTT_fmod(y, 1.0f);
if (y_frac < 0.01f)
y += 0.01f;
else if (y_frac > 0.99f)
y -= 0.01f;
+
+ orig[0] = x;
orig[1] = y;
/* test a ray from (-infinity,y) to (x,y) */
@@ -15715,35 +16270,35 @@ static float stbtt__cuberoot( float x )
return (float) STBTT_pow( x,1.0f/3.0f);
}
-/* x^3 + c*x^2 + b*x + a = 0 */
+/* x^3 + a*x^2 + b*x + c = 0 */
static int stbtt__solve_cubic(float a, float b, float c, float* r)
{
- float s = -a / 3;
- float p = b - a*a / 3;
- float q = a * (2*a*a - 9*b) / 27 + c;
+ float s = -a / 3;
+ float p = b - a*a / 3;
+ float q = a * (2*a*a - 9*b) / 27 + c;
float p3 = p*p*p;
- float d = q*q + 4*p3 / 27;
- if (d >= 0) {
- float z = (float) STBTT_sqrt(d);
- float u = (-q + z) / 2;
- float v = (-q - z) / 2;
- u = stbtt__cuberoot(u);
- v = stbtt__cuberoot(v);
- r[0] = s + u + v;
- return 1;
- } else {
- float u = (float) STBTT_sqrt(-p/3);
- float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; /* p3 must be negative, since d is negative */
- float m = (float) STBTT_cos(v);
+ float d = q*q + 4*p3 / 27;
+ if (d >= 0) {
+ float z = (float) STBTT_sqrt(d);
+ float u = (-q + z) / 2;
+ float v = (-q - z) / 2;
+ u = stbtt__cuberoot(u);
+ v = stbtt__cuberoot(v);
+ r[0] = s + u + v;
+ return 1;
+ } else {
+ float u = (float) STBTT_sqrt(-p/3);
+ float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; /* p3 must be negative, since d is negative */
+ float m = (float) STBTT_cos(v);
float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f;
- r[0] = s + u * 2 * m;
- r[1] = s - u * (m + n);
- r[2] = s - u * (m - n);
+ r[0] = s + u * 2 * m;
+ r[1] = s - u * (m + n);
+ r[2] = s - u * (m - n);
/* STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? */
/* STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); */
/* STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); */
- return 3;
+ return 3;
}
}
@@ -15820,18 +16375,17 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
for (i=0; i < num_verts; ++i) {
float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
- /* check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve */
- float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy);
- if (dist2 < min_dist*min_dist)
- min_dist = (float) STBTT_sqrt(dist2);
-
- if (verts[i].type == STBTT_vline) {
+ if (verts[i].type == STBTT_vline && precompute[i] != 0.0f) {
float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y;
+ float dist,dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy);
+ if (dist2 < min_dist*min_dist)
+ min_dist = (float) STBTT_sqrt(dist2);
+
/* coarse culling against bbox */
/* if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && */
/* sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) */
- float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i];
+ dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i];
STBTT_assert(i != 0);
if (dist < min_dist) {
/* check position along line */
@@ -15858,7 +16412,8 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
float ax = x1-x0, ay = y1-y0;
float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
float mx = x0 - sx, my = y0 - sy;
- float res[3],px,py,t,it;
+ float res[3] = {0.f,0.f,0.f};
+ float px,py,t,it,dist2;
float a_inv = precompute[i];
if (a_inv == 0.0) { /* if a_inv is 0, it's 2nd degree so use quadratic formula */
float a = 3*(ax*bx + ay*by);
@@ -15885,6 +16440,10 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
float d = (mx*ax+my*ay) * a_inv;
num = stbtt__solve_cubic(b, c, d, res);
}
+ dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy);
+ if (dist2 < min_dist*min_dist)
+ min_dist = (float) STBTT_sqrt(dist2);
+
if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) {
t = res[0], it = 1.0f - t;
px = it*it*x0 + 2*t*it*x1 + t*t*x2;
@@ -16144,6 +16703,12 @@ STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const
/* FULL VERSION HISTORY */
/* */
+/* 1.25 (2021-07-11) many fixes */
+/* 1.24 (2020-02-05) fix warning */
+/* 1.23 (2020-02-02) query SVG data for glyphs; query whole kerning table (but only kern not GPOS) */
+/* 1.22 (2019-08-11) minimize missing-glyph duplication; fix kerning if both 'GPOS' and 'kern' are defined */
+/* 1.21 (2019-02-25) fix warning */
+/* 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics() */
/* 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod */
/* 1.18 (2018-01-29) add missing function */
/* 1.17 (2017-07-23) make more arguments const; doc fix */
@@ -16328,7 +16893,7 @@ nk_font_chinese_glyph_ranges(void)
0x3000, 0x30FF,
0x31F0, 0x31FF,
0xFF00, 0xFFEF,
- 0x4e00, 0x9FAF,
+ 0x4E00, 0x9FAF,
0
};
return ranges;
@@ -16389,7 +16954,7 @@ nk_font_baker_memory(nk_size *temp, int *glyph_count,
*temp += nk_build_align + nk_baker_align;
}
NK_INTERN struct nk_font_baker*
-nk_font_baker(void *memory, int glyph_count, int count, struct nk_allocator *alloc)
+nk_font_baker(void *memory, int glyph_count, int count, const struct nk_allocator *alloc)
{
struct nk_font_baker *baker;
if (!memory) return 0;
@@ -16406,7 +16971,7 @@ NK_INTERN int
nk_font_bake_pack(struct nk_font_baker *baker,
nk_size *image_memory, int *width, int *height, struct nk_recti *custom,
const struct nk_font_config *config_list, int count,
- struct nk_allocator *alloc)
+ const struct nk_allocator *alloc)
{
NK_STORAGE const nk_size max_height = 1024 * 32;
const struct nk_font_config *config_iter, *it;
@@ -16432,16 +16997,18 @@ nk_font_bake_pack(struct nk_font_baker *baker,
}
/* setup font baker from temporary memory */
for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
- struct stbtt_fontinfo *font_info = &baker->build[i++].info;
it = config_iter;
- font_info->userdata = alloc;
- do {if (!stbtt_InitFont(font_info, (const unsigned char*)it->ttf_blob, 0))
- return nk_false;
+ do {
+ struct stbtt_fontinfo *font_info = &baker->build[i++].info;
+ font_info->userdata = (void*)alloc;
+
+ if (!stbtt_InitFont(font_info, (const unsigned char*)it->ttf_blob, stbtt_GetFontOffsetForIndex((const unsigned char*)it->ttf_blob, 0)))
+ return nk_false;
} while ((it = it->n) != config_iter);
}
*height = 0;
*width = (total_glyph_count > 1000) ? 1024 : 512;
- stbtt_PackBegin(&baker->spc, 0, (int)*width, (int)max_height, 0, 1, alloc);
+ stbtt_PackBegin(&baker->spc, 0, (int)*width, (int)max_height, 0, 1, (void*)alloc);
{
int input_i = 0;
int range_n = 0;
@@ -16595,7 +17162,6 @@ nk_font_bake(struct nk_font_baker *baker, void *image_memory, int width, int hei
/* query glyph bounds from stb_truetype */
const stbtt_packedchar *pc = &range->chardata_for_range[char_idx];
- if (!pc->x0 && !pc->x1 && !pc->y0 && !pc->y1) continue;
codepoint = (nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
stbtt_GetPackedQuad(range->chardata_for_range, (int)width,
(int)height, char_idx, &dummy_x, &dummy_y, &q, 0);
@@ -16746,7 +17312,7 @@ nk_font_query_font_glyph(nk_handle handle, float height,
}
#endif
NK_API const struct nk_font_glyph*
-nk_font_find_glyph(struct nk_font *font, nk_rune unicode)
+nk_font_find_glyph(const struct nk_font *font, nk_rune unicode)
{
int i = 0;
int count;
@@ -16809,8 +17375,8 @@ nk_font_init(struct nk_font *font, float pixel_height,
*
* ProggyClean.ttf
* Copyright (c) 2004, 2005 Tristan Grimmer
- * MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip)
- * Download and more information at http://upperbounds.net
+ * MIT license https://github.com/bluescan/proggyfonts/blob/master/LICENSE
+ * Download and more information at https://github.com/bluescan/proggyfonts
*-----------------------------------------------------------------------------*/
#ifdef __clang__
#pragma clang diagnostic push
@@ -17135,7 +17701,7 @@ nk_font_atlas_init_default(struct nk_font_atlas *atlas)
}
#endif
NK_API void
-nk_font_atlas_init(struct nk_font_atlas *atlas, struct nk_allocator *alloc)
+nk_font_atlas_init(struct nk_font_atlas *atlas, const struct nk_allocator *alloc)
{
NK_ASSERT(atlas);
NK_ASSERT(alloc);
@@ -17146,7 +17712,7 @@ nk_font_atlas_init(struct nk_font_atlas *atlas, struct nk_allocator *alloc)
}
NK_API void
nk_font_atlas_init_custom(struct nk_font_atlas *atlas,
- struct nk_allocator *permanent, struct nk_allocator *temporary)
+ const struct nk_allocator *permanent, const struct nk_allocator *temporary)
{
NK_ASSERT(atlas);
NK_ASSERT(permanent);
@@ -17426,7 +17992,7 @@ nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,
tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
NK_ASSERT(tmp);
if (!tmp) goto failed;
- memset(tmp,0,tmp_size);
+ NK_MEMSET(tmp,0,tmp_size);
/* allocate glyph memory for all fonts */
baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
@@ -17517,20 +18083,20 @@ failed:
}
NK_API void
nk_font_atlas_end(struct nk_font_atlas *atlas, nk_handle texture,
- struct nk_draw_null_texture *null)
+ struct nk_draw_null_texture *tex_null)
{
int i = 0;
struct nk_font *font_iter;
NK_ASSERT(atlas);
if (!atlas) {
- if (!null) return;
- null->texture = texture;
- null->uv = nk_vec2(0.5f,0.5f);
+ if (!tex_null) return;
+ tex_null->texture = texture;
+ tex_null->uv = nk_vec2(0.5f,0.5f);
}
- if (null) {
- null->texture = texture;
- null->uv.x = (atlas->custom.x + 0.5f)/(float)atlas->tex_width;
- null->uv.y = (atlas->custom.y + 0.5f)/(float)atlas->tex_height;
+ if (tex_null) {
+ tex_null->texture = texture;
+ tex_null->uv.x = (atlas->custom.x + 0.5f)/(float)atlas->tex_width;
+ tex_null->uv.y = (atlas->custom.y + 0.5f)/(float)atlas->tex_height;
}
for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
font_iter->texture = texture;
@@ -17616,7 +18182,6 @@ nk_font_atlas_clear(struct nk_font_atlas *atlas)
-
/* ===============================================================
*
* INPUT
@@ -17699,6 +18264,17 @@ nk_input_button(struct nk_context *ctx, enum nk_buttons id, int x, int y, nk_boo
btn->clicked_pos.y = (float)y;
btn->down = down;
btn->clicked++;
+
+ /* Fix Click-Drag for touch events. */
+ in->mouse.delta.x = 0;
+ in->mouse.delta.y = 0;
+#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
+ if (down == 1 && id == NK_BUTTON_LEFT)
+ {
+ in->mouse.down_pos.x = btn->clicked_pos.x;
+ in->mouse.down_pos.y = btn->clicked_pos.y;
+ }
+#endif
}
NK_API void
nk_input_scroll(struct nk_context *ctx, struct nk_vec2 val)
@@ -17729,7 +18305,7 @@ nk_input_glyph(struct nk_context *ctx, const nk_glyph glyph)
NK_API void
nk_input_char(struct nk_context *ctx, char c)
{
- nk_glyph glyph;
+ nk_glyph glyph = {0};
NK_ASSERT(ctx);
if (!ctx) return;
glyph[0] = c;
@@ -17764,6 +18340,22 @@ nk_input_has_mouse_click_in_rect(const struct nk_input *i, enum nk_buttons id,
return nk_true;
}
NK_API nk_bool
+nk_input_has_mouse_click_in_button_rect(const struct nk_input *i, enum nk_buttons id,
+ struct nk_rect b)
+{
+ const struct nk_mouse_button *btn;
+ if (!i) return nk_false;
+ btn = &i->mouse.buttons[id];
+#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
+ if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h)
+ || !NK_INBOX(i->mouse.down_pos.x,i->mouse.down_pos.y,b.x,b.y,b.w,b.h))
+#else
+ if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h))
+#endif
+ return nk_false;
+ return nk_true;
+}
+NK_API nk_bool
nk_input_has_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id,
struct nk_rect b, nk_bool down)
{
@@ -17893,13 +18485,13 @@ NK_API void nk_style_default(struct nk_context *ctx){nk_style_from_table(ctx, 0)
NK_COLOR(NK_COLOR_TOGGLE_HOVER, 120,120,120,255) \
NK_COLOR(NK_COLOR_TOGGLE_CURSOR, 45, 45, 45, 255) \
NK_COLOR(NK_COLOR_SELECT, 45, 45, 45, 255) \
- NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \
+ NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \
NK_COLOR(NK_COLOR_SLIDER, 38, 38, 38, 255) \
NK_COLOR(NK_COLOR_SLIDER_CURSOR, 100,100,100,255) \
NK_COLOR(NK_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \
NK_COLOR(NK_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \
NK_COLOR(NK_COLOR_PROPERTY, 38, 38, 38, 255) \
- NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \
+ NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \
NK_COLOR(NK_COLOR_EDIT_CURSOR, 175,175,175,255) \
NK_COLOR(NK_COLOR_COMBO, 45, 45, 45, 255) \
NK_COLOR(NK_COLOR_CHART, 120,120,120,255) \
@@ -17909,7 +18501,11 @@ NK_API void nk_style_default(struct nk_context *ctx){nk_style_from_table(ctx, 0)
NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \
NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_HOVER, 120,120,120,255) \
NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_ACTIVE, 150,150,150,255) \
- NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255)
+ NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255) \
+ NK_COLOR(NK_COLOR_KNOB, 38, 38, 38, 255) \
+ NK_COLOR(NK_COLOR_KNOB_CURSOR, 100,100,100,255) \
+ NK_COLOR(NK_COLOR_KNOB_CURSOR_HOVER, 120,120,120,255) \
+ NK_COLOR(NK_COLOR_KNOB_CURSOR_ACTIVE, 150,150,150,255)
NK_GLOBAL const struct nk_color
nk_default_color_style[NK_COLOR_COUNT] = {
@@ -17929,6 +18525,14 @@ nk_style_get_color_by_name(enum nk_style_colors c)
return nk_color_names[c];
}
NK_API struct nk_style_item
+nk_style_item_color(struct nk_color col)
+{
+ struct nk_style_item i;
+ i.type = NK_STYLE_ITEM_COLOR;
+ i.data.color = col;
+ return i;
+}
+NK_API struct nk_style_item
nk_style_item_image(struct nk_image img)
{
struct nk_style_item i;
@@ -17937,11 +18541,11 @@ nk_style_item_image(struct nk_image img)
return i;
}
NK_API struct nk_style_item
-nk_style_item_color(struct nk_color col)
+nk_style_item_nine_slice(struct nk_nine_slice slice)
{
struct nk_style_item i;
- i.type = NK_STYLE_ITEM_COLOR;
- i.data.color = col;
+ i.type = NK_STYLE_ITEM_NINE_SLICE;
+ i.data.slice = slice;
return i;
}
NK_API struct nk_style_item
@@ -17961,6 +18565,7 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
struct nk_style_toggle *toggle;
struct nk_style_selectable *select;
struct nk_style_slider *slider;
+ struct nk_style_knob *knob;
struct nk_style_progress *prog;
struct nk_style_scrollbar *scroll;
struct nk_style_edit *edit;
@@ -17979,27 +18584,32 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
text = &style->text;
text->color = table[NK_COLOR_TEXT];
text->padding = nk_vec2(0,0);
+ text->color_factor = 1.0f;
+ text->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* default button */
button = &style->button;
nk_zero_struct(*button);
- button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
- button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
- button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
- button->border_color = table[NK_COLOR_BORDER];
- button->text_background = table[NK_COLOR_BUTTON];
- button->text_normal = table[NK_COLOR_TEXT];
- button->text_hover = table[NK_COLOR_TEXT];
- button->text_active = table[NK_COLOR_TEXT];
- button->padding = nk_vec2(2.0f,2.0f);
- button->image_padding = nk_vec2(0.0f,0.0f);
- button->touch_padding = nk_vec2(0.0f, 0.0f);
- button->userdata = nk_handle_ptr(0);
- button->text_alignment = NK_TEXT_CENTERED;
- button->border = 1.0f;
- button->rounding = 4.0f;
- button->draw_begin = 0;
- button->draw_end = 0;
+ button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
+ button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
+ button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
+ button->border_color = table[NK_COLOR_BORDER];
+ button->text_background = table[NK_COLOR_BUTTON];
+ button->text_normal = table[NK_COLOR_TEXT];
+ button->text_hover = table[NK_COLOR_TEXT];
+ button->text_active = table[NK_COLOR_TEXT];
+ button->padding = nk_vec2(2.0f,2.0f);
+ button->image_padding = nk_vec2(0.0f,0.0f);
+ button->touch_padding = nk_vec2(0.0f, 0.0f);
+ button->userdata = nk_handle_ptr(0);
+ button->text_alignment = NK_TEXT_CENTERED;
+ button->border = 1.0f;
+ button->rounding = 4.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
+ button->draw_begin = 0;
+ button->draw_end = 0;
/* contextual button */
button = &style->contextual_button;
@@ -18018,6 +18628,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@@ -18038,6 +18651,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 1.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@@ -18059,6 +18675,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
toggle->border_color = nk_rgba(0,0,0,0);
toggle->border = 0.0f;
toggle->spacing = 4;
+ toggle->color_factor = 1.0f;
+ toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* option toggle */
toggle = &style->option;
@@ -18078,6 +18696,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
toggle->border_color = nk_rgba(0,0,0,0);
toggle->border = 0.0f;
toggle->spacing = 4;
+ toggle->color_factor = 1.0f;
+ toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* selectable */
select = &style->selectable;
@@ -18099,6 +18719,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
select->touch_padding = nk_vec2(0,0);
select->userdata = nk_handle_ptr(0);
select->rounding = 0.0f;
+ select->color_factor = 1.0f;
+ select->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
select->draw_begin = 0;
select->draw_end = 0;
@@ -18124,6 +18746,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
slider->show_buttons = nk_false;
slider->bar_height = 8;
slider->rounding = 0;
+ slider->color_factor = 1.0f;
+ slider->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
slider->draw_begin = 0;
slider->draw_end = 0;
@@ -18143,10 +18767,39 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
style->slider.dec_button = style->slider.inc_button;
+ /* knob */
+ knob = &style->knob;
+ nk_zero_struct(*knob);
+ knob->normal = nk_style_item_hide();
+ knob->hover = nk_style_item_hide();
+ knob->active = nk_style_item_hide();
+ knob->knob_normal = table[NK_COLOR_KNOB];
+ knob->knob_hover = table[NK_COLOR_KNOB];
+ knob->knob_active = table[NK_COLOR_KNOB];
+ knob->cursor_normal = table[NK_COLOR_KNOB_CURSOR];
+ knob->cursor_hover = table[NK_COLOR_KNOB_CURSOR_HOVER];
+ knob->cursor_active = table[NK_COLOR_KNOB_CURSOR_ACTIVE];
+
+ knob->knob_border_color = table[NK_COLOR_BORDER];
+ knob->knob_border = 1.0f;
+
+ knob->padding = nk_vec2(2,2);
+ knob->spacing = nk_vec2(2,2);
+ knob->cursor_width = 2;
+ knob->color_factor = 1.0f;
+ knob->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
+
+ knob->userdata = nk_handle_ptr(0);
+ knob->draw_begin = 0;
+ knob->draw_end = 0;
+
/* progressbar */
prog = &style->progress;
nk_zero_struct(*prog);
@@ -18164,6 +18817,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
prog->border = 0;
prog->cursor_rounding = 0;
prog->cursor_border = 0;
+ prog->color_factor = 1.0f;
+ prog->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
prog->draw_begin = 0;
prog->draw_end = 0;
@@ -18187,6 +18842,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
scroll->rounding = 0;
scroll->border_cursor = 0;
scroll->rounding_cursor = 0;
+ scroll->color_factor = 1.0f;
+ scroll->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
scroll->draw_begin = 0;
scroll->draw_end = 0;
style->scrollv = style->scrollh;
@@ -18207,6 +18864,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
style->scrollh.dec_button = style->scrollh.inc_button;
@@ -18238,6 +18898,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
edit->cursor_size = 4;
edit->border = 1;
edit->rounding = 0;
+ edit->color_factor = 1.0f;
+ edit->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* property */
property = &style->property;
@@ -18257,6 +18919,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
property->rounding = 10;
property->draw_begin = 0;
property->draw_end = 0;
+ property->color_factor = 1.0f;
+ property->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* property buttons */
button = &style->property.dec_button;
@@ -18275,6 +18939,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
style->property.inc_button = style->property.dec_button;
@@ -18301,6 +18968,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
edit->cursor_size = 8;
edit->border = 0;
edit->rounding = 0;
+ edit->color_factor = 1.0f;
+ edit->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* chart */
chart = &style->chart;
@@ -18312,6 +18981,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
chart->padding = nk_vec2(4,4);
chart->border = 0;
chart->rounding = 0;
+ chart->color_factor = 1.0f;
+ chart->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
+ chart->show_markers = nk_true;
/* combo */
combo = &style->combo;
@@ -18330,6 +19002,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
combo->spacing = nk_vec2(4,0);
combo->border = 1;
combo->rounding = 0;
+ combo->color_factor = 1.0f;
+ combo->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* combo button */
button = &style->combo.button;
@@ -18348,6 +19022,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@@ -18363,6 +19040,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
tab->indent = 10.0f;
tab->border = 1;
tab->rounding = 0;
+ tab->color_factor = 1.0f;
+ tab->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
/* tab button */
button = &style->tab.tab_minimize_button;
@@ -18381,6 +19060,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
style->tab.tab_maximize_button =*button;
@@ -18402,6 +19084,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
style->tab.node_maximize_button =*button;
@@ -18439,6 +19124,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@@ -18459,6 +19147,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
+ button->color_factor_text = 1.0f;
+ button->color_factor_background = 1.0f;
+ button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@@ -18625,7 +19316,7 @@ nk_style_load_cursor(struct nk_context *ctx, enum nk_style_cursor cursor,
style->cursors[cursor] = c;
}
NK_API void
-nk_style_load_all_cursors(struct nk_context *ctx, struct nk_cursor *cursors)
+nk_style_load_all_cursors(struct nk_context *ctx, const struct nk_cursor *cursors)
{
int i = 0;
struct nk_style *style;
@@ -18640,7 +19331,6 @@ nk_style_load_all_cursors(struct nk_context *ctx, struct nk_cursor *cursors)
-
/* ==============================================================
*
* CONTEXT
@@ -18703,7 +19393,7 @@ nk_init_custom(struct nk_context *ctx, struct nk_buffer *cmds,
return 1;
}
NK_API nk_bool
-nk_init(struct nk_context *ctx, struct nk_allocator *alloc,
+nk_init(struct nk_context *ctx, const struct nk_allocator *alloc,
const struct nk_user_font *font)
{
NK_ASSERT(alloc);
@@ -18992,7 +19682,7 @@ nk__next(struct nk_context *ctx, const struct nk_command *cmd)
*
* ===============================================================*/
NK_LIB void
-nk_pool_init(struct nk_pool *pool, struct nk_allocator *alloc,
+nk_pool_init(struct nk_pool *pool, const struct nk_allocator *alloc,
unsigned int capacity)
{
NK_ASSERT(capacity >= 1);
@@ -19022,7 +19712,7 @@ nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size)
NK_ASSERT(size >= sizeof(struct nk_page));
if (size < sizeof(struct nk_page)) return;
/* first nk_page_element is embedded in nk_page, additional elements follow in adjacent space */
- pool->capacity = 1 + (unsigned)(size - sizeof(struct nk_page)) / sizeof(struct nk_page_element);
+ pool->capacity = (unsigned)(1 + (size - sizeof(struct nk_page)) / sizeof(struct nk_page_element));
pool->pages = (struct nk_page*)memory;
pool->type = NK_BUFFER_FIXED;
pool->size = size;
@@ -19186,7 +19876,7 @@ nk_add_value(struct nk_context *ctx, struct nk_window *win,
return &win->tables->values[win->tables->size++];
}
NK_LIB nk_uint*
-nk_find_value(struct nk_window *win, nk_hash name)
+nk_find_value(const struct nk_window *win, nk_hash name)
{
struct nk_table *iter = win->tables;
while (iter) {
@@ -19206,7 +19896,6 @@ nk_find_value(struct nk_window *win, nk_hash name)
-
/* ===============================================================
*
* PANEL
@@ -19282,12 +19971,12 @@ nk_panel_get_border_color(const struct nk_style *style, enum nk_panel_type type)
NK_LIB nk_bool
nk_panel_is_sub(enum nk_panel_type type)
{
- return (type & NK_PANEL_SET_SUB)?1:0;
+ return ((int)type & (int)NK_PANEL_SET_SUB)?1:0;
}
NK_LIB nk_bool
nk_panel_is_nonblock(enum nk_panel_type type)
{
- return (type & NK_PANEL_SET_NONBLOCK)?1:0;
+ return ((int)type & (int)NK_PANEL_SET_NONBLOCK)?1:0;
}
NK_LIB nk_bool
nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type panel_type)
@@ -19328,8 +20017,8 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* window movement */
if ((win->flags & NK_WINDOW_MOVABLE) && !(win->flags & NK_WINDOW_ROM)) {
- int left_mouse_down;
- int left_mouse_clicked;
+ nk_bool left_mouse_down;
+ unsigned int left_mouse_clicked;
int left_mouse_click_in_cursor;
/* calculate draggable window space */
@@ -19344,7 +20033,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* window movement by dragging */
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
- left_mouse_clicked = (int)in->mouse.buttons[NK_BUTTON_LEFT].clicked;
+ left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
NK_BUTTON_LEFT, header, nk_true);
if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
@@ -19422,12 +20111,20 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* draw header background */
header.h += 1.0f;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- text.background = nk_rgba(0,0,0,0);
- nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
- } else {
- text.background = background->data.color;
- nk_fill_rect(out, header, 0, background->data.color);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ text.background = nk_rgba(0,0,0,0);
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ text.background = background->data.color;
+ nk_fill_rect(out, header, 0, background->data.color);
+ break;
}
/* window close button */
@@ -19488,7 +20185,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
label.h = font->height + 2 * style->window.header.label_padding.y;
label.w = t + 2 * style->window.header.spacing.x;
label.w = NK_CLAMP(0, label.w, header.x + header.w - label.x);
- nk_widget_text(out, label,(const char*)title, text_len, &text, NK_TEXT_LEFT, font);}
+ nk_widget_text(out, label, (const char*)title, text_len, &text, NK_TEXT_LEFT, font);}
}
/* draw window background */
@@ -19498,9 +20195,18 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
body.w = win->bounds.w;
body.y = (win->bounds.y + layout->header_height);
body.h = (win->bounds.h - layout->header_height);
- if (style->window.fixed_background.type == NK_STYLE_ITEM_IMAGE)
- nk_draw_image(out, body, &style->window.fixed_background.data.image, nk_white);
- else nk_fill_rect(out, body, 0, style->window.fixed_background.data.color);
+
+ switch(style->window.fixed_background.type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, body, &style->window.fixed_background.data.image, nk_white);
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, body, &style->window.fixed_background.data.slice, nk_white);
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, body, style->window.rounding, style->window.fixed_background.data.color);
+ break;
+ }
}
/* set clipping rectangle */
@@ -19610,7 +20316,7 @@ nk_panel_end(struct nk_context *ctx)
root_window = root_window->parent;
/* only allow scrolling if parent window is active */
- scroll_has_scrolling = 0;
+ scroll_has_scrolling = nk_false;
if ((root_window == ctx->active) && layout->has_scrolling) {
/* and panel is being hovered and inside clip rect*/
if (nk_input_is_mouse_hovering_rect(in, layout->bounds) &&
@@ -19627,13 +20333,13 @@ nk_panel_end(struct nk_context *ctx)
scroll_has_scrolling = nk_true;
}
}
- } else if (!nk_panel_is_sub(layout->type)) {
+ } else {
/* window mouse wheel scrolling */
scroll_has_scrolling = (window == ctx->active) && layout->has_scrolling;
if (in && (in->mouse.scroll_delta.y > 0 || in->mouse.scroll_delta.x > 0) && scroll_has_scrolling)
window->scrolled = nk_true;
else window->scrolled = nk_false;
- } else scroll_has_scrolling = nk_false;
+ }
{
/* vertical scrollbar */
@@ -19694,7 +20400,7 @@ nk_panel_end(struct nk_context *ctx)
: (window->bounds.y + window->bounds.h));
struct nk_rect b = window->bounds;
b.h = padding_y - window->bounds.y;
- nk_stroke_rect(out, b, 0, layout->border, border_color);
+ nk_stroke_rect(out, b, style->window.rounding, layout->border, border_color);
}
/* scaler */
@@ -19854,7 +20560,7 @@ nk_free_window(struct nk_context *ctx, struct nk_window *win)
nk_free_page_element(ctx, pe);}
}
NK_LIB struct nk_window*
-nk_find_window(struct nk_context *ctx, nk_hash hash, const char *name)
+nk_find_window(const struct nk_context *ctx, nk_hash hash, const char *name)
{
struct nk_window *iter;
iter = ctx->begin;
@@ -19991,6 +20697,7 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
NK_MEMCPY(win->name_string, name, name_length);
win->name_string[name_length] = 0;
win->popup.win = 0;
+ win->widgets_disabled = nk_false;
if (!ctx->active)
ctx->active = win;
} else {
@@ -20162,7 +20869,7 @@ nk_window_get_height(const struct nk_context *ctx)
return ctx->current->bounds.h;
}
NK_API struct nk_rect
-nk_window_get_content_region(struct nk_context *ctx)
+nk_window_get_content_region(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
@@ -20170,7 +20877,7 @@ nk_window_get_content_region(struct nk_context *ctx)
return ctx->current->layout->clip;
}
NK_API struct nk_vec2
-nk_window_get_content_region_min(struct nk_context *ctx)
+nk_window_get_content_region_min(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
@@ -20179,7 +20886,7 @@ nk_window_get_content_region_min(struct nk_context *ctx)
return nk_vec2(ctx->current->layout->clip.x, ctx->current->layout->clip.y);
}
NK_API struct nk_vec2
-nk_window_get_content_region_max(struct nk_context *ctx)
+nk_window_get_content_region_max(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
@@ -20189,7 +20896,7 @@ nk_window_get_content_region_max(struct nk_context *ctx)
ctx->current->layout->clip.y + ctx->current->layout->clip.h);
}
NK_API struct nk_vec2
-nk_window_get_content_region_size(struct nk_context *ctx)
+nk_window_get_content_region_size(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
@@ -20198,7 +20905,7 @@ nk_window_get_content_region_size(struct nk_context *ctx)
return nk_vec2(ctx->current->layout->clip.w, ctx->current->layout->clip.h);
}
NK_API struct nk_command_buffer*
-nk_window_get_canvas(struct nk_context *ctx)
+nk_window_get_canvas(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
@@ -20207,7 +20914,7 @@ nk_window_get_canvas(struct nk_context *ctx)
return &ctx->current->buffer;
}
NK_API struct nk_panel*
-nk_window_get_panel(struct nk_context *ctx)
+nk_window_get_panel(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
@@ -20215,7 +20922,7 @@ nk_window_get_panel(struct nk_context *ctx)
return ctx->current->layout;
}
NK_API void
-nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
+nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
{
struct nk_window *win;
NK_ASSERT(ctx);
@@ -20238,17 +20945,22 @@ nk_window_has_focus(const struct nk_context *ctx)
return ctx->current == ctx->active;
}
NK_API nk_bool
-nk_window_is_hovered(struct nk_context *ctx)
+nk_window_is_hovered(const struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
- if (!ctx || !ctx->current) return 0;
- if(ctx->current->flags & NK_WINDOW_HIDDEN)
+ if (!ctx || !ctx->current || (ctx->current->flags & NK_WINDOW_HIDDEN))
return 0;
- return nk_input_is_mouse_hovering_rect(&ctx->input, ctx->current->bounds);
+ else {
+ struct nk_rect actual_bounds = ctx->current->bounds;
+ if (ctx->begin->flags & NK_WINDOW_MINIMIZED) {
+ actual_bounds.h = ctx->current->layout->header_height;
+ }
+ return nk_input_is_mouse_hovering_rect(&ctx->input, actual_bounds);
+ }
}
NK_API nk_bool
-nk_window_is_any_hovered(struct nk_context *ctx)
+nk_window_is_any_hovered(const struct nk_context *ctx)
{
struct nk_window *iter;
NK_ASSERT(ctx);
@@ -20275,14 +20987,14 @@ nk_window_is_any_hovered(struct nk_context *ctx)
return 0;
}
NK_API nk_bool
-nk_item_is_any_active(struct nk_context *ctx)
+nk_item_is_any_active(const struct nk_context *ctx)
{
int any_hovered = nk_window_is_any_hovered(ctx);
int any_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED);
return any_hovered || any_active;
}
NK_API nk_bool
-nk_window_is_collapsed(struct nk_context *ctx, const char *name)
+nk_window_is_collapsed(const struct nk_context *ctx, const char *name)
{
int title_len;
nk_hash title_hash;
@@ -20297,7 +21009,7 @@ nk_window_is_collapsed(struct nk_context *ctx, const char *name)
return win->flags & NK_WINDOW_MINIMIZED;
}
NK_API nk_bool
-nk_window_is_closed(struct nk_context *ctx, const char *name)
+nk_window_is_closed(const struct nk_context *ctx, const char *name)
{
int title_len;
nk_hash title_hash;
@@ -20312,7 +21024,7 @@ nk_window_is_closed(struct nk_context *ctx, const char *name)
return (win->flags & NK_WINDOW_CLOSED);
}
NK_API nk_bool
-nk_window_is_hidden(struct nk_context *ctx, const char *name)
+nk_window_is_hidden(const struct nk_context *ctx, const char *name)
{
int title_len;
nk_hash title_hash;
@@ -20327,7 +21039,7 @@ nk_window_is_hidden(struct nk_context *ctx, const char *name)
return (win->flags & NK_WINDOW_HIDDEN);
}
NK_API nk_bool
-nk_window_is_active(struct nk_context *ctx, const char *name)
+nk_window_is_active(const struct nk_context *ctx, const char *name)
{
int title_len;
nk_hash title_hash;
@@ -20342,7 +21054,7 @@ nk_window_is_active(struct nk_context *ctx, const char *name)
return win == ctx->active;
}
NK_API struct nk_window*
-nk_window_find(struct nk_context *ctx, const char *name)
+nk_window_find(const struct nk_context *ctx, const char *name)
{
int title_len;
nk_hash title_hash;
@@ -20372,7 +21084,6 @@ nk_window_set_bounds(struct nk_context *ctx,
if (!ctx) return;
win = nk_window_find(ctx, name);
if (!win) return;
- NK_ASSERT(ctx->current != win && "You cannot update a currently in procecss window");
win->bounds = bounds;
}
NK_API void
@@ -20475,6 +21186,15 @@ nk_window_set_focus(struct nk_context *ctx, const char *name)
}
ctx->active = win;
}
+NK_API void
+nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding)
+{
+ struct nk_rect space;
+ enum nk_widget_layout_states state = nk_widget(&space, ctx);
+ struct nk_command_buffer *canvas = nk_window_get_canvas(ctx);
+ if (!state) return;
+ nk_fill_rect(canvas, space, rounding && space.h > 1.5f ? space.h / 2.0f : 0, color);
+}
@@ -20505,7 +21225,7 @@ nk_popup_begin(struct nk_context *ctx, enum nk_popup_type type,
win = ctx->current;
panel = win->layout;
- NK_ASSERT(!(panel->type & NK_PANEL_SET_POPUP) && "popups are not allowed to have popups");
+ NK_ASSERT(!((int)panel->type & (int)NK_PANEL_SET_POPUP) && "popups are not allowed to have popups");
(void)panel;
title_len = (int)nk_strlen(title);
title_hash = nk_murmur_hash(title, (int)title_len, NK_PANEL_POPUP);
@@ -20599,7 +21319,7 @@ nk_nonblock_begin(struct nk_context *ctx,
/* popups cannot have popups */
win = ctx->current;
panel = win->layout;
- NK_ASSERT(!(panel->type & NK_PANEL_SET_POPUP));
+ NK_ASSERT(!((int)panel->type & (int)NK_PANEL_SET_POPUP));
(void)panel;
popup = win->popup.win;
if (!popup) {
@@ -20672,7 +21392,7 @@ nk_popup_close(struct nk_context *ctx)
popup = ctx->current;
NK_ASSERT(popup->parent);
- NK_ASSERT(popup->layout->type & NK_PANEL_SET_POPUP);
+ NK_ASSERT((int)popup->layout->type & (int)NK_PANEL_SET_POPUP);
popup->flags |= NK_WINDOW_HIDDEN;
}
NK_API void
@@ -20708,7 +21428,7 @@ nk_popup_end(struct nk_context *ctx)
nk_push_scissor(&win->buffer, win->layout->clip);
}
NK_API void
-nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
+nk_popup_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
{
struct nk_window *popup;
@@ -20755,6 +21475,7 @@ nk_contextual_begin(struct nk_context *ctx, nk_flags flags, struct nk_vec2 size,
struct nk_window *win;
struct nk_window *popup;
struct nk_rect body;
+ struct nk_input* in;
NK_STORAGE const struct nk_rect null_rect = {-1,-1,0,0};
int is_clicked = 0;
@@ -20775,35 +21496,39 @@ nk_contextual_begin(struct nk_context *ctx, nk_flags flags, struct nk_vec2 size,
/* check if currently active contextual is active */
popup = win->popup.win;
is_open = (popup && win->popup.type == NK_PANEL_CONTEXTUAL);
- is_clicked = nk_input_mouse_clicked(&ctx->input, NK_BUTTON_RIGHT, trigger_bounds);
- if (win->popup.active_con && win->popup.con_count != win->popup.active_con)
- return 0;
- if (!is_open && win->popup.active_con)
- win->popup.active_con = 0;
- if ((!is_open && !is_clicked))
- return 0;
+ in = win->widgets_disabled ? 0 : &ctx->input;
+ if (in) {
+ is_clicked = nk_input_mouse_clicked(in, NK_BUTTON_RIGHT, trigger_bounds);
+ if (win->popup.active_con && win->popup.con_count != win->popup.active_con)
+ return 0;
+ if (!is_open && win->popup.active_con)
+ win->popup.active_con = 0;
+ if ((!is_open && !is_clicked))
+ return 0;
- /* calculate contextual position on click */
- win->popup.active_con = win->popup.con_count;
- if (is_clicked) {
- body.x = ctx->input.mouse.pos.x;
- body.y = ctx->input.mouse.pos.y;
- } else {
- body.x = popup->bounds.x;
- body.y = popup->bounds.y;
- }
- body.w = size.x;
- body.h = size.y;
+ /* calculate contextual position on click */
+ win->popup.active_con = win->popup.con_count;
+ if (is_clicked) {
+ body.x = in->mouse.pos.x;
+ body.y = in->mouse.pos.y;
+ } else {
+ body.x = popup->bounds.x;
+ body.y = popup->bounds.y;
+ }
- /* start nonblocking contextual popup */
- ret = nk_nonblock_begin(ctx, flags|NK_WINDOW_NO_SCROLLBAR, body,
+ body.w = size.x;
+ body.h = size.y;
+
+ /* start nonblocking contextual popup */
+ ret = nk_nonblock_begin(ctx, flags | NK_WINDOW_NO_SCROLLBAR, body,
null_rect, NK_PANEL_CONTEXTUAL);
- if (ret) win->popup.type = NK_PANEL_CONTEXTUAL;
- else {
- win->popup.active_con = 0;
- win->popup.type = NK_PANEL_NONE;
- if (win->popup.win)
- win->popup.win->flags = 0;
+ if (ret) win->popup.type = NK_PANEL_CONTEXTUAL;
+ else {
+ win->popup.active_con = 0;
+ win->popup.type = NK_PANEL_NONE;
+ if (win->popup.win)
+ win->popup.win->flags = 0;
+ }
}
return ret;
}
@@ -20935,7 +21660,7 @@ nk_contextual_end(struct nk_context *ctx)
popup = ctx->current;
panel = popup->layout;
NK_ASSERT(popup->parent);
- NK_ASSERT(panel->type & NK_PANEL_SET_POPUP);
+ NK_ASSERT((int)panel->type & (int)NK_PANEL_SET_POPUP);
if (panel->flags & NK_WINDOW_DYNAMIC) {
/* Close behavior
This is a bit of a hack solution since we do not know before we end our popup
@@ -21092,7 +21817,7 @@ nk_menu_begin_text(struct nk_context *ctx, const char *title, int len,
win = ctx->current;
state = nk_widget(&header, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || win->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
if (nk_do_button_text(&ctx->last_widget_state, &win->buffer, header,
title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in, ctx->style.font))
is_clicked = nk_true;
@@ -21122,7 +21847,7 @@ nk_menu_begin_image(struct nk_context *ctx, const char *id, struct nk_image img,
win = ctx->current;
state = nk_widget(&header, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
if (nk_do_button_image(&ctx->last_widget_state, &win->buffer, header,
img, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in))
is_clicked = nk_true;
@@ -21147,7 +21872,7 @@ nk_menu_begin_symbol(struct nk_context *ctx, const char *id,
win = ctx->current;
state = nk_widget(&header, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
if (nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, header,
sym, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in, ctx->style.font))
is_clicked = nk_true;
@@ -21172,7 +21897,7 @@ nk_menu_begin_image_text(struct nk_context *ctx, const char *title, int len,
win = ctx->current;
state = nk_widget(&header, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
if (nk_do_button_text_image(&ctx->last_widget_state, &win->buffer,
header, img, title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button,
ctx->style.font, in))
@@ -21205,7 +21930,7 @@ nk_menu_begin_symbol_text(struct nk_context *ctx, const char *title, int len,
state = nk_widget(&header, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
if (nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer,
header, sym, title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button,
ctx->style.font, in)) is_clicked = nk_true;
@@ -21311,6 +22036,8 @@ nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel
struct nk_vec2 spacing;
+ NK_UNUSED(type);
+
spacing = style->window.spacing;
/* calculate the usable panel space */
@@ -21394,7 +22121,7 @@ nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt,
win->layout->row.item_width = (float)width;
}
NK_API float
-nk_layout_ratio_from_pixel(struct nk_context *ctx, float pixel_width)
+nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width)
{
struct nk_window *win;
NK_ASSERT(ctx);
@@ -21723,7 +22450,7 @@ nk_layout_space_push(struct nk_context *ctx, struct nk_rect rect)
layout->row.item = rect;
}
NK_API struct nk_rect
-nk_layout_space_bounds(struct nk_context *ctx)
+nk_layout_space_bounds(const struct nk_context *ctx)
{
struct nk_rect ret;
struct nk_window *win;
@@ -21742,7 +22469,7 @@ nk_layout_space_bounds(struct nk_context *ctx)
return ret;
}
NK_API struct nk_rect
-nk_layout_widget_bounds(struct nk_context *ctx)
+nk_layout_widget_bounds(const struct nk_context *ctx)
{
struct nk_rect ret;
struct nk_window *win;
@@ -21761,7 +22488,7 @@ nk_layout_widget_bounds(struct nk_context *ctx)
return ret;
}
NK_API struct nk_vec2
-nk_layout_space_to_screen(struct nk_context *ctx, struct nk_vec2 ret)
+nk_layout_space_to_screen(const struct nk_context *ctx, struct nk_vec2 ret)
{
struct nk_window *win;
struct nk_panel *layout;
@@ -21777,7 +22504,7 @@ nk_layout_space_to_screen(struct nk_context *ctx, struct nk_vec2 ret)
return ret;
}
NK_API struct nk_vec2
-nk_layout_space_to_local(struct nk_context *ctx, struct nk_vec2 ret)
+nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 ret)
{
struct nk_window *win;
struct nk_panel *layout;
@@ -21793,7 +22520,7 @@ nk_layout_space_to_local(struct nk_context *ctx, struct nk_vec2 ret)
return ret;
}
NK_API struct nk_rect
-nk_layout_space_rect_to_screen(struct nk_context *ctx, struct nk_rect ret)
+nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect ret)
{
struct nk_window *win;
struct nk_panel *layout;
@@ -21809,7 +22536,7 @@ nk_layout_space_rect_to_screen(struct nk_context *ctx, struct nk_rect ret)
return ret;
}
NK_API struct nk_rect
-nk_layout_space_rect_to_local(struct nk_context *ctx, struct nk_rect ret)
+nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect ret)
{
struct nk_window *win;
struct nk_panel *layout;
@@ -21861,7 +22588,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
layout->bounds.w, layout->row.columns);
- #define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
+ #define NK_FRAC(x) (x - (float)(int)nk_roundf(x)) /* will be used to remove fookin gaps */
/* calculate the width of one item inside the current layout space */
switch (layout->row.type) {
case NK_LAYOUT_DYNAMIC_FIXED: {
@@ -21990,7 +22717,7 @@ nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx)
layout->row.index++;
}
NK_LIB void
-nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
+nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx)
{
float y;
int index;
@@ -22000,8 +22727,10 @@ nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
- if (!ctx || !ctx->current || !ctx->current->layout)
+ if (!ctx || !ctx->current || !ctx->current->layout) {
+ *bounds = nk_rect(0,0,0,0);
return;
+ }
win = ctx->current;
layout = win->layout;
@@ -22018,7 +22747,12 @@ nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
layout->at_y = y;
layout->row.index = index;
}
-
+NK_API void
+nk_spacer(struct nk_context *ctx )
+{
+ struct nk_rect dummy_rect = { 0, 0, 0, 0 };
+ nk_panel_alloc_space( &dummy_rect, ctx );
+}
@@ -22071,14 +22805,19 @@ nk_tree_state_base(struct nk_context *ctx, enum nk_tree_type type,
widget_state = nk_widget(&header, ctx);
if (type == NK_TREE_TAB) {
const struct nk_style_item *background = &style->tab.background;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(out, header, &background->data.image, nk_white);
- text.background = nk_rgba(0,0,0,0);
- } else {
- text.background = background->data.color;
- nk_fill_rect(out, header, 0, style->tab.border_color);
- nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
- style->tab.rounding, background->data.color);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, header, &background->data.image, nk_rgb_factor(nk_white, style->tab.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, header, &background->data.slice, nk_rgb_factor(nk_white, style->tab.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, header, 0, nk_rgb_factor(style->tab.border_color, style->tab.color_factor));
+ nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
+ style->tab.rounding, nk_rgb_factor(background->data.color, style->tab.color_factor));
+ break;
}
} else text.background = style->window.background;
@@ -22122,7 +22861,7 @@ nk_tree_state_base(struct nk_context *ctx, enum nk_tree_type type,
label.y = sym.y;
label.w = header.w - (sym.w + item_spacing.y + style->tab.indent);
label.h = style->font->height;
- text.text = style->tab.text;
+ text.text = nk_rgb_factor(style->tab.text, style->tab.color_factor);
text.padding = nk_vec2(0,0);
nk_widget_text(out, label, title, nk_strlen(title), &text,
NK_TEXT_LEFT, style->font);}
@@ -22256,12 +22995,20 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
widget_state = nk_widget(&header, ctx);
if (type == NK_TREE_TAB) {
const struct nk_style_item *background = &style->tab.background;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(out, header, &background->data.image, nk_white);
- } else {
- nk_fill_rect(out, header, 0, style->tab.border_color);
- nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
- style->tab.rounding, background->data.color);
+
+ switch (background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, header, &background->data.image, nk_rgb_factor(nk_white, style->tab.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, header, &background->data.slice, nk_rgb_factor(nk_white, style->tab.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, header, 0, nk_rgb_factor(style->tab.border_color, style->tab.color_factor));
+ nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
+ style->tab.rounding, nk_rgb_factor(background->data.color, style->tab.color_factor));
+
+ break;
}
}
@@ -22688,7 +23435,7 @@ nk_list_view_end(struct nk_list_view *view)
*
* ===============================================================*/
NK_API struct nk_rect
-nk_widget_bounds(struct nk_context *ctx)
+nk_widget_bounds(const struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
@@ -22699,7 +23446,7 @@ nk_widget_bounds(struct nk_context *ctx)
return bounds;
}
NK_API struct nk_vec2
-nk_widget_position(struct nk_context *ctx)
+nk_widget_position(const struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
@@ -22711,7 +23458,7 @@ nk_widget_position(struct nk_context *ctx)
return nk_vec2(bounds.x, bounds.y);
}
NK_API struct nk_vec2
-nk_widget_size(struct nk_context *ctx)
+nk_widget_size(const struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
@@ -22723,7 +23470,7 @@ nk_widget_size(struct nk_context *ctx)
return nk_vec2(bounds.w, bounds.h);
}
NK_API float
-nk_widget_width(struct nk_context *ctx)
+nk_widget_width(const struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
@@ -22735,7 +23482,7 @@ nk_widget_width(struct nk_context *ctx)
return bounds.w;
}
NK_API float
-nk_widget_height(struct nk_context *ctx)
+nk_widget_height(const struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
@@ -22747,7 +23494,7 @@ nk_widget_height(struct nk_context *ctx)
return bounds.h;
}
NK_API nk_bool
-nk_widget_is_hovered(struct nk_context *ctx)
+nk_widget_is_hovered(const struct nk_context *ctx)
{
struct nk_rect c, v;
struct nk_rect bounds;
@@ -22769,7 +23516,7 @@ nk_widget_is_hovered(struct nk_context *ctx)
return nk_input_is_mouse_hovering_rect(&ctx->input, bounds);
}
NK_API nk_bool
-nk_widget_is_mouse_clicked(struct nk_context *ctx, enum nk_buttons btn)
+nk_widget_is_mouse_clicked(const struct nk_context *ctx, enum nk_buttons btn)
{
struct nk_rect c, v;
struct nk_rect bounds;
@@ -22791,7 +23538,7 @@ nk_widget_is_mouse_clicked(struct nk_context *ctx, enum nk_buttons btn)
return nk_input_mouse_clicked(&ctx->input, btn, bounds);
}
NK_API nk_bool
-nk_widget_has_mouse_click_down(struct nk_context *ctx, enum nk_buttons btn, nk_bool down)
+nk_widget_has_mouse_click_down(const struct nk_context *ctx, enum nk_buttons btn, nk_bool down)
{
struct nk_rect c, v;
struct nk_rect bounds;
@@ -22856,12 +23603,14 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
nk_unify(&v, &c, bounds->x, bounds->y, bounds->x + bounds->w, bounds->y + bounds->h);
if (!NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->x, bounds->y, bounds->w, bounds->h))
return NK_WIDGET_INVALID;
+ if (win->widgets_disabled)
+ return NK_WIDGET_DISABLED;
if (!NK_INBOX(in->mouse.pos.x, in->mouse.pos.y, v.x, v.y, v.w, v.h))
return NK_WIDGET_ROM;
return NK_WIDGET_VALID;
}
NK_API enum nk_widget_layout_states
-nk_widget_fitting(struct nk_rect *bounds, struct nk_context *ctx,
+nk_widget_fitting(struct nk_rect *bounds, const struct nk_context *ctx,
struct nk_vec2 item_padding)
{
/* update the bounds to stand without padding */
@@ -22908,7 +23657,132 @@ nk_spacing(struct nk_context *ctx, int cols)
nk_panel_alloc_space(&none, ctx);
} layout->row.index = index;
}
+NK_API void
+nk_widget_disable_begin(struct nk_context* ctx)
+{
+ struct nk_window* win;
+ struct nk_style* style;
+
+ NK_ASSERT(ctx);
+ NK_ASSERT(ctx->current);
+
+ if (!ctx || !ctx->current)
+ return;
+
+ win = ctx->current;
+ style = &ctx->style;
+ win->widgets_disabled = nk_true;
+
+ style->button.color_factor_text = style->button.disabled_factor;
+ style->button.color_factor_background = style->button.disabled_factor;
+ style->chart.color_factor = style->chart.disabled_factor;
+ style->checkbox.color_factor = style->checkbox.disabled_factor;
+ style->combo.color_factor = style->combo.disabled_factor;
+ style->combo.button.color_factor_text = style->combo.button.disabled_factor;
+ style->combo.button.color_factor_background = style->combo.button.disabled_factor;
+ style->contextual_button.color_factor_text = style->contextual_button.disabled_factor;
+ style->contextual_button.color_factor_background = style->contextual_button.disabled_factor;
+ style->edit.color_factor = style->edit.disabled_factor;
+ style->edit.scrollbar.color_factor = style->edit.scrollbar.disabled_factor;
+ style->menu_button.color_factor_text = style->menu_button.disabled_factor;
+ style->menu_button.color_factor_background = style->menu_button.disabled_factor;
+ style->option.color_factor = style->option.disabled_factor;
+ style->progress.color_factor = style->progress.disabled_factor;
+ style->property.color_factor = style->property.disabled_factor;
+ style->property.inc_button.color_factor_text = style->property.inc_button.disabled_factor;
+ style->property.inc_button.color_factor_background = style->property.inc_button.disabled_factor;
+ style->property.dec_button.color_factor_text = style->property.dec_button.disabled_factor;
+ style->property.dec_button.color_factor_background = style->property.dec_button.disabled_factor;
+ style->property.edit.color_factor = style->property.edit.disabled_factor;
+ style->scrollh.color_factor = style->scrollh.disabled_factor;
+ style->scrollh.inc_button.color_factor_text = style->scrollh.inc_button.disabled_factor;
+ style->scrollh.inc_button.color_factor_background = style->scrollh.inc_button.disabled_factor;
+ style->scrollh.dec_button.color_factor_text = style->scrollh.dec_button.disabled_factor;
+ style->scrollh.dec_button.color_factor_background = style->scrollh.dec_button.disabled_factor;
+ style->scrollv.color_factor = style->scrollv.disabled_factor;
+ style->scrollv.inc_button.color_factor_text = style->scrollv.inc_button.disabled_factor;
+ style->scrollv.inc_button.color_factor_background = style->scrollv.inc_button.disabled_factor;
+ style->scrollv.dec_button.color_factor_text = style->scrollv.dec_button.disabled_factor;
+ style->scrollv.dec_button.color_factor_background = style->scrollv.dec_button.disabled_factor;
+ style->selectable.color_factor = style->selectable.disabled_factor;
+ style->slider.color_factor = style->slider.disabled_factor;
+ style->slider.inc_button.color_factor_text = style->slider.inc_button.disabled_factor;
+ style->slider.inc_button.color_factor_background = style->slider.inc_button.disabled_factor;
+ style->slider.dec_button.color_factor_text = style->slider.dec_button.disabled_factor;
+ style->slider.dec_button.color_factor_background = style->slider.dec_button.disabled_factor;
+ style->tab.color_factor = style->tab.disabled_factor;
+ style->tab.node_maximize_button.color_factor_text = style->tab.node_maximize_button.disabled_factor;
+ style->tab.node_minimize_button.color_factor_text = style->tab.node_minimize_button.disabled_factor;
+ style->tab.tab_maximize_button.color_factor_text = style->tab.tab_maximize_button.disabled_factor;
+ style->tab.tab_maximize_button.color_factor_background = style->tab.tab_maximize_button.disabled_factor;
+ style->tab.tab_minimize_button.color_factor_text = style->tab.tab_minimize_button.disabled_factor;
+ style->tab.tab_minimize_button.color_factor_background = style->tab.tab_minimize_button.disabled_factor;
+ style->text.color_factor = style->text.disabled_factor;
+}
+NK_API void
+nk_widget_disable_end(struct nk_context* ctx)
+{
+ struct nk_window* win;
+ struct nk_style* style;
+
+ NK_ASSERT(ctx);
+ NK_ASSERT(ctx->current);
+
+ if (!ctx || !ctx->current)
+ return;
+
+ win = ctx->current;
+ style = &ctx->style;
+
+ win->widgets_disabled = nk_false;
+
+ style->button.color_factor_text = 1.0f;
+ style->button.color_factor_background = 1.0f;
+ style->chart.color_factor = 1.0f;
+ style->checkbox.color_factor = 1.0f;
+ style->combo.color_factor = 1.0f;
+ style->combo.button.color_factor_text = 1.0f;
+ style->combo.button.color_factor_background = 1.0f;
+ style->contextual_button.color_factor_text = 1.0f;
+ style->contextual_button.color_factor_background = 1.0f;
+ style->edit.color_factor = 1.0f;
+ style->edit.scrollbar.color_factor = 1.0f;
+ style->menu_button.color_factor_text = 1.0f;
+ style->menu_button.color_factor_background = 1.0f;
+ style->option.color_factor = 1.0f;
+ style->progress.color_factor = 1.0f;
+ style->property.color_factor = 1.0f;
+ style->property.inc_button.color_factor_text = 1.0f;
+ style->property.inc_button.color_factor_background = 1.0f;
+ style->property.dec_button.color_factor_text = 1.0f;
+ style->property.dec_button.color_factor_background = 1.0f;
+ style->property.edit.color_factor = 1.0f;
+ style->scrollh.color_factor = 1.0f;
+ style->scrollh.inc_button.color_factor_text = 1.0f;
+ style->scrollh.inc_button.color_factor_background = 1.0f;
+ style->scrollh.dec_button.color_factor_text = 1.0f;
+ style->scrollh.dec_button.color_factor_background = 1.0f;
+ style->scrollv.color_factor = 1.0f;
+ style->scrollv.inc_button.color_factor_text = 1.0f;
+ style->scrollv.inc_button.color_factor_background = 1.0f;
+ style->scrollv.dec_button.color_factor_text = 1.0f;
+ style->scrollv.dec_button.color_factor_background = 1.0f;
+ style->selectable.color_factor = 1.0f;
+ style->slider.color_factor = 1.0f;
+ style->slider.inc_button.color_factor_text = 1.0f;
+ style->slider.inc_button.color_factor_background = 1.0f;
+ style->slider.dec_button.color_factor_text = 1.0f;
+ style->slider.dec_button.color_factor_background = 1.0f;
+ style->tab.color_factor = 1.0f;
+ style->tab.node_maximize_button.color_factor_text = 1.0f;
+ style->tab.node_minimize_button.color_factor_text = 1.0f;
+ style->tab.tab_maximize_button.color_factor_text = 1.0f;
+ style->tab.tab_maximize_button.color_factor_background = 1.0f;
+ style->tab.tab_minimize_button.color_factor_text = 1.0f;
+ style->tab.tab_minimize_button.color_factor_background = 1.0f;
+ style->text.color_factor = 1.0f;
+}
@@ -23026,7 +23900,7 @@ nk_text_colored(struct nk_context *ctx, const char *str, int len,
text.padding.x = item_padding.x;
text.padding.y = item_padding.y;
text.background = style->window.background;
- text.text = color;
+ text.text = nk_rgb_factor(color, style->text.color_factor);
nk_widget_text(&win->buffer, bounds, str, len, &text, alignment, style->font);
}
NK_API void
@@ -23053,7 +23927,7 @@ nk_text_wrap_colored(struct nk_context *ctx, const char *str,
text.padding.x = item_padding.x;
text.padding.y = item_padding.y;
text.background = style->window.background;
- text.text = color;
+ text.text = nk_rgb_factor(color, style->text.color_factor);
nk_widget_text_wrap(&win->buffer, bounds, str, len, &text, style->font);
}
#ifdef NK_INCLUDE_STANDARD_VARARGS
@@ -23227,43 +24101,42 @@ nk_handle_id(int id)
return handle;
}
NK_API struct nk_image
-nk_subimage_ptr(void *ptr, unsigned short w, unsigned short h, struct nk_rect r)
+nk_subimage_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect r)
{
struct nk_image s;
nk_zero(&s, sizeof(s));
s.handle.ptr = ptr;
s.w = w; s.h = h;
- s.region[0] = (unsigned short)r.x;
- s.region[1] = (unsigned short)r.y;
- s.region[2] = (unsigned short)r.w;
- s.region[3] = (unsigned short)r.h;
+ s.region[0] = (nk_ushort)r.x;
+ s.region[1] = (nk_ushort)r.y;
+ s.region[2] = (nk_ushort)r.w;
+ s.region[3] = (nk_ushort)r.h;
return s;
}
NK_API struct nk_image
-nk_subimage_id(int id, unsigned short w, unsigned short h, struct nk_rect r)
+nk_subimage_id(int id, nk_ushort w, nk_ushort h, struct nk_rect r)
{
struct nk_image s;
nk_zero(&s, sizeof(s));
s.handle.id = id;
s.w = w; s.h = h;
- s.region[0] = (unsigned short)r.x;
- s.region[1] = (unsigned short)r.y;
- s.region[2] = (unsigned short)r.w;
- s.region[3] = (unsigned short)r.h;
+ s.region[0] = (nk_ushort)r.x;
+ s.region[1] = (nk_ushort)r.y;
+ s.region[2] = (nk_ushort)r.w;
+ s.region[3] = (nk_ushort)r.h;
return s;
}
NK_API struct nk_image
-nk_subimage_handle(nk_handle handle, unsigned short w, unsigned short h,
- struct nk_rect r)
+nk_subimage_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect r)
{
struct nk_image s;
nk_zero(&s, sizeof(s));
s.handle = handle;
s.w = w; s.h = h;
- s.region[0] = (unsigned short)r.x;
- s.region[1] = (unsigned short)r.y;
- s.region[2] = (unsigned short)r.w;
- s.region[3] = (unsigned short)r.h;
+ s.region[0] = (nk_ushort)r.x;
+ s.region[1] = (nk_ushort)r.y;
+ s.region[2] = (nk_ushort)r.w;
+ s.region[3] = (nk_ushort)r.h;
return s;
}
NK_API struct nk_image
@@ -23347,6 +24220,113 @@ nk_image_color(struct nk_context *ctx, struct nk_image img, struct nk_color col)
+/* ===============================================================
+ *
+ * 9-SLICE
+ *
+ * ===============================================================*/
+NK_API struct nk_nine_slice
+nk_sub9slice_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
+{
+ struct nk_nine_slice s;
+ struct nk_image *i = &s.img;
+ nk_zero(&s, sizeof(s));
+ i->handle.ptr = ptr;
+ i->w = w; i->h = h;
+ i->region[0] = (nk_ushort)rgn.x;
+ i->region[1] = (nk_ushort)rgn.y;
+ i->region[2] = (nk_ushort)rgn.w;
+ i->region[3] = (nk_ushort)rgn.h;
+ s.l = l; s.t = t; s.r = r; s.b = b;
+ return s;
+}
+NK_API struct nk_nine_slice
+nk_sub9slice_id(int id, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
+{
+ struct nk_nine_slice s;
+ struct nk_image *i = &s.img;
+ nk_zero(&s, sizeof(s));
+ i->handle.id = id;
+ i->w = w; i->h = h;
+ i->region[0] = (nk_ushort)rgn.x;
+ i->region[1] = (nk_ushort)rgn.y;
+ i->region[2] = (nk_ushort)rgn.w;
+ i->region[3] = (nk_ushort)rgn.h;
+ s.l = l; s.t = t; s.r = r; s.b = b;
+ return s;
+}
+NK_API struct nk_nine_slice
+nk_sub9slice_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
+{
+ struct nk_nine_slice s;
+ struct nk_image *i = &s.img;
+ nk_zero(&s, sizeof(s));
+ i->handle = handle;
+ i->w = w; i->h = h;
+ i->region[0] = (nk_ushort)rgn.x;
+ i->region[1] = (nk_ushort)rgn.y;
+ i->region[2] = (nk_ushort)rgn.w;
+ i->region[3] = (nk_ushort)rgn.h;
+ s.l = l; s.t = t; s.r = r; s.b = b;
+ return s;
+}
+NK_API struct nk_nine_slice
+nk_nine_slice_handle(nk_handle handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
+{
+ struct nk_nine_slice s;
+ struct nk_image *i = &s.img;
+ nk_zero(&s, sizeof(s));
+ i->handle = handle;
+ i->w = 0; i->h = 0;
+ i->region[0] = 0;
+ i->region[1] = 0;
+ i->region[2] = 0;
+ i->region[3] = 0;
+ s.l = l; s.t = t; s.r = r; s.b = b;
+ return s;
+}
+NK_API struct nk_nine_slice
+nk_nine_slice_ptr(void *ptr, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
+{
+ struct nk_nine_slice s;
+ struct nk_image *i = &s.img;
+ nk_zero(&s, sizeof(s));
+ NK_ASSERT(ptr);
+ i->handle.ptr = ptr;
+ i->w = 0; i->h = 0;
+ i->region[0] = 0;
+ i->region[1] = 0;
+ i->region[2] = 0;
+ i->region[3] = 0;
+ s.l = l; s.t = t; s.r = r; s.b = b;
+ return s;
+}
+NK_API struct nk_nine_slice
+nk_nine_slice_id(int id, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
+{
+ struct nk_nine_slice s;
+ struct nk_image *i = &s.img;
+ nk_zero(&s, sizeof(s));
+ i->handle.id = id;
+ i->w = 0; i->h = 0;
+ i->region[0] = 0;
+ i->region[1] = 0;
+ i->region[2] = 0;
+ i->region[3] = 0;
+ s.l = l; s.t = t; s.r = r; s.b = b;
+ return s;
+}
+NK_API int
+nk_nine_slice_is_sub9slice(const struct nk_nine_slice* slice)
+{
+ NK_ASSERT(slice);
+ return !(slice->img.w == 0 && slice->img.h == 0);
+}
+
+
+
+
+
/* ==============================================================
*
* BUTTON
@@ -23400,6 +24380,19 @@ nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type,
nk_fill_triangle(out, points[0].x, points[0].y, points[1].x, points[1].y,
points[2].x, points[2].y, foreground);
} break;
+ case NK_SYMBOL_TRIANGLE_UP_OUTLINE:
+ case NK_SYMBOL_TRIANGLE_DOWN_OUTLINE:
+ case NK_SYMBOL_TRIANGLE_LEFT_OUTLINE:
+ case NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE: {
+ enum nk_heading heading;
+ struct nk_vec2 points[3];
+ heading = (type == NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE) ? NK_RIGHT :
+ (type == NK_SYMBOL_TRIANGLE_LEFT_OUTLINE) ? NK_LEFT:
+ (type == NK_SYMBOL_TRIANGLE_UP_OUTLINE) ? NK_UP: NK_DOWN;
+ nk_triangle_from_direction(points, content, 0, 0, heading);
+ nk_stroke_triangle(out, points[0].x, points[0].y, points[1].x, points[1].y,
+ points[2].x, points[2].y, border_width, foreground);
+ } break;
default:
case NK_SYMBOL_NONE:
case NK_SYMBOL_MAX: break;
@@ -23416,7 +24409,7 @@ nk_button_behavior(nk_flags *state, struct nk_rect r,
*state = NK_WIDGET_STATE_HOVERED;
if (nk_input_is_mouse_down(i, NK_BUTTON_LEFT))
*state = NK_WIDGET_STATE_ACTIVE;
- if (nk_input_has_mouse_click_in_rect(i, NK_BUTTON_LEFT, r)) {
+ if (nk_input_has_mouse_click_in_button_rect(i, NK_BUTTON_LEFT, r)) {
ret = (behavior != NK_BUTTON_DEFAULT) ?
nk_input_is_mouse_down(i, NK_BUTTON_LEFT):
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
@@ -23444,11 +24437,17 @@ nk_draw_button(struct nk_command_buffer *out,
background = &style->active;
else background = &style->normal;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(out, *bounds, &background->data.image, nk_white);
- } else {
- nk_fill_rect(out, *bounds, style->rounding, background->data.color);
- nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
+ switch (background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor_background));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor_background));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor_background));
+ nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor_background));
+ break;
}
return background;
}
@@ -23467,8 +24466,8 @@ nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r,
/* calculate button content space */
content->x = r.x + style->padding.x + style->border + style->rounding;
content->y = r.y + style->padding.y + style->border + style->rounding;
- content->w = r.w - (2 * style->padding.x + style->border + style->rounding*2);
- content->h = r.h - (2 * style->padding.y + style->border + style->rounding*2);
+ content->w = r.w - (2 * (style->padding.x + style->border + style->rounding));
+ content->h = r.h - (2 * (style->padding.y + style->border + style->rounding));
/* execute button behavior */
bounds.x = r.x - style->touch_padding.x;
@@ -23497,6 +24496,8 @@ nk_draw_button_text(struct nk_command_buffer *out,
text.text = style->text_active;
else text.text = style->text_normal;
+ text.text = nk_rgb_factor(text.text, style->color_factor_text);
+
text.padding = nk_vec2(0,0);
nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
}
@@ -23544,6 +24545,8 @@ nk_draw_button_symbol(struct nk_command_buffer *out,
else if (state & NK_WIDGET_STATE_ACTIVED)
sym = style->text_active;
else sym = style->text_normal;
+
+ sym = nk_rgb_factor(sym, style->color_factor_text);
nk_draw_symbol(out, type, *content, bg, sym, 1, font);
}
NK_LIB nk_bool
@@ -23575,7 +24578,7 @@ nk_draw_button_image(struct nk_command_buffer *out,
nk_flags state, const struct nk_style_button *style, const struct nk_image *img)
{
nk_draw_button(out, bounds, state, style);
- nk_draw_image(out, *content, img, nk_white);
+ nk_draw_image(out, *content, img, nk_rgb_factor(nk_white, style->color_factor_background));
}
NK_LIB nk_bool
nk_do_button_image(nk_flags *state,
@@ -23632,6 +24635,8 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out,
text.text = style->text_normal;
}
+ sym = nk_rgb_factor(sym, style->color_factor_text);
+ text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0,0);
nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0, font);
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
@@ -23689,9 +24694,10 @@ nk_draw_button_text_image(struct nk_command_buffer *out,
text.text = style->text_active;
else text.text = style->text_normal;
- text.padding = nk_vec2(0,0);
+ text.text = nk_rgb_factor(text.text, style->color_factor_text);
+ text.padding = nk_vec2(0, 0);
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
- nk_draw_image(out, *image, img, nk_white);
+ nk_draw_image(out, *image, img, nk_rgb_factor(nk_white, style->color_factor_background));
}
NK_LIB nk_bool
nk_do_button_text_image(nk_flags *state,
@@ -23796,7 +24802,7 @@ nk_button_text_styled(struct nk_context *ctx,
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_button_text(&ctx->last_widget_state, &win->buffer, bounds,
title, len, style->text_alignment, ctx->button_behavior,
style, in, ctx->style.font);
@@ -23841,7 +24847,7 @@ nk_button_color(struct nk_context *ctx, struct nk_color color)
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
button = ctx->style.button;
button.normal = nk_style_item_color(color);
@@ -23873,7 +24879,7 @@ nk_button_symbol_styled(struct nk_context *ctx,
layout = win->layout;
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, bounds,
symbol, ctx->button_behavior, style, in, ctx->style.font);
}
@@ -23906,7 +24912,7 @@ nk_button_image_styled(struct nk_context *ctx, const struct nk_style_button *sty
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_button_image(&ctx->last_widget_state, &win->buffer, bounds,
img, ctx->button_behavior, style, in);
}
@@ -23940,7 +24946,7 @@ nk_button_symbol_text_styled(struct nk_context *ctx,
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer, bounds,
symbol, text, len, align, ctx->button_behavior,
style, ctx->style.font, in);
@@ -23987,7 +24993,7 @@ nk_button_image_text_styled(struct nk_context *ctx,
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_button_text_image(&ctx->last_widget_state, &win->buffer,
bounds, img, text, len, align, ctx->button_behavior,
style, ctx->style.font, in);
@@ -24039,7 +25045,7 @@ nk_draw_checkbox(struct nk_command_buffer *out,
nk_flags state, const struct nk_style_toggle *style, nk_bool active,
const struct nk_rect *label, const struct nk_rect *selector,
const struct nk_rect *cursors, const char *string, int len,
- const struct nk_user_font *font)
+ const struct nk_user_font *font, nk_flags text_alignment)
{
const struct nk_style_item *background;
const struct nk_style_item *cursor;
@@ -24060,28 +25066,29 @@ nk_draw_checkbox(struct nk_command_buffer *out,
text.text = style->text_normal;
}
+ text.text = nk_rgb_factor(text.text, style->color_factor);
+ text.padding.x = 0;
+ text.padding.y = 0;
+ text.background = style->text_background;
+ nk_widget_text(out, *label, string, len, &text, text_alignment, font);
+
/* draw background and cursor */
if (background->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_rect(out, *selector, 0, style->border_color);
- nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color);
- } else nk_draw_image(out, *selector, &background->data.image, nk_white);
+ nk_fill_rect(out, *selector, 0, nk_rgb_factor(style->border_color, style->color_factor));
+ nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, nk_rgb_factor(background->data.color, style->color_factor));
+ } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
if (active) {
if (cursor->type == NK_STYLE_ITEM_IMAGE)
- nk_draw_image(out, *cursors, &cursor->data.image, nk_white);
+ nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
else nk_fill_rect(out, *cursors, 0, cursor->data.color);
}
-
- text.padding.x = 0;
- text.padding.y = 0;
- text.background = style->text_background;
- nk_widget_text(out, *label, string, len, &text, NK_TEXT_LEFT, font);
}
NK_LIB void
nk_draw_option(struct nk_command_buffer *out,
nk_flags state, const struct nk_style_toggle *style, nk_bool active,
const struct nk_rect *label, const struct nk_rect *selector,
const struct nk_rect *cursors, const char *string, int len,
- const struct nk_user_font *font)
+ const struct nk_user_font *font, nk_flags text_alignment)
{
const struct nk_style_item *background;
const struct nk_style_item *cursor;
@@ -24102,28 +25109,29 @@ nk_draw_option(struct nk_command_buffer *out,
text.text = style->text_normal;
}
+ text.text = nk_rgb_factor(text.text, style->color_factor);
+ text.padding.x = 0;
+ text.padding.y = 0;
+ text.background = style->text_background;
+ nk_widget_text(out, *label, string, len, &text, text_alignment, font);
+
/* draw background and cursor */
if (background->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_circle(out, *selector, style->border_color);
- nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color);
- } else nk_draw_image(out, *selector, &background->data.image, nk_white);
+ nk_fill_circle(out, *selector, nk_rgb_factor(style->border_color, style->color_factor));
+ nk_fill_circle(out, nk_shrink_rect(*selector, style->border), nk_rgb_factor(background->data.color, style->color_factor));
+ } else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
if (active) {
if (cursor->type == NK_STYLE_ITEM_IMAGE)
- nk_draw_image(out, *cursors, &cursor->data.image, nk_white);
+ nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
else nk_fill_circle(out, *cursors, cursor->data.color);
}
-
- text.padding.x = 0;
- text.padding.y = 0;
- text.background = style->text_background;
- nk_widget_text(out, *label, string, len, &text, NK_TEXT_LEFT, font);
}
NK_LIB nk_bool
nk_do_toggle(nk_flags *state,
struct nk_command_buffer *out, struct nk_rect r,
nk_bool *active, const char *str, int len, enum nk_toggle_type type,
const struct nk_style_toggle *style, const struct nk_input *in,
- const struct nk_user_font *font)
+ const struct nk_user_font *font, nk_flags widget_alignment, nk_flags text_alignment)
{
int was_active;
struct nk_rect bounds;
@@ -24149,8 +25157,37 @@ nk_do_toggle(nk_flags *state,
/* calculate the selector space */
select.w = font->height;
select.h = select.w;
- select.y = r.y + r.h/2.0f - select.h/2.0f;
- select.x = r.x;
+
+ if (widget_alignment & NK_WIDGET_ALIGN_RIGHT) {
+ select.x = r.x + r.w - font->height;
+
+ /* label in front of the selector */
+ label.x = r.x;
+ label.w = r.w - select.w - style->spacing * 2;
+ } else if (widget_alignment & NK_WIDGET_ALIGN_CENTERED) {
+ select.x = r.x + (r.w - select.w) / 2;
+
+ /* label in front of selector */
+ label.x = r.x;
+ label.w = (r.w - select.w - style->spacing * 2) / 2;
+ } else { /* Default: NK_WIDGET_ALIGN_LEFT */
+ select.x = r.x;
+
+ /* label behind the selector */
+ label.x = select.x + select.w + style->spacing;
+ label.w = NK_MAX(r.x + r.w, label.x) - label.x;
+ }
+
+ if (widget_alignment & NK_WIDGET_ALIGN_TOP) {
+ select.y = r.y;
+ } else if (widget_alignment & NK_WIDGET_ALIGN_BOTTOM) {
+ select.y = r.y + r.h - select.h - 2 * style->padding.y;
+ } else { /* Default: NK_WIDGET_ALIGN_MIDDLE */
+ select.y = r.y + r.h/2.0f - select.h/2.0f;
+ }
+
+ label.y = select.y;
+ label.h = select.w;
/* calculate the bounds of the cursor inside the selector */
cursor.x = select.x + style->padding.x + style->border;
@@ -24158,12 +25195,6 @@ nk_do_toggle(nk_flags *state,
cursor.w = select.w - (2 * style->padding.x + 2 * style->border);
cursor.h = select.h - (2 * style->padding.y + 2 * style->border);
- /* label behind the selector */
- label.x = select.x + select.w + style->spacing;
- label.y = select.y;
- label.w = NK_MAX(r.x + r.w, label.x) - label.x;
- label.h = select.w;
-
/* update selector */
was_active = *active;
*active = nk_toggle_behavior(in, bounds, state, *active);
@@ -24172,9 +25203,9 @@ nk_do_toggle(nk_flags *state,
if (style->draw_begin)
style->draw_begin(out, style->userdata);
if (type == NK_TOGGLE_CHECK) {
- nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
+ nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font, text_alignment);
} else {
- nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
+ nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font, text_alignment);
}
if (style->draw_end)
style->draw_end(out, style->userdata);
@@ -24208,9 +25239,37 @@ nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active)
state = nk_widget(&bounds, ctx);
if (!state) return active;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &active,
- text, len, NK_TOGGLE_CHECK, &style->checkbox, in, style->font);
+ text, len, NK_TOGGLE_CHECK, &style->checkbox, in, style->font, NK_WIDGET_LEFT, NK_TEXT_LEFT);
+ return active;
+}
+NK_API nk_bool
+nk_check_text_align(struct nk_context *ctx, const char *text, int len, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ struct nk_window *win;
+ struct nk_panel *layout;
+ const struct nk_input *in;
+ const struct nk_style *style;
+
+ struct nk_rect bounds;
+ enum nk_widget_layout_states state;
+
+ NK_ASSERT(ctx);
+ NK_ASSERT(ctx->current);
+ NK_ASSERT(ctx->current->layout);
+ if (!ctx || !ctx->current || !ctx->current->layout)
+ return active;
+
+ win = ctx->current;
+ style = &ctx->style;
+ layout = win->layout;
+
+ state = nk_widget(&bounds, ctx);
+ if (!state) return active;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &active,
+ text, len, NK_TOGGLE_CHECK, &style->checkbox, in, style->font, widget_alignment, text_alignment);
return active;
}
NK_API unsigned int
@@ -24240,6 +25299,18 @@ nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *act
return old_val != *active;
}
NK_API nk_bool
+nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ int old_val;
+ NK_ASSERT(ctx);
+ NK_ASSERT(text);
+ NK_ASSERT(active);
+ if (!ctx || !text || !active) return 0;
+ old_val = *active;
+ *active = nk_check_text_align(ctx, text, len, *active, widget_alignment, text_alignment);
+ return old_val != *active;
+}
+NK_API nk_bool
nk_checkbox_flags_text(struct nk_context *ctx, const char *text, int len,
unsigned int *flags, unsigned int value)
{
@@ -24270,6 +25341,10 @@ NK_API nk_bool nk_checkbox_label(struct nk_context *ctx, const char *label, nk_b
{
return nk_checkbox_text(ctx, label, nk_strlen(label), active);
}
+NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ return nk_checkbox_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
+}
NK_API nk_bool nk_checkbox_flags_label(struct nk_context *ctx, const char *label,
unsigned int *flags, unsigned int value)
{
@@ -24303,9 +25378,37 @@ nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_act
state = nk_widget(&bounds, ctx);
if (!state) return (int)state;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &is_active,
- text, len, NK_TOGGLE_OPTION, &style->option, in, style->font);
+ text, len, NK_TOGGLE_OPTION, &style->option, in, style->font, NK_WIDGET_LEFT, NK_TEXT_LEFT);
+ return is_active;
+}
+NK_API nk_bool
+nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ struct nk_window *win;
+ struct nk_panel *layout;
+ const struct nk_input *in;
+ const struct nk_style *style;
+
+ struct nk_rect bounds;
+ enum nk_widget_layout_states state;
+
+ NK_ASSERT(ctx);
+ NK_ASSERT(ctx->current);
+ NK_ASSERT(ctx->current->layout);
+ if (!ctx || !ctx->current || !ctx->current->layout)
+ return is_active;
+
+ win = ctx->current;
+ style = &ctx->style;
+ layout = win->layout;
+
+ state = nk_widget(&bounds, ctx);
+ if (!state) return (int)state;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &is_active,
+ text, len, NK_TOGGLE_OPTION, &style->option, in, style->font, widget_alignment, text_alignment);
return is_active;
}
NK_API nk_bool
@@ -24321,15 +25424,37 @@ nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active
return old_value != *active;
}
NK_API nk_bool
+nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ int old_value;
+ NK_ASSERT(ctx);
+ NK_ASSERT(text);
+ NK_ASSERT(active);
+ if (!ctx || !text || !active) return 0;
+ old_value = *active;
+ *active = nk_option_text_align(ctx, text, len, old_value, widget_alignment, text_alignment);
+ return old_value != *active;
+}
+NK_API nk_bool
nk_option_label(struct nk_context *ctx, const char *label, nk_bool active)
{
return nk_option_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool
+nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ return nk_option_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
+}
+NK_API nk_bool
nk_radio_label(struct nk_context *ctx, const char *label, nk_bool *active)
{
return nk_radio_text(ctx, label, nk_strlen(label), active);
}
+NK_API nk_bool
+nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
+{
+ return nk_radio_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
+}
@@ -24375,16 +25500,26 @@ nk_draw_selectable(struct nk_command_buffer *out,
text.text = style->text_normal_active;
}
}
+
+ text.text = nk_rgb_factor(text.text, style->color_factor);
+
/* draw selectable background and text */
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(out, *bounds, &background->data.image, nk_white);
- text.background = nk_rgba(0,0,0,0);
- } else {
- nk_fill_rect(out, *bounds, style->rounding, background->data.color);
- text.background = background->data.color;
+ switch (background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ text.background = background->data.color;
+ nk_fill_rect(out, *bounds, style->rounding, background->data.color);
+ break;
}
if (icon) {
- if (img) nk_draw_image(out, *icon, img, nk_white);
+ if (img) nk_draw_image(out, *icon, img, nk_rgb_factor(nk_white, style->color_factor));
else nk_draw_symbol(out, sym, *icon, text.background, text.text, 1, font);
}
nk_widget_text(out, *bounds, string, len, &text, align, font);
@@ -24545,7 +25680,7 @@ nk_selectable_text(struct nk_context *ctx, const char *str, int len,
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_selectable(&ctx->last_widget_state, &win->buffer, bounds,
str, len, align, value, &style->selectable, in, style->font);
}
@@ -24574,7 +25709,7 @@ nk_selectable_image_text(struct nk_context *ctx, struct nk_image img,
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_selectable_image(&ctx->last_widget_state, &win->buffer, bounds,
str, len, align, value, &img, &style->selectable, in, style->font);
}
@@ -24603,7 +25738,7 @@ nk_selectable_symbol_text(struct nk_context *ctx, enum nk_symbol_type sym,
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_selectable_symbol(&ctx->last_widget_state, &win->buffer, bounds,
str, len, align, value, sym, &style->selectable, in, style->font);
}
@@ -24735,6 +25870,7 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
bar_color = style->bar_normal;
cursor = &style->cursor_normal;
}
+
/* calculate slider background bar */
bar.x = bounds->x;
bar.y = (visual_cursor->y + visual_cursor->h/2) - bounds->h/12;
@@ -24748,21 +25884,28 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
fill.h = bar.h;
/* draw background */
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(out, *bounds, &background->data.image, nk_white);
- } else {
- nk_fill_rect(out, *bounds, style->rounding, background->data.color);
- nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor));
+ nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
+ break;
}
/* draw slider bar */
- nk_fill_rect(out, bar, style->rounding, bar_color);
- nk_fill_rect(out, fill, style->rounding, style->bar_filled);
+ nk_fill_rect(out, bar, style->rounding, nk_rgb_factor(bar_color, style->color_factor));
+ nk_fill_rect(out, fill, style->rounding, nk_rgb_factor(style->bar_filled, style->color_factor));
/* draw cursor */
if (cursor->type == NK_STYLE_ITEM_IMAGE)
- nk_draw_image(out, *visual_cursor, &cursor->data.image, nk_white);
- else nk_fill_circle(out, *visual_cursor, cursor->data.color);
+ nk_draw_image(out, *visual_cursor, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ else
+ nk_fill_circle(out, *visual_cursor, nk_rgb_factor(cursor->data.color, style->color_factor));
}
NK_LIB float
nk_do_slider(nk_flags *state,
@@ -24880,7 +26023,7 @@ nk_slider_float(struct nk_context *ctx, float min_value, float *value, float max
state = nk_widget(&bounds, ctx);
if (!state) return ret;
- in = (/*state == NK_WIDGET_ROM || */ layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (/*state == NK_WIDGET_ROM || */ state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
old_value = *value;
*value = nk_do_slider(&ctx->last_widget_state, &win->buffer, bounds, min_value,
@@ -24915,6 +26058,259 @@ nk_slider_int(struct nk_context *ctx, int min, int *val, int max, int step)
/* ===============================================================
*
+ * KNOB
+ *
+ * ===============================================================*/
+
+NK_LIB float
+nk_knob_behavior(nk_flags *state, struct nk_input *in,
+ struct nk_rect bounds, float knob_min, float knob_max, float knob_value,
+ float knob_step, float knob_steps,
+ enum nk_heading zero_direction, float dead_zone_percent)
+{
+ struct nk_vec2 origin;
+ float angle = 0.0f;
+ origin.x = bounds.x + (bounds.w / 2);
+ origin.y = bounds.y + (bounds.h / 2);
+
+ nk_widget_state_reset(state);
+
+ /* handle click and drag input */
+ if(in &&
+ in->mouse.buttons[NK_BUTTON_LEFT].down &&
+ nk_input_has_mouse_click_down_in_rect(in, NK_BUTTON_LEFT, bounds, nk_true)){
+ /* calculate angle from origin and rotate */
+ const float direction_rads[4] = {
+ NK_PI * 2.5f, /* 90 NK_UP */
+ NK_PI * 2.0f, /* 0 NK_RIGHT */
+ NK_PI * 1.5f, /* 270 NK_DOWN */
+ NK_PI, /* 180 NK_LEFT */
+ };
+ *state = NK_WIDGET_STATE_ACTIVE;
+
+ angle = NK_ATAN2(in->mouse.pos.y - origin.y, in->mouse.pos.x - origin.x) + direction_rads[zero_direction];
+ angle -= (angle > NK_PI * 2) ? NK_PI * 3 : NK_PI;
+
+ /* account for dead space applied when drawing */
+ angle *= 1.0f / (1.0f - dead_zone_percent);
+ angle = NK_CLAMP(-NK_PI, angle, NK_PI);
+
+ /* convert -pi -> pi range to 0.0 -> 1.0 */
+ angle = (angle + NK_PI) / (NK_PI * 2);
+
+ /* click to closest step */
+ knob_value = knob_min + ( (int)(angle * knob_steps + (knob_step / 2)) ) * knob_step;
+ knob_value = NK_CLAMP(knob_min, knob_value, knob_max);
+ }
+
+ /* knob widget state */
+ if (nk_input_is_mouse_hovering_rect(in, bounds)){
+ *state = NK_WIDGET_STATE_HOVERED;
+ /* handle scroll and arrow inputs */
+ if (in->mouse.scroll_delta.y > 0 ||
+ (in->keyboard.keys[NK_KEY_UP].down && in->keyboard.keys[NK_KEY_UP].clicked)) {
+ knob_value += knob_step;
+ }
+
+ if (in->mouse.scroll_delta.y < 0 ||
+ (in->keyboard.keys[NK_KEY_DOWN].down && in->keyboard.keys[NK_KEY_DOWN].clicked)) {
+ knob_value -= knob_step;
+ }
+ /* easiest way to disable scrolling of parent panels..knob eats scrolling */
+ in->mouse.scroll_delta.y = 0;
+ knob_value = NK_CLAMP(knob_min, knob_value, knob_max);
+ }
+ if (*state & NK_WIDGET_STATE_HOVER &&
+ !nk_input_is_mouse_prev_hovering_rect(in, bounds))
+ *state |= NK_WIDGET_STATE_ENTERED;
+ else if (nk_input_is_mouse_prev_hovering_rect(in, bounds))
+ *state |= NK_WIDGET_STATE_LEFT;
+
+ return knob_value;
+}
+NK_LIB void
+nk_draw_knob(struct nk_command_buffer *out, nk_flags state,
+ const struct nk_style_knob *style, const struct nk_rect *bounds, float min, float value, float max,
+ enum nk_heading zero_direction, float dead_zone_percent)
+{
+ const struct nk_style_item *background;
+ struct nk_color knob_color, cursor;
+
+ NK_UNUSED(min);
+ NK_UNUSED(max);
+ NK_UNUSED(value);
+
+ if (state & NK_WIDGET_STATE_ACTIVED) {
+ background = &style->active;
+ knob_color = style->knob_active;
+ cursor = style->cursor_active;
+ } else if (state & NK_WIDGET_STATE_HOVER) {
+ background = &style->hover;
+ knob_color = style->knob_hover;
+ cursor = style->cursor_hover;
+ } else {
+ background = &style->normal;
+ knob_color = style->knob_normal;
+ cursor = style->cursor_normal;
+ }
+
+ /* draw background */
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *bounds, 0, nk_rgb_factor(background->data.color, style->color_factor));
+ nk_stroke_rect(out, *bounds, 0, style->border, nk_rgb_factor(style->border_color, style->color_factor));
+ break;
+ }
+
+ /* draw knob */
+ nk_fill_circle(out, *bounds, nk_rgb_factor(knob_color, style->color_factor));
+ if(style->knob_border > 0){
+ struct nk_rect border_bounds = *bounds;
+ border_bounds.x += style->knob_border / 2;
+ border_bounds.y += style->knob_border / 2;
+ border_bounds.w -= style->knob_border;
+ border_bounds.h -= style->knob_border;
+ nk_stroke_circle(out, border_bounds, style->knob_border, nk_rgb_factor(style->knob_border_color, style->color_factor));
+ }
+ { /* calculate cursor line cords */
+ float half_circle_size = (bounds->w / 2);
+ float angle = (value - min) / (max - min);
+ float alive_zone = 1.0f - dead_zone_percent;
+ struct nk_vec2 cursor_start, cursor_end;
+ const float direction_rads[4] = {
+ NK_PI * 1.5f, /* 90 NK_UP */
+ 0.0f, /* 0 NK_RIGHT */
+ NK_PI * 0.5f, /* 270 NK_DOWN */
+ NK_PI, /* 180 NK_LEFT */
+ };
+ /* calculate + apply dead zone */
+ angle = (angle * alive_zone) + (dead_zone_percent / 2);
+
+ /* percentage 0.0 -> 1.0 to radians, rads are 0.0 to (2*pi) NOT -pi to pi */
+ angle *= NK_PI * 2;
+
+ /* apply zero angle */
+ angle += direction_rads[zero_direction];
+ if(angle > NK_PI * 2)
+ angle -= NK_PI * 2;
+
+ cursor_start.x = bounds->x + half_circle_size + (angle > NK_PI);
+ cursor_start.y = bounds->y + half_circle_size + (angle < NK_PI_HALF || angle > (NK_PI * 1.5f));
+
+ cursor_end.x = cursor_start.x + (half_circle_size * NK_COS(angle));
+ cursor_end.y = cursor_start.y + (half_circle_size * NK_SIN(angle));
+
+ /* cut off half of the cursor */
+ cursor_start.x = (cursor_start.x + cursor_end.x) / 2;
+ cursor_start.y = (cursor_start.y + cursor_end.y) / 2;
+
+ /* draw cursor */
+ nk_stroke_line(out, cursor_start.x, cursor_start.y, cursor_end.x, cursor_end.y, 2, nk_rgb_factor(cursor, style->color_factor));
+ }
+}
+NK_LIB float
+nk_do_knob(nk_flags *state,
+ struct nk_command_buffer *out, struct nk_rect bounds,
+ float min, float val, float max, float step,
+ enum nk_heading zero_direction, float dead_zone_percent,
+ const struct nk_style_knob *style, struct nk_input *in)
+{
+ float knob_range;
+ float knob_min;
+ float knob_max;
+ float knob_value;
+ float knob_steps;
+
+ NK_ASSERT(style);
+ NK_ASSERT(out);
+ if (!out || !style)
+ return 0;
+
+ /* remove padding from knob bounds */
+ bounds.y = bounds.y + style->padding.y;
+ bounds.x = bounds.x + style->padding.x;
+ bounds.h = NK_MAX(bounds.h, 2*style->padding.y);
+ bounds.w = NK_MAX(bounds.w, 2*style->padding.x);
+ bounds.w -= 2 * style->padding.x;
+ bounds.h -= 2 * style->padding.y;
+ if(bounds.h < bounds.w){
+ bounds.x += (bounds.w - bounds.h) / 2;
+ bounds.w = bounds.h;
+ }
+
+ /* make sure the provided values are correct */
+ knob_max = NK_MAX(min, max);
+ knob_min = NK_MIN(min, max);
+ knob_value = NK_CLAMP(knob_min, val, knob_max);
+ knob_range = knob_max - knob_min;
+ knob_steps = knob_range / step;
+
+ knob_value = nk_knob_behavior(state, in, bounds, knob_min, knob_max, knob_value, step, knob_steps, zero_direction, dead_zone_percent);
+
+ /* draw knob */
+ if (style->draw_begin) style->draw_begin(out, style->userdata);
+ nk_draw_knob(out, *state, style, &bounds, knob_min, knob_value, knob_max, zero_direction, dead_zone_percent);
+ if (style->draw_end) style->draw_end(out, style->userdata);
+ return knob_value;
+}
+NK_API nk_bool
+nk_knob_float(struct nk_context *ctx, float min_value, float *value, float max_value,
+ float value_step, enum nk_heading zero_direction, float dead_zone_degrees)
+{
+ struct nk_window *win;
+ struct nk_panel *layout;
+ struct nk_input *in;
+ const struct nk_style *style;
+
+ int ret = 0;
+ float old_value;
+ struct nk_rect bounds;
+ enum nk_widget_layout_states state;
+
+ NK_ASSERT(ctx);
+ NK_ASSERT(ctx->current);
+ NK_ASSERT(ctx->current->layout);
+ NK_ASSERT(value);
+ NK_ASSERT(NK_BETWEEN(dead_zone_degrees, 0.0f, 360.0f));
+ if (!ctx || !ctx->current || !ctx->current->layout || !value)
+ return ret;
+
+ win = ctx->current;
+ style = &ctx->style;
+ layout = win->layout;
+
+ state = nk_widget(&bounds, ctx);
+ if (!state) return ret;
+ in = (state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+
+ old_value = *value;
+ *value = nk_do_knob(&ctx->last_widget_state, &win->buffer, bounds, min_value,
+ old_value, max_value, value_step, zero_direction, dead_zone_degrees / 360.0f, &style->knob, in);
+
+ return (old_value > *value || old_value < *value);
+}
+NK_API nk_bool
+nk_knob_int(struct nk_context *ctx, int min, int *val, int max, int step,
+ enum nk_heading zero_direction, float dead_zone_degrees)
+{
+ int ret;
+ float value = (float)*val;
+ ret = nk_knob_float(ctx, (float)min, &value, (float)max, (float)step, zero_direction, dead_zone_degrees);
+ *val = (int)value;
+ return ret;
+}
+
+
+
+
+/* ===============================================================
+ *
* PROGRESS
*
* ===============================================================*/
@@ -24972,16 +26368,32 @@ nk_draw_progress(struct nk_command_buffer *out, nk_flags state,
}
/* draw background */
- if (background->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_rect(out, *bounds, style->rounding, background->data.color);
- nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
- } else nk_draw_image(out, *bounds, &background->data.image, nk_white);
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor));
+ nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
+ break;
+ }
/* draw cursor */
- if (cursor->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_rect(out, *scursor, style->rounding, cursor->data.color);
- nk_stroke_rect(out, *scursor, style->rounding, style->border, style->border_color);
- } else nk_draw_image(out, *scursor, &cursor->data.image, nk_white);
+ switch(cursor->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *scursor, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *scursor, &cursor->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *scursor, style->rounding, nk_rgb_factor(cursor->data.color, style->color_factor));
+ nk_stroke_rect(out, *scursor, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
+ break;
+ }
}
NK_LIB nk_size
nk_do_progress(nk_flags *state,
@@ -25039,7 +26451,7 @@ nk_progress(struct nk_context *ctx, nk_size *cur, nk_size max, nk_bool is_modify
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
old_value = *cur;
*cur = nk_do_progress(&ctx->last_widget_state, &win->buffer, bounds,
*cur, max, is_modifyable, &style->progress, in);
@@ -25070,7 +26482,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
{
nk_flags ws = 0;
int left_mouse_down;
- int left_mouse_clicked;
+ unsigned int left_mouse_clicked;
int left_mouse_click_in_cursor;
float scroll_delta;
@@ -25158,18 +26570,32 @@ nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state,
}
/* draw background */
- if (background->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_rect(out, *bounds, style->rounding, background->data.color);
- nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
- } else {
- nk_draw_image(out, *bounds, &background->data.image, nk_white);
+ switch (background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *bounds, &background->data.image, nk_white);
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *bounds, style->rounding, background->data.color);
+ nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
+ break;
}
/* draw cursor */
- if (cursor->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_rect(out, *scroll, style->rounding_cursor, cursor->data.color);
- nk_stroke_rect(out, *scroll, style->rounding_cursor, style->border_cursor, style->cursor_border_color);
- } else nk_draw_image(out, *scroll, &cursor->data.image, nk_white);
+ switch (cursor->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, *scroll, &cursor->data.image, nk_white);
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, *scroll, &cursor->data.slice, nk_white);
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, *scroll, style->rounding_cursor, cursor->data.color);
+ nk_stroke_rect(out, *scroll, style->rounding_cursor, style->border_cursor, style->cursor_border_color);
+ break;
+ }
}
NK_LIB float
nk_do_scrollbarv(nk_flags *state,
@@ -25629,21 +27055,28 @@ nk_is_word_boundary( struct nk_text_edit *state, int idx)
{
int len;
nk_rune c;
- if (idx <= 0) return 1;
+ if (idx < 0) return 1;
if (!nk_str_at_rune(&state->string, idx, &c, &len)) return 1;
- return (c == ' ' || c == '\t' ||c == 0x3000 || c == ',' || c == ';' ||
- c == '(' || c == ')' || c == '{' || c == '}' || c == '[' || c == ']' ||
- c == '|');
+#ifndef NK_IS_WORD_BOUNDARY
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' ||
+ c == '\v' || c == 0x3000);
+#else
+ return NK_IS_WORD_BOUNDARY(c);
+#endif
}
NK_INTERN int
nk_textedit_move_to_word_previous(struct nk_text_edit *state)
{
int c = state->cursor - 1;
- while( c >= 0 && !nk_is_word_boundary(state, c))
- --c;
-
- if( c < 0 )
- c = 0;
+ if (c > 0) {
+ if (nk_is_word_boundary(state, c)) {
+ while (c > 0 && nk_is_word_boundary(state, --c));
+ }
+ while (!nk_is_word_boundary(state, --c));
+ c++;
+ } else {
+ return 0;
+ }
return c;
}
@@ -25651,12 +27084,15 @@ NK_INTERN int
nk_textedit_move_to_word_next(struct nk_text_edit *state)
{
const int len = state->string.len;
- int c = state->cursor+1;
- while( c < len && !nk_is_word_boundary(state, c))
- ++c;
-
- if( c > len )
- c = len;
+ int c = state->cursor;
+ if (c < len) {
+ if (!nk_is_word_boundary(state, c)) {
+ while (c < len && !nk_is_word_boundary(state, ++c));
+ }
+ while (c < len && nk_is_word_boundary(state, ++c));
+ } else {
+ return len;
+ }
return c;
}
@@ -25746,7 +27182,7 @@ nk_textedit_text(struct nk_text_edit *state, const char *text, int total_len)
text+text_len, 1))
{
nk_textedit_makeundo_insert(state, state->cursor, 1);
- ++state->cursor;
+ state->cursor = NK_MIN(state->cursor + 1, state->string.len);
state->has_preferred_x = 0;
}
}
@@ -25841,7 +27277,7 @@ retry:
case NK_KEY_TEXT_WORD_LEFT:
if (shift_mod) {
if( !NK_TEXT_HAS_SELECTION( state ) )
- nk_textedit_prep_selection_at_cursor(state);
+ nk_textedit_prep_selection_at_cursor(state);
state->cursor = nk_textedit_move_to_word_previous(state);
state->select_end = state->cursor;
nk_textedit_clamp(state );
@@ -26344,7 +27780,7 @@ nk_textedit_init_fixed(struct nk_text_edit *state, void *memory, nk_size size)
nk_str_init_fixed(&state->string, memory, size);
}
NK_API void
-nk_textedit_init(struct nk_text_edit *state, struct nk_allocator *alloc, nk_size size)
+nk_textedit_init(struct nk_text_edit *state, const struct nk_allocator *alloc, nk_size size)
{
NK_ASSERT(state);
NK_ASSERT(alloc);
@@ -26476,6 +27912,9 @@ nk_edit_draw_text(struct nk_command_buffer *out,
txt.background = background;
txt.text = foreground;
+ foreground = nk_rgb_factor(foreground, style->color_factor);
+ background = nk_rgb_factor(background, style->color_factor);
+
glyph_len = nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
if (!glyph_len) return;
while ((text_len < byte_len) && glyph_len)
@@ -26567,7 +28006,6 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
/* update edit state */
prev_state = (char)edit->active;
- is_hovered = (char)nk_input_is_mouse_hovering_rect(in, bounds);
if (in && in->mouse.buttons[NK_BUTTON_LEFT].clicked && in->mouse.buttons[NK_BUTTON_LEFT].down) {
edit->active = NK_INBOX(in->mouse.pos.x, in->mouse.pos.y,
bounds.x, bounds.y, bounds.w, bounds.h);
@@ -26711,10 +28149,19 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
else background = &style->normal;
/* draw background frame */
- if (background->type == NK_STYLE_ITEM_COLOR) {
- nk_fill_rect(out, bounds, style->rounding, background->data.color);
- nk_stroke_rect(out, bounds, style->rounding, style->border, style->border_color);
- } else nk_draw_image(out, bounds, &background->data.image, nk_white);}
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(out, bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(out, bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(out, bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor));
+ nk_stroke_rect(out, bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
+ break;
+ }}
+
area.w = NK_MAX(0, area.w - style->cursor_size);
if (edit->active)
@@ -26850,10 +28297,12 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
} else edit->scrollbar.x = 0;
if (flags & NK_EDIT_MULTILINE) {
- /* vertical scroll */
+ /* vertical scroll: like horizontal, it only adjusts if the
+ * cursor leaves the visible area, and then only just enough
+ * to keep it visible */
if (cursor_pos.y < edit->scrollbar.y)
- edit->scrollbar.y = NK_MAX(0.0f, cursor_pos.y - row_height);
- if (cursor_pos.y >= edit->scrollbar.y + area.h)
+ edit->scrollbar.y = NK_MAX(0.0f, cursor_pos.y);
+ if (cursor_pos.y > edit->scrollbar.y + area.h - row_height)
edit->scrollbar.y = edit->scrollbar.y + row_height;
} else edit->scrollbar.y = 0;
}
@@ -26876,9 +28325,13 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
scroll_step = scroll.h * 0.10f;
scroll_inc = scroll.h * 0.01f;
scroll_target = text_size.y;
- edit->scrollbar.y = nk_do_scrollbarv(&ws, out, scroll, 0,
+ edit->scrollbar.y = nk_do_scrollbarv(&ws, out, scroll, is_hovered,
scroll_offset, scroll_target, scroll_step, scroll_inc,
&style->scrollbar, in, font);
+ /* Eat mouse scroll if we're active */
+ if (is_hovered && in->mouse.scroll_delta.y) {
+ in->mouse.scroll_delta.y = 0;
+ }
}
}
@@ -26917,8 +28370,11 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
}
if (background->type == NK_STYLE_ITEM_IMAGE)
background_color = nk_rgba(0,0,0,0);
- else background_color = background->data.color;
+ else
+ background_color = background->data.color;
+ cursor_color = nk_rgb_factor(cursor_color, style->color_factor);
+ cursor_text_color = nk_rgb_factor(cursor_text_color, style->color_factor);
if (edit->select_start == edit->select_end) {
/* no selection so just draw the complete text */
@@ -27024,7 +28480,12 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
}
if (background->type == NK_STYLE_ITEM_IMAGE)
background_color = nk_rgba(0,0,0,0);
- else background_color = background->data.color;
+ else
+ background_color = background->data.color;
+
+ background_color = nk_rgb_factor(background_color, style->color_factor);
+ text_color = nk_rgb_factor(text_color, style->color_factor);
+
nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
area.y - edit->scrollbar.y, 0, begin, l, row_height, font,
background_color, text_color, nk_false);
@@ -27144,6 +28605,8 @@ nk_edit_buffer(struct nk_context *ctx, nk_flags flags,
style = &ctx->style;
state = nk_widget(&bounds, ctx);
if (!state) return state;
+ else if (state == NK_WIDGET_DISABLED)
+ flags |= NK_EDIT_READ_ONLY;
in = (win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
/* check if edit is currently hot item */
@@ -27243,6 +28706,7 @@ nk_property_behavior(nk_flags *ws, const struct nk_input *in,
struct nk_rect empty, int *state, struct nk_property_variant *variant,
float inc_per_pixel)
{
+ nk_widget_state_reset(ws);
if (in && *state == NK_PROPERTY_DEFAULT) {
if (nk_button_behavior(ws, edit, in, NK_BUTTON_DEFAULT))
*state = NK_PROPERTY_EDIT;
@@ -27276,19 +28740,30 @@ nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property *
text.text = style->label_normal;
}
+ text.text = nk_rgb_factor(text.text, style->color_factor);
+
/* draw background */
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(out, *bounds, &background->data.image, nk_white);
- text.background = nk_rgba(0,0,0,0);
- } else {
- text.background = background->data.color;
- nk_fill_rect(out, *bounds, style->rounding, background->data.color);
- nk_stroke_rect(out, *bounds, style->rounding, style->border, background->data.color);
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ text.background = background->data.color;
+ nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor));
+ nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
+ break;
}
/* draw label */
text.padding = nk_vec2(0,0);
- nk_widget_text(out, *label, name, len, &text, NK_TEXT_CENTERED, font);
+ if (name && name[0] != '#') {
+ nk_widget_text(out, *label, name, len, &text, NK_TEXT_CENTERED, font);
+ }
}
NK_LIB void
nk_do_property(nk_flags *ws,
@@ -27306,7 +28781,7 @@ nk_do_property(nk_flags *ws,
nk_filter_float
};
nk_bool active, old;
- int num_len, name_len;
+ int num_len = 0, name_len = 0;
char string[NK_MAX_NUMBER_BUFFER];
float size;
@@ -27326,7 +28801,9 @@ nk_do_property(nk_flags *ws,
left.y = property.y + style->border + property.h/2.0f - left.h/2;
/* text label */
- name_len = nk_strlen(name);
+ if (name && name[0] != '#') {
+ name_len = nk_strlen(name);
+ }
size = font->width(font->userdata, font->height, name, name_len);
label.x = left.x + left.w + style->padding.x;
label.w = (float)size + 2 * style->padding.x;
@@ -27433,7 +28910,7 @@ nk_do_property(nk_flags *ws,
text_edit->string.buffer.memory.ptr = dst;
text_edit->string.buffer.size = NK_MAX_NUMBER_BUFFER;
text_edit->mode = NK_TEXT_EDIT_MODE_INSERT;
- nk_do_edit(ws, out, edit, NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
+ nk_do_edit(ws, out, edit, (int)NK_EDIT_FIELD|(int)NK_EDIT_AUTO_SELECT,
filters[filter], text_edit, &style->edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
*length = text_edit->string.len;
@@ -27567,7 +29044,7 @@ nk_property(struct nk_context *ctx, const char *name, struct nk_property_variant
old_state = *state;
ctx->text_edit.clip = ctx->clip;
in = ((s == NK_WIDGET_ROM && !win->property.active) ||
- layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED) ? 0 : &ctx->input;
nk_do_property(&ctx->last_widget_state, &win->buffer, bounds, name,
variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
select_end, &style->property, filter, in, style->font, &ctx->text_edit,
@@ -27642,7 +29119,7 @@ nk_property_double(struct nk_context *ctx, const char *name,
nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
*val = variant.value.d;
}
-NK_API nk_bool
+NK_API int
nk_propertyi(struct nk_context *ctx, const char *name, int min, int val,
int max, int step, float inc_per_pixel)
{
@@ -27736,20 +29213,28 @@ nk_chart_begin_colored(struct nk_context *ctx, enum nk_chart_type type,
{struct nk_chart_slot *slot = &chart->slots[chart->slot++];
slot->type = type;
slot->count = count;
- slot->color = color;
+ slot->color = nk_rgb_factor(color, style->color_factor);
slot->highlight = highlight;
slot->min = NK_MIN(min_value, max_value);
slot->max = NK_MAX(min_value, max_value);
- slot->range = slot->max - slot->min;}
+ slot->range = slot->max - slot->min;
+ slot->show_markers = style->show_markers;}
/* draw chart background */
background = &style->background;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(&win->buffer, bounds, &background->data.image, nk_white);
- } else {
- nk_fill_rect(&win->buffer, bounds, style->rounding, style->border_color);
- nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border),
- style->rounding, style->background.data.color);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(&win->buffer, bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(&win->buffer, bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(&win->buffer, bounds, style->rounding, nk_rgb_factor(style->border_color, style->color_factor));
+ nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border),
+ style->rounding, nk_rgb_factor(style->background.data.color, style->color_factor));
+ break;
}
return 1;
}
@@ -27765,6 +29250,8 @@ nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type type,
struct nk_color color, struct nk_color highlight,
int count, float min_value, float max_value)
{
+ const struct nk_style_chart* style;
+
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
@@ -27772,16 +29259,19 @@ nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type type,
if (!ctx || !ctx->current || !ctx->current->layout) return;
if (ctx->current->layout->chart.slot >= NK_CHART_MAX_SLOT) return;
+ style = &ctx->style.chart;
+
/* add another slot into the graph */
{struct nk_chart *chart = &ctx->current->layout->chart;
struct nk_chart_slot *slot = &chart->slots[chart->slot++];
slot->type = type;
slot->count = count;
- slot->color = color;
+ slot->color = nk_rgb_factor(color, style->color_factor);
slot->highlight = highlight;
slot->min = NK_MIN(min_value, max_value);
slot->max = NK_MAX(min_value, max_value);
- slot->range = slot->max - slot->min;}
+ slot->range = slot->max - slot->min;
+ slot->show_markers = style->show_markers;}
}
NK_API void
nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type type,
@@ -27795,7 +29285,7 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
struct nk_chart *g, float value, int slot)
{
struct nk_panel *layout = win->layout;
- const struct nk_input *i = &ctx->input;
+ const struct nk_input *i = ctx->current->widgets_disabled ? 0 : &ctx->input;
struct nk_command_buffer *out = &win->buffer;
nk_flags ret = 0;
@@ -27821,14 +29311,16 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
bounds.w = bounds.h = 4;
color = g->slots[slot].color;
- if (!(layout->flags & NK_WINDOW_ROM) &&
+ if (!(layout->flags & NK_WINDOW_ROM) && i &&
NK_INBOX(i->mouse.pos.x,i->mouse.pos.y, g->slots[slot].last.x-3, g->slots[slot].last.y-3, 6, 6)){
ret = nk_input_is_mouse_hovering_rect(i, bounds) ? NK_CHART_HOVERING : 0;
ret |= (i->mouse.buttons[NK_BUTTON_LEFT].down &&
i->mouse.buttons[NK_BUTTON_LEFT].clicked) ? NK_CHART_CLICKED: 0;
color = g->slots[slot].highlight;
}
- nk_fill_rect(out, bounds, 0, color);
+ if (g->slots[slot].show_markers) {
+ nk_fill_rect(out, bounds, 0, color);
+ }
g->slots[slot].index += 1;
return ret;
}
@@ -27852,7 +29344,9 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
color = g->slots[slot].highlight;
}
}
- nk_fill_rect(out, nk_rect(cur.x - 2, cur.y - 2, 4, 4), 0, color);
+ if (g->slots[slot].show_markers) {
+ nk_fill_rect(out, nk_rect(cur.x - 2, cur.y - 2, 4, 4), 0, color);
+ }
/* save current data point position */
g->slots[slot].last.x = cur.x;
@@ -27865,7 +29359,7 @@ nk_chart_push_column(const struct nk_context *ctx, struct nk_window *win,
struct nk_chart *chart, float value, int slot)
{
struct nk_command_buffer *out = &win->buffer;
- const struct nk_input *in = &ctx->input;
+ const struct nk_input *in = ctx->current->widgets_disabled ? 0 : &ctx->input;
struct nk_panel *layout = win->layout;
float ratio;
@@ -27895,7 +29389,7 @@ nk_chart_push_column(const struct nk_context *ctx, struct nk_window *win,
item.x = item.x + ((float)chart->slots[slot].index);
/* user chart bar selection */
- if (!(layout->flags & NK_WINDOW_ROM) &&
+ if (!(layout->flags & NK_WINDOW_ROM) && in &&
NK_INBOX(in->mouse.pos.x,in->mouse.pos.y,item.x,item.y,item.w,item.h)) {
ret = NK_CHART_HOVERING;
ret |= (!in->mouse.buttons[NK_BUTTON_LEFT].down &&
@@ -28194,7 +29688,7 @@ nk_color_pick(struct nk_context * ctx, struct nk_colorf *color,
layout = win->layout;
state = nk_widget(&bounds, ctx);
if (!state) return 0;
- in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
+ in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
return nk_do_color_picker(&ctx->last_widget_state, &win->buffer, color, fmt, bounds,
nk_vec2(0,0), in, config->font);
}
@@ -28276,7 +29770,7 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
if (s == NK_WIDGET_INVALID)
return 0;
- in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
+ in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
is_clicked = nk_true;
@@ -28291,13 +29785,23 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
background = &style->combo.normal;
text.text = style->combo.label_normal;
}
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- text.background = nk_rgba(0,0,0,0);
- nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
- } else {
- text.background = background->data.color;
- nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
- nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
+
+ text.text = nk_rgb_factor(text.text, style->combo.color_factor);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ text.background = background->data.color;
+ nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
+ nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
+ break;
}
{
/* print currently selected text item */
@@ -28376,7 +29880,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
if (s == NK_WIDGET_INVALID)
return 0;
- in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
+ in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
is_clicked = nk_true;
@@ -28387,11 +29891,17 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
background = &style->combo.hover;
else background = &style->combo.normal;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(&win->buffer, header, &background->data.image,nk_white);
- } else {
- nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
- nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
+ nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
+ break;
}
{
struct nk_rect content;
@@ -28428,7 +29938,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
else
bounds.w = header.w - 4 * style->combo.content_padding.x;
- nk_fill_rect(&win->buffer, bounds, 0, color);
+ nk_fill_rect(&win->buffer, bounds, 0, nk_rgb_factor(color, style->combo.color_factor));
/* draw open/close button */
if (draw_button_symbol)
@@ -28463,7 +29973,7 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
if (s == NK_WIDGET_INVALID)
return 0;
- in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
+ in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
is_clicked = nk_true;
@@ -28479,13 +29989,22 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
symbol_color = style->combo.symbol_hover;
}
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- sym_background = nk_rgba(0,0,0,0);
- nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
- } else {
- sym_background = background->data.color;
- nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
- nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
+ symbol_color = nk_rgb_factor(symbol_color, style->combo.color_factor);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ sym_background = nk_rgba(0, 0, 0, 0);
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ sym_background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ sym_background = background->data.color;
+ nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
+ nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
+ break;
}
{
struct nk_rect bounds = {0,0,0,0};
@@ -28550,7 +30069,7 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
s = nk_widget(&header, ctx);
if (!s) return 0;
- in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
+ in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
is_clicked = nk_true;
@@ -28568,13 +30087,24 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
symbol_color = style->combo.symbol_normal;
text.text = style->combo.label_normal;
}
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- text.background = nk_rgba(0,0,0,0);
- nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
- } else {
- text.background = background->data.color;
- nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
- nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
+
+ text.text = nk_rgb_factor(text.text, style->combo.color_factor);
+ symbol_color = nk_rgb_factor(symbol_color, style->combo.color_factor);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ text.background = background->data.color;
+ nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
+ nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
+ break;
}
{
struct nk_rect content;
@@ -28644,7 +30174,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
if (s == NK_WIDGET_INVALID)
return 0;
- in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
+ in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
is_clicked = nk_true;
@@ -28655,11 +30185,17 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
background = &style->combo.hover;
else background = &style->combo.normal;
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
- } else {
- nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
- nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
+ switch (background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
+ nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
+ break;
}
{
struct nk_rect bounds = {0,0,0,0};
@@ -28696,7 +30232,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
else
bounds.w = header.w - 2 * style->combo.content_padding.x;
- nk_draw_image(&win->buffer, bounds, &img, nk_white);
+ nk_draw_image(&win->buffer, bounds, &img, nk_rgb_factor(nk_white, style->combo.color_factor));
/* draw open/close button */
if (draw_button_symbol)
@@ -28730,7 +30266,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
s = nk_widget(&header, ctx);
if (!s) return 0;
- in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
+ in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
is_clicked = nk_true;
@@ -28745,13 +30281,23 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
background = &style->combo.normal;
text.text = style->combo.label_normal;
}
- if (background->type == NK_STYLE_ITEM_IMAGE) {
- text.background = nk_rgba(0,0,0,0);
- nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
- } else {
- text.background = background->data.color;
- nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
- nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
+
+ text.text = nk_rgb_factor(text.text, style->combo.color_factor);
+
+ switch(background->type) {
+ case NK_STYLE_ITEM_IMAGE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_NINE_SLICE:
+ text.background = nk_rgba(0, 0, 0, 0);
+ nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
+ break;
+ case NK_STYLE_ITEM_COLOR:
+ text.background = background->data.color;
+ nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
+ nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
+ break;
}
{
struct nk_rect content;
@@ -28789,7 +30335,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
image.y = header.y + style->combo.content_padding.y;
image.h = header.h - 2 * style->combo.content_padding.y;
image.w = image.h;
- nk_draw_image(&win->buffer, image, &img, nk_white);
+ nk_draw_image(&win->buffer, image, &img, nk_rgb_factor(nk_white, style->combo.color_factor));
/* draw label */
text.padding = nk_vec2(0,0);
@@ -28859,7 +30405,7 @@ NK_API void nk_combo_close(struct nk_context *ctx)
nk_contextual_close(ctx);
}
NK_API int
-nk_combo(struct nk_context *ctx, const char **items, int count,
+nk_combo(struct nk_context *ctx, const char *const *items, int count,
int selected, int item_height, struct nk_vec2 size)
{
int i = 0;
@@ -28977,7 +30523,7 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c
} return selected;
}
NK_API void
-nk_combobox(struct nk_context *ctx, const char **items, int count,
+nk_combobox(struct nk_context *ctx, const char *const *items, int count,
int *selected, int item_height, struct nk_vec2 size)
{
*selected = nk_combo(ctx, items, count, *selected, item_height, size);
@@ -29006,7 +30552,6 @@ nk_combobox_callback(struct nk_context *ctx,
-
/* ===============================================================
*
* TOOLTIP
@@ -29030,7 +30575,7 @@ nk_tooltip_begin(struct nk_context *ctx, float width)
/* make sure that no nonblocking popup is currently active */
win = ctx->current;
in = &ctx->input;
- if (win->popup.win && (win->popup.type & NK_PANEL_SET_NONBLOCK))
+ if (win->popup.win && ((int)win->popup.type & (int)NK_PANEL_SET_NONBLOCK))
return 0;
w = nk_iceilf(width);
@@ -29164,14 +30709,56 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// ## Changelog
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~none
-/// [date][x.yy.zz]-[description]
-/// -[date]: date on which the change has been pushed
-/// -[x.yy.zz]: Numerical version string representation. Each version number on the right
-/// resets back to zero if version on the left is incremented.
-/// - [x]: Major version with API and library breaking changes
-/// - [yy]: Minor version with non-breaking API and library changes
-/// - [zz]: Bug fix version with no direct changes to API
-///
+/// [date] ([x.y.z]) - [description]
+/// - [date]: date on which the change has been pushed
+/// - [x.y.z]: Version string, represented in Semantic Versioning format
+/// - [x]: Major version with API and library breaking changes
+/// - [y]: Minor version with non-breaking API and library changes
+/// - [z]: Patch version with no direct changes to the API
+///
+/// - 2025/04/06 (4.12.7) - Fix text input navigation and mouse scrolling
+/// - 2025/03/29 (4.12.6) - Fix unitialized data in nk_input_char
+/// - 2025/03/05 (4.12.5) - Fix scrolling knob also scrolling parent window, remove dead code
+/// - 2024/12/11 (4.12.4) - Fix array subscript [0, 0] is outside array bounds of ‘char[1]’
+/// - 2024/12/11 (4.12.3) - Fix border color for property widgets
+/// - 2024/11/20 (4.12.2) - Fix int/float type conversion warnings in `nk_roundf`
+/// - 2024/03/07 (4.12.1) - Fix bitwise operations warnings in C++20
+/// - 2023/11/26 (4.12.0) - Added an alignment option to checkboxes and radio buttons.
+/// - 2023/10/11 (4.11.0) - Added nk_widget_disable_begin() and nk_widget_disable_end()
+/// - 2022/12/23 (4.10.6) - Fix incorrect glyph index in nk_font_bake()
+/// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly
+/// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0
+/// - 2022/09/03 (4.10.3) - Renamed the `null` texture variable to `tex_null`
+/// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE
+/// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
+/// nk_edit_xxx limit
+/// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
+/// - 2022/04/19 (4.9.8) - Added nk_rule_horizontal() widget
+/// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
+/// only trigger when the mouse position was inside the same button on down
+/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS
+/// - 2021/12/22 (4.9.5) - Revert layout bounds not accounting for padding due to regressions
+/// - 2021/12/22 (4.9.4) - Fix checking hovering when window is minimized
+/// - 2021/12/22 (4.09.3) - Fix layout bounds not accounting for padding
+/// - 2021/12/19 (4.09.2) - Update to stb_rect_pack.h v1.01 and stb_truetype.h v1.26
+/// - 2021/12/16 (4.09.1) - Fix the majority of GCC warnings
+/// - 2021/10/16 (4.09.0) - Added nk_spacer() widget
+/// - 2021/09/22 (4.08.6) - Fix "may be used uninitialized" warnings in nk_widget
+/// - 2021/09/22 (4.08.5) - GCC __builtin_offsetof only exists in version 4 and later
+/// - 2021/09/15 (4.08.4) - Fix "'num_len' may be used uninitialized" in nk_do_property
+/// - 2021/09/15 (4.08.3) - Fix "Templates cannot be declared to have 'C' Linkage"
+/// - 2021/09/08 (4.08.2) - Fix warnings in C89 builds
+/// - 2021/09/08 (4.08.1) - Use compiler builtins for NK_OFFSETOF when possible
+/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
+/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
+/// - 2021/08/15 (4.07.4) - Fix conversion and sign conversion warnings
+/// - 2021/08/08 (4.07.3) - Fix crash when baking merged fonts
+/// - 2021/08/08 (4.07.2) - Fix Multiline Edit wrong offset
+/// - 2021/03/17 (4.07.1) - Fix warning about unused parameter
+/// - 2021/03/17 (4.07.0) - Fix nk_property hover bug
+/// - 2021/03/15 (4.06.4) - Change nk_propertyi back to int
+/// - 2021/03/15 (4.06.3) - Update documentation for functions that now return nk_bool
+/// - 2020/12/19 (4.06.2) - Fix additional C++ style comments which are not allowed in ISO C90.
/// - 2020/10/11 (4.06.1) - Fix C++ style comments which are not allowed in ISO C90.
/// - 2020/10/07 (4.06.0) - Fix nk_combo return type wrongly changed to nk_bool
/// - 2020/09/05 (4.05.0) - Use the nk_font_atlas allocator for stb_truetype memory management.
@@ -29212,7 +30799,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2018/01/31 (3.00.5) - Fixed overcalculation of cursor data in font baking process.
/// - 2018/01/31 (3.00.4) - Removed name collision with stb_truetype.
/// - 2018/01/28 (3.00.3) - Fixed panel window border drawing bug.
-/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separed group identifier and title.
+/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separated group identifier and title.
/// - 2018/01/07 (3.00.1) - Started to change documentation style.
/// - 2018/01/05 (3.00.0) - BREAKING CHANGE: The previous color picker API was broken
/// because of conversions between float and byte color representation.
@@ -29223,13 +30810,13 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2017/12/23 (2.00.7) - Fixed small warning.
/// - 2017/12/23 (2.00.7) - Fixed `nk_edit_buffer` behavior if activated to allow input.
/// - 2017/12/23 (2.00.7) - Fixed modifyable progressbar dragging visuals and input behavior.
-/// - 2017/12/04 (2.00.6) - Added formated string tooltip widget.
+/// - 2017/12/04 (2.00.6) - Added formatted string tooltip widget.
/// - 2017/11/18 (2.00.5) - Fixed window becoming hidden with flag `NK_WINDOW_NO_INPUT`.
/// - 2017/11/15 (2.00.4) - Fixed font merging.
/// - 2017/11/07 (2.00.3) - Fixed window size and position modifier functions.
/// - 2017/09/14 (2.00.2) - Fixed `nk_edit_buffer` and `nk_edit_focus` behavior.
/// - 2017/09/14 (2.00.1) - Fixed window closing behavior.
-/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifing window position and size funtions now
+/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifying window position and size functions now
/// require the name of the window and must happen outside the window
/// building process (between function call nk_begin and nk_end).
/// - 2017/09/11 (1.40.9) - Fixed window background flag if background window is declared last.
@@ -29256,7 +30843,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2017/06/08 (1.39.0) - Added function to retrieve window space without calling a `nk_layout_xxx` function.
/// - 2017/06/06 (1.38.5) - Fixed `nk_convert` return flag for command buffer.
/// - 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped.
-/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries.
+/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundaries.
/// - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space.
/// - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size.
/// - 2017/05/06 (1.38.0) - Added platform double-click support.
@@ -29273,7 +30860,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2017/03/04 (1.34.2) - Fixed text edit filtering.
/// - 2017/03/04 (1.34.1) - Fixed group closable flag.
/// - 2017/02/25 (1.34.0) - Added custom draw command for better language binding support.
-/// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus.
+/// - 2017/01/24 (1.33.0) - Added programmatic way to remove edit focus.
/// - 2017/01/24 (1.32.3) - Fixed wrong define for basic type definitions for windows.
/// - 2017/01/21 (1.32.2) - Fixed input capture from hidden or closed windows.
/// - 2017/01/21 (1.32.1) - Fixed slider behavior and drawing.
@@ -29282,7 +30869,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// dynamic and static widgets.
/// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit.
/// - 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows.
-/// - 2016/12/03 (1.29.1) - Fixed wrapped text with no seperator and C89 error.
+/// - 2016/12/03 (1.29.1) - Fixed wrapped text with no separator and C89 error.
/// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters.
/// - 2016/11/22 (1.28.6) - Fixed window minimized closing bug.
/// - 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior.
@@ -29318,7 +30905,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// text in every edit widget if one of them is scrolled.
/// - 2016/09/28 (1.22.3) - Fixed small bug in edit widgets if not active. The wrong
/// text length is passed. It should have been in bytes but
-/// was passed as glyphes.
+/// was passed as glyphs.
/// - 2016/09/20 (1.22.2) - Fixed color button size calculation.
/// - 2016/09/20 (1.22.1) - Fixed some `nk_vsnprintf` behavior bugs and removed `<stdio.h>`
/// again from `NK_INCLUDE_STANDARD_VARARGS`.
@@ -29398,13 +30985,13 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2016/08/16 (1.09.5) - Fixed ROM mode for deeper levels of popup windows parents.
/// - 2016/08/15 (1.09.4) - Editbox are now still active if enter was pressed with flag
/// `NK_EDIT_SIG_ENTER`. Main reasoning is to be able to keep
-/// typing after commiting.
+/// typing after committing.
/// - 2016/08/15 (1.09.4) - Removed redundant code.
/// - 2016/08/15 (1.09.4) - Fixed negative numbers in `nk_strtoi` and remove unused variable.
/// - 2016/08/15 (1.09.3) - Fixed `NK_WINDOW_BACKGROUND` flag behavior to select a background
/// window only as selected by hovering and not by clicking.
/// - 2016/08/14 (1.09.2) - Fixed a bug in font atlas which caused wrong loading
-/// of glyphes for font with multiple ranges.
+/// of glyphs for font with multiple ranges.
/// - 2016/08/12 (1.09.1) - Added additional function to check if window is currently
/// hidden and therefore not visible.
/// - 2016/08/12 (1.09.1) - nk_window_is_closed now queries the correct flag `NK_WINDOW_CLOSED`
@@ -29420,8 +31007,8 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// precision.
/// - 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`.
/// - 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
-/// to wrong wiget width calculation which results in widgets falsly
-/// becomming tagged as not inside window and cannot be accessed.
+/// to wrong widget width calculation which results in widgets falsely
+/// becoming tagged as not inside window and cannot be accessed.
/// - 2016/08/08 (1.07.0) - Nuklear now differentiates between hiding a window (NK_WINDOW_HIDDEN) and
/// closing a window (NK_WINDOW_CLOSED). A window can be hidden/shown
/// by using `nk_window_show` and closed by either clicking the close
@@ -29468,7 +31055,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2016/07/15 (1.01.0) - Removed internal font baking API and simplified
/// font atlas memory management by converting pointer
/// arrays for fonts and font configurations to lists.
-/// - 2016/07/15 (1.00.0) - Changed button API to use context dependend button
+/// - 2016/07/15 (1.00.0) - Changed button API to use context dependent button
/// behavior instead of passing it for every function call.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// ## Gallery