forked from bartvdbraak/blender
Fix for extra string width padding in ui_text_icon_width, causing labels in right-aligned layouts show an annoying gap. If the layout is right-aligned, make the text button align right as well, so text is drawn at the right side of the alloted rect.
This commit is contained in:
parent
0d7f7c253b
commit
8066c09df2
@ -1599,6 +1599,14 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
|
||||
else
|
||||
but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
/* to compensate for string size padding in ui_text_icon_width,
|
||||
* make text aligned right if the layout is aligned right.
|
||||
*/
|
||||
if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) {
|
||||
but->flag &= ~UI_TEXT_LEFT; /* default, needs to be unset */
|
||||
but->flag |= UI_TEXT_RIGHT;
|
||||
}
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
|
@ -1147,6 +1147,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
|
||||
if (but->editstr || (but->flag & UI_TEXT_LEFT))
|
||||
fstyle->align = UI_STYLE_TEXT_LEFT;
|
||||
else if (but->flag & UI_TEXT_RIGHT)
|
||||
fstyle->align = UI_STYLE_TEXT_RIGHT;
|
||||
else
|
||||
fstyle->align = UI_STYLE_TEXT_CENTER;
|
||||
|
||||
@ -1333,10 +1335,16 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
|
||||
if (but->editstr || (but->flag & UI_TEXT_LEFT)) {
|
||||
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
||||
}
|
||||
else if ((but->flag & UI_TEXT_RIGHT)) {
|
||||
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
||||
}
|
||||
}
|
||||
else if ((but->flag & UI_TEXT_LEFT)) {
|
||||
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
||||
}
|
||||
else if ((but->flag & UI_TEXT_RIGHT)) {
|
||||
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
||||
}
|
||||
|
||||
/* unlink icon for this button type */
|
||||
if (but->type == SEARCH_MENU_UNLINK && but->drawstr[0]) {
|
||||
|
Loading…
Reference in New Issue
Block a user