Animation: move group colors switch to user preferences

Move the "Show Group Colors" toggle from a per-editor option to a single
user preference in the Animation preferences. The Grease Pencil
animation channel side panel allows picking a channel color; this now
shows a message when channel colors are disabled.

The old "Show Group Colors" toggle had to be set per editor, and was on
by default. This meant that disabling group colors would require an
action for every file, for every editor. It is very hard to select a
color that works both as bone color in the 3D Viewport (needs to be
bright there) as well as the channel list (needs to be dark there), most
animators turn channel list colors off.

Differential Revision: https://developer.blender.org/D9391
This commit is contained in:
Sybren A. Stüvel 2020-10-30 10:57:46 +01:00
parent 25375c769a
commit ad85256e71
Notes: blender-bot 2023-02-14 06:19:41 +01:00
Referenced by commit fb82cfb539, Animation: Show Channel Group Colors is now off by default
Referenced by commit 6ed6741ee3, Point users to new location of "Show Group Colors" option
Referenced by issue #87884, Colored bone group doesn't make Keyframe names colored too in the Timeline or Dopesheet
Referenced by issue #82134, Allow disabling Group Colors in animation editors via preference
12 changed files with 52 additions and 51 deletions

View File

@ -881,13 +881,18 @@ class GreasePencilLayerDisplayPanel:
gpd = ob.data
gpl = gpd.layers.active
row = layout.row(align=True)
use_colors = context.preferences.edit.use_anim_channel_group_colors
col = layout.column(align=True)
col.active = use_colors
row = col.row(align=True)
row.prop(gpl, "channel_color")
if not use_colors:
col.label(text="Channel Colors are disabled in Animation preferences")
row = layout.row(align=True)
row.prop(gpl, "use_solo_mode", text="Show Only on Keyframed")
class GreasePencilFlipTintColors(Operator):
bl_label = "Flip Colors"
bl_idname = "gpencil.tint_flip"

View File

@ -347,7 +347,6 @@ class DOPESHEET_MT_view(Menu):
col.active = context.space_data.mode != 'SHAPEKEY'
col.prop(st, "show_sliders")
layout.prop(st, "show_group_colors")
layout.prop(st, "show_interpolation")
layout.prop(st, "show_extremes")
layout.prop(st, "use_auto_merge_keyframes")

View File

@ -543,6 +543,7 @@ class USERPREF_PT_animation_fcurves(AnimationPanel, CenterAlignMixIn, Panel):
flow.prop(edit, "keyframe_new_interpolation_type", text="Default Interpolation")
flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
flow.prop(edit, "use_anim_channel_group_colors")
# -----------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 3
#define BLENDER_FILE_SUBVERSION 4
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -808,6 +808,10 @@ void blo_do_versions_userdef(UserDef *userdef)
userdef->uiflag &= ~USER_UIFLAG_UNUSED_3;
}
if (!USER_VERSION_ATLEAST(292, 4)) {
userdef->animation_flag = USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -54,6 +54,7 @@
#include "DNA_simulation_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
#include "DNA_userdef_types.h"
#include "DNA_volume_types.h"
#include "DNA_world_types.h"
@ -170,28 +171,9 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac,
}
/* helper method to test if group colors should be drawn */
static bool acf_show_channel_colors(bAnimContext *ac)
static bool acf_show_channel_colors(void)
{
bool showGroupColors = false;
if (ac->sl) {
switch (ac->spacetype) {
case SPACE_ACTION: {
SpaceAction *saction = (SpaceAction *)ac->sl;
showGroupColors = !(saction->flag & SACTION_NODRAWGCOLORS);
break;
}
case SPACE_GRAPH: {
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
showGroupColors = !(sipo->flag & SIPO_NODRAWGCOLORS);
break;
}
}
}
return showGroupColors;
return (U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS) != 0;
}
/* get backdrop color for generic channels */
@ -200,7 +182,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
bActionGroup *grp = NULL;
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
bool showGroupColors = acf_show_channel_colors(ac);
bool showGroupColors = acf_show_channel_colors();
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
@ -240,7 +222,7 @@ static void acf_gpencil_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
bool showGroupColors = acf_show_channel_colors(ac);
bool showGroupColors = acf_show_channel_colors();
if ((showGroupColors) && (ale->type == ANIMTYPE_GPLAYER)) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
@ -848,10 +830,10 @@ static bAnimChannelType ACF_OBJECT = {
/* Group ------------------------------------------- */
/* get backdrop color for group widget */
static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
static void acf_group_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3])
{
bActionGroup *agrp = (bActionGroup *)ale->data;
bool showGroupColors = acf_show_channel_colors(ac);
bool showGroupColors = acf_show_channel_colors();
if (showGroupColors && agrp->customCol) {
uchar cp[3];

View File

@ -145,7 +145,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
uchar col1a[4], col2a[4];
uchar col1b[4], col2b[4];
const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS);
const bool show_group_colors = U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
/* get theme colors */
UI_GetThemeColor4ubv(TH_SHADE2, col2);

View File

@ -857,7 +857,7 @@ typedef enum eSAction_Flag {
/* show pose-markers (local to action) in Action Editor mode */
SACTION_POSEMARKERS_SHOW = (1 << 6),
/* don't draw action channels using group colors (where applicable) */
SACTION_NODRAWGCOLORS = (1 << 7),
/* SACTION_NODRAWGCOLORS = (1 << 7), DEPRECATED */
/* SACTION_NODRAWCFRANUM = (1 << 8), DEPRECATED */
/* don't perform realtime updates */
SACTION_NOREALTIMEUPDATES = (1 << 10),

View File

@ -465,7 +465,7 @@ typedef enum eGraphEdit_Flag {
/* don't draw curves with AA ("beauty-draw") for performance */
SIPO_BEAUTYDRAW_OFF = (1 << 12),
/* draw grouped channels with colors set in group */
SIPO_NODRAWGCOLORS = (1 << 13),
/* SIPO_NODRAWGCOLORS = (1 << 13), DEPRECATED */
/* normalize curves on display */
SIPO_NORMALIZE = (1 << 14),
SIPO_NORMALIZE_FREEZE = (1 << 15),

View File

@ -826,13 +826,13 @@ typedef struct UserDef {
short autokey_mode;
/** Flags for autokeying. */
short autokey_flag;
/** Flags for animation. */
short animation_flag;
/** Options for text rendering. */
char text_render;
char navigation_mode;
char _pad9[2];
/** Turn-table rotation amount per-pixel in radians. Scaled with DPI. */
float view_rotate_sensitivity_turntable;
/** Track-ball rotation scale. */
@ -1147,6 +1147,15 @@ typedef enum eAutokey_Flag {
ANIMRECORD_FLAG_WITHNLA = (1 << 10),
} eAutokey_Flag;
/**
* Animation flags
* #UserDef.animation_flag, used for animation flags that aren't covered by more specific flags
* (like eAutokey_Flag).
*/
typedef enum eUserpref_Anim_Flags {
USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0),
} eUserpref_Anim_Flags;
/** #UserDef.transopts */
typedef enum eUserpref_Translation_Flags {
USER_TR_TOOLTIPS = (1 << 0),

View File

@ -5175,15 +5175,6 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
"(Action and Shape Key Editors only)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NODRAWGCOLORS);
RNA_def_property_ui_text(
prop,
"Show Group Colors",
"Display groups and channels with colors matching their corresponding groups "
"(pose bones only currently)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
prop = RNA_def_property(srna, "show_interpolation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_SHOW_INTERPOLATION);
RNA_def_property_ui_text(prop,
@ -5351,14 +5342,6 @@ static void rna_def_space_graph(BlenderRNA *brna)
"(disable for better performance)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWGCOLORS);
RNA_def_property_ui_text(
prop,
"Show Group Colors",
"Display groups and channels with colors matching their corresponding groups");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
prop = RNA_def_property(srna, "show_markers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SHOW_MARKERS);
RNA_def_property_ui_text(

View File

@ -409,6 +409,15 @@ static void rna_userdef_autokeymode_set(PointerRNA *ptr, int value)
}
}
static void rna_userdef_anim_update(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *UNUSED(ptr))
{
WM_main_add_notifier(NC_SPACE | ND_SPACE_GRAPH, NULL);
WM_main_add_notifier(NC_SPACE | ND_SPACE_DOPESHEET, NULL);
USERDEF_TAG_DIRTY;
}
static void rna_userdef_tablet_api_update(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *UNUSED(ptr))
@ -4994,6 +5003,15 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
"Color for newly added transformation F-Curves (Location, Rotation, Scale) "
"and also Color is based on the transform axis");
prop = RNA_def_property(srna, "use_anim_channel_group_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "animation_flag", USER_ANIM_SHOW_CHANNEL_GROUP_COLORS);
RNA_def_property_ui_text(
prop,
"Channel Group Colors",
"Use animation channel group colors; generally this is used to show bone group colors");
RNA_def_property_boolean_default(prop, true);
RNA_def_property_update(prop, 0, "rna_userdef_anim_update");
prop = RNA_def_property(srna, "fcurve_new_auto_smoothing", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_fcurve_auto_smoothing_items);
RNA_def_property_enum_sdna(prop, NULL, "auto_smoothing_new");