Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_regions.c
| Context not available. | |||||
| #define UI_TIP_PAD_FAC 1.3f | #define UI_TIP_PAD_FAC 1.3f | ||||
| #define UI_TIP_PADDING (int)(UI_TIP_PAD_FAC * UI_UNIT_Y) | #define UI_TIP_PADDING (int)(UI_TIP_PAD_FAC * UI_UNIT_Y) | ||||
| #define MAX_TOOLTIP_LINES 8 | #define MAX_TOOLTIP_LINES 12 /* inreased to work nicely with multilined descriptions in tooltips */ | ||||
| #define MAX_TOOLTIP_LINE_CHARS 64 | |||||
| typedef struct uiTooltipData { | typedef struct uiTooltipData { | ||||
| rcti bbox; | rcti bbox; | ||||
| uiFontStyle fstyle; | uiFontStyle fstyle; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| /* Enum item label & tip */ | /* Enum item label & tip (automatically multilined!) */ | ||||
| if (enum_tip.strinfo) { | if (enum_tip.strinfo) { | ||||
| BLI_strncpy(data->lines[data->totline], enum_tip.strinfo, sizeof(data->lines[0])); | char max_str[MAX_TOOLTIP_LINE_CHARS]; | ||||
| char *breakpoint, *char_rem; | |||||
| int char_ofs; | |||||
| data->format[data->totline].is_pad = true; | data->format[data->totline].is_pad = true; | ||||
| char_rem = enum_tip.strinfo; | |||||
| while (strlen(char_rem) >= MAX_TOOLTIP_LINE_CHARS) { | |||||
campbellbarton: This should really be based on text width, not the number of characters, Especially since some… | |||||
| BLI_strncpy(max_str, char_rem, MAX_TOOLTIP_LINE_CHARS); | |||||
| breakpoint = strrchr(max_str, ' '); | |||||
psy-fiUnsubmitted Not Done Inline Actionsmight be nice to also allow newline characters to be used here as well. psy-fi: might be nice to also allow newline characters to be used here as well. | |||||
| char_ofs = breakpoint - max_str + 1; | |||||
| BLI_strncpy(data->lines[data->totline], char_rem, char_ofs); | |||||
| char_rem += char_ofs; | |||||
| data->format[data->totline].color_id = UI_TIP_LC_VALUE; | |||||
| data->totline++; | |||||
| } | |||||
| BLI_strncpy(data->lines[data->totline], char_rem, MAX_TOOLTIP_LINE_CHARS); | |||||
| data->format[data->totline].color_id = UI_TIP_LC_VALUE; | data->format[data->totline].color_id = UI_TIP_LC_VALUE; | ||||
| data->totline++; | data->totline++; | ||||
| } | } | ||||
| Context not available. | |||||
This should really be based on text width, not the number of characters, Especially since some unicode characters can be multi-byte.
I would prefer to move most of the logic here into BLF, So you could give it a string and it could return an array of offsets into the string array given.
This way we could use it anywhere multi-line was needed.