From 387bf726ac0fa47149d72ccaaa0df6fadf90df0f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 22 Apr 2018 22:55:05 +0200 Subject: UI: Editor outline color themable Note: Not bothering with doversion, re-using 280, 10 bump. --- source/blender/editors/include/UI_resources.h | 2 ++ source/blender/editors/interface/resources.c | 5 +++++ source/blender/editors/screen/screen_draw.c | 30 ++++++++++++++++----------- source/blender/makesdna/DNA_userdef_types.h | 3 ++- source/blender/makesrna/intern/rna_userdef.c | 6 ++++++ 5 files changed, 33 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 49c9cffdd54..2fc9b2946fb 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -275,6 +275,8 @@ typedef enum ThemeColorID { TH_WIDGET_EMBOSS, + TH_EDITOR_OUTLINE, + TH_AXIS_X, /* X/Y/Z Axis */ TH_AXIS_Y, TH_AXIS_Z, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 31d9f08fdd8..1bc834a121c 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -658,6 +658,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case TH_WIDGET_EMBOSS: cp = btheme->tui.widget_emboss; break; + case TH_EDITOR_OUTLINE: + cp = btheme->tui.editor_outline; + break; case TH_AXIS_X: cp = btheme->tui.xaxis; break; case TH_AXIS_Y: @@ -881,6 +884,7 @@ void ui_theme_init_default(void) btheme->tui.iconfile[0] = 0; rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255); rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f); + rgba_char_args_set_fl(btheme->tui.editor_outline, 0.25f, 0.25f, 0.25f, 1.0f); rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255); rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); @@ -2977,6 +2981,7 @@ void init_userdef_do_versions(void) btheme->tui.wcol_progress.roundness = 0.25f; btheme->tui.wcol_list_item.roundness = 0.2f; btheme->tui.wcol_pie_menu.roundness = 0.5f; + rgba_char_args_set_fl(btheme->tui.editor_outline, 0.25f, 0.25f, 0.25f, 1.0f); } } diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 6bb3bbe7405..fde60ee1960 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -34,6 +34,7 @@ #include "WM_types.h" #include "UI_interface.h" +#include "UI_resources.h" #include "screen_intern.h" @@ -212,15 +213,13 @@ static void draw_join_shape(ScrArea *sa, char dir, unsigned int pos) } } -/* This color is used for the internal area embossing and their round corners. */ -float edge_colors[4] = {0.25f, 0.25f, 0.25f, 1.0f}; - #define CORNER_RESOLUTION 10 static void drawscredge_corner_geometry( int sizex, int sizey, int corner_x, int corner_y, int center_x, int center_y, - double angle_offset) + double angle_offset, + const float *color) { const int radius = ABS(corner_x - center_x); const int line_thickness = U.pixelsize; @@ -272,7 +271,8 @@ static void drawscredge_corner_geometry( tri_array[i + 1][0] = x; tri_array[i + 1][1] = y; } - UI_draw_anti_fan(tri_array, CORNER_RESOLUTION + 1, edge_colors); + + UI_draw_anti_fan(tri_array, CORNER_RESOLUTION + 1, color); } #undef CORNER_RESOLUTION @@ -280,6 +280,8 @@ static void drawscredge_corner_geometry( static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) { int size = 10 * U.pixelsize; + float color[4] = {0}; + UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, color); /* Bottom-Left. */ drawscredge_corner_geometry(sizex, sizey, @@ -287,7 +289,8 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) sa->v1->vec.y, sa->v1->vec.x + size, sa->v1->vec.y + size, - M_PI_2 * 2.0f); + M_PI_2 * 2.0f, + color); /* Top-Left. */ drawscredge_corner_geometry(sizex, sizey, @@ -295,7 +298,8 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) sa->v2->vec.y, sa->v2->vec.x + size, sa->v2->vec.y - size, - M_PI_2); + M_PI_2, + color); /* Top-Right. */ drawscredge_corner_geometry(sizex, sizey, @@ -303,7 +307,8 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) sa->v3->vec.y, sa->v3->vec.x - size, sa->v3->vec.y - size, - 0.0f); + 0.0f, + color); /* Bottom-Right. */ drawscredge_corner_geometry(sizex, sizey, @@ -311,7 +316,8 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) sa->v4->vec.y, sa->v4->vec.x - size, sa->v4->vec.y + size, - M_PI_2 * 3.0f); + M_PI_2 * 3.0f, + color); /* Wrap up the corners with a nice embossing. */ rcti rect = sa->totrct; @@ -319,7 +325,7 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4fv(edge_colors); + immUniformColor4fv(color); immBeginAtMost(GWN_PRIM_LINES, 8); /* Right. */ @@ -441,7 +447,7 @@ void ED_screen_draw_edges(wmWindow *win) if (U.pixelsize > 1.0f) { /* FIXME: doesn't our glLineWidth already scale by U.pixelsize? */ glLineWidth((2.0f * U.pixelsize) - 1); - immUniformColor3fv(edge_colors); + immUniformThemeColor(TH_EDITOR_OUTLINE); for (sa = screen->areabase.first; sa; sa = sa->next) { drawscredge_area(sa, winsize_x, winsize_y, pos); @@ -449,7 +455,7 @@ void ED_screen_draw_edges(wmWindow *win) } glLineWidth(1); - immUniformColor3fv(edge_colors); + immUniformThemeColor(TH_EDITOR_OUTLINE); for (sa = screen->areabase.first; sa; sa = sa->next) { drawscredge_area(sa, winsize_x, winsize_y, pos); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 4bb796c84f1..ba6d022e556 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -180,7 +180,8 @@ typedef struct ThemeUI { float menu_shadow_fac; short menu_shadow_width; - short pad[3]; + char editor_outline[4]; + short pad[1]; char iconfile[256]; // FILE_MAXFILE length float icon_alpha; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9ff2ee4fe4b..45843bc2b1c 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1078,6 +1078,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Widget Emboss", "Color of the 1px shadow line underlying widgets"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "editor_outline", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "editor_outline"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Editor Outline", "Color of the outline of the editors and their round corners"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + /* axis */ prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "xaxis"); -- cgit v1.2.3