| 18906 | return nk_input_has_mouse_click_down_in_rect(&ctx->input, btn, bounds, down); |
| 18907 | } |
| 18908 | NK_API enum nk_widget_layout_states |
| 18909 | nk_widget(struct nk_rect *bounds, const struct nk_context *ctx) |
| 18910 | { |
| 18911 | struct nk_rect c, v; |
| 18912 | struct nk_window *win; |
| 18913 | struct nk_panel *layout; |
| 18914 | const struct nk_input *in; |
| 18915 | |
| 18916 | NK_ASSERT(ctx); |
| 18917 | NK_ASSERT(ctx->current); |
| 18918 | NK_ASSERT(ctx->current->layout); |
| 18919 | if (!ctx || !ctx->current || !ctx->current->layout) |
| 18920 | return NK_WIDGET_INVALID; |
| 18921 | |
| 18922 | /* allocate space and check if the widget needs to be updated and drawn */ |
| 18923 | nk_panel_alloc_space(bounds, ctx); |
| 18924 | win = ctx->current; |
| 18925 | layout = win->layout; |
| 18926 | in = &ctx->input; |
| 18927 | c = layout->clip; |
| 18928 | |
| 18929 | /* if one of these triggers you forgot to add an `if` condition around either |
| 18930 | a window, group, popup, combobox or contextual menu `begin` and `end` block. |
| 18931 | Example: |
| 18932 | if (nk_begin(...) {...} nk_end(...); or |
| 18933 | if (nk_group_begin(...) { nk_group_end(...);} */ |
| 18934 | NK_ASSERT(!(layout->flags & NK_WINDOW_MINIMIZED)); |
| 18935 | NK_ASSERT(!(layout->flags & NK_WINDOW_HIDDEN)); |
| 18936 | NK_ASSERT(!(layout->flags & NK_WINDOW_CLOSED)); |
| 18937 | |
| 18938 | /* need to convert to int here to remove floating point errors */ |
| 18939 | bounds->x = (float)((int)bounds->x); |
| 18940 | bounds->y = (float)((int)bounds->y); |
| 18941 | bounds->w = (float)((int)bounds->w); |
| 18942 | bounds->h = (float)((int)bounds->h); |
| 18943 | |
| 18944 | c.x = (float)((int)c.x); |
| 18945 | c.y = (float)((int)c.y); |
| 18946 | c.w = (float)((int)c.w); |
| 18947 | c.h = (float)((int)c.h); |
| 18948 | |
| 18949 | nk_unify(&v, &c, bounds->x, bounds->y, bounds->x + bounds->w, bounds->y + bounds->h); |
| 18950 | if (!NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->x, bounds->y, bounds->w, bounds->h)) |
| 18951 | return NK_WIDGET_INVALID; |
| 18952 | if (!NK_INBOX(in->mouse.pos.x, in->mouse.pos.y, v.x, v.y, v.w, v.h)) |
| 18953 | return NK_WIDGET_ROM; |
| 18954 | return NK_WIDGET_VALID; |
| 18955 | } |
| 18956 | NK_API enum nk_widget_layout_states |
| 18957 | nk_widget_fitting(struct nk_rect *bounds, struct nk_context *ctx, |
| 18958 | struct nk_vec2 item_padding) |
no test coverage detected