Anim: Improve readability of channel colors in channel list #112861

Manually merged
Sybren A. Stüvel merged 8 commits from dr.sybren/blender:pr/69059-anim-channel-bg-color into main 2023-09-29 08:44:13 +02:00
5 changed files with 151 additions and 130 deletions

View File

@ -876,6 +876,7 @@ void blo_do_versions_userdef(UserDef *userdef)
*/
{
/* Keep this block, even when empty. */
userdef->animation_flag |= USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
}
LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) {

View File

@ -174,58 +174,12 @@ static bool acf_show_channel_colors()
static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
bActionGroup *grp = nullptr;
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
bool showGroupColors = acf_show_channel_colors();
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
grp = fcu->grp;
}
/* set color for normal channels
* - use 3 shades of color group/standard color for 3 indentation level
* - only use group colors if allowed to, and if actually feasible
*/
if (showGroupColors && (grp) && (grp->customCol)) {
uchar cp[3];
if (indent == 2) {
copy_v3_v3_uchar(cp, grp->cs.solid);
}
else if (indent == 1) {
copy_v3_v3_uchar(cp, grp->cs.select);
}
else {
copy_v3_v3_uchar(cp, grp->cs.active);
}
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
}
else {
/* FIXME: what happens when the indentation is 1 greater than what it should be
* (due to grouping)? */
int colOfs = 10 - 10 * indent;
UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
}
}
/* get backdrop color for grease pencil channels */
static void acf_gpencil_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
{
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();
if ((showGroupColors) && (ale->type == ANIMTYPE_GPLAYER)) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
copy_v3_v3(r_color, gpl->color);
}
else {
int colOfs = 10 - 10 * indent;
UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
}
/* FIXME: what happens when the indentation is 1 greater than what it should be
* (due to grouping)? */
int colOfs = 10 - 10 * indent;
dr.sybren marked this conversation as resolved
Review

This variable name took me a bit to grok. colOffset would be better, I think.

This variable name took me a bit to grok. `colOffset` would be better, I think.
UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
}
/* backdrop for generic channels */
@ -519,6 +473,7 @@ static bAnimChannelType ACF_SUMMARY = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_summary_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_summary_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ nullptr,
@ -630,6 +585,7 @@ static bAnimChannelType ACF_SCENE = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_root_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_root_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ nullptr,
@ -810,6 +766,7 @@ static bAnimChannelType ACF_OBJECT = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_root_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_root_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ nullptr,
@ -828,31 +785,11 @@ static bAnimChannelType ACF_OBJECT = {
/* get backdrop color for group widget */
static void acf_group_color(bAnimContext * /*ac*/, bAnimListElem *ale, float r_color[3])
{
bActionGroup *agrp = (bActionGroup *)ale->data;
bool showGroupColors = acf_show_channel_colors();
if (showGroupColors && agrp->customCol) {
uchar cp[3];
/* highlight only for active */
if (ale->flag & AGRP_ACTIVE) {
copy_v3_v3_uchar(cp, agrp->cs.select);
}
else {
copy_v3_v3_uchar(cp, agrp->cs.solid);
}
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
if (ale->flag & AGRP_ACTIVE) {
UI_GetThemeColor3fv(TH_GROUP_ACTIVE, r_color);
}
else {
/* highlight only for active */
if (ale->flag & AGRP_ACTIVE) {
UI_GetThemeColor3fv(TH_GROUP_ACTIVE, r_color);
}
else {
UI_GetThemeColor3fv(TH_GROUP, r_color);
}
UI_GetThemeColor3fv(TH_GROUP, r_color);
}
}
@ -977,12 +914,45 @@ static void *acf_group_setting_ptr(bAnimListElem *ale,
return GET_ACF_FLAG_PTR(agrp->flag, r_type);
}
static bool get_actiongroup_color(const bActionGroup *agrp, uint8_t r_color[3])
{
if (!agrp) {
return false;
}
const int8_t color_index = agrp->customCol;
if (color_index == 0) {
return false;
}
const ThemeWireColor *wire_color;
if (color_index < 0) {
wire_color = &agrp->cs;
}
else {
const bTheme *btheme = UI_GetTheme();
wire_color = &btheme->tarm[(color_index - 1)];
}
r_color[0] = wire_color->solid[0];
r_color[1] = wire_color->solid[1];
r_color[2] = wire_color->solid[2];
return true;
}
static bool acf_group_channel_color(const bAnimListElem *ale, uint8_t r_color[3])
{
const bActionGroup *agrp = static_cast<const bActionGroup *>(ale->data);
return get_actiongroup_color(agrp, r_color);
}
/** Group type define. */
static bAnimChannelType ACF_GROUP = {
/*channel_type_name*/ "Group",
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_group_color,
/*get_channel_color*/ acf_group_channel_color,
/*draw_backdrop*/ acf_group_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ acf_generic_group_offset,
@ -1090,12 +1060,19 @@ static void *acf_fcurve_setting_ptr(bAnimListElem *ale,
return GET_ACF_FLAG_PTR(fcu->flag, r_type);
}
static bool acf_fcurve_channel_color(const bAnimListElem *ale, uint8_t r_color[3])
{
const FCurve *fcu = static_cast<const FCurve *>(ale->data);
return get_actiongroup_color(fcu->grp, r_color);
}
/** F-Curve type define. */
static bAnimChannelType ACF_FCURVE = {
/*channel_type_name*/ "F-Curve",
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_generic_channel_color,
/*get_channel_color*/ acf_fcurve_channel_color,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_flexible,
/* XXX rename this to f-curves only? */
@ -1212,6 +1189,7 @@ static bAnimChannelType ACF_NLACONTROLS = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_nla_controls_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_nla_controls_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ acf_generic_group_offset,
@ -1252,6 +1230,7 @@ static bAnimChannelType ACF_NLACURVE = {
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_generic_channel_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_group_offset,
@ -1342,6 +1321,7 @@ static bAnimChannelType ACF_FILLACTD = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -1427,6 +1407,7 @@ static bAnimChannelType ACF_FILLDRIVERS = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -1508,6 +1489,7 @@ static bAnimChannelType ACF_DSMAT = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -1589,6 +1571,7 @@ static bAnimChannelType ACF_DSLIGHT = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -1677,6 +1660,7 @@ static bAnimChannelType ACF_DSTEX = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_dstex_offset,
@ -1762,6 +1746,7 @@ static bAnimChannelType ACF_DSCACHEFILE = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -1847,6 +1832,7 @@ static bAnimChannelType ACF_DSCAM = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -1938,6 +1924,7 @@ static bAnimChannelType ACF_DSCUR = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2038,6 +2025,7 @@ static bAnimChannelType ACF_DSSKEY = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2119,6 +2107,7 @@ static bAnimChannelType ACF_DSWOR = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2200,6 +2189,7 @@ static bAnimChannelType ACF_DSPART = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2281,6 +2271,7 @@ static bAnimChannelType ACF_DSMBALL = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2362,6 +2353,7 @@ static bAnimChannelType ACF_DSARM = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2454,6 +2446,7 @@ static bAnimChannelType ACF_DSNTREE = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_dsntree_offset,
@ -2535,6 +2528,7 @@ static bAnimChannelType ACF_DSLINESTYLE = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2616,6 +2610,7 @@ static bAnimChannelType ACF_DSMESH = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/* XXX: this only works for compositing. */
@ -2698,6 +2693,7 @@ static bAnimChannelType ACF_DSLAT = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/* XXX: this only works for compositing. */
@ -2780,6 +2776,7 @@ static bAnimChannelType ACF_DSSPK = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2861,6 +2858,7 @@ static bAnimChannelType ACF_DSCURVES = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -2941,6 +2939,7 @@ static bAnimChannelType ACF_DSPOINTCLOUD = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -3021,6 +3020,7 @@ static bAnimChannelType ACF_DSVOLUME = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -3101,6 +3101,7 @@ static bAnimChannelType ACF_DSGPENCIL = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -3182,6 +3183,7 @@ static bAnimChannelType ACF_DSMCLIP = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_generic_dataexpand_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_dataexpand_backdrop,
/*get_indent_level*/ acf_generic_indentation_1,
/*get_offset*/ acf_generic_basic_offset,
@ -3297,6 +3299,7 @@ static bAnimChannelType ACF_SHAPEKEY = {
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_generic_channel_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ acf_generic_basic_offset,
@ -3379,6 +3382,7 @@ static bAnimChannelType ACF_GPD_LEGACY = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_gpd_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_group_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ acf_generic_group_offset,
@ -3463,6 +3467,13 @@ static int acf_gpl_setting_flag_legacy(bAnimContext * /*ac*/,
}
}
static bool acf_gpl_channel_color(const bAnimListElem *ale, uint8_t r_color[3])
{
const bGPDlayer *gpl = static_cast<const bGPDlayer *>(ale->data);
rgb_float_to_uchar(r_color, gpl->color);
return true;
}
/* get pointer to the setting */
static void *acf_gpl_setting_ptr_legacy(bAnimListElem *ale,
eAnimChannel_Settings /*setting*/,
@ -3479,7 +3490,8 @@ static bAnimChannelType ACF_GPL_LEGACY = {
/*channel_type_name*/ "GPencil Layer",
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_gpencil_channel_color,
/*get_backdrop_color*/ acf_generic_channel_color,
/*get_channel_color*/ acf_gpl_channel_color,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_flexible,
/*get_offset*/ acf_generic_group_offset,
@ -3675,6 +3687,7 @@ static bAnimChannelType ACF_GPD = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_gpd_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_group_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ acf_generic_group_offset,
@ -3693,7 +3706,8 @@ static bAnimChannelType ACF_GPL = {
/*channel_type_name*/ "Grease Pencil Layer",
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_gpencil_channel_color,
/*get_backdrop_color*/ acf_generic_channel_color,
/*get_channel_color*/ acf_gpl_channel_color,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_flexible,
/*get_offset*/ greasepencil::layer_offset,
@ -3713,6 +3727,7 @@ static bAnimChannelType ACF_GPLGROUP = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ greasepencil::layer_group_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_group_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ greasepencil::layer_offset,
@ -3793,6 +3808,7 @@ static bAnimChannelType ACF_MASKDATA = {
/*channel_role*/ ACHANNEL_ROLE_EXPANDER,
/*get_backdrop_color*/ acf_mask_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_group_backdrop,
/*get_indent_level*/ acf_generic_indentation_0,
/*get_offset*/ acf_generic_group_offset,
@ -3889,6 +3905,7 @@ static bAnimChannelType ACF_MASKLAYER = {
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_generic_channel_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_flexible,
/*get_offset*/ acf_generic_group_offset,
@ -4029,6 +4046,7 @@ static bAnimChannelType ACF_NLATRACK = {
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/*get_backdrop_color*/ acf_nlatrack_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_generic_channel_backdrop,
/*get_indent_level*/ acf_generic_indentation_flexible,
/*get_offset*/ acf_generic_group_offset, /* XXX? */
@ -4210,6 +4228,7 @@ static bAnimChannelType ACF_NLAACTION = {
/*channel_role*/ ACHANNEL_ROLE_CHANNEL,
/* NOTE: the backdrop handles this too, since it needs special hacks. */
/*get_backdrop_color*/ acf_nlaaction_color,
/*get_channel_color*/ nullptr,
/*draw_backdrop*/ acf_nlaaction_backdrop,
/*get_indent_level*/ acf_generic_indentation_flexible,
@ -4509,6 +4528,9 @@ void ANIM_channel_setting_set(bAnimContext *ac,
/** Extra offset for the visibility icons in the graph editor. */
#define GRAPH_ICON_VISIBILITY_OFFSET (GRAPH_COLOR_BAND_WIDTH * 1.5f)
#define CHANNEL_COLOR_RECT_WIDTH (0.5f * ICON_WIDTH)
#define CHANNEL_COLOR_RECT_MARGIN (2.0f * UI_SCALE_FAC)
/* Helper - Check if a channel needs renaming */
static bool achannel_is_being_renamed(const bAnimContext *ac,
const bAnimChannelType *acf,
@ -4774,6 +4796,14 @@ void ANIM_channel_draw(
/* check if there's enough space for the toggles if the sliders are drawn too */
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2))
{
/* NOTE: The comments here match the comments in ANIM_channel_draw_widgets(), as that
* function and this one are strongly coupled. */
/* Little channel color rectangle. */
if (acf_show_channel_colors()) {
offset += CHANNEL_COLOR_RECT_WIDTH + 2 * CHANNEL_COLOR_RECT_MARGIN;
}
/* solo... */
if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) {
/* A touch of padding because the star icon is so wide. */
@ -5607,6 +5637,32 @@ void ANIM_channel_draw_widgets(const bContext *C,
/* check if there's enough space for the toggles if the sliders are drawn too */
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2))
{
/* NOTE: The comments here match the comments in ANIM_channel_draw(), as that
* function and this one are strongly coupled. */
/* Little channel color rectangle. */
const bool show_group_colors = acf_show_channel_colors();
if (show_group_colors) {
const float rect_width = CHANNEL_COLOR_RECT_WIDTH;
const float rect_margin = CHANNEL_COLOR_RECT_MARGIN;
uint8_t color[3];
if (acf->get_channel_color && acf->get_channel_color(ale, color)) {
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3ubv(color);
GPUVertFormat format = {0};
uint pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immRectf(pos,
rect->xmax - rect_width - rect_margin,
rect->ymin + rect_margin,
rect->xmax - rect_margin,
rect->ymax - rect_margin);
immUnbindProgram();
}
offset -= rect_width + 2 * rect_margin;
}
/* solo... */
if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) {
offset -= ICON_WIDTH;

View File

@ -570,6 +570,12 @@ struct bAnimChannelType {
/* -- Drawing -- */
/** Get RGB color that is used to draw the majority of the backdrop. */
void (*get_backdrop_color)(bAnimContext *ac, bAnimListElem *ale, float r_color[3]);
/** Get RGB color that represents this channel.
* \return true when r_color was updated, false when there is no color for this channel.
*/
bool (*get_channel_color)(const bAnimListElem *ale, uint8_t r_color[3]);
/** Draw backdrop strip for channel. */
void (*draw_backdrop)(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc);
/** Get depth of indentation (relative to the depth channel is nested at). */

View File

@ -188,8 +188,6 @@ static void draw_backdrops(bAnimContext *ac, ListBase &anim_data, View2D *v2d, u
uchar col1b[4], col2b[4];
uchar col_summary[4];
const bool show_group_colors = U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
/* get theme colors */
UI_GetThemeColor4ubv(TH_SHADE2, col2);
UI_GetThemeColor4ubv(TH_HILITE, col1);
@ -245,45 +243,9 @@ static void draw_backdrops(bAnimContext *ac, ListBase &anim_data, View2D *v2d, u
immUniformColor3ubvAlpha(col2b, sel ? col1[3] : col2b[3]);
break;
}
case ANIMTYPE_GROUP: {
bActionGroup *agrp = static_cast<bActionGroup *>(ale->data);
if (show_group_colors && agrp->customCol) {
if (sel) {
immUniformColor3ubvAlpha((uchar *)agrp->cs.select, col1a[3]);
}
else {
immUniformColor3ubvAlpha((uchar *)agrp->cs.solid, col2a[3]);
}
}
else {
immUniformColor4ubv(sel ? col1a : col2a);
}
case ANIMTYPE_GROUP:
immUniformColor4ubv(sel ? col1a : col2a);
break;
}
case ANIMTYPE_FCURVE: {
FCurve *fcu = static_cast<FCurve *>(ale->data);
if (show_group_colors && fcu->grp && fcu->grp->customCol) {
immUniformColor3ubvAlpha((uchar *)fcu->grp->cs.active, sel ? col1[3] : col2[3]);
}
else {
immUniformColor4ubv(sel ? col1 : col2);
}
break;
}
case ANIMTYPE_GPLAYER: {
if (show_group_colors) {
uchar gpl_col[4];
bGPDlayer *gpl = (bGPDlayer *)ale->data;
rgb_float_to_uchar(gpl_col, gpl->color);
gpl_col[3] = col1[3];
immUniformColor4ubv(sel ? col1 : gpl_col);
}
else {
immUniformColor4ubv(sel ? col1 : col2);
}
break;
}
default: {
immUniformColor4ubv(sel ? col1 : col2);
}
@ -294,26 +256,11 @@ static void draw_backdrops(bAnimContext *ac, ListBase &anim_data, View2D *v2d, u
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
uchar *color;
uchar gpl_col[4];
switch (ale->type) {
case ANIMTYPE_SUMMARY:
color = col_summary;
break;
case ANIMTYPE_GPLAYER: {
if (show_group_colors) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
rgb_float_to_uchar(gpl_col, gpl->color);
gpl_col[3] = col1[3];
color = sel ? col1 : gpl_col;
}
else {
color = sel ? col1 : col2;
}
break;
}
case ANIMTYPE_GREASE_PENCIL_LAYER_GROUP:
color = sel ? col1a : col2a;
break;
@ -356,6 +303,16 @@ static void draw_backdrops(bAnimContext *ac, ListBase &anim_data, View2D *v2d, u
immRectf(pos, v2d->cur.xmin, ymin, ac->scene->r.sfra, ymax);
immRectf(pos, ac->scene->r.efra, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax);
}
/* Alpha-over the channel color, if it's there. */
{
const bool show_group_colors = U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
uint8_t color[3];
if (show_group_colors && acf->get_channel_color && acf->get_channel_color(ale, color)) {
immUniformColor3ubvAlpha(color, 32);
immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax);
}
}
}
}

View File

@ -5370,6 +5370,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_anim_channel_group_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(
prop, nullptr, "animation_flag", USER_ANIM_SHOW_CHANNEL_GROUP_COLORS);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(
prop,
"Channel Group Colors",