Fix background color use in 3D view
authorCampbell Barton <ideasman42@gmail.com>
Fri, 11 Jan 2019 01:59:19 +0000 (12:59 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 11 Jan 2019 01:59:19 +0000 (12:59 +1100)
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.

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

index 7a7f804bbedc5eda9dd88cb917c23e99cde30a70..aa275d6a99e6b5d34dff15574a3decd488a6d57a 100644 (file)
@@ -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),
index bc2212f60911ba167417e3c47f6139ea305a2e5e..25daceab13dbf0be442a8a2b3121b2de0b848ceb 100644 (file)
@@ -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
index 4fed46170a900b9a961e5a647b0f418aa6b4fca4..3143c5069e619add8e3a60d3dfdd8709e2789288 100644 (file)
@@ -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;
 
index aa2f480597b0186a44f659c9ce8cd6e6acd23cbe..e611894443d25ca3fc4e0ca3b8443eec129a73cc 100644 (file)
@@ -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);
index a4a449c1ee5afc73601ee89b51cfc05a8144fb26..937378dabb47d38d9af53d752084bba3ce2f4366 100644 (file)
@@ -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). */
index 6514e4baaf32f8d59d4bfb35f88ea2a2c9435a4f..c0e735b02a68bbc626276bb55258fdffba9bb107 100644 (file)
@@ -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);
index 4c53049e7720c375edfe285cfa2ddb92a22d76a5..5f4b22c572b4d7c251c89788c1b0e43bf5668085 100644 (file)
@@ -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);
        }
 }
index 74991ad8ab1569faefe7290171b0534294ebbb0f..ef0ae332fad9748db252f819654089146766836f 100644 (file)
@@ -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,
index 5f132295c045a706c72faa5e446938d78af5a699..3aadfeb5321cd5dbb8a0872e075d207f010396cc 100644 (file)
@@ -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)
index 540806d4b671f7c1884826b4a62a94fc861fd5b5..96f18ade149658c78730bee94d526c0318f0dc5f 100644 (file)
@@ -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])
index 301dba3fac2ce641a2851edde74eb48b9df14024..a749fba502692903560d7aba35c5a72ba5e91c02 100644 (file)
@@ -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];
 
index 7600c6c98d111603e7bd5e1ce60470d224c4283d..15f20a6aba7d636e6c042cf44041a1422c80e211 100644 (file)
@@ -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);
        RNA_def_struct_ui_text(srna, "Theme Background Color", "Theme settings for background colors and gradient");
 
        prop = RNA_def_property(srna, "show_grad", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "show_back_grad", 1);
        RNA_def_property_ui_text(prop, "Use Gradient",
                                 "Do a gradient for the background of the viewport working area");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       prop = RNA_def_property(srna, "gradient", PROP_FLOAT, PROP_COLOR_GAMMA);
+       prop = RNA_def_property(srna, "high_gradient", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "back");
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Gradient Low", "");
+       RNA_def_property_ui_text(prop, "Gradient High/Off", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       prop = RNA_def_property(srna, "high_gradient", PROP_FLOAT, PROP_COLOR_GAMMA);
+       prop = RNA_def_property(srna, "gradient", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "back_grad");
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Gradient High/Off", "");
+       RNA_def_property_ui_text(prop, "Gradient Low", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
@@ -1415,6 +1424,8 @@ static void rna_def_userdef_theme_space_gradient(BlenderRNA *brna)
        /* gradient/background settings */
        prop = RNA_def_property(srna, "gradients", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_struct_type(prop, "ThemeGradientColors");
+       RNA_def_property_pointer_funcs(prop, "rna_Theme_gradient_colors_get", NULL, NULL, NULL);
        RNA_def_property_ui_text(prop, "Gradient Colors", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");