diff options
-rw-r--r-- | source/blender/editors/include/BIF_glutil.h | 1 | ||||
-rw-r--r-- | source/blender/editors/include/UI_resources.h | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 21 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 24 | ||||
-rw-r--r-- | source/blender/gpu/GPU_immediate.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_immediate.c | 8 |
7 files changed, 63 insertions, 9 deletions
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 25fcdf33524..35d38bf4ca1 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -128,6 +128,7 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2); /* use this version when VertexFormat has a vec3 position */ void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2); +void imm_draw_line(unsigned pos, float x1, float y1, float x2, float y2); /** * Pack color into 3 bytes * diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index be03647d6f4..b7a5217a862 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -353,6 +353,10 @@ void UI_GetThemeColor4fv(int colorid, float col[4]); // get four color values, range 0.0-1.0, complete with shading offset for the RGB components void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]); void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]); + +// get four colour values ranged between 0 and 255; includes the alpha channel +void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4]); + // get four color values, range 0.0-1.0, complete with shading offset for the RGB components and blending void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 73a9ea928cc..999556025db 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1307,6 +1307,27 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) glColor4ub(r, g, b, a); } +void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4]) +{ + int r, g, b, a; + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + r = coloffset + (int) cp[0]; + CLAMP(r, 0, 255); + g = coloffset + (int) cp[1]; + CLAMP(g, 0, 255); + b = coloffset + (int) cp[2]; + CLAMP(b, 0, 255); + a = alphaoffset + (int) cp[3]; + CLAMP(a, 0, 255); + + col[0] = r; + col[1] = g; + col[2] = b; + col[3] = a; +} + void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]) { const unsigned char *cp1, *cp2; diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 47593252ecb..ef514dd5e84 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -53,8 +53,8 @@ #include "UI_interface.h" - -void fdrawline(float x1, float y1, float x2, float y2) /* DEPRECATED */ +/* DEPRECATED: use imm_draw_line instead */ +void fdrawline(float x1, float y1, float x2, float y2) { glBegin(GL_LINES); glVertex2f(x1, y1); @@ -213,6 +213,14 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2) immEnd(); } +void imm_draw_line(unsigned pos, float x1, float y1, float x2, float y2) +{ + immBegin(PRIM_LINES, 2); + immVertex2f(pos, x1, y1); + immVertex2f(pos, x2, y2); + immEnd(); +} + void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2) { /* use this version when VertexFormat has a vec3 position */ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 18f4a02ab72..d25f2502e98 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1681,20 +1681,32 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); /* selection status */ if (TSELEM_OPEN(tselem, soops)) - if (tselem->type == TSE_RNA_STRUCT) - glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); + if (tselem->type == TSE_RNA_STRUCT) { + VertexFormat *format = immVertexFormat(); + unsigned pos = add_attrib(format, "pos", GL_INT, 2, CONVERT_INT_TO_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immThemeColorShadeAlpha(TH_BACK, -15, -200); + immRecti(pos, 0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); + immUnbindProgram(); + } *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); - if (tselem->type == TSE_RNA_STRUCT) - fdrawline(0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax, (float)*starty + UI_UNIT_Y); + if (tselem->type == TSE_RNA_STRUCT) { + VertexFormat *format = immVertexFormat(); + unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immThemeColorShadeAlpha(TH_BACK, -15, -200); + imm_draw_line(pos, 0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax, (float)*starty + UI_UNIT_Y); + immUnbindProgram(); + } } } } @@ -1768,8 +1780,6 @@ static void outliner_draw_tree( if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* struct marks */ - UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); - //UI_ThemeColorShade(TH_BACK, -20); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); } diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index f601d062d48..4a0840e22c0 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -46,3 +46,5 @@ void immUniformThemeColorShade(int color_id, int offset); void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset); void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset); void immUniformThemeColorBlend(int color_id1, int color_id2, float fac); +void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset); + diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 685c31dc3e0..5188ca4c0e2 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -28,6 +28,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" #include "UI_resources.h" +#include "BLI_utildefines.h" #include "gpu_shader_private.h" @@ -71,3 +72,10 @@ void immUniformThemeColorBlend(int color_id1, int color_id2, float fac) UI_GetThemeColorBlend3ubv(color_id1, color_id2, fac, color); immUniformColor3ubv(color); } + +void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) +{ + unsigned char col[4]; + UI_GetThemeColorShadeAlpha4ubv(colorid, coloffset, alphaoffset, col); + immUniformColor4ub(col[0], col[1], col[2], col[3]); +} |