Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRed Mser <RedMser>2020-09-16 02:42:38 +0300
committerHans Goudey <h.goudey@me.com>2020-09-16 02:42:38 +0300
commit675807e2b6b29558367d49ab7f9f30e90c975fcb (patch)
treeb06dd846a129ff2493d44b888e8786d5da2b47fc /source/blender
parent1858535a105c306282d95d1894f4f8dc088d17e4 (diff)
UI: Add grid-related theme options
This commit makes grid theming more consistent and capable by adding some new theme colors related to grid rendering. - Add grid theme color for node editor. `UI_view2d_multi_grid_draw` is called with TH_GRID instead of a shaded `TH_BACK`. Also color-blend `TH_NODE_GROUP`. - Make the movie clip editor's clip preview grid respect grid theme color (`ED_region_grid_draw` uses color-blended `TH_GRID`). - Add versioning code to allow fixing existing themes (the resulting themes should visually look the same as before) These changes did cause some inconsistencies in the movie clip editor, even after adjusting the themes accordingly: 1. The alpha slider of the grid color affects the background and not the grid lines themselves. 2. The grids used by graph and dopesheet mode could already be themed in the past. Now that the clip preview's grid can also be themed, two different modes share the same theme color. Differential Revision: https://developer.blender.org/D8699
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c7
-rw-r--r--source/blender/editors/interface/resources.c6
-rw-r--r--source/blender/editors/interface/view2d.c7
-rw-r--r--source/blender/editors/screen/area.c10
-rw-r--r--source/blender/editors/space_image/image_draw.c2
-rw-r--r--source/blender/editors/space_node/node_draw.c4
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c18
7 files changed, 37 insertions, 17 deletions
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index d53959a1949..3cc2372a2b0 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -241,6 +241,13 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
}
FROM_DEFAULT_V4_UCHAR(space_properties.match);
+
+ /* New grid theme color defaults are the same as the existing background colors,
+ * so they are copied to limit disruption. */
+ copy_v3_v3_uchar(btheme->space_clip.grid, btheme->space_clip.back);
+ btheme->space_clip.grid[3] = 255.0f;
+
+ copy_v3_v3_uchar(btheme->space_node.grid, btheme->space_node.back);
}
#undef FROM_DEFAULT_V4_UCHAR
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 87474369e8d..76ad3981586 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1246,9 +1246,9 @@ void UI_GetThemeColorBlendShade3ubv(
CLAMP(fac, 0.0f, 1.0f);
float blend[3];
- blend[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
- blend[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
- blend[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+ blend[0] = (offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0])) / 255.0f;
+ blend[1] = (offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1])) / 255.0f;
+ blend[2] = (offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2])) / 255.0f;
unit_float_to_uchar_clamp_v3(col, blend);
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 7651989c2df..9057ccaa762 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1341,7 +1341,9 @@ void UI_view2d_multi_grid_draw(
immBeginAtMost(GPU_PRIM_LINES, vertex_count);
for (int level = 0; level < totlevels; level++) {
- UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color);
+ /* Blend the background color (colorid) with the grid color, to avoid either too low contrast
+ * or high contrast grid lines. This only has an effect if colorid != TH_GRID. */
+ UI_GetThemeColorBlendShade3ubv(colorid, TH_GRID, 0.25f, offset, grid_line_color);
int i = (int)(v2d->cur.xmin / lstep);
if (v2d->cur.xmin > 0.0f) {
@@ -1382,7 +1384,8 @@ void UI_view2d_multi_grid_draw(
}
/* X and Y axis */
- UI_GetThemeColorShade3ubv(colorid, -18 + ((totlevels - 1) * -6), grid_line_color);
+ UI_GetThemeColorBlendShade3ubv(
+ colorid, TH_GRID, 0.5f, -18 + ((totlevels - 1) * -6), grid_line_color);
immAttrSkip(color);
immVertex2f(pos, 0.0f, v2d->cur.ymin);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index bfd98741ac8..58251bbb6d9 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -3660,8 +3660,12 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ float gridcolor[4];
+ UI_GetThemeColor4fv(TH_GRID, gridcolor);
+
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformThemeColorShade(TH_BACK, 20);
+ /* To fake alpha-blending, color shading is reduced when alpha is nearing 0. */
+ immUniformThemeColorBlendShade(TH_BACK, TH_GRID, gridcolor[3], 20 * gridcolor[3]);
immRectf(pos, x1, y1, x2, y2);
immUnbindProgram();
@@ -3699,7 +3703,7 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl
immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large);
float theme_color[3];
- UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color);
+ UI_GetThemeColorShade3fv(TH_GRID, (int)(20.0f * (1.0f - blendfac)), theme_color);
fac = 0.0f;
/* the fine resolution level */
@@ -3716,7 +3720,7 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl
}
if (count_large > 0) {
- UI_GetThemeColor3fv(TH_BACK, theme_color);
+ UI_GetThemeColor3fv(TH_GRID, theme_color);
fac = 0.0f;
/* the large resolution level */
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 60dd134646d..7934d600cf1 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -826,7 +826,7 @@ static void draw_udim_tile_grids(ARegion *region, SpaceImage *sima, Image *ima)
immBegin(GPU_PRIM_LINES, 8 * num_tiles);
float theme_color[3], selected_color[3];
- UI_GetThemeColorShade3fv(TH_BACK, 60.0f, theme_color);
+ UI_GetThemeColorShade3fv(TH_GRID, 60.0f, theme_color);
UI_GetThemeColor3fv(TH_FACE_SELECT, selected_color);
if (ima != NULL) {
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index fc4685929d3..0c5ec1bf80e 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1803,7 +1803,7 @@ void drawnodespace(const bContext *C, ARegion *region)
/* grid, uses theme color based on node path depth */
UI_view2d_multi_grid_draw(v2d,
- (depth > 0 ? TH_NODE_GROUP : TH_BACK),
+ (depth > 0 ? TH_NODE_GROUP : TH_GRID),
ED_node_grid_size(),
NODE_GRID_STEPS,
grid_levels);
@@ -1847,7 +1847,7 @@ void drawnodespace(const bContext *C, ARegion *region)
}
else {
/* default grid */
- UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, grid_levels);
+ UI_view2d_multi_grid_draw(v2d, TH_GRID, ED_node_grid_size(), NODE_GRID_STEPS, grid_levels);
/* backdrop */
draw_nodespace_back_pix(C, region, snode, NODE_INSTANCE_KEY_NONE);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 118a512caf9..7986e129067 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2795,6 +2795,11 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
rna_def_userdef_theme_spaces_main(srna);
rna_def_userdef_theme_spaces_list_main(srna);
+ prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Grid", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
prop = RNA_def_property(srna, "node_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "select");
RNA_def_property_array(prop, 3);
@@ -2982,6 +2987,12 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Theme Image Editor", "Theme settings for the Image Editor");
rna_def_userdef_theme_spaces_main(srna);
+
+ prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_ui_text(prop, "Grid", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
rna_def_userdef_theme_spaces_vertex(srna);
rna_def_userdef_theme_spaces_face(srna);
@@ -3066,11 +3077,6 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Metadata Text", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_array(prop, 4);
- RNA_def_property_ui_text(prop, "Grid", "");
- RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
-
rna_def_userdef_theme_spaces_curves(srna, false, false, false, true);
rna_def_userdef_theme_spaces_paint_curves(srna);
@@ -3656,7 +3662,7 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
rna_def_userdef_theme_spaces_list_main(srna);
prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_array(prop, 3);
+ RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Grid", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");