blender 2.8: Opengl: UI_draw_roundbox
all is in the title too.. Reviewers: merwin Reviewed By: merwin Subscribers: Blendify, Severin Tags: #bf_blender_2.8, #opengl_gfx Maniphest Tasks: T49043 Differential Revision: https://developer.blender.org/D2337
This commit is contained in:
@@ -142,6 +142,7 @@ MINLINE void float_to_byte_dither_v3(unsigned char b[3], const float f[3], float
|
||||
rgba_char_args_set(col, (r) * 255, (g) * 255, (b) * 255, (a) * 255)
|
||||
|
||||
MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const char b, const char a);
|
||||
MINLINE void rgba_float_args_set(float col[4], const float r, const float g, const float b, const float a);
|
||||
MINLINE void rgba_char_args_test_set(char col[4], const char r, const char g, const char b, const char a);
|
||||
MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack);
|
||||
|
||||
|
||||
@@ -239,6 +239,14 @@ MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const c
|
||||
col[3] = a;
|
||||
}
|
||||
|
||||
MINLINE void rgba_float_args_set(float col[4], const float r, const float g, const float b, const float a)
|
||||
{
|
||||
col[0] = r;
|
||||
col[1] = g;
|
||||
col[2] = b;
|
||||
col[3] = a;
|
||||
}
|
||||
|
||||
MINLINE void rgba_char_args_test_set(char col[4], const char r, const char g, const char b, const char a)
|
||||
{
|
||||
if (col[3] == 0) {
|
||||
|
||||
@@ -308,7 +308,7 @@ typedef enum {
|
||||
* Functions to draw various shapes, taking theme settings into account.
|
||||
* Used for code that draws its own UI style elements. */
|
||||
|
||||
void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad);
|
||||
void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad, float color[4]);
|
||||
void UI_draw_roundbox_corner_set(int type);
|
||||
int UI_draw_roundbox_corner_get(void);
|
||||
void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, float rad);
|
||||
|
||||
@@ -419,9 +419,9 @@ void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float maxy, f
|
||||
}
|
||||
|
||||
/* (old, used in outliner) plain antialiased filled box */
|
||||
void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad)
|
||||
void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float rad, float color[4])
|
||||
{
|
||||
ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA);
|
||||
ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA, color);
|
||||
}
|
||||
|
||||
void UI_draw_text_underline(int pos_x, int pos_y, int len, int height)
|
||||
|
||||
@@ -682,7 +682,7 @@ struct wmIMEData *ui_but_ime_data_get(uiBut *but);
|
||||
|
||||
/* interface_widgets.c */
|
||||
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
|
||||
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha);
|
||||
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha, float color[4]);
|
||||
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
|
||||
void ui_draw_pie_center(uiBlock *block);
|
||||
uiWidgetColors *ui_tooltip_get_theme(void);
|
||||
|
||||
@@ -307,7 +307,6 @@ void UI_fontstyle_draw_simple_backdrop(
|
||||
const float margin = height / 4.0f;
|
||||
|
||||
/* backdrop */
|
||||
glColor4ubv(bg);
|
||||
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL | UI_RB_ALPHA);
|
||||
UI_draw_roundbox(
|
||||
@@ -315,7 +314,7 @@ void UI_fontstyle_draw_simple_backdrop(
|
||||
(y + decent) - margin,
|
||||
x + width + margin,
|
||||
(y + decent) + height + margin,
|
||||
margin);
|
||||
margin, bg);
|
||||
|
||||
glColor4ubv(fg);
|
||||
}
|
||||
|
||||
@@ -212,13 +212,11 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha)
|
||||
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha, float color[4])
|
||||
{
|
||||
float color[4];
|
||||
int j;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glGetFloatv(GL_CURRENT_COLOR, color); // I will make the change in a futur patch, use as it is for now
|
||||
if (use_alpha) {
|
||||
color[3] = 0.5f;
|
||||
}
|
||||
|
||||
@@ -339,8 +339,8 @@ static void region_draw_azone_tab_plus(AZone *az)
|
||||
break;
|
||||
}
|
||||
|
||||
glColor4f(0.05f, 0.05f, 0.05f, 0.4f);
|
||||
UI_draw_roundbox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
|
||||
float color[4] = {0.05f, 0.05f, 0.05f, 0.4f};
|
||||
UI_draw_roundbox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
@@ -262,9 +262,10 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade)
|
||||
{
|
||||
UI_ThemeColorShade(colorid, shade);
|
||||
float color[4];
|
||||
UI_GetThemeColorShade4fv(colorid, shade, color);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox((float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f);
|
||||
UI_draw_roundbox((float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f, color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -443,13 +443,14 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
|
||||
node_draw_shadow(snode, node, BASIS_RAD, alpha);
|
||||
|
||||
/* body */
|
||||
if (node->flag & NODE_CUSTOM_COLOR)
|
||||
glColor4f(node->color[0], node->color[1], node->color[2], alpha);
|
||||
if (node->flag & NODE_CUSTOM_COLOR) {
|
||||
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
|
||||
}
|
||||
else
|
||||
UI_ThemeColor4(TH_NODE_FRAME);
|
||||
UI_GetThemeColor4fv(TH_NODE_FRAME, color);
|
||||
glEnable(GL_BLEND);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* outline active and selected emphasis */
|
||||
|
||||
@@ -738,10 +738,10 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
|
||||
else {
|
||||
const float margin = 3.0f;
|
||||
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.33f);
|
||||
float color[4] = {0.0f, 0.0f, 0.0f, 0.33f};
|
||||
glEnable(GL_BLEND);
|
||||
UI_draw_roundbox(rct->xmin - margin, rct->ymin - margin,
|
||||
rct->xmax + margin, rct->ymax + margin, radius + margin);
|
||||
rct->xmax + margin, rct->ymax + margin, radius + margin, color);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
@@ -880,21 +880,20 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
|
||||
/* header uses color from backdrop, but we make it opaqie */
|
||||
if (color_id == TH_NODE) {
|
||||
float col[3];
|
||||
UI_GetThemeColorShade3fv(color_id, -20, col);
|
||||
glColor4f(col[0], col[1], col[2], 1.0f);
|
||||
UI_GetThemeColorShade3fv(color_id, -20, color);
|
||||
}
|
||||
else
|
||||
UI_ThemeColor(color_id);
|
||||
UI_GetThemeColor4fv(color_id, color);
|
||||
|
||||
if (node->flag & NODE_MUTED)
|
||||
UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
|
||||
UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
|
||||
|
||||
|
||||
|
||||
#ifdef WITH_COMPOSITOR
|
||||
if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) {
|
||||
if (COM_isHighlightedbNode(node)) {
|
||||
UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f);
|
||||
UI_GetThemeColorBlendShade4fv(color_id, TH_ACTIVE, 0.5f, 0, color);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -902,7 +901,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
glLineWidth(1.0f);
|
||||
|
||||
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD, color);
|
||||
|
||||
/* show/hide icons */
|
||||
iconofs = rct->xmax - 0.35f * U.widget_unit;
|
||||
@@ -972,14 +971,15 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
|
||||
/* body */
|
||||
if (!nodeIsRegistered(node))
|
||||
UI_ThemeColor4(TH_REDALERT); /* use warning color to indicate undefined types */
|
||||
else if (node->flag & NODE_CUSTOM_COLOR)
|
||||
glColor3fv(node->color);
|
||||
UI_GetThemeColor4fv(TH_REDALERT, color); /* use warning color to indicate undefined types */
|
||||
else if (node->flag & NODE_CUSTOM_COLOR) {
|
||||
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], 1.0f);
|
||||
}
|
||||
else
|
||||
UI_ThemeColor4(TH_NODE);
|
||||
UI_GetThemeColor4fv(TH_NODE, color);
|
||||
glEnable(GL_BLEND);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD, color);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* outline active and selected emphasis */
|
||||
@@ -1038,19 +1038,19 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
||||
/* body */
|
||||
UI_ThemeColor(color_id);
|
||||
if (node->flag & NODE_MUTED)
|
||||
UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
|
||||
UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
|
||||
|
||||
#ifdef WITH_COMPOSITOR
|
||||
if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) {
|
||||
if (COM_isHighlightedbNode(node)) {
|
||||
UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f);
|
||||
UI_GetThemeColorBlendShade4fv(color_id, TH_ACTIVE, 0.5f, 0, color);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)ntree;
|
||||
#endif
|
||||
|
||||
UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad);
|
||||
UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color);
|
||||
|
||||
/* outline active and selected emphasis */
|
||||
if (node->flag & SELECT) {
|
||||
|
||||
@@ -1381,13 +1381,14 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
|
||||
float ufac = UI_UNIT_X / 20.0f;
|
||||
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
glColor4ub(255, 255, 255, 100);
|
||||
float color[4] = {1.0f, 1.0f, 1.0f, 0.4f};
|
||||
UI_draw_roundbox(
|
||||
(float) *offsx - 1.0f * ufac,
|
||||
(float)ys + 1.0f * ufac,
|
||||
(float)*offsx + UI_UNIT_X - 2.0f * ufac,
|
||||
(float)ys + UI_UNIT_Y - ufac,
|
||||
(float)UI_UNIT_Y / 2.0f - ufac);
|
||||
(float)UI_UNIT_Y / 2.0f - ufac,
|
||||
color);
|
||||
glEnable(GL_BLEND); /* roundbox disables */
|
||||
}
|
||||
|
||||
@@ -1434,12 +1435,12 @@ static void outliner_draw_tree_element(
|
||||
float ufac = UI_UNIT_X / 20.0f;
|
||||
int offsx = 0;
|
||||
eOLDrawState active = OL_DRAWSEL_NONE;
|
||||
|
||||
float color[4];
|
||||
tselem = TREESTORE(te);
|
||||
|
||||
if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) {
|
||||
int xmax = ar->v2d.cur.xmax;
|
||||
unsigned char alpha = 128;
|
||||
float alpha = 0.5f;
|
||||
|
||||
if ((tselem->flag & TSE_TEXTBUT) && (*te_edit == NULL)) {
|
||||
*te_edit = te;
|
||||
@@ -1455,7 +1456,7 @@ static void outliner_draw_tree_element(
|
||||
if (tselem->type == 0) {
|
||||
if (te->idcode == ID_SCE) {
|
||||
if (tselem->id == (ID *)scene) {
|
||||
glColor4ub(255, 255, 255, alpha);
|
||||
rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha);
|
||||
active = OL_DRAWSEL_ACTIVE;
|
||||
}
|
||||
}
|
||||
@@ -1464,8 +1465,7 @@ static void outliner_draw_tree_element(
|
||||
if (group_select_flag(gr)) {
|
||||
char col[4];
|
||||
UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col);
|
||||
col[3] = alpha;
|
||||
glColor4ubv((GLubyte *)col);
|
||||
rgba_float_args_set(color, (float)col[0] / 255, (float)col[1] / 255, (float)col[2] / 255, alpha);
|
||||
|
||||
active = OL_DRAWSEL_ACTIVE;
|
||||
}
|
||||
@@ -1491,18 +1491,17 @@ static void outliner_draw_tree_element(
|
||||
UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col);
|
||||
col[3] = alpha;
|
||||
}
|
||||
|
||||
glColor4ubv((GLubyte *)col);
|
||||
rgba_float_args_set(color, (float)col[0] / 255, (float)col[1] / 255, (float)col[2] / 255, alpha);
|
||||
}
|
||||
|
||||
}
|
||||
else if (scene->obedit && scene->obedit->data == tselem->id) {
|
||||
glColor4ub(255, 255, 255, alpha);
|
||||
rgba_float_args_set(color, 1.0f, 1.0f, 1.0f, alpha);
|
||||
active = OL_DRAWSEL_ACTIVE;
|
||||
}
|
||||
else {
|
||||
if (tree_element_active(C, scene, soops, te, OL_SETSEL_NONE, false)) {
|
||||
glColor4ub(220, 220, 255, alpha);
|
||||
rgba_float_args_set(color, 0.85f, 0.85f, 1.0f, alpha);
|
||||
active = OL_DRAWSEL_ACTIVE;
|
||||
}
|
||||
}
|
||||
@@ -1511,7 +1510,7 @@ static void outliner_draw_tree_element(
|
||||
if (tree_element_type_active(NULL, scene, soops, te, tselem, OL_SETSEL_NONE, false) != OL_DRAWSEL_NONE) {
|
||||
active = OL_DRAWSEL_ACTIVE;
|
||||
}
|
||||
glColor4ub(220, 220, 255, alpha);
|
||||
rgba_float_args_set(color, 0.85f, 0.85f, 1.0f, alpha);
|
||||
}
|
||||
|
||||
/* active circle */
|
||||
@@ -1522,7 +1521,7 @@ static void outliner_draw_tree_element(
|
||||
(float)*starty + 1.0f * ufac,
|
||||
(float)startx + 2.0f * UI_UNIT_X - 2.0f * ufac,
|
||||
(float)*starty + UI_UNIT_Y - 1.0f * ufac,
|
||||
UI_UNIT_Y / 2.0f - 1.0f * ufac);
|
||||
UI_UNIT_Y / 2.0f - 1.0f * ufac, color);
|
||||
glEnable(GL_BLEND); /* roundbox disables it */
|
||||
|
||||
te->flag |= TE_ACTIVE; // for lookup in display hierarchies
|
||||
|
||||
@@ -906,7 +906,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
|
||||
{
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
uiWidgetColors wcol = btheme->tui.wcol_scroll;
|
||||
unsigned char col[4];
|
||||
float col[4];
|
||||
float rad;
|
||||
|
||||
UI_ThemeColor(TH_BACK);
|
||||
@@ -916,11 +916,10 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
|
||||
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
rad = 0.4f * min_ii(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
|
||||
UI_GetThemeColor3ubv(TH_HILITE, col);
|
||||
col[3] = 48;
|
||||
glColor4ubv(col);
|
||||
UI_GetThemeColor3fv(TH_HILITE, col);
|
||||
col[3] = 0.18f;
|
||||
glEnable(GL_BLEND);
|
||||
UI_draw_roundbox(st->txtscroll.xmin + 1, st->txtscroll.ymin, st->txtscroll.xmax - 1, st->txtscroll.ymax, rad);
|
||||
UI_draw_roundbox(st->txtscroll.xmin + 1, st->txtscroll.ymin, st->txtscroll.xmax - 1, st->txtscroll.ymax, rad, col);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
@@ -429,9 +429,9 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
//unsigned int color_act = 0x666600;
|
||||
unsigned int color_act = 0xffffff;
|
||||
unsigned int color_base = 0x0;
|
||||
unsigned char color_back[4] = {0xff, 0xff, 0xff, 0x80};
|
||||
unsigned char color_text[3];
|
||||
unsigned char color_wire[3];
|
||||
float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f};
|
||||
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
@@ -530,12 +530,11 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
pos[1] = co_ss[1][1] - (numstr_size[1] / 2.0f);
|
||||
|
||||
/* draw text (bg) */
|
||||
glColor4ubv(color_back);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox(
|
||||
pos[0] - bg_margin, pos[1] - bg_margin,
|
||||
pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1],
|
||||
bg_radius);
|
||||
bg_radius, color_back);
|
||||
/* draw text */
|
||||
glColor3ubv(color_text);
|
||||
BLF_position(blf_mono_font, pos[0], pos[1], 0.0f);
|
||||
@@ -620,11 +619,10 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
pos[1] -= numstr_size[1] / 2.0f;
|
||||
|
||||
/* draw text (bg) */
|
||||
glColor4ubv(color_back);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox(pos[0] - bg_margin, pos[1] - bg_margin,
|
||||
pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1],
|
||||
bg_radius);
|
||||
bg_radius, color_back);
|
||||
/* draw text */
|
||||
glColor3ubv(color_text);
|
||||
BLF_position(blf_mono_font, pos[0], pos[1], 0.0f);
|
||||
|
||||
Reference in New Issue
Block a user