From 213e3af26130568eb7492ea08309cc98a204cfac Mon Sep 17 00:00:00 2001 From: Kevin Harrison Date: Mon, 17 Dec 2018 16:21:14 -0500 Subject: [PATCH] Add nk_popup_get_scroll and nk_popup_set_scroll --- nuklear.h | 31 +++++++++++++++++++++++++++++++ src/nuklear.h | 2 ++ src/nuklear_popup.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/nuklear.h b/nuklear.h index 69dd7c6..5ac2e2c 100644 --- a/nuklear.h +++ b/nuklear.h @@ -3467,6 +3467,8 @@ NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userd NK_API int 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_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y); /* ============================================================================= * * COMBOBOX @@ -17009,7 +17011,36 @@ nk_popup_end(struct nk_context *ctx) ctx->current = win; 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) +{ + struct nk_window *popup; + NK_ASSERT(ctx); + NK_ASSERT(ctx->current); + NK_ASSERT(ctx->current->layout); + if (!ctx || !ctx->current || !ctx->current->layout) + return; + + popup = ctx->current; + *offset_x = popup->scrollbar.x; + *offset_y = popup->scrollbar.y; +} +NK_API void +nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y) +{ + struct nk_window *popup; + + NK_ASSERT(ctx); + NK_ASSERT(ctx->current); + NK_ASSERT(ctx->current->layout); + if (!ctx || !ctx->current || !ctx->current->layout) + return; + + popup = ctx->current; + popup->scrollbar.x = offset_x; + popup->scrollbar.y = offset_y; +} diff --git a/src/nuklear.h b/src/nuklear.h index 8e04bf1..e995899 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -3248,6 +3248,8 @@ NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userd NK_API int 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_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y); /* ============================================================================= * * COMBOBOX diff --git a/src/nuklear_popup.c b/src/nuklear_popup.c index 203bd7f..68bc965 100644 --- a/src/nuklear_popup.c +++ b/src/nuklear_popup.c @@ -225,4 +225,33 @@ nk_popup_end(struct nk_context *ctx) ctx->current = win; 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) +{ + struct nk_window *popup; + NK_ASSERT(ctx); + NK_ASSERT(ctx->current); + NK_ASSERT(ctx->current->layout); + if (!ctx || !ctx->current || !ctx->current->layout) + return; + + popup = ctx->current; + *offset_x = popup->scrollbar.x; + *offset_y = popup->scrollbar.y; +} +NK_API void +nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y) +{ + struct nk_window *popup; + + NK_ASSERT(ctx); + NK_ASSERT(ctx->current); + NK_ASSERT(ctx->current->layout); + if (!ctx || !ctx->current || !ctx->current->layout) + return; + + popup = ctx->current; + popup->scrollbar.x = offset_x; + popup->scrollbar.y = offset_y; +}