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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-11 14:27:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-11 14:27:13 +0400
commitdde5e5ce2581ffd544b442c58d6eefbc1ff61772 (patch)
treeaf78298120e7318acd89370aaddedb5ba24b7c26 /source
parent7d2652ad7c8ad1b1851db2b148e17e0410b1c334 (diff)
User Interface: Align number buttons labels to the left, number right
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/unit.c3
-rw-r--r--source/blender/editors/interface/interface.c5
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_widgets.c28
4 files changed, 35 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 8e92f86502e..17aad7a5a2c 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -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 */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 79db94e5da8..aaaf64ba86e 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -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);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 3ef7117ffdb..cbc1cd2cbbd 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -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;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d353983ff70..9826f07e464 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -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);