From b62e1146e13cf94e14d7ef8003b8a4cde87d0437 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 Mar 2020 11:40:04 +1100 Subject: UI: add view aligned gizmo color Was hard coded to white making white backgrounds impractical. D7162 by @billreynish with edits. --- source/blender/blenkernel/BKE_blender_version.h | 2 +- .../blender/blenloader/intern/versioning_userdef.c | 13 +++++++++---- source/blender/editors/include/UI_resources.h | 1 + source/blender/editors/interface/resources.c | 3 +++ .../editors/space_view3d/view3d_gizmo_ruler.c | 2 +- .../blender/editors/transform/transform_gizmo_2d.c | 22 +++++++++++++++++++--- .../blender/editors/transform/transform_gizmo_3d.c | 2 +- source/blender/makesdna/DNA_userdef_types.h | 2 +- source/blender/makesrna/intern/rna_userdef.c | 6 ++++++ 9 files changed, 42 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 2a4394ee096..18fd804c8c4 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ * \note Use #STRINGIFY() rather than defining with quotes. */ #define BLENDER_VERSION 283 -#define BLENDER_SUBVERSION 9 +#define BLENDER_SUBVERSION 10 /** 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 0f749785a47..8ed853e97c4 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -196,6 +196,15 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) FROM_DEFAULT_V4_UCHAR(space_info.info_warning); } + if (!USER_VERSION_ATLEAST(283, 10)) { + FROM_DEFAULT_V4_UCHAR(tui.gizmo_view_align); + + FROM_DEFAULT_V4_UCHAR(space_sequencer.active_strip); + FROM_DEFAULT_V4_UCHAR(space_sequencer.selected_strip); + FROM_DEFAULT_V4_UCHAR(space_sequencer.color_strip); + FROM_DEFAULT_V4_UCHAR(space_sequencer.mask); + } + /** * Versioning code until next subversion bump goes here. * @@ -207,10 +216,6 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) */ { /* Keep this block, even when empty. */ - FROM_DEFAULT_V4_UCHAR(space_sequencer.active_strip); - FROM_DEFAULT_V4_UCHAR(space_sequencer.selected_strip); - FROM_DEFAULT_V4_UCHAR(space_sequencer.color_strip); - FROM_DEFAULT_V4_UCHAR(space_sequencer.mask); } #undef FROM_DEFAULT_V4_UCHAR diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 7e510edd95b..c7300f298c0 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -315,6 +315,7 @@ typedef enum ThemeColorID { TH_GIZMO_HI, TH_GIZMO_PRIMARY, TH_GIZMO_SECONDARY, + TH_GIZMO_VIEW_ALIGN, TH_GIZMO_A, TH_GIZMO_B, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 6e18352bad3..4207a4b522a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -918,6 +918,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_GIZMO_SECONDARY: cp = btheme->tui.gizmo_secondary; break; + case TH_GIZMO_VIEW_ALIGN: + cp = btheme->tui.gizmo_view_align; + break; case TH_GIZMO_A: cp = btheme->tui.gizmo_a; break; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 83539900f36..c202cc297f4 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -864,7 +864,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4fv(color_act); + immUniformThemeColor3(TH_GIZMO_VIEW_ALIGN); imm_draw_circle_wire_2d(pos, co_ss_snap[0], co_ss_snap[1], size * U.pixelsize, 32); diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index 74f5924b717..82d51141a8b 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -315,6 +315,11 @@ static void gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup WM_gizmo_set_scale(gz, 1.0f); } else { + float color[4], color_hi[4]; + UI_GetThemeColor4fv(TH_GIZMO_VIEW_ALIGN, color); + copy_v4_v4(color_hi, color); + color[3] *= 0.6f; + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon"); RNA_property_enum_set(gz->ptr, prop, ICON_NONE); @@ -322,7 +327,8 @@ static void gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup /* Make the center low alpha. */ WM_gizmo_set_line_width(gz, 2.0f); RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.0); - WM_gizmo_set_color(gz, (const float[4]){1, 1, 1, 0.6}); + WM_gizmo_set_color(gz, color); + WM_gizmo_set_color_highlight(gz, color_hi); WM_gizmo_set_scale(gz, 0.2f); } @@ -629,6 +635,11 @@ static void gizmo2d_resize_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgrou WM_gizmo_set_scale(gz, 1.0f); } else { + float color[4], color_hi[4]; + UI_GetThemeColor4fv(TH_GIZMO_VIEW_ALIGN, color); + copy_v4_v4(color_hi, color); + color[3] *= 0.6f; + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon"); RNA_property_enum_set(gz->ptr, prop, ICON_NONE); @@ -636,7 +647,8 @@ static void gizmo2d_resize_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgrou /* Make the center low alpha. */ WM_gizmo_set_line_width(gz, 2.0f); RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.0); - WM_gizmo_set_color(gz, (const float[4]){1, 1, 1, 0.6}); + WM_gizmo_set_color(gz, color); + WM_gizmo_set_color_highlight(gz, color_hi); WM_gizmo_set_scale(gz, 1.2f); } @@ -754,6 +766,9 @@ static void gizmo2d_rotate_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgrou WM_gizmo_set_scale(gz, 1.2f); { + float color[4]; + UI_GetThemeColor4fv(TH_GIZMO_VIEW_ALIGN, color); + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon"); RNA_property_enum_set(gz->ptr, prop, ICON_NONE); @@ -761,7 +776,8 @@ static void gizmo2d_rotate_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgrou /* Make the center low alpha. */ WM_gizmo_set_line_width(gz, 2.0f); RNA_float_set(gz->ptr, "backdrop_fill_alpha", 0.0); - WM_gizmo_set_color(gz, (const float[4]){1, 1, 1, 0.6}); + WM_gizmo_set_color(gz, color); + WM_gizmo_set_color_highlight(gz, color); } /* Assign operator. */ diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 0548cc4e503..57f302e2d50 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -397,7 +397,7 @@ static void gizmo_get_axis_color(const int axis_idx, case MAN_AXIS_ROT_C: case MAN_AXIS_SCALE_C: case MAN_AXIS_ROT_T: - copy_v4_fl(r_col, 1.0f); + UI_GetThemeColor4fv(TH_GIZMO_VIEW_ALIGN, r_col); break; } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 6a3eaf2ca9a..ccd93fb9b06 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -182,6 +182,7 @@ typedef struct ThemeUI { unsigned char gizmo_hi[4]; unsigned char gizmo_primary[4]; unsigned char gizmo_secondary[4]; + unsigned char gizmo_view_align[4]; unsigned char gizmo_a[4]; unsigned char gizmo_b[4]; @@ -200,7 +201,6 @@ typedef struct ThemeUI { unsigned char icon_shading[4]; /** File folders. */ unsigned char icon_folder[4]; - char _pad2[4]; /** Intensity of the border icons. >0 will render an border around themed * icons. */ float icon_border_intensity; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index e3d83a0cf0c..69694624a2b 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1571,6 +1571,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Gizmo Secondary", ""); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "gizmo_view_align", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_view_align"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Gizmo View Align", ""); + RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "gizmo_a", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "gizmo_a"); RNA_def_property_array(prop, 3); -- cgit v1.2.3