Commit: 1386a4a0f2b03f44f123381448240652788cca29
Author: Campbell Barton
Date:   Thu Nov 15 00:05:54 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB1386a4a0f2b03f44f123381448240652788cca29

Gizmo: get background color based on view option

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

M       source/blender/editors/include/ED_view3d.h
M       source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
M       source/blender/editors/space_view3d/view3d_utils.c

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

diff --git a/source/blender/editors/include/ED_view3d.h 
b/source/blender/editors/include/ED_view3d.h
index 35c92c3561b..f0c805eea8d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -107,6 +107,7 @@ enum eV3DCursorOrient {
        V3D_CURSOR_ORIENT_GEOM,
 };
 
+void ED_view3d_background_color_get(const struct Scene *scene, const struct 
View3D *v3d, float r_color[3]);
 struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D 
*v3d);
 void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct 
View3D *v3d, float mat[3][3]);
 void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct 
View3D *v3d, float mat[4][4]);
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c 
b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
index 3ea563fb918..acffb29c82a 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
@@ -184,7 +184,10 @@ static void draw_xyz_wire(
 
 static void axis_geom_draw(
         const wmGizmo *gz, const float color[4], const bool UNUSED(select),
-        /* Needed for screen-aligned font drawing. */
+#ifdef USE_FADE_BACKGROUND
+        const float color_bg[3],
+#endif
+        /* Matrix is needed for screen-aligned font drawing. */
         const float matrix_final[4][4])
 {
        GPU_line_width(gz->line_width);
@@ -253,11 +256,6 @@ static void axis_geom_draw(
                }
        }
 
-#ifdef USE_FADE_BACKGROUND
-       float color_bg[3];
-       UI_GetThemeColor3fv(TH_HIGH_GRAD, color_bg);
-#endif
-
        for (int axis_index = 0; axis_index < ARRAY_SIZE(axis_order); 
axis_index++) {
                const int index = axis_order[axis_index].index;
                const int axis = axis_order[axis_index].axis;
@@ -376,7 +374,7 @@ static void axis_geom_draw(
 }
 
 static void axis3d_draw_intern(
-        const bContext *UNUSED(C), wmGizmo *gz,
+        const bContext *C, wmGizmo *gz,
         const bool select, const bool highlight)
 {
        const float *color = highlight ? gz->color_hi : gz->color;
@@ -394,8 +392,25 @@ static void axis3d_draw_intern(
        GPU_matrix_push();
        GPU_matrix_mul(matrix_final);
 
+#ifdef USE_FADE_BACKGROUND
+       float color_bg[3];
+       if (select == false) {
+               ED_view3d_background_color_get(CTX_data_scene(C), 
CTX_wm_view3d(C), color_bg);
+       }
+       else {
+               zero_v3(color_bg);
+       }
+#else
+       UNUSED_VARS(C);
+#endif
+
        GPU_blend(true);
-       axis_geom_draw(gz, color, select, matrix_final);
+       axis_geom_draw(
+               gz, color, select,
+#ifdef USE_FADE_BACKGROUND
+               color_bg,
+#endif
+               matrix_final);
        GPU_blend(false);
        GPU_matrix_pop();
 }
diff --git a/source/blender/editors/space_view3d/view3d_utils.c 
b/source/blender/editors/space_view3d/view3d_utils.c
index 9b006bf4d9b..022fccd7ce7 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -36,6 +36,7 @@
 #include "DNA_curve_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_world_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -65,6 +66,8 @@
 #include "ED_screen.h"
 #include "ED_view3d.h"
 
+#include "UI_resources.h"
+
 #include "view3d_intern.h"  /* own include */
 
 /* -------------------------------------------------------------------- */
@@ -72,6 +75,22 @@
  *
  * \{ */
 
+void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, 
float r_color[3])
+{
+       switch (v3d->shading.background_type) {
+               case V3D_SHADING_BACKGROUND_WORLD:
+                       copy_v3_v3(r_color, &scene->world->horr);
+                       break;
+               case V3D_SHADING_BACKGROUND_VIEWPORT:
+                       copy_v3_v3(r_color, v3d->shading.background_color);
+                       break;
+               case V3D_SHADING_BACKGROUND_THEME:
+               default:
+                       UI_GetThemeColor3fv(TH_HIGH_GRAD, r_color);
+                       break;
+       }
+}
+
 View3DCursor *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
 {
        if (v3d && v3d->localvd) {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to