Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r--source/blender/editors/interface/interface_widgets.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index fa4a0a1e07d..86a5fd5dabb 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2300,7 +2300,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
if (!use_right_only) {
/* for underline drawing */
- float font_xofs, font_yofs;
+ int font_xofs, font_yofs;
int drawlen = (drawstr_left_len == INT_MAX) ? strlen(drawstr + but->ofs) :
(drawstr_left_len - but->ofs);
@@ -2315,7 +2315,8 @@ static void widget_draw_text(const uiFontStyle *fstyle,
},
drawlen,
&font_xofs,
- &font_yofs);
+ &font_yofs,
+ NULL);
if (but->menu_key != '\0') {
char fixedbuf[128];
@@ -2342,7 +2343,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
ul_advance = BLF_width(fstyle->uifont_id, fixedbuf, ul_index) + (1.0f * UI_DPI_FAC);
BLF_position(fstyle->uifont_id,
- rect->xmin + font_xofs + ul_advance,
+ rect->xmin + font_xofs + (int)ul_advance,
rect->ymin + font_yofs,
0.0f);
BLF_color4ubv(fstyle->uifont_id, wcol->text);
@@ -5267,8 +5268,13 @@ void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(bl
/* helper call to draw a menu item without button */
/* state: UI_ACTIVE or 0 */
-void ui_draw_menu_item(
- const uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep)
+void ui_draw_menu_item(const uiFontStyle *fstyle,
+ rcti *rect,
+ const char *name,
+ int iconid,
+ int state,
+ bool use_sep,
+ int *r_name_width)
{
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
rcti _rect = *rect;
@@ -5318,13 +5324,22 @@ void ui_draw_menu_item(
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
}
- UI_fontstyle_draw(fstyle,
- rect,
- drawstr,
- wt->wcol.text,
- &(struct uiFontStyleDraw_Params){
- .align = UI_STYLE_TEXT_LEFT,
- });
+ int xofs = 0, yofs = 0;
+ struct ResultBLF info;
+ UI_fontstyle_draw_ex(fstyle,
+ rect,
+ drawstr,
+ wt->wcol.text,
+ &(struct uiFontStyleDraw_Params){
+ .align = UI_STYLE_TEXT_LEFT,
+ },
+ BLF_DRAW_STR_DUMMY_MAX,
+ &xofs,
+ &yofs,
+ &info);
+ if (r_name_width != NULL) {
+ *r_name_width = xofs + info.width;
+ }
}
/* part text right aligned */