From 2269759fdf94cb7017685e4ce3f7677b3d8227ae Mon Sep 17 00:00:00 2001 From: Pawel Franitza Date: Fri, 28 Feb 2020 14:07:21 +0100 Subject: UI: add theme option for grid levels to display in node editor background Differential Revision: https://developer.blender.org/D6916 --- source/blender/blenloader/intern/versioning_userdef.c | 4 ++++ source/blender/editors/include/UI_resources.h | 1 + source/blender/editors/interface/resources.c | 3 +++ source/blender/editors/space_node/node_draw.c | 11 ++++++++--- source/blender/makesdna/DNA_userdef_types.h | 3 ++- source/blender/makesrna/intern/rna_userdef.c | 8 ++++++++ 6 files changed, 26 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index f70988c9277..2fefa56fbe5 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -188,6 +188,10 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) FROM_DEFAULT_V4_UCHAR(space_clip.time_marker_line_selected); } + if (!USER_VERSION_ATLEAST(283, 6)) { + btheme->space_node.grid_levels = U_theme_default.space_node.grid_levels; + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 10ca89c8222..8730d945c81 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -231,6 +231,7 @@ typedef enum ThemeColorID { TH_DRAWEXTRA_FACEANG, TH_NODE_CURVING, + TH_NODE_GRID_LEVELS, TH_MARKER_OUTLINE, TH_MARKER, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index cdbd049346e..4d8bfe6b418 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -640,6 +640,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_NODE_CURVING: cp = &ts->noodle_curving; break; + case TH_NODE_GRID_LEVELS: + cp = &ts->grid_levels; + break; case TH_SEQ_MOVIE: cp = ts->movie; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index d9e1216e1bb..91a42de05f2 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1691,6 +1691,8 @@ void drawnodespace(const bContext *C, ARegion *ar) snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; + int grid_levels = UI_GetThemeValueType(TH_NODE_GRID_LEVELS, SPACE_NODE); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* only set once */ @@ -1753,8 +1755,11 @@ void drawnodespace(const bContext *C, ARegion *ar) snode_setup_v2d(snode, ar, center); /* grid, uses theme color based on node path depth */ - UI_view2d_multi_grid_draw( - v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2); + UI_view2d_multi_grid_draw(v2d, + (depth > 0 ? TH_NODE_GROUP : TH_BACK), + ED_node_grid_size(), + NODE_GRID_STEPS, + grid_levels); /* backdrop */ draw_nodespace_back_pix(C, ar, snode, path->parent_key); @@ -1795,7 +1800,7 @@ void drawnodespace(const bContext *C, ARegion *ar) } else { /* default grid */ - UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2); + UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, grid_levels); /* backdrop */ draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index d0d966381d1..e79d4ccae3a 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -315,6 +315,7 @@ typedef struct ThemeSpace { unsigned char vertex_size, outline_width, obcenter_dia, facedot_size; unsigned char noodle_curving; + unsigned char grid_levels; /* syntax for textwindow and nodes */ unsigned char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte @@ -323,7 +324,7 @@ typedef struct ThemeSpace { unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort unsigned char line_numbers[4]; - char _pad6[4]; + char _pad6[3]; unsigned char nodeclass_output[4], nodeclass_filter[4]; unsigned char nodeclass_vector[4], nodeclass_texture[4]; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 3e223d613b8..4b2a512c010 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2817,6 +2817,14 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Noodle curving", "Curving of the noodle"); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "grid_levels", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "grid_levels"); + RNA_def_property_int_default(prop, 2); + RNA_def_property_range(prop, 0, 2); + RNA_def_property_ui_text( + prop, "Grid levels", "Amount of grid lines displayed in the background"); + RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "input_node", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "syntaxn"); RNA_def_property_array(prop, 3); -- cgit v1.2.3