diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-11-15 04:04:59 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-11-15 04:27:54 +0300 |
commit | 665aa6a2a0c672f43da55daddcc4fb4db09e78b1 (patch) | |
tree | 8ef2c45c18f71a84a9a93449cb8d34707bee25b8 /source/blender | |
parent | 8859aa38281803932fbd15039d313bd50da277fa (diff) |
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
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_math_color.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_color_inline.c | 8 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ruler.c | 8 |
14 files changed, 61 insertions, 57 deletions
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 5e6b1256d30..c7abe6192f7 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -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); diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 01a805a09b6..bc3a1ee3e90 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -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) { diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index a1289e48da5..7031aab54b4 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -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); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c2c16d31e13..c5c029c7cd8 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -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) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index fcf827bdbe6..439ebfb1202 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -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); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 8b41302b5bb..fd127ac6182 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -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); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 80fc47e25e8..b073af375f7 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -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; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 2acc9e7bfe7..bd35a7d580b 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -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); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 18674fa8354..f049d616aa7 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -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); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 774bc0661cc..25e6e3d83b3 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -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 */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 6b3349719c5..2a0593e6a0d 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -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) { diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index ecdab26942a..fd55f4d4fdc 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -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 diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 81605a80f69..30b607e063d 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -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); } diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 3c13ab9d595..bed2df68abe 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -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); |