Skip to content

Commit

Permalink
Allow for NULL arguments to nk_***_get_scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
keharriso authored and borodust committed Jun 23, 2019
1 parent 213e3af commit 26a3480
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
26 changes: 16 additions & 10 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,8 @@ NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
/// Parameter | Description
/// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __offset_x__ | A pointer to the x offset output
/// __offset_y__ | A pointer to the y offset output
/// __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
Expand Down Expand Up @@ -2744,8 +2744,8 @@ NK_API void nk_group_scrolled_end(struct nk_context*);
/// -------------|-----------------------------------------------------------
/// __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
/// __y_offset__ | A pointer to the y offset output
/// __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_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
/*/// #### nk_group_set_scroll
Expand Down Expand Up @@ -16533,8 +16533,10 @@ nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_
if (!ctx || !ctx->current)
return ;
win = ctx->current;
*offset_x = win->scrollbar.x;
*offset_y = win->scrollbar.y;
if (offset_x)
*offset_x = win->scrollbar.x;
if (offset_y)
*offset_y = win->scrollbar.y;
}
NK_API int
nk_window_has_focus(const struct nk_context *ctx)
Expand Down Expand Up @@ -17023,8 +17025,10 @@ nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y
return;

popup = ctx->current;
*offset_x = popup->scrollbar.x;
*offset_y = popup->scrollbar.y;
if (offset_x)
*offset_x = popup->scrollbar.x;
if (offset_y)
*offset_y = popup->scrollbar.y;
}
NK_API void
nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
Expand Down Expand Up @@ -18866,8 +18870,10 @@ nk_group_get_scroll(struct nk_context *ctx, const char *id, nk_uint *x_offset, n
if (!x_offset_ptr || !y_offset_ptr) return;
*x_offset_ptr = *y_offset_ptr = 0;
} else y_offset_ptr = nk_find_value(win, id_hash+1);
*x_offset = *x_offset_ptr;
*y_offset = *y_offset_ptr;
if (x_offset)
*x_offset = *x_offset_ptr;
if (y_offset)
*y_offset = *y_offset_ptr;
}
NK_API void
nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset)
Expand Down
8 changes: 4 additions & 4 deletions src/nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,8 @@ NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
/// Parameter | Description
/// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __offset_x__ | A pointer to the x offset output
/// __offset_y__ | A pointer to the y offset output
/// __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
Expand Down Expand Up @@ -2525,8 +2525,8 @@ NK_API void nk_group_scrolled_end(struct nk_context*);
/// -------------|-----------------------------------------------------------
/// __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
/// __y_offset__ | A pointer to the y offset output
/// __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_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
/*/// #### nk_group_set_scroll
Expand Down
6 changes: 4 additions & 2 deletions src/nuklear_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ nk_group_get_scroll(struct nk_context *ctx, const char *id, nk_uint *x_offset, n
if (!x_offset_ptr || !y_offset_ptr) return;
*x_offset_ptr = *y_offset_ptr = 0;
} else y_offset_ptr = nk_find_value(win, id_hash+1);
*x_offset = *x_offset_ptr;
*y_offset = *y_offset_ptr;
if (x_offset)
*x_offset = *x_offset_ptr;
if (y_offset)
*y_offset = *y_offset_ptr;
}
NK_API void
nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset)
Expand Down
6 changes: 4 additions & 2 deletions src/nuklear_popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y
return;

popup = ctx->current;
*offset_x = popup->scrollbar.x;
*offset_y = popup->scrollbar.y;
if (offset_x)
*offset_x = popup->scrollbar.x;
if (offset_y)
*offset_y = popup->scrollbar.y;
}
NK_API void
nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
Expand Down
6 changes: 4 additions & 2 deletions src/nuklear_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_
if (!ctx || !ctx->current)
return ;
win = ctx->current;
*offset_x = win->scrollbar.x;
*offset_y = win->scrollbar.y;
if (offset_x)
*offset_x = win->scrollbar.x;
if (offset_y)
*offset_y = win->scrollbar.y;
}
NK_API int
nk_window_has_focus(const struct nk_context *ctx)
Expand Down

0 comments on commit 26a3480

Please sign in to comment.