User Interface: Align number buttons labels to the left, number right
This commit is contained in:
parent
7d2652ad7c
commit
dde5e5ce25
|
@ -392,7 +392,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
|
|||
while (unit->name_short[j] && (i < len_max)) {
|
||||
str[i++] = unit->name_short[j++];
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (pad) {
|
||||
/* this loop only runs if so many zeros were removed that
|
||||
* the unit name only used padded chars,
|
||||
|
@ -402,6 +402,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
|
|||
str[i++] = pad;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* terminate no matter whats done with padding above */
|
||||
|
|
|
@ -2867,6 +2867,11 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
|
|||
{
|
||||
but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT);
|
||||
}
|
||||
#ifdef USE_NUMBUTS_LR_ALIGN
|
||||
else if (ELEM(but->type, NUM, NUMSLI)) {
|
||||
but->drawflag |= UI_BUT_TEXT_LEFT;
|
||||
}
|
||||
#endif
|
||||
|
||||
but->drawflag |= (block->flag & UI_BUT_ALIGN);
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ enum {
|
|||
/* bit-row */
|
||||
#define UI_BITBUT_ROW(min, max) (((max) >= 31 ? 0xFFFFFFFF : (1 << (max + 1)) - 1) - ((min) ? ((1 << (min)) - 1) : 0) )
|
||||
|
||||
/* split numbuts by ':' and align l/r */
|
||||
#define USE_NUMBUTS_LR_ALIGN
|
||||
|
||||
typedef struct uiLinkLine { /* only for draw/edit */
|
||||
struct uiLinkLine *next, *prev;
|
||||
struct uiBut *from, *to;
|
||||
|
|
|
@ -1124,6 +1124,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
|||
{
|
||||
int drawstr_left_len = UI_MAX_DRAW_STR;
|
||||
char *drawstr_right = NULL;
|
||||
bool use_right_only = false;
|
||||
|
||||
/* for underline drawing */
|
||||
float font_xofs, font_yofs;
|
||||
|
@ -1198,10 +1199,31 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_NUMBUTS_LR_ALIGN
|
||||
if (!drawstr_right && ELEM(but->type, NUM, NUMSLI) && (but->editstr == NULL)) {
|
||||
drawstr_right = strchr(but->drawstr + but->ofs, ':');
|
||||
if (drawstr_right) {
|
||||
drawstr_right++;
|
||||
drawstr_left_len = (drawstr_right - but->drawstr);
|
||||
|
||||
while (*drawstr_right == ' ') {
|
||||
drawstr_right++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* no prefix, even so use only cpoin */
|
||||
drawstr_right = but->drawstr + but->ofs;
|
||||
use_right_only = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
glColor4ubv((unsigned char *)wcol->text);
|
||||
|
||||
uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs,
|
||||
drawstr_left_len - but->ofs, &font_xofs, &font_yofs);
|
||||
if (!use_right_only) {
|
||||
uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs,
|
||||
drawstr_left_len - but->ofs, &font_xofs, &font_yofs);
|
||||
}
|
||||
|
||||
if (but->menu_key != '\0') {
|
||||
char fixedbuf[128];
|
||||
|
@ -2273,7 +2295,7 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
|
|||
{
|
||||
uiWidgetBase wtb;
|
||||
const float rad = 0.5f * BLI_rcti_size_y(rect);
|
||||
float textofs = rad * 0.75f;
|
||||
float textofs = rad * 0.85f;
|
||||
|
||||
if (state & UI_SELECT)
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
|
Loading…
Reference in New Issue