| 25133 | nk_popup_end(ctx); |
| 25134 | } |
| 25135 | NK_API void |
| 25136 | nk_tooltip(struct nk_context *ctx, const char *text) |
| 25137 | { |
| 25138 | const struct nk_style *style; |
| 25139 | struct nk_vec2 padding; |
| 25140 | |
| 25141 | int text_len; |
| 25142 | float text_width; |
| 25143 | float text_height; |
| 25144 | |
| 25145 | NK_ASSERT(ctx); |
| 25146 | NK_ASSERT(ctx->current); |
| 25147 | NK_ASSERT(ctx->current->layout); |
| 25148 | NK_ASSERT(text); |
| 25149 | if (!ctx || !ctx->current || !ctx->current->layout || !text) |
| 25150 | return; |
| 25151 | |
| 25152 | /* fetch configuration data */ |
| 25153 | style = &ctx->style; |
| 25154 | padding = style->window.padding; |
| 25155 | |
| 25156 | /* calculate size of the text and tooltip */ |
| 25157 | text_len = nk_strlen(text); |
| 25158 | text_width = style->font->width(style->font->userdata, |
| 25159 | style->font->height, text, text_len); |
| 25160 | text_width += (4 * padding.x); |
| 25161 | text_height = (style->font->height + 2 * padding.y); |
| 25162 | |
| 25163 | /* execute tooltip and fill with text */ |
| 25164 | if (nk_tooltip_begin(ctx, (float)text_width)) { |
| 25165 | nk_layout_row_dynamic(ctx, (float)text_height, 1); |
| 25166 | nk_text(ctx, text, text_len, NK_TEXT_LEFT); |
| 25167 | nk_tooltip_end(ctx); |
| 25168 | } |
| 25169 | } |
| 25170 | #ifdef NK_INCLUDE_STANDARD_VARARGS |
| 25171 | NK_API void |
| 25172 | nk_tooltipf(struct nk_context *ctx, const char *fmt, ...) |
no test coverage detected