2#include "nuklear_internal.h"
10nk_tooltip_begin(
struct nk_context *ctx,
float width)
13 return nk_tooltip_begin_offset(ctx, width, ctx->style.window.tooltip_origin, ctx->style.window.tooltip_offset);
17nk_tooltip_begin_offset(
struct nk_context *ctx,
float width,
enum nk_tooltip_pos position,
struct nk_vec2 offset)
26 NK_ASSERT(ctx->current);
27 NK_ASSERT(ctx->current->layout);
28 if (!ctx || !ctx->current || !ctx->current->layout)
34 if (win->popup.win && ((
int)win->popup.type & (
int)NK_PANEL_SET_NONBLOCK))
38 h = NK_MAX(win->layout->row.min_height, ctx->style.font->
height+2*ctx->style.window.padding.y);
41 x = nk_ifloorf(in->mouse.pos.x + 1) - (int)win->layout->clip.x + offset.x;
42 y = nk_ifloorf(in->mouse.pos.y + 1) - (int)win->layout->clip.y + offset.y;
59 case NK_MIDDLE_CENTER:
71 case NK_BOTTOM_CENTER:
80 NK_ASSERT(0 &&
"Invalid tooltip position");
86 bounds.h = (float)nk_iceilf(nk_null_rect.h);
88 ret = nk_popup_begin(ctx, NK_POPUP_DYNAMIC,
89 "__##Tooltip##__", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER, bounds);
91 win->popup.type = NK_PANEL_TOOLTIP;
92 ctx->current->layout->type = NK_PANEL_TOOLTIP;
100 NK_ASSERT(ctx->current);
101 if (!ctx || !ctx->current)
return;
108nk_tooltip_offset(
struct nk_context *ctx,
const char *text,
enum nk_tooltip_pos position,
struct nk_vec2 offset)
118 NK_ASSERT(ctx->current);
119 NK_ASSERT(ctx->current->layout);
121 if (!ctx || !ctx->current || !ctx->current->layout || !text)
126 padding = style->window.padding;
129 text_len = nk_strlen(text);
130 text_width = style->font->
width(style->font->userdata,
131 style->font->
height, text, text_len);
132 text_width += (4 * padding.x);
133 text_height = (style->font->
height + 2 * padding.y);
136 if (nk_tooltip_begin_offset(ctx, (
float)text_width, position, offset)) {
138 nk_text(ctx, text, text_len, NK_TEXT_LEFT);
144nk_tooltip(
struct nk_context *ctx,
const char *text)
147 nk_tooltip_offset(ctx, text, ctx->style.window.tooltip_origin, ctx->style.window.tooltip_offset);
149#ifdef NK_INCLUDE_STANDARD_VARARGS
151nk_tooltipf_offset(
struct nk_context *ctx,
enum nk_tooltip_pos position,
struct nk_vec2 offset,
const char *fmt, ...)
155 nk_tooltipfv_offset(ctx, position, offset, fmt, args);
159nk_tooltipf(
struct nk_context *ctx,
const char *fmt, ...)
163 nk_tooltipfv(ctx, fmt, args);
167nk_tooltipfv_offset(
struct nk_context *ctx,
enum nk_tooltip_pos position,
struct nk_vec2 offset,
const char *fmt, va_list args)
170 nk_strfmt(buf, NK_LEN(buf), fmt, args);
171 nk_tooltip_offset(ctx, buf, position, offset);
174nk_tooltipfv(
struct nk_context *ctx,
const char *fmt, va_list args)
177 nk_strfmt(buf, NK_LEN(buf), fmt, args);
178 nk_tooltip(ctx, buf);
main API and documentation file
@ NK_WINDOW_ROM
sets window widgets into a read only mode and does not allow input changes
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Sets current row layout to share horizontal space between @cols number of widgets evenly.
nk_text_width_f width
!< max height of the font
float height
!< user provided font handle