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:
authorCampbell Barton <ideasman42@gmail.com>2010-12-20 06:59:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-20 06:59:22 +0300
commit3bed4cbf2b4c09dcb62197b8a8c4ec4224abc8b7 (patch)
treefc800fc89f29db4ac9d951ff148b8424c8cb7c73 /source/blender/editors/interface
parent17f37dceccb99d7eb58f7c29908eeb2bd87cd7ff (diff)
fix [#25283] Edge length display difficult to read
- made theme colors for mesh edge len & face angle/area display. - use %g rather then %f for float display, trims unneeded zeros. - store cached 2d and 3d text color as bytes rather then floats, compare when drawing to avoid setting the context. - use unsigned char for more color functions, avoids casting to glColorubv().
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_draw.c10
-rw-r--r--source/blender/editors/interface/interface_widgets.c14
-rw-r--r--source/blender/editors/interface/resources.c79
-rw-r--r--source/blender/editors/interface/view2d.c15
4 files changed, 74 insertions, 44 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index d06fe5efcf0..65261371329 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1342,7 +1342,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o
}
-static void glColor3ubvShade(char *col, int shade)
+static void glColor3ubvShade(unsigned char *col, int shade)
{
glColor3ub(col[0]-shade>0?col[0]-shade:0,
col[1]-shade>0?col[1]-shade:0,
@@ -1379,7 +1379,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
/* backdrop */
if(cumap->flag & CUMA_DO_CLIP) {
- glColor3ubvShade(wcol->inner, -20);
+ glColor3ubvShade((unsigned char *)wcol->inner, -20);
glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
glColor3ubv((unsigned char*)wcol->inner);
glRectf(rect->xmin + zoomx*(cumap->clipr.xmin-offsx),
@@ -1393,13 +1393,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
}
/* grid, every .25 step */
- glColor3ubvShade(wcol->inner, -16);
+ glColor3ubvShade((unsigned char *)wcol->inner, -16);
ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f);
/* grid, every 1.0 step */
- glColor3ubvShade(wcol->inner, -24);
+ glColor3ubvShade((unsigned char *)wcol->inner, -24);
ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f);
/* axes */
- glColor3ubvShade(wcol->inner, -50);
+ glColor3ubvShade((unsigned char *)wcol->inner, -50);
glBegin(GL_LINES);
glVertex2f(rect->xmin, rect->ymin + zoomy*(-offsy));
glVertex2f(rect->xmax, rect->ymin + zoomy*(-offsy));
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 319d51cdf75..1d49735d63a 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -555,7 +555,7 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
/* prepares shade colors */
-static void shadecolors4(char *coltop, char *coldown, char *color, short shadetop, short shadedown)
+static void shadecolors4(char *coltop, char *coldown, const char *color, short shadetop, short shadedown)
{
coltop[0]= CLAMPIS(color[0]+shadetop, 0, 255);
@@ -569,7 +569,7 @@ static void shadecolors4(char *coltop, char *coldown, char *color, short shadeto
coldown[3]= color[3];
}
-static void round_box_shade_col4(char *col1, char *col2, float fac)
+static void round_box_shade_col4(const char *col1, const char *col2, float fac)
{
int faci, facm;
unsigned char col[4];
@@ -1431,7 +1431,7 @@ void ui_widget_color_init(ThemeUI *tui)
/* ************ button callbacks, state ***************** */
-static void widget_state_blend(char *cp, char *cpstate, float fac)
+static void widget_state_blend(char *cp, const char *cpstate, const float fac)
{
if(fac != 0.0f) {
cp[0]= (int)((1.0f-fac)*cp[0] + fac*cpstate[0]);
@@ -1523,9 +1523,9 @@ static void widget_state_label(uiWidgetType *wt, int state)
widget_state(wt, state);
if(state & UI_SELECT)
- UI_GetThemeColor4ubv(TH_TEXT_HI, wt->wcol.text);
+ UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
else
- UI_GetThemeColor4ubv(TH_TEXT, wt->wcol.text);
+ UI_GetThemeColor4ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
}
@@ -2594,7 +2594,7 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
{
uiWidgetBase wtb;
- char col[4];
+ unsigned char col[4];
/* state copy! */
wt->wcol= *(wt->wcol_theme);
@@ -2607,7 +2607,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
/* make mask to draw over image */
UI_GetThemeColor3ubv(TH_BACK, col);
- glColor3ubv((unsigned char*)col);
+ glColor3ubv(col);
round_box__edges(&wtb, 15, rect, 0.0f, 4.0);
widgetbase_outline(&wtb);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 2bc72d717c0..fa36eed5911 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -81,14 +81,14 @@ void ui_resources_free(void)
/* THEMES */
/* ******************************************************** */
-char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
+const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
{
ThemeSpace *ts= NULL;
static char error[4]={240, 0, 240, 255};
static char alert[4]={240, 60, 60, 255};
static char headerdesel[4]={0,0,0,255};
- char *cp= error;
+ const char *cp= error;
if(btheme) {
@@ -285,6 +285,12 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp= ts->face_dot; break;
case TH_FACEDOT_SIZE:
cp= &ts->facedot_size; break;
+ case TH_DRAWEXTRA_EDGELEN:
+ cp= ts->extra_edge_len; break;
+ case TH_DRAWEXTRA_FACEAREA:
+ cp= ts->extra_face_area; break;
+ case TH_DRAWEXTRA_FACEANG:
+ cp= ts->extra_face_angle; break;
case TH_NORMAL:
cp= ts->normal; break;
case TH_VNORMAL:
@@ -402,7 +408,7 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
}
}
- return cp;
+ return (unsigned char *)cp;
}
#define SETCOLTEST(col, r, g, b, a) if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
@@ -515,6 +521,11 @@ void ui_theme_init_default(void)
SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
btheme->tv3d.facedot_size= 4;
+
+ SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
+ SETCOL(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
+ SETCOL(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
+
SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
@@ -709,20 +720,20 @@ void UI_SetTheme(int spacetype, int regionid)
// for space windows only
void UI_ThemeColor(int colorid)
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- glColor3ub(cp[0], cp[1], cp[2]);
+ glColor3ubv(cp);
}
// plus alpha
void UI_ThemeColor4(int colorid)
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- glColor4ub(cp[0], cp[1], cp[2], cp[3]);
+ glColor4ubv(cp);
}
@@ -730,7 +741,7 @@ void UI_ThemeColor4(int colorid)
void UI_ThemeColorShade(int colorid, int offset)
{
int r, g, b;
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
r= offset + (int) cp[0];
@@ -745,7 +756,7 @@ void UI_ThemeColorShade(int colorid, int offset)
void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
{
int r, g, b, a;
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
r= coloffset + (int) cp[0];
@@ -763,7 +774,7 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
{
int r, g, b;
- char *cp1, *cp2;
+ const unsigned char *cp1, *cp2;
cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
@@ -780,7 +791,7 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
{
int r, g, b;
- char *cp1, *cp2;
+ const unsigned char *cp1, *cp2;
cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
@@ -801,7 +812,7 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
{
int r, g, b, a;
- char *cp1, *cp2;
+ const unsigned char *cp1, *cp2;
cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
@@ -824,7 +835,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
// get individual values, not scaled
float UI_GetThemeValuef(int colorid)
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((float)cp[0]);
@@ -834,7 +845,7 @@ float UI_GetThemeValuef(int colorid)
// get individual values, not scaled
int UI_GetThemeValue(int colorid)
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((int) cp[0]);
@@ -845,7 +856,7 @@ int UI_GetThemeValue(int colorid)
// get the color, range 0.0-1.0
void UI_GetThemeColor3fv(int colorid, float *col)
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0]= ((float)cp[0])/255.0;
@@ -857,7 +868,7 @@ void UI_GetThemeColor3fv(int colorid, float *col)
void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
{
int r, g, b;
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
@@ -874,9 +885,9 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
}
// get the color, in char pointer
-void UI_GetThemeColor3ubv(int colorid, char *col)
+void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0]= cp[0];
@@ -885,9 +896,9 @@ void UI_GetThemeColor3ubv(int colorid, char *col)
}
// get the color, in char pointer
-void UI_GetThemeColor4ubv(int colorid, char *col)
+void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0]= cp[0];
@@ -896,9 +907,9 @@ void UI_GetThemeColor4ubv(int colorid, char *col)
col[3]= cp[3];
}
-void UI_GetThemeColorType4ubv(int colorid, int spacetype, char *col)
+void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
{
- char *cp;
+ const unsigned char *cp;
cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
col[0]= cp[0];
@@ -908,7 +919,7 @@ void UI_GetThemeColorType4ubv(int colorid, int spacetype, char *col)
}
// blends and shades between two char color pointers
-void UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset)
+void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
{
int r, g, b;
@@ -925,7 +936,7 @@ void UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset)
}
// get a 3 byte color, blended and shaded between two other char color pointers
-void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset)
+void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
{
int r, g, b;
@@ -951,24 +962,27 @@ void UI_ThemeClearColor(int colorid)
glClearColor(col[0], col[1], col[2], 0.0);
}
-void UI_make_axis_color(char *src_col, char *dst_col, char axis)
+void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
{
switch(axis)
{
- case 'x':
+ case 'X':
dst_col[0]= src_col[0]>219?255:src_col[0]+36;
dst_col[1]= src_col[1]<26?0:src_col[1]-26;
dst_col[2]= src_col[2]<26?0:src_col[2]-26;
break;
- case 'y':
+ case 'Y':
dst_col[0]= src_col[0]<46?0:src_col[0]-36;
dst_col[1]= src_col[1]>189?255:src_col[1]+66;
dst_col[2]= src_col[2]<46?0:src_col[2]-36;
break;
- default:
+ case 'Z':
dst_col[0]= src_col[0]<26?0:src_col[0]-26;
dst_col[1]= src_col[1]<26?0:src_col[1]-26;
dst_col[2]= src_col[2]>209?255:src_col[2]+46;
+ break;
+ default:
+ BKE_assert(!"invalid axis arg");
}
}
@@ -1488,6 +1502,15 @@ void init_userdef_do_versions(void)
btheme->tui.wcol_progress= wcol_progress;
}
}
+
+ if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
+ bTheme *btheme;
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
+ SETCOL(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
+ SETCOL(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
+ }
+ }
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 21146dc8cec..13dca032a6c 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -2006,7 +2006,10 @@ static ListBase strings= {NULL, NULL};
typedef struct View2DString {
struct View2DString *next, *prev;
- GLbyte col[4];
+ union {
+ unsigned char ub[4];
+ int pack;
+ } col;
short mval[2];
rcti rect;
} View2DString;
@@ -2026,9 +2029,9 @@ void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, co
memcpy(v2s_str, str, len);
BLI_addtail(&strings, v2s);
+ v2s->col.pack= *((int *)col);
v2s->mval[0]= mval[0];
v2s->mval[1]= mval[1];
- QUATCOPY(v2s->col, col);
}
}
@@ -2043,17 +2046,18 @@ void UI_view2d_text_cache_rectf(View2D *v2d, rctf *rect, const char *str, const
UI_view2d_to_region_no_clip(v2d, rect->xmin, rect->ymin, &v2s->rect.xmin, &v2s->rect.ymin);
UI_view2d_to_region_no_clip(v2d, rect->xmax, rect->ymax, &v2s->rect.xmax, &v2s->rect.ymax);
+ v2s->col.pack= *((int *)col);
v2s->mval[0]= v2s->rect.xmin;
v2s->mval[1]= v2s->rect.ymin;
BLI_addtail(&strings, v2s);
- QUATCOPY(v2s->col, col);
}
void UI_view2d_text_cache_draw(ARegion *ar)
{
View2DString *v2s;
+ int col_pack_prev= 0;
// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
@@ -2068,7 +2072,10 @@ void UI_view2d_text_cache_draw(ARegion *ar)
yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
if(yofs<1) yofs= 1;
- glColor3bv(v2s->col);
+ if(col_pack_prev != v2s->col.pack) {
+ glColor3ubv(v2s->col.ub);
+ col_pack_prev= v2s->col.pack;
+ }
if(v2s->rect.xmin >= v2s->rect.xmax)
BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, 65535);