@@ -3849,7 +3849,7 @@ NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune
3849
3849
/// Finally the most complex API wise is using nuklear's font baking API.
3850
3850
//
3851
3851
/// #### Using your own implementation without vertex buffer output
3852
- ///
3852
+ ///
3853
3853
/// So first up the easiest way to do font handling is by just providing a
3854
3854
/// `nk_user_font` struct which only requires the height in pixel of the used
3855
3855
/// 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
3872
3872
/// font.userdata.ptr = &your_font_class_or_struct;
3873
3873
/// font.height = your_font_height;
3874
3874
/// font.width = your_text_width_calculation;
3875
- ///
3875
+ ///
3876
3876
/// struct nk_context ctx;
3877
3877
/// nk_init_default(&ctx, &font);
3878
3878
/// ```
3879
3879
/// #### Using your own implementation with vertex buffer output
3880
- ///
3880
+ ///
3881
3881
/// While the first approach works fine if you don't want to use the optional
3882
3882
/// vertex buffer output it is not enough if you do. To get font handling working
3883
3883
/// 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
3906
3906
/// glyph.offset.x = ...;
3907
3907
/// glyph.offset.y = ...;
3908
3908
/// }
3909
- ///
3909
+ ///
3910
3910
/// struct nk_user_font font;
3911
3911
/// font.userdata.ptr = &your_font_class_or_struct;
3912
3912
/// font.height = your_font_height;
3913
3913
/// font.width = your_text_width_calculation;
3914
3914
/// font.query = query_your_font_glyph;
3915
3915
/// font.texture.id = your_font_texture;
3916
- ///
3916
+ ///
3917
3917
/// struct nk_context ctx;
3918
3918
/// nk_init_default(&ctx, &font);
3919
3919
/// ```
3920
3920
///
3921
3921
/// #### Nuklear font baker
3922
- ///
3922
+ ///
3923
3923
/// The final approach if you do not have a font handling functionality or don't
3924
3924
/// want to use it in this library is by using the optional font baker.
3925
3925
/// The font baker APIs can be used to create a font plus font atlas texture
3926
3926
/// and can be used with or without the vertex buffer output.
3927
- ///
3927
+ ///
3928
3928
/// It still uses the `nk_user_font` struct and the two different approaches
3929
3929
/// previously stated still work. The font baker is not located inside
3930
3930
/// `nk_context` like all other systems since it can be understood as more of
3931
3931
/// an extension to nuklear and does not really depend on any `nk_context` state.
3932
- ///
3932
+ ///
3933
3933
/// Font baker need to be initialized first by one of the nk_font_atlas_init_xxx
3934
3934
/// functions. If you don't care about memory just call the default version
3935
3935
/// `nk_font_atlas_init_default` which will allocate all memory from the standard library.
3936
3936
/// If you want to control memory allocation but you don't care if the allocated
3937
3937
/// memory is temporary and therefore can be freed directly after the baking process
3938
3938
/// is over or permanent you can call `nk_font_atlas_init`.
3939
- ///
3939
+ ///
3940
3940
/// After successfully initializing the font baker you can add Truetype(.ttf) fonts from
3941
3941
/// different sources like memory or from file by calling one of the `nk_font_atlas_add_xxx`.
3942
3942
/// functions. Adding font will permanently store each font, font config and ttf memory block(!)
3943
3943
/// inside the font atlas and allows to reuse the font atlas. If you don't want to reuse
3944
3944
/// the font baker by for example adding additional fonts you can call
3945
3945
/// `nk_font_atlas_cleanup` after the baking process is over (after calling nk_font_atlas_end).
3946
- ///
3946
+ ///
3947
3947
/// As soon as you added all fonts you wanted you can now start the baking process
3948
3948
/// for every selected glyph to image by calling `nk_font_atlas_bake`.
3949
3949
/// 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
3954
3954
/// to your font texture or object and optionally fills a `struct nk_draw_null_texture`
3955
3955
/// which can be used for the optional vertex output. If you don't want it just
3956
3956
/// set the argument to `NULL`.
3957
- ///
3957
+ ///
3958
3958
/// At this point you are done and if you don't want to reuse the font atlas you
3959
3959
/// can call `nk_font_atlas_cleanup` to free all truetype blobs and configuration
3960
3960
/// memory. Finally if you don't use the font atlas and any of it's fonts anymore
3961
3961
/// you need to call `nk_font_atlas_clear` to free all memory still being used.
3962
- ///
3962
+ ///
3963
3963
/// ```c
3964
3964
/// struct nk_font_atlas atlas;
3965
3965
/// 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
3968
3968
/// nk_font *font2 = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font2.ttf", 16, 0);
3969
3969
/// const void* img = nk_font_atlas_bake(&atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
3970
3970
/// nk_font_atlas_end(&atlas, nk_handle_id(texture), 0);
3971
- ///
3971
+ ///
3972
3972
/// struct nk_context ctx;
3973
3973
/// nk_init_default(&ctx, &font->handle);
3974
3974
/// while (1) {
3975
- ///
3975
+ ///
3976
3976
/// }
3977
3977
/// nk_font_atlas_clear(&atlas);
3978
3978
/// ```
@@ -4167,7 +4167,7 @@ NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
4167
4167
/// not as much control is needed.
4168
4168
/// In general all memory inside this library can be provided from the user in
4169
4169
/// three different ways.
4170
- ///
4170
+ ///
4171
4171
/// The first way and the one providing most control is by just passing a fixed
4172
4172
/// size memory block. In this case all control lies in the hand of the user
4173
4173
/// 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*);
4176
4176
/// you have to take over the resizing. While being a fixed sized buffer sounds
4177
4177
/// quite limiting, it is very effective in this library since the actual memory
4178
4178
/// consumption is quite stable and has a fixed upper bound for a lot of cases.
4179
- ///
4179
+ ///
4180
4180
/// If you don't want to think about how much memory the library should allocate
4181
4181
/// at all time or have a very dynamic UI with unpredictable memory consumption
4182
4182
/// habits but still want control over memory allocation you can use the dynamic
4183
4183
/// allocator based API. The allocator consists of two callbacks for allocating
4184
4184
/// and freeing memory and optional userdata so you can plugin your own allocator.
4185
- ///
4185
+ ///
4186
4186
/// The final and easiest way can be used by defining
4187
4187
/// NK_INCLUDE_DEFAULT_ALLOCATOR which uses the standard library memory
4188
4188
/// 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*);
4437
4437
/// started. It is probably important to note that the command buffer is the main
4438
4438
/// drawing API and the optional vertex buffer API only takes this format and
4439
4439
/// converts it into a hardware accessible format.
4440
- ///
4440
+ ///
4441
4441
/// To use the command queue to draw your own widgets you can access the
4442
4442
/// command buffer of each window by calling `nk_window_get_canvas` after
4443
4443
/// previously having called `nk_begin`:
4444
- ///
4444
+ ///
4445
4445
/// ```c
4446
4446
/// void draw_red_rectangle_widget(struct nk_context *ctx)
4447
4447
/// {
4448
4448
/// struct nk_command_buffer *canvas;
4449
4449
/// struct nk_input *input = &ctx->input;
4450
4450
/// canvas = nk_window_get_canvas(ctx);
4451
- ///
4451
+ ///
4452
4452
/// struct nk_rect space;
4453
4453
/// enum nk_widget_layout_states state;
4454
4454
/// state = nk_widget(&space, ctx);
4455
4455
/// if (!state) return;
4456
- ///
4456
+ ///
4457
4457
/// if (state != NK_WIDGET_ROM)
4458
4458
/// update_your_widget_by_user_input(...);
4459
4459
/// nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0));
4460
4460
/// }
4461
- ///
4461
+ ///
4462
4462
/// if (nk_begin(...)) {
4463
4463
/// nk_layout_row_dynamic(ctx, 25, 1);
4464
4464
/// draw_red_rectangle_widget(ctx);
4465
4465
/// }
4466
4466
/// nk_end(..)
4467
- ///
4467
+ ///
4468
4468
/// ```
4469
4469
/// Important to know if you want to create your own widgets is the `nk_widget`
4470
4470
/// 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
4747
4747
NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4748
4748
NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4749
4749
NK_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*);
4750
4751
NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4751
4752
NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4752
4753
NK_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);
4765
4766
/// library since converting the default library draw command output is done by
4766
4767
/// just calling `nk_convert` but I decided to still make this library accessible
4767
4768
/// since it can be useful.
4768
- ///
4769
+ ///
4769
4770
/// The draw list is based on a path buffering and polygon and polyline
4770
4771
/// rendering API which allows a lot of ways to draw 2D content to screen.
4771
4772
/// In fact it is probably more powerful than needed but allows even more crazy
@@ -5581,19 +5582,19 @@ struct nk_window {
5581
5582
/// red button you can temporarily push the old button color onto a stack
5582
5583
/// draw the button with a red color and then you just pop the old color
5583
5584
/// back from the stack:
5584
- ///
5585
+ ///
5585
5586
/// nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(nk_rgb(255,0,0)));
5586
5587
/// nk_style_push_style_item(ctx, &ctx->style.button.hover, nk_style_item_color(nk_rgb(255,0,0)));
5587
5588
/// nk_style_push_style_item(ctx, &ctx->style.button.active, nk_style_item_color(nk_rgb(255,0,0)));
5588
5589
/// nk_style_push_vec2(ctx, &cx->style.button.padding, nk_vec2(2,2));
5589
- ///
5590
+ ///
5590
5591
/// nk_button(...);
5591
- ///
5592
+ ///
5592
5593
/// nk_style_pop_style_item(ctx);
5593
5594
/// nk_style_pop_style_item(ctx);
5594
5595
/// nk_style_pop_style_item(ctx);
5595
5596
/// nk_style_pop_vec2(ctx);
5596
- ///
5597
+ ///
5597
5598
/// Nuklear has a stack for style_items, float properties, vector properties,
5598
5599
/// flags, colors, fonts and for button_behavior. Each has it's own fixed size stack
5599
5600
/// 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)
18162
18163
return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked);
18163
18164
}
18164
18165
NK_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
18165
18172
nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key)
18166
18173
{
18167
18174
const struct nk_key *k;
@@ -20080,7 +20087,7 @@ nk_panel_end(struct nk_context *ctx)
20080
20087
20081
20088
/* hide scroll if no user input */
20082
20089
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;
20084
20091
int is_window_hovered = nk_window_is_hovered(ctx);
20085
20092
int any_item_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED);
20086
20093
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,
27475
27482
in->mouse.buttons[NK_BUTTON_LEFT].clicked) {
27476
27483
nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
27477
27484
} 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)) {
27479
27486
nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
27480
27487
cursor_follow = nk_true;
27481
27488
} else if (is_hovered && in->mouse.buttons[NK_BUTTON_RIGHT].clicked &&
0 commit comments