@@ -3849,7 +3849,7 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
38493849/// Finally the most complex API wise is using nuklear's font baking API.
38503850//
38513851/// #### Using your own implementation without vertex buffer output
3852- ///
3852+ ///
38533853/// So first up the easiest way to do font handling is by just providing a
38543854/// `nk_user_font` struct which only requires the height in pixel of the used
38553855/// font and a callback to calculate the width of a string. This way of handling
@@ -3872,12 +3872,12 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
38723872/// font.userdata.ptr = &your_font_class_or_struct;
38733873/// font.height = your_font_height;
38743874/// font.width = your_text_width_calculation;
3875- ///
3875+ ///
38763876/// struct nk_context ctx;
38773877/// nk_init_default(&ctx, &font);
38783878/// ```
38793879/// #### Using your own implementation with vertex buffer output
3880- ///
3880+ ///
38813881/// While the first approach works fine if you don't want to use the optional
38823882/// vertex buffer output it is not enough if you do. To get font handling working
38833883/// for these cases you have to provide two additional parameters inside the
@@ -3906,44 +3906,44 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
39063906/// glyph.offset.x = ...;
39073907/// glyph.offset.y = ...;
39083908/// }
3909- ///
3909+ ///
39103910/// struct nk_user_font font;
39113911/// font.userdata.ptr = &your_font_class_or_struct;
39123912/// font.height = your_font_height;
39133913/// font.width = your_text_width_calculation;
39143914/// font.query = query_your_font_glyph;
39153915/// font.texture.id = your_font_texture;
3916- ///
3916+ ///
39173917/// struct nk_context ctx;
39183918/// nk_init_default(&ctx, &font);
39193919/// ```
39203920///
39213921/// #### Nuklear font baker
3922- ///
3922+ ///
39233923/// The final approach if you do not have a font handling functionality or don't
39243924/// want to use it in this library is by using the optional font baker.
39253925/// The font baker APIs can be used to create a font plus font atlas texture
39263926/// and can be used with or without the vertex buffer output.
3927- ///
3927+ ///
39283928/// It still uses the `nk_user_font` struct and the two different approaches
39293929/// previously stated still work. The font baker is not located inside
39303930/// `nk_context` like all other systems since it can be understood as more of
39313931/// an extension to nuklear and does not really depend on any `nk_context` state.
3932- ///
3932+ ///
39333933/// Font baker need to be initialized first by one of the nk_font_atlas_init_xxx
39343934/// functions. If you don't care about memory just call the default version
39353935/// `nk_font_atlas_init_default` which will allocate all memory from the standard library.
39363936/// If you want to control memory allocation but you don't care if the allocated
39373937/// memory is temporary and therefore can be freed directly after the baking process
39383938/// is over or permanent you can call `nk_font_atlas_init`.
3939- ///
3939+ ///
39403940/// After successfully initializing the font baker you can add Truetype(.ttf) fonts from
39413941/// different sources like memory or from file by calling one of the `nk_font_atlas_add_xxx`.
39423942/// functions. Adding font will permanently store each font, font config and ttf memory block(!)
39433943/// inside the font atlas and allows to reuse the font atlas. If you don't want to reuse
39443944/// the font baker by for example adding additional fonts you can call
39453945/// `nk_font_atlas_cleanup` after the baking process is over (after calling nk_font_atlas_end).
3946- ///
3946+ ///
39473947/// As soon as you added all fonts you wanted you can now start the baking process
39483948/// for every selected glyph to image by calling `nk_font_atlas_bake`.
39493949/// The baking process returns image memory, width and height which can be used to
@@ -3954,12 +3954,12 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
39543954/// to your font texture or object and optionally fills a `struct nk_draw_null_texture`
39553955/// which can be used for the optional vertex output. If you don't want it just
39563956/// set the argument to `NULL`.
3957- ///
3957+ ///
39583958/// At this point you are done and if you don't want to reuse the font atlas you
39593959/// can call `nk_font_atlas_cleanup` to free all truetype blobs and configuration
39603960/// memory. Finally if you don't use the font atlas and any of it's fonts anymore
39613961/// you need to call `nk_font_atlas_clear` to free all memory still being used.
3962- ///
3962+ ///
39633963/// ```c
39643964/// struct nk_font_atlas atlas;
39653965/// nk_font_atlas_init_default(&atlas);
@@ -3968,11 +3968,11 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
39683968/// nk_font *font2 = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font2.ttf", 16, 0);
39693969/// const void* img = nk_font_atlas_bake(&atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
39703970/// nk_font_atlas_end(&atlas, nk_handle_id(texture), 0);
3971- ///
3971+ ///
39723972/// struct nk_context ctx;
39733973/// nk_init_default(&ctx, &font->handle);
39743974/// while (1) {
3975- ///
3975+ ///
39763976/// }
39773977/// nk_font_atlas_clear(&atlas);
39783978/// ```
@@ -4167,7 +4167,7 @@ NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
41674167/// not as much control is needed.
41684168/// In general all memory inside this library can be provided from the user in
41694169/// three different ways.
4170- ///
4170+ ///
41714171/// The first way and the one providing most control is by just passing a fixed
41724172/// size memory block. In this case all control lies in the hand of the user
41734173/// since he can exactly control where the memory comes from and how much memory
@@ -4176,13 +4176,13 @@ NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
41764176/// you have to take over the resizing. While being a fixed sized buffer sounds
41774177/// quite limiting, it is very effective in this library since the actual memory
41784178/// consumption is quite stable and has a fixed upper bound for a lot of cases.
4179- ///
4179+ ///
41804180/// If you don't want to think about how much memory the library should allocate
41814181/// at all time or have a very dynamic UI with unpredictable memory consumption
41824182/// habits but still want control over memory allocation you can use the dynamic
41834183/// allocator based API. The allocator consists of two callbacks for allocating
41844184/// and freeing memory and optional userdata so you can plugin your own allocator.
4185- ///
4185+ ///
41864186/// The final and easiest way can be used by defining
41874187/// NK_INCLUDE_DEFAULT_ALLOCATOR which uses the standard library memory
41884188/// allocation functions malloc and free and takes over complete control over
@@ -4437,34 +4437,34 @@ NK_API void nk_textedit_redo(struct nk_text_edit*);
44374437/// started. It is probably important to note that the command buffer is the main
44384438/// drawing API and the optional vertex buffer API only takes this format and
44394439/// converts it into a hardware accessible format.
4440- ///
4440+ ///
44414441/// To use the command queue to draw your own widgets you can access the
44424442/// command buffer of each window by calling `nk_window_get_canvas` after
44434443/// previously having called `nk_begin`:
4444- ///
4444+ ///
44454445/// ```c
44464446/// void draw_red_rectangle_widget(struct nk_context *ctx)
44474447/// {
44484448/// struct nk_command_buffer *canvas;
44494449/// struct nk_input *input = &ctx->input;
44504450/// canvas = nk_window_get_canvas(ctx);
4451- ///
4451+ ///
44524452/// struct nk_rect space;
44534453/// enum nk_widget_layout_states state;
44544454/// state = nk_widget(&space, ctx);
44554455/// if (!state) return;
4456- ///
4456+ ///
44574457/// if (state != NK_WIDGET_ROM)
44584458/// update_your_widget_by_user_input(...);
44594459/// nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0));
44604460/// }
4461- ///
4461+ ///
44624462/// if (nk_begin(...)) {
44634463/// nk_layout_row_dynamic(ctx, 25, 1);
44644464/// draw_red_rectangle_widget(ctx);
44654465/// }
44664466/// nk_end(..)
4467- ///
4467+ ///
44684468/// ```
44694469/// Important to know if you want to create your own widgets is the `nk_widget`
44704470/// call. It allocates space on the panel reserved for this widget to be used,
@@ -4747,6 +4747,7 @@ NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, s
47474747NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
47484748NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
47494749NK_API nk_bool nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4750+ NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
47504751NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
47514752NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
47524753NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
@@ -4765,7 +4766,7 @@ NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
47654766/// library since converting the default library draw command output is done by
47664767/// just calling `nk_convert` but I decided to still make this library accessible
47674768/// since it can be useful.
4768- ///
4769+ ///
47694770/// The draw list is based on a path buffering and polygon and polyline
47704771/// rendering API which allows a lot of ways to draw 2D content to screen.
47714772/// In fact it is probably more powerful than needed but allows even more crazy
@@ -5581,19 +5582,19 @@ struct nk_window {
55815582/// red button you can temporarily push the old button color onto a stack
55825583/// draw the button with a red color and then you just pop the old color
55835584/// back from the stack:
5584- ///
5585+ ///
55855586/// nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(nk_rgb(255,0,0)));
55865587/// nk_style_push_style_item(ctx, &ctx->style.button.hover, nk_style_item_color(nk_rgb(255,0,0)));
55875588/// nk_style_push_style_item(ctx, &ctx->style.button.active, nk_style_item_color(nk_rgb(255,0,0)));
55885589/// nk_style_push_vec2(ctx, &cx->style.button.padding, nk_vec2(2,2));
5589- ///
5590+ ///
55905591/// nk_button(...);
5591- ///
5592+ ///
55925593/// nk_style_pop_style_item(ctx);
55935594/// nk_style_pop_style_item(ctx);
55945595/// nk_style_pop_style_item(ctx);
55955596/// nk_style_pop_vec2(ctx);
5596- ///
5597+ ///
55975598/// Nuklear has a stack for style_items, float properties, vector properties,
55985599/// flags, colors, fonts and for button_behavior. Each has it's own fixed size stack
55995600/// which can be changed at compile time.
@@ -18162,6 +18163,12 @@ nk_input_is_mouse_released(const struct nk_input *i, enum nk_buttons id)
1816218163 return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked);
1816318164}
1816418165NK_API nk_bool
18166+ nk_input_is_mouse_moved(const struct nk_input *i)
18167+ {
18168+ if (!i) return nk_false;
18169+ return i->mouse.delta.x != 0 || i->mouse.delta.y != 0;
18170+ }
18171+ NK_API nk_bool
1816518172nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key)
1816618173{
1816718174 const struct nk_key *k;
@@ -20080,7 +20087,7 @@ nk_panel_end(struct nk_context *ctx)
2008020087
2008120088 /* hide scroll if no user input */
2008220089 if (window->flags & NK_WINDOW_SCROLL_AUTO_HIDE) {
20083- int has_input = ctx->input.mouse.delta.x != 0 || ctx->input.mouse.delta.y != 0 || ctx->input.mouse.scroll_delta.y != 0;
20090+ int has_input = nk_input_is_mouse_moved(& ctx->input) || ctx->input.mouse.scroll_delta.y != 0;
2008420091 int is_window_hovered = nk_window_is_hovered(ctx);
2008520092 int any_item_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED);
2008620093 if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
@@ -27475,7 +27482,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
2747527482 in->mouse.buttons[NK_BUTTON_LEFT].clicked) {
2747627483 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
2747727484 } else if (is_hovered && in->mouse.buttons[NK_BUTTON_LEFT].down &&
27478- (in->mouse.delta.x != 0.0f || in->mouse.delta.y != 0.0f )) {
27485+ nk_input_is_mouse_moved (in)) {
2747927486 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
2748027487 cursor_follow = nk_true;
2748127488 } else if (is_hovered && in->mouse.buttons[NK_BUTTON_RIGHT].clicked &&
0 commit comments