2#include "nuklear_internal.h"
18 NK_STORAGE
const struct nk_rect null_rect = {-1,-1,0,0};
24 NK_ASSERT(ctx->current);
25 NK_ASSERT(ctx->current->layout);
26 if (!ctx || !ctx->current || !ctx->current->layout)
30 ++win->popup.con_count;
31 if (ctx->current != ctx->active)
35 popup = win->popup.win;
36 is_open = (popup && win->popup.type == NK_PANEL_CONTEXTUAL);
37 in = win->widgets_disabled ? 0 : &ctx->input;
39 is_clicked = nk_input_mouse_clicked(in, NK_BUTTON_RIGHT, trigger_bounds);
40 if (win->popup.active_con && win->popup.con_count != win->popup.active_con)
42 if (!is_open && win->popup.active_con)
43 win->popup.active_con = 0;
44 if ((!is_open && !is_clicked))
48 win->popup.active_con = win->popup.con_count;
50 body.x = in->mouse.pos.x;
51 body.y = in->mouse.pos.y;
53 body.x = popup->bounds.x;
54 body.y = popup->bounds.y;
61 ret = nk_nonblock_begin(ctx, flags | NK_WINDOW_NO_SCROLLBAR, body,
62 null_rect, NK_PANEL_CONTEXTUAL);
63 if (ret) win->popup.type = NK_PANEL_CONTEXTUAL;
65 win->popup.active_con = 0;
66 win->popup.type = NK_PANEL_NONE;
68 win->popup.win->flags = 0;
74nk_contextual_item_text(
struct nk_context *ctx,
const char *text,
int len,
85 NK_ASSERT(ctx->current);
86 NK_ASSERT(ctx->current->layout);
87 if (!ctx || !ctx->current || !ctx->current->layout)
92 state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
93 if (!state)
return nk_false;
96 if (nk_do_button_text(&ctx->last_widget_state, &win->buffer, bounds,
97 text, len, alignment, NK_BUTTON_DEFAULT, &style->contextual_button, in, style->font)) {
98 nk_contextual_close(ctx);
104nk_contextual_item_label(
struct nk_context *ctx,
const char *label, nk_flags align)
106 return nk_contextual_item_text(ctx, label, nk_strlen(label), align);
110 const char *text,
int len, nk_flags align)
120 NK_ASSERT(ctx->current);
121 NK_ASSERT(ctx->current->layout);
122 if (!ctx || !ctx->current || !ctx->current->layout)
127 state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
128 if (!state)
return nk_false;
131 if (nk_do_button_text_image(&ctx->last_widget_state, &win->buffer, bounds,
132 img, text, len, align, NK_BUTTON_DEFAULT, &style->contextual_button, style->font, in)){
133 nk_contextual_close(ctx);
140 const char *label, nk_flags align)
142 return nk_contextual_item_image_text(ctx, img, label, nk_strlen(label), align);
145nk_contextual_item_symbol_text(
struct nk_context *ctx,
enum nk_symbol_type symbol,
146 const char *text,
int len, nk_flags align)
156 NK_ASSERT(ctx->current);
157 NK_ASSERT(ctx->current->layout);
158 if (!ctx || !ctx->current || !ctx->current->layout)
163 state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
164 if (!state)
return nk_false;
167 if (nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer, bounds,
168 symbol, text, len, align, NK_BUTTON_DEFAULT, &style->contextual_button, style->font, in)) {
169 nk_contextual_close(ctx);
175nk_contextual_item_symbol_label(
struct nk_context *ctx,
enum nk_symbol_type symbol,
176 const char *text, nk_flags align)
178 return nk_contextual_item_symbol_text(ctx, symbol, text, nk_strlen(text), align);
184 NK_ASSERT(ctx->current);
185 NK_ASSERT(ctx->current->layout);
186 if (!ctx || !ctx->current || !ctx->current->layout)
return;
195 NK_ASSERT(ctx->current);
196 if (!ctx || !ctx->current)
return;
198 popup = ctx->current;
199 panel = popup->layout;
200 NK_ASSERT(popup->parent);
201 NK_ASSERT((
int)panel->type & (
int)NK_PANEL_SET_POPUP);
208 struct nk_rect body = {0,0,0,0};
209 if (panel->at_y < (panel->bounds.y + panel->bounds.h)) {
210 struct nk_vec2 padding = nk_panel_get_padding(&ctx->style, panel->type);
211 body = panel->bounds;
212 body.y = (panel->at_y + panel->footer_height + panel->border + padding.y + panel->row.height);
213 body.h = (panel->bounds.y + panel->bounds.h) - body.y;
215 {
int pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);
216 int in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body);
217 if (pressed && in_body)
main API and documentation file
@ NK_WINDOW_HIDDEN
Hides window and stops any window interaction and drawing.
@ NK_WINDOW_ROM
sets window widgets into a read only mode and does not allow input changes
@ NK_WINDOW_DYNAMIC
special window type growing up in height while being filled to a certain maximum height
@ NK_WIDGET_ROM
The widget is partially visible and cannot be updated.