[Bf-blender-cvs] [5c6d5cb8639] master: Fix background color use in 3D view

Campbell Barton noreply at git.blender.org
Fri Jan 11 03:06:33 CET 2019


Commit: 5c6d5cb8639aa71e2728258e9a4afe7c9d822bc7
Author: Campbell Barton
Date:   Fri Jan 11 12:59:19 2019 +1100
Branches: master
https://developer.blender.org/rB5c6d5cb8639aa71e2728258e9a4afe7c9d822bc7

Fix background color use in 3D view

TH_BACK was being used when drawing the 3D view even though
there was no way to set the color in the preferences.

The color was zero'd when moving to the new 2.8x theme.

Having both gradient and background colors was confusing,
especially having to use 'TH_HIGH_GRAD' for the 3D view, 'TH_BACK' for
other views.

Move the background color back to 'TH_BACK', 'TH_BACK_GRAD' is used
when gradients are enabled.
RNA is unchanged so presets don't need updating.

===================================================================

M	release/datafiles/userdef/userdef_default_theme.c
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/draw/engines/eevee/eevee_lookdev.c
M	source/blender/draw/engines/workbench/workbench_data.c
M	source/blender/draw/intern/draw_common.c
M	source/blender/draw/intern/draw_view.c
M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_view3d/view3d_utils.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 7a7f804bbed..aa275d6a99e 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -279,6 +279,7 @@ const bTheme U_theme_default = {
 		.facedot_size = 4,
 	},
 	.tv3d = {
+		.back = RGBA(0x393939ff),
 		.title = RGBA(0xeeeeeeff),
 		.text = RGBA(0xe6e6e6ff),
 		.text_hi = RGBA(0xffffffff),
@@ -298,10 +299,6 @@ const bTheme U_theme_default = {
 			.back = RGBA(0x333333f0),
 			.sub_back = RGBA(0x0000003e),
 		},
-		.gradients = {
-			.gradient = RGBA(0x39393900),
-			.high_gradient = RGBA(0x393939ff),
-		},
 		.grid = RGBA(0xa7a7a733),
 		.wire = RGBA(0x000000ff),
 		.wire_edit = RGBA(0x111111ff),
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index bc2212f6091..25daceab13d 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      40
+#define BLENDER_SUBVERSION      41
 /* Several breakages with 280, e.g. collections vs layers */
 #define BLENDER_MINVERSION      280
 #define BLENDER_MINSUBVERSION   0
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 4fed46170a9..3143c5069e6 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -108,6 +108,10 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
 		copy_v4_v4_char(btheme->tuserpref.execution_buts, btheme->tuserpref.navigation_bar);
 	}
 
+	if (!USER_VERSION_ATLEAST(280, 41)) {
+		copy_v4_v4_char(btheme->tv3d.back, U_theme_default.tv3d.back);
+	}
+
 #undef USER_VERSION_ATLEAST
 }
 
@@ -465,10 +469,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
 		        USER_UIFLAG_DEPRECATED_22);
 	}
 
-	/**
-	 * Include next version bump.
-	 */
-	{
+	if (!USER_VERSION_ATLEAST(280, 41)) {
 		/* (keep this block even if it becomes empty). */
 
 		if (userdef->pie_tap_timeout == 0) {
@@ -476,6 +477,13 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
 		}
 	}
 
+	/**
+	 * Include next version bump.
+	 */
+	{
+		/* (keep this block even if it becomes empty). */
+	}
+
 	if (userdef->pixelsize == 0.0f)
 		userdef->pixelsize = 1.0f;
 
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index aa2f480597b..e611894443d 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -109,7 +109,7 @@ void EEVEE_lookdev_cache_init(
 			stl->g_data->light_cache = stl->lookdev_lightcache;
 
 			static float background_color[4];
-			UI_GetThemeColor4fv(TH_HIGH_GRAD, background_color);
+			UI_GetThemeColor4fv(TH_BACK, background_color);
 			/* XXX: Really quick conversion to avoid washed out background.
 			 * Needs to be addressed properly (color managed using ocio). */
 			srgb_to_linearrgb_v4(background_color, background_color);
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index a4a449c1ee5..937378dabb4 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -67,8 +67,8 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
 		copy_v3_v3(wd->background_color_high, v3d->shading.background_color);
 	}
 	else if (v3d) {
-		UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low);
-		UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
+		UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_BACK_GRAD : TH_BACK, wd->background_color_low);
+		UI_GetThemeColor3fv(TH_BACK, wd->background_color_high);
 
 		/* XXX: Really quick conversion to avoid washed out background.
 		 * Needs to be addressed properly (color managed using ocio). */
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 6514e4baaf3..c0e735b02a6 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -60,8 +60,8 @@ void DRW_globals_update(void)
 	UI_GetThemeColor4fv(TH_WIRE_EDIT, ts.colorWireEdit);
 	UI_GetThemeColor4fv(TH_ACTIVE, ts.colorActive);
 	UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect);
-	UI_GetThemeColorBlend4f(TH_SELECT, TH_HIGH_GRAD, 0.66f, ts.colorDupliSelect);
-	UI_GetThemeColorBlend4f(TH_WIRE, TH_HIGH_GRAD, 0.66f, ts.colorDupli);
+	UI_GetThemeColorBlend4f(TH_SELECT, TH_BACK, 0.5f, ts.colorDupliSelect);
+	UI_GetThemeColorBlend4f(TH_WIRE, TH_BACK, 0.5f, ts.colorDupli);
 	UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, ts.colorLibrarySelect);
 	UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, ts.colorLibrary);
 	UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform);
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 4c53049e772..5f4b22c572b 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -95,8 +95,8 @@ void DRW_draw_background(void)
 
 		immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER);
 
-		UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
-		UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
+		UI_GetThemeColor3ubv(TH_BACK_GRAD, col_lo);
+		UI_GetThemeColor3ubv(TH_BACK, col_hi);
 
 		immBegin(GPU_PRIM_TRI_FAN, 4);
 		immAttr3ubv(color, col_lo);
@@ -118,7 +118,7 @@ void DRW_draw_background(void)
 	}
 	else {
 		/* Solid background Color */
-		UI_ThemeClearColorAlpha(TH_HIGH_GRAD, 1.0f);
+		UI_ThemeClearColorAlpha(TH_BACK, 1.0f);
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 	}
 }
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 74991ad8ab1..ef0ae332fad 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -58,6 +58,8 @@ typedef enum ThemeColorID {
 // common colors among spaces
 
 	TH_BACK,
+	/** Use when 'TH_SHOW_BACK_GRAD' is set (the lower, darker color). */
+	TH_BACK_GRAD,
 	TH_TEXT,
 	TH_TEXT_HI,
 	TH_TITLE,
@@ -296,8 +298,6 @@ typedef enum ThemeColorID {
 	TH_GIZMO_A,
 	TH_GIZMO_B,
 
-	TH_LOW_GRAD,
-	TH_HIGH_GRAD,
 	TH_SHOW_BACK_GRAD,
 
 	TH_INFO_SELECTED,
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 5f132295c04..3aadfeb5321 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -194,15 +194,13 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
 					}
 					cp = back;
 					break;
-				case TH_LOW_GRAD:
-					cp = ts->gradients.gradient;
-					break;
-				case TH_HIGH_GRAD:
-					cp = ts->gradients.high_gradient;
+				case TH_BACK_GRAD:
+					cp = ts->back_grad;
 					break;
+
 				case TH_SHOW_BACK_GRAD:
 					cp = &setting;
-					setting = ts->gradients.show_grad;
+					setting = ts->show_back_grad;
 					break;
 				case TH_TEXT:
 					if (theme_regionid == RGN_TYPE_WINDOW)
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 540806d4b67..96f18ade149 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -88,7 +88,7 @@ void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float
 		return;
 	}
 
-	UI_GetThemeColor3fv(TH_HIGH_GRAD, r_color);
+	UI_GetThemeColor3fv(TH_BACK, r_color);
 }
 
 void ED_view3d_cursor3d_calc_mat3(const Scene *scene, float mat[3][3])
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 301dba3fac2..a749fba5026 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -164,13 +164,6 @@ typedef struct uiPanelColors {
 	char pad2[4];
 } uiPanelColors;
 
-typedef struct uiGradientColors {
-	char gradient[4];
-	char high_gradient[4];
-	int show_grad;
-	int pad2;
-} uiGradientColors;
-
 typedef struct ThemeUI {
 	/* Interface Elements (buttons, menus, icons) */
 	uiWidgetColors wcol_regular, wcol_tool, wcol_toolbar_item, wcol_text;
@@ -227,6 +220,11 @@ typedef struct ThemeUI {
 typedef struct ThemeSpace {
 	/* main window colors */
 	char back[4];
+	char back_grad[4];
+
+	char show_back_grad;
+	char _pad0[3];
+
 	/** Panel title. */
 	char title[4];
 	char text[4];
@@ -277,8 +275,6 @@ typedef struct ThemeSpace {
 	/* note, cannot use name 'panel' because of DNA mapping old files */
 	uiPanelColors panelcolors;
 
-	uiGradientColors gradients;
-
 	char shade1[4];
 	char shade2[4];
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 7600c6c98d1..15f20a6aba7 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -418,6 +418,11 @@ static PointerRNA rna_Theme_space_generic_get(PointerRNA *ptr)
 	return rna_pointer_inherit_refine(ptr, &RNA_ThemeSpaceGeneric, ptr->data);
 }
 
+static PointerRNA rna_Theme_gradient_colors_get(PointerRNA *ptr)
+{
+	return rna_pointer_inherit_refine(ptr, &RNA_ThemeGradientColors, ptr->data);
+}
+
 static PointerRNA rna_Theme_space_gradient_get(PointerRNA *ptr)
 {
 	return rna_pointer_inherit_refine(ptr, &RNA_ThemeSpaceGradient, ptr->data);
@@ -1045,27 +1050,31 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna)
 
 static void rna_def_userdef_theme_ui_gradient(BlenderRNA *brna)
 {
+	/* Fake struct, keep this for compatible theme presets. */
 	StructRNA *srna;
 	PropertyRNA *prop;
 
 	srna = RNA_def_struct(brna, "ThemeGradientColors", NULL);
-	RNA_def_struct_sdna(srna, "uiGradientColors");
+	RNA_def_struct_sdna(srna, "ThemeSpace");
 	RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
 	R

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list