Updating outliner_draw_struct_marks to retained mode
Had to add a few utility functions to replace existing functions. Let me know if these are duplicates. Reviewers: merwin Reviewed By: merwin Tags: #bf_blender_2.8 Maniphest Tasks: T49043 Differential Revision: https://developer.blender.org/D2434
This commit is contained in:
parent
7eb4c850d3
commit
4e2c6ad8ee
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue