From 493c4dd65ba7f135c1904a3f88f83000697cc78d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 10 May 2023 14:19:27 +0200 Subject: [PATCH] Geometry Nodes: add theme option for simulated frames in timeline The new theme setting for the dope sheet (timeline) allows changing the color of the bar that shows which frames are cached/baked. The invalid/cached/baked status is differentiated by hardcoded transparency values. In theory, those could be separate theme settings though. Pull Request: https://projects.blender.org/blender/blender/pulls/107738 --- release/datafiles/userdef/userdef_default_theme.c | 1 + source/blender/blenloader/intern/versioning_userdef.c | 1 + source/blender/editors/include/UI_resources.h | 1 + source/blender/editors/interface/resources.cc | 3 +++ source/blender/editors/space_action/action_draw.cc | 7 ++++--- source/blender/makesdna/DNA_userdef_types.h | 2 +- source/blender/makesrna/intern/rna_userdef.c | 6 ++++++ 7 files changed, 17 insertions(+), 4 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 14c1b9d2a94..2da837a3d51 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -567,6 +567,7 @@ const bTheme U_theme_default = { .handle_vertex_size = 4, .anim_active = RGBA(0x4d272766), .anim_preview_range = RGBA(0xa14d0066), + .simulated_frames = RGBA(0x721e65ff), }, .space_nla = { .back = RGBA(0x30303000), diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 1f62b887ec3..7a74e65793d 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -109,6 +109,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) { /* Keep this block, even when empty. */ FROM_DEFAULT_V4_UCHAR(space_node.node_zone_simulation); + FROM_DEFAULT_V4_UCHAR(space_action.simulated_frames); } #undef FROM_DEFAULT_V4_UCHAR diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 14cf889ed6d..ea97b7815ea 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -180,6 +180,7 @@ typedef enum ThemeColorID { TH_NODE_ATTRIBUTE, TH_NODE_ZONE_SIMULATION, + TH_SIMULATED_FRAMES, TH_CONSOLE_OUTPUT, TH_CONSOLE_INPUT, diff --git a/source/blender/editors/interface/resources.cc b/source/blender/editors/interface/resources.cc index cbcd3757f93..894aaa935e3 100644 --- a/source/blender/editors/interface/resources.cc +++ b/source/blender/editors/interface/resources.cc @@ -644,6 +644,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_NODE_ZONE_SIMULATION: cp = ts->node_zone_simulation; break; + case TH_SIMULATED_FRAMES: + cp = ts->simulated_frames; + break; case TH_SEQ_MOVIE: cp = ts->movie; diff --git a/source/blender/editors/space_action/action_draw.cc b/source/blender/editors/space_action/action_draw.cc index 8574175c739..a85e28b781f 100644 --- a/source/blender/editors/space_action/action_draw.cc +++ b/source/blender/editors/space_action/action_draw.cc @@ -691,17 +691,18 @@ static void timeline_cache_draw_simulation_nodes( GPU_matrix_scale_2f(1.0, height); float color[4]; + UI_GetThemeColor4fv(TH_SIMULATED_FRAMES, color); switch (cache.cache_state()) { case blender::bke::sim::CacheState::Invalid: { - copy_v4_fl4(color, 0.8, 0.8, 0.2, 0.3); + color[3] = 0.4f; break; } case blender::bke::sim::CacheState::Valid: { - copy_v4_fl4(color, 0.8, 0.8, 0.2, 1.0); + color[3] = 0.7f; break; } case blender::bke::sim::CacheState::Baked: { - copy_v4_fl4(color, 1.0, 0.6, 0.2, 1.0); + color[3] = 1.0f; break; } } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 224eef908dd..e0ac3c2437a 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -345,7 +345,7 @@ typedef struct ThemeSpace { unsigned char nodeclass_geometry[4], nodeclass_attribute[4]; unsigned char node_zone_simulation[4]; - char _pad8[4]; + unsigned char simulated_frames[4]; /** For sequence editor. */ unsigned char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index a4410936454..2437b4c61a4 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3563,6 +3563,12 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Interpolation Line", "Color of lines showing non-bezier interpolation modes"); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + + prop = RNA_def_property(srna, "simulated_frames", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "simulated_frames"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Simulated Frames", ""); + RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); } static void rna_def_userdef_theme_space_nla(BlenderRNA *brna)