143 struct nk_rect bounds, nk_flags flags)
154 NK_ASSERT(ctx->style.font && ctx->style.font->
width &&
"if this triggers you forgot to add a font");
155 NK_ASSERT(!ctx->current &&
"if this triggers you missed a `nk_end` call");
156 if (!ctx || ctx->current || !title || !name)
161 name_len = (int)nk_strlen(name);
162 name_hash = nk_murmur_hash(name, (
int)name_len, NK_WINDOW_TITLE);
163 win = nk_find_window(ctx, name_hash, name);
166 nk_size name_length = (nk_size)name_len;
167 win = (
struct nk_window*)nk_create_window(ctx);
171 if (flags & NK_WINDOW_BACKGROUND)
172 nk_insert_window(ctx, win, NK_INSERT_FRONT);
173 else nk_insert_window(ctx, win, NK_INSERT_BACK);
174 nk_command_buffer_init(&win->buffer, &ctx->memory, NK_CLIPPING_ON);
177 win->bounds = bounds;
178 win->name = name_hash;
179 name_length = NK_MIN(name_length, NK_WINDOW_MAX_NAME-1);
180 NK_MEMCPY(win->name_string, name, name_length);
181 win->name_string[name_length] = 0;
183 win->widgets_disabled = nk_false;
188 win->flags &= ~(nk_flags)(NK_WINDOW_PRIVATE-1);
190 if (!(win->flags & (NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE)))
191 win->bounds = bounds;
199 NK_ASSERT(win->seq != ctx->seq);
210 }
else nk_start(ctx, win);
215 int inpanel, ishovered;
217 float h = ctx->style.font->
height + 2.0f * style->window.header.padding.y +
218 (2.0f * style->window.header.label_padding.y);
220 win->bounds:
nk_rect(win->bounds.x, win->bounds.y, win->bounds.w, h);
223 inpanel = nk_input_has_mouse_click_down_in_rect(&ctx->input, NK_BUTTON_LEFT, win_bounds, nk_true);
224 inpanel = inpanel && ctx->input.mouse.buttons[NK_BUTTON_LEFT].clicked;
225 ishovered = nk_input_is_mouse_hovering_rect(&ctx->input, win_bounds);
226 if ((win != ctx->active) && ishovered && !ctx->input.mouse.buttons[NK_BUTTON_LEFT].down) {
230 iter->bounds:
nk_rect(iter->bounds.x, iter->bounds.y, iter->bounds.w, h);
231 if (NK_INTERSECT(win_bounds.x, win_bounds.y, win_bounds.w, win_bounds.h,
232 iter_bounds.x, iter_bounds.y, iter_bounds.w, iter_bounds.h) &&
236 if (iter->popup.win && iter->popup.active && !(iter->flags &
NK_WINDOW_HIDDEN) &&
237 NK_INTERSECT(win->bounds.x, win_bounds.y, win_bounds.w, win_bounds.h,
238 iter->popup.win->bounds.x, iter->popup.win->bounds.y,
239 iter->popup.win->bounds.w, iter->popup.win->bounds.h))
246 if (iter && inpanel && (win != ctx->end)) {
251 iter->bounds:
nk_rect(iter->bounds.x, iter->bounds.y, iter->bounds.w, h);
252 if (NK_INBOX(ctx->input.mouse.pos.x, ctx->input.mouse.pos.y,
253 iter_bounds.x, iter_bounds.y, iter_bounds.w, iter_bounds.h) &&
256 if (iter->popup.win && iter->popup.active && !(iter->flags &
NK_WINDOW_HIDDEN) &&
257 NK_INTERSECT(win_bounds.x, win_bounds.y, win_bounds.w, win_bounds.h,
258 iter->popup.win->bounds.x, iter->popup.win->bounds.y,
259 iter->popup.win->bounds.w, iter->popup.win->bounds.h))
264 if (iter && !(win->flags &
NK_WINDOW_ROM) && (win->flags & NK_WINDOW_BACKGROUND)) {
268 if (!(iter->flags & NK_WINDOW_BACKGROUND)) {
271 nk_remove_window(ctx, iter);
272 nk_insert_window(ctx, iter, NK_INSERT_BACK);
275 if (!iter && ctx->end != win) {
276 if (!(win->flags & NK_WINDOW_BACKGROUND)) {
279 nk_remove_window(ctx, win);
280 nk_insert_window(ctx, win, NK_INSERT_BACK);
285 if (ctx->end != win && !(win->flags & NK_WINDOW_BACKGROUND))
289 win->layout = (
struct nk_panel*)nk_create_panel(ctx);
291 ret = nk_panel_begin(ctx, title, NK_PANEL_WINDOW);
292 win->layout->offset_x = &win->scrollbar.x;
293 win->layout->offset_y = &win->scrollbar.y;