Allow for NULL arguments to nk_***_get_scroll

master
Kevin Harrison 2019-02-20 10:55:12 -05:00 committed by Pavel Korolev
parent 213e3af261
commit 26a3480a31
5 changed files with 32 additions and 20 deletions

View File

@ -1732,8 +1732,8 @@ NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
/// Parameter | Description /// Parameter | Description
/// -------------|----------------------------------------------------------- /// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct /// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __offset_x__ | A pointer to the x offset output /// __offset_x__ | A pointer to the x offset output (or NULL to ignore)
/// __offset_y__ | A pointer to the y offset output /// __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_API void nk_window_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
/*/// #### nk_window_has_focus /*/// #### nk_window_has_focus
@ -2744,8 +2744,8 @@ NK_API void nk_group_scrolled_end(struct nk_context*);
/// -------------|----------------------------------------------------------- /// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct /// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __id__ | The id of the group to get the scroll position of /// __id__ | The id of the group to get the scroll position of
/// __x_offset__ | A pointer to the x offset output /// __x_offset__ | A pointer to the x offset output (or NULL to ignore)
/// __y_offset__ | A pointer to the y offset output /// __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_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
/*/// #### nk_group_set_scroll /*/// #### nk_group_set_scroll
@ -16533,8 +16533,10 @@ nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_
if (!ctx || !ctx->current) if (!ctx || !ctx->current)
return ; return ;
win = ctx->current; win = ctx->current;
*offset_x = win->scrollbar.x; if (offset_x)
*offset_y = win->scrollbar.y; *offset_x = win->scrollbar.x;
if (offset_y)
*offset_y = win->scrollbar.y;
} }
NK_API int NK_API int
nk_window_has_focus(const struct nk_context *ctx) nk_window_has_focus(const struct nk_context *ctx)
@ -17023,8 +17025,10 @@ nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y
return; return;
popup = ctx->current; popup = ctx->current;
*offset_x = popup->scrollbar.x; if (offset_x)
*offset_y = popup->scrollbar.y; *offset_x = popup->scrollbar.x;
if (offset_y)
*offset_y = popup->scrollbar.y;
} }
NK_API void NK_API void
nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y) nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
@ -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; if (!x_offset_ptr || !y_offset_ptr) return;
*x_offset_ptr = *y_offset_ptr = 0; *x_offset_ptr = *y_offset_ptr = 0;
} else y_offset_ptr = nk_find_value(win, id_hash+1); } else y_offset_ptr = nk_find_value(win, id_hash+1);
*x_offset = *x_offset_ptr; if (x_offset)
*y_offset = *y_offset_ptr; *x_offset = *x_offset_ptr;
if (y_offset)
*y_offset = *y_offset_ptr;
} }
NK_API void NK_API void
nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset) nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset)

View File

@ -1513,8 +1513,8 @@ NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
/// Parameter | Description /// Parameter | Description
/// -------------|----------------------------------------------------------- /// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct /// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __offset_x__ | A pointer to the x offset output /// __offset_x__ | A pointer to the x offset output (or NULL to ignore)
/// __offset_y__ | A pointer to the y offset output /// __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_API void nk_window_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
/*/// #### nk_window_has_focus /*/// #### nk_window_has_focus
@ -2525,8 +2525,8 @@ NK_API void nk_group_scrolled_end(struct nk_context*);
/// -------------|----------------------------------------------------------- /// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct /// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __id__ | The id of the group to get the scroll position of /// __id__ | The id of the group to get the scroll position of
/// __x_offset__ | A pointer to the x offset output /// __x_offset__ | A pointer to the x offset output (or NULL to ignore)
/// __y_offset__ | A pointer to the y offset output /// __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_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
/*/// #### nk_group_set_scroll /*/// #### nk_group_set_scroll

View File

@ -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; if (!x_offset_ptr || !y_offset_ptr) return;
*x_offset_ptr = *y_offset_ptr = 0; *x_offset_ptr = *y_offset_ptr = 0;
} else y_offset_ptr = nk_find_value(win, id_hash+1); } else y_offset_ptr = nk_find_value(win, id_hash+1);
*x_offset = *x_offset_ptr; if (x_offset)
*y_offset = *y_offset_ptr; *x_offset = *x_offset_ptr;
if (y_offset)
*y_offset = *y_offset_ptr;
} }
NK_API void NK_API void
nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset) nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset)

View File

@ -237,8 +237,10 @@ nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y
return; return;
popup = ctx->current; popup = ctx->current;
*offset_x = popup->scrollbar.x; if (offset_x)
*offset_y = popup->scrollbar.y; *offset_x = popup->scrollbar.x;
if (offset_y)
*offset_y = popup->scrollbar.y;
} }
NK_API void NK_API void
nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y) nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)

View File

@ -412,8 +412,10 @@ nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_
if (!ctx || !ctx->current) if (!ctx || !ctx->current)
return ; return ;
win = ctx->current; win = ctx->current;
*offset_x = win->scrollbar.x; if (offset_x)
*offset_y = win->scrollbar.y; *offset_x = win->scrollbar.x;
if (offset_y)
*offset_y = win->scrollbar.y;
} }
NK_API int NK_API int
nk_window_has_focus(const struct nk_context *ctx) nk_window_has_focus(const struct nk_context *ctx)