2 #include "nuklear_internal.h"
11 nk_uint *x_offset, nk_uint *y_offset,
const char *title, nk_flags flags)
18 nk_panel_alloc_space(&bounds, ctx);
19 {
const struct nk_rect *c = &win->layout->clip;
20 if (!NK_INTERSECT(c->x, c->y, c->w, c->h, bounds.x, bounds.y, bounds.w, bounds.h) &&
21 !(flags & NK_WINDOW_MOVABLE)) {
28 nk_zero(&panel,
sizeof(panel));
29 panel.bounds = bounds;
31 panel.scrollbar.x = *x_offset;
32 panel.scrollbar.y = *y_offset;
33 panel.buffer = win->buffer;
34 panel.layout = (
struct nk_panel*)nk_create_panel(ctx);
35 ctx->current = &panel;
36 nk_panel_begin(ctx, (flags & NK_WINDOW_TITLE) ? title: 0, NK_PANEL_GROUP);
38 win->buffer = panel.buffer;
39 win->buffer.clip = panel.layout->clip;
40 panel.layout->offset_x = x_offset;
41 panel.layout->offset_y = y_offset;
42 panel.layout->parent = win->layout;
43 win->layout = panel.layout;
49 nk_flags f = panel.layout->flags;
70 NK_ASSERT(ctx->current);
71 if (!ctx || !ctx->current)
75 NK_ASSERT(ctx->current);
77 NK_ASSERT(win->layout);
84 panel_padding = nk_panel_get_padding(&ctx->style, NK_PANEL_GROUP);
85 pan.bounds.y = g->bounds.y - (g->header_height + g->menu.h);
86 pan.bounds.x = g->bounds.x - panel_padding.x;
87 pan.bounds.w = g->bounds.w + 2 * panel_padding.x;
88 pan.bounds.h = g->bounds.h + g->header_height + g->menu.h;
89 if (g->flags & NK_WINDOW_BORDER) {
90 pan.bounds.x -= g->border;
91 pan.bounds.y -= g->border;
92 pan.bounds.w += 2*g->border;
93 pan.bounds.h += 2*g->border;
95 if (!(g->flags & NK_WINDOW_NO_SCROLLBAR)) {
96 pan.bounds.w += ctx->style.window.scrollbar_size.x;
97 pan.bounds.h += ctx->style.window.scrollbar_size.y;
99 pan.scrollbar.x = *g->offset_x;
100 pan.scrollbar.y = *g->offset_y;
101 pan.flags = g->flags;
102 pan.buffer = win->buffer;
108 nk_unify(&clip, &parent->clip, pan.bounds.x, pan.bounds.y,
109 pan.bounds.x + pan.bounds.w, pan.bounds.y + pan.bounds.h + panel_padding.x);
110 nk_push_scissor(&pan.buffer, clip);
113 win->buffer = pan.buffer;
114 nk_push_scissor(&win->buffer, parent->clip);
116 win->layout = parent;
117 g->bounds = pan.bounds;
122 struct nk_scroll *scroll,
const char *title, nk_flags flags)
128 const char *title, nk_flags flags)
138 NK_ASSERT(ctx->current);
139 NK_ASSERT(ctx->current->layout);
140 if (!ctx || !ctx->current || !ctx->current->layout || !
id)
145 id_len = (int)nk_strlen(
id);
146 id_hash = nk_murmur_hash(
id, (
int)id_len, NK_PANEL_GROUP);
147 x_offset = nk_find_value(win, id_hash);
149 x_offset = nk_add_value(ctx, win, id_hash, 0);
150 y_offset = nk_add_value(ctx, win, id_hash+1, 0);
154 if (!x_offset || !y_offset)
return 0;
155 *x_offset = *y_offset = 0;
156 }
else y_offset = nk_find_value(win, id_hash+1);
175 nk_uint *x_offset_ptr;
176 nk_uint *y_offset_ptr;
180 NK_ASSERT(ctx->current);
181 NK_ASSERT(ctx->current->layout);
182 if (!ctx || !ctx->current || !ctx->current->layout || !
id)
187 id_len = (int)nk_strlen(
id);
188 id_hash = nk_murmur_hash(
id, (
int)id_len, NK_PANEL_GROUP);
189 x_offset_ptr = nk_find_value(win, id_hash);
191 x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
192 y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
194 NK_ASSERT(x_offset_ptr);
195 NK_ASSERT(y_offset_ptr);
196 if (!x_offset_ptr || !y_offset_ptr)
return;
197 *x_offset_ptr = *y_offset_ptr = 0;
198 }
else y_offset_ptr = nk_find_value(win, id_hash+1);
200 *x_offset = *x_offset_ptr;
202 *y_offset = *y_offset_ptr;
210 nk_uint *x_offset_ptr;
211 nk_uint *y_offset_ptr;
215 NK_ASSERT(ctx->current);
216 NK_ASSERT(ctx->current->layout);
217 if (!ctx || !ctx->current || !ctx->current->layout || !
id)
222 id_len = (int)nk_strlen(
id);
223 id_hash = nk_murmur_hash(
id, (
int)id_len, NK_PANEL_GROUP);
224 x_offset_ptr = nk_find_value(win, id_hash);
226 x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
227 y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
229 NK_ASSERT(x_offset_ptr);
230 NK_ASSERT(y_offset_ptr);
231 if (!x_offset_ptr || !y_offset_ptr)
return;
232 *x_offset_ptr = *y_offset_ptr = 0;
233 }
else y_offset_ptr = nk_find_value(win, id_hash+1);
234 *x_offset_ptr = x_offset;
235 *y_offset_ptr = y_offset;
main API and documentation file
NK_API nk_bool nk_group_begin(struct nk_context *, const char *title, nk_flags)
Starts a new widget group.
@ NK_WINDOW_CLOSED
Directly closes and frees the window at the end of the frame.
@ NK_WINDOW_MINIMIZED
marks the window as minimized
@ NK_WINDOW_ROM
sets window widgets into a read only mode and does not allow input changes
NK_API void nk_group_scrolled_end(struct nk_context *)
NK_API void nk_group_get_scroll(struct nk_context *, const char *id, nk_uint *x_offset, nk_uint *y_offset)
NK_API nk_bool nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags)
NK_API nk_bool nk_group_begin_titled(struct nk_context *, const char *name, const char *title, nk_flags)
Starts a new widget group.
NK_API void nk_group_set_scroll(struct nk_context *, const char *id, nk_uint x_offset, nk_uint y_offset)
NK_API void nk_end(struct nk_context *ctx)
NK_API void nk_group_end(struct nk_context *)
NK_API nk_bool nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *off, const char *title, nk_flags)