diff options
author | Joshua Leung <aligorith@gmail.com> | 2012-05-24 05:25:31 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2012-05-24 05:25:31 +0400 |
commit | 8e97203f7d1101d8069b22f0f9a5666812704e22 (patch) | |
tree | 160ce3d1d9751745629d71c42ce3f6f963698843 /source | |
parent | 57b488574a0720eb749e9daa16df1979db9bbe6f (diff) |
Restoring Group Colours for Animation Channels - Part 1
This commit restores the group colours support for F-Curves and F-Curve Groups
in the DopeSheet and Graph Editors. Currently the relevant settings for groups
are only exposed via RNA, but a followup commit will add support for
automatically setting these colours. By default, DopeSheet and Graph Editors are
set to display these colours if/when they are available.
This functionality used to be in 2.48, and is a useful mechanism for visually
distinguishing between channels for different controls when animating (if group
colours are used on the rigs too).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 64 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_action_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_action.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 97 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 12 |
8 files changed, 126 insertions, 62 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index dd9a0600725..c4fca2d4ea5 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -146,18 +146,39 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } +/* helper method to test if group colors should be drawn */ +static short acf_show_channel_colors(bAnimContext *ac) +{ + short showGroupColors = 0; + + if (ac->sl) { + switch (ac->spacetype) { + case SPACE_ACTION: + { + SpaceAction *saction = (SpaceAction *)ac->sl; + showGroupColors = !(saction->flag & SACTION_NODRAWGCOLORS); + } + break; + case SPACE_IPO: + { + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + showGroupColors = !(sipo->flag & SIPO_NODRAWGCOLORS); + } + break; + } + } + + return showGroupColors; +} + /* get backdrop color for generic channels */ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3]) { bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - SpaceAction *saction = NULL; bActionGroup *grp = NULL; short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; + short showGroupColors = acf_show_channel_colors(ac); - /* get context info needed... */ - if ((ac->sl) && (ac->spacetype == SPACE_ACTION)) - saction = (SpaceAction *)ac->sl; - if (ale->type == ANIMTYPE_FCURVE) { FCurve *fcu = (FCurve *)ale->data; grp = fcu->grp; @@ -167,9 +188,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa * - use 3 shades of color group/standard color for 3 indention level * - only use group colors if allowed to, and if actually feasible */ - if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) && - ((grp) && (grp->customCol)) ) - { + if (showGroupColors && (grp) && (grp->customCol)) { unsigned char cp[3]; if (indent == 2) { @@ -730,13 +749,30 @@ static bAnimChannelType ACF_OBJECT = /* Group ------------------------------------------- */ /* get backdrop color for group widget */ -static void acf_group_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3]) +static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3]) { - /* highlight only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, r_color); - else - UI_GetThemeColorShade3fv(TH_GROUP, 20, r_color); + bActionGroup *agrp = (bActionGroup *)ale->data; + short showGroupColors = acf_show_channel_colors(ac); + + if (showGroupColors && agrp->customCol) { + unsigned char cp[3]; + + /* highlight only for active */ + if (ale->flag & AGRP_ACTIVE) + copy_v3_v3_char((char *)cp, agrp->cs.active); + else + copy_v3_v3_char((char *)cp, agrp->cs.solid); + + /* copy the colors over, transforming from bytes to floats */ + rgb_uchar_to_float(r_color, cp); + } + else { + /* highlight only for active */ + if (ale->flag & AGRP_ACTIVE) + UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, r_color); + else + UI_GetThemeColorShade3fv(TH_GROUP, 20, r_color); + } } /* backdrop for group widget */ diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 30b3e75255d..9cb5ca5da55 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -612,7 +612,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), // XXX depreceated... irrelevant for current groups implementation + SACTION_NODRAWGCOLORS = (1<<7), /* don't draw current frame number beside frame indicator */ SACTION_NODRAWCFRANUM = (1<<8), /* temporary flag to force channel selections to be synced with main */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 0bc91907d6e..375258cb92b 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -763,6 +763,8 @@ enum FileSortTypeE { #define SIPO_NOREALTIMEUPDATES (1<<11) /* don't draw curves with AA ("beauty-draw") for performance */ #define SIPO_BEAUTYDRAW_OFF (1<<12) + /* draw grouped channels with colors set in group */ +#define SIPO_NODRAWGCOLORS (1<<13) /* SpaceIpo->mode (Graph Editor Mode) */ enum { diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 21eba3faf02..d2eeaa72fed 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -55,6 +55,8 @@ extern EnumPropertyItem image_type_items[]; extern EnumPropertyItem image_color_mode_items[]; extern EnumPropertyItem image_depth_mode_items[]; +extern EnumPropertyItem color_sets_items[]; + extern EnumPropertyItem beztriple_keyframe_type_items[]; extern EnumPropertyItem beztriple_handle_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index c264210fd91..b63109ed137 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -480,10 +480,8 @@ static void rna_def_action_group(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Expanded", "Action Group is expanded"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "custom_color", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "customCol"); - RNA_def_property_ui_text(prop, "Custom Color", "Index of custom color set"); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + /* color set */ + rna_def_actionbone_group_common(srna, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } /* fcurve.keyframe_points */ diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index a2054622031..cb90211eff9 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -193,6 +193,9 @@ void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const const char *structname_slots, const char *update); void rna_def_render_layer_common(struct StructRNA *srna, int scene); +void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb); +void rna_ActionGroup_colorset_set(struct PointerRNA *ptr, int value); + void rna_ID_name_get(struct PointerRNA *ptr, char *value); int rna_ID_name_length(struct PointerRNA *ptr); void rna_ID_name_set(struct PointerRNA *ptr, const char *value); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 6ec0932dba8..83d40b26cd0 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -60,6 +60,33 @@ EnumPropertyItem posebone_rotmode_items[] = { {0, NULL, 0, NULL, NULL} }; +/* Bone and Group Color Sets */ +EnumPropertyItem color_sets_items[] = { + {0, "DEFAULT", 0, "Default Colors", ""}, + {1, "THEME01", 0, "01 - Theme Color Set", ""}, + {2, "THEME02", 0, "02 - Theme Color Set", ""}, + {3, "THEME03", 0, "03 - Theme Color Set", ""}, + {4, "THEME04", 0, "04 - Theme Color Set", ""}, + {5, "THEME05", 0, "05 - Theme Color Set", ""}, + {6, "THEME06", 0, "06 - Theme Color Set", ""}, + {7, "THEME07", 0, "07 - Theme Color Set", ""}, + {8, "THEME08", 0, "08 - Theme Color Set", ""}, + {9, "THEME09", 0, "09 - Theme Color Set", ""}, + {10, "THEME10", 0, "10 - Theme Color Set", ""}, + {11, "THEME11", 0, "11 - Theme Color Set", ""}, + {12, "THEME12", 0, "12 - Theme Color Set", ""}, + {13, "THEME13", 0, "13 - Theme Color Set", ""}, + {14, "THEME14", 0, "14 - Theme Color Set", ""}, + {15, "THEME15", 0, "15 - Theme Color Set", ""}, + {16, "THEME16", 0, "16 - Theme Color Set", ""}, + {17, "THEME17", 0, "17 - Theme Color Set", ""}, + {18, "THEME18", 0, "18 - Theme Color Set", ""}, + {19, "THEME19", 0, "19 - Theme Color Set", ""}, + {20, "THEME20", 0, "20 - Theme Color Set", ""}, + {-1, "CUSTOM", 0, "Custom Color Set", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "BIK_api.h" @@ -107,7 +134,8 @@ static char *rna_PoseBone_path(PointerRNA *ptr) return BLI_sprintfN("pose.bones[\"%s\"]", ((bPoseChannel *)ptr->data)->name); } -static void rna_BoneGroup_color_set_set(PointerRNA *ptr, int value) +/* shared for actions groups and bone groups */ +void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) { bActionGroup *grp = ptr->data; @@ -622,34 +650,31 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) #else -static void rna_def_bone_group(BlenderRNA *brna) +/* common properties for Action/Bone Groups - related to color */ +void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const char *update_cb) { - static EnumPropertyItem prop_colorSets_items[] = { - {0, "DEFAULT", 0, "Default Colors", ""}, - {1, "THEME01", 0, "01 - Theme Color Set", ""}, - {2, "THEME02", 0, "02 - Theme Color Set", ""}, - {3, "THEME03", 0, "03 - Theme Color Set", ""}, - {4, "THEME04", 0, "04 - Theme Color Set", ""}, - {5, "THEME05", 0, "05 - Theme Color Set", ""}, - {6, "THEME06", 0, "06 - Theme Color Set", ""}, - {7, "THEME07", 0, "07 - Theme Color Set", ""}, - {8, "THEME08", 0, "08 - Theme Color Set", ""}, - {9, "THEME09", 0, "09 - Theme Color Set", ""}, - {10, "THEME10", 0, "10 - Theme Color Set", ""}, - {11, "THEME11", 0, "11 - Theme Color Set", ""}, - {12, "THEME12", 0, "12 - Theme Color Set", ""}, - {13, "THEME13", 0, "13 - Theme Color Set", ""}, - {14, "THEME14", 0, "14 - Theme Color Set", ""}, - {15, "THEME15", 0, "15 - Theme Color Set", ""}, - {16, "THEME16", 0, "16 - Theme Color Set", ""}, - {17, "THEME17", 0, "17 - Theme Color Set", ""}, - {18, "THEME18", 0, "18 - Theme Color Set", ""}, - {19, "THEME19", 0, "19 - Theme Color Set", ""}, - {20, "THEME20", 0, "20 - Theme Color Set", ""}, - {-1, "CUSTOM", 0, "Custom Color Set", ""}, - {0, NULL, 0, NULL, NULL} - }; + PropertyRNA *prop; + /* color set + colors */ + prop = RNA_def_property(srna, "color_set", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "customCol"); + RNA_def_property_enum_items(prop, color_sets_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_ActionGroup_colorset_set", NULL); + RNA_def_property_ui_text(prop, "Color Set", "Custom color set to use"); + RNA_def_property_update(prop, update_flag, update_cb); + + /* TODO: editing the colors for this should result in changes to the color type... */ + prop = RNA_def_property(srna, "colors", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "ThemeBoneColorSet"); + /* NOTE: the DNA data is not really a pointer, but this code works :) */ + RNA_def_property_pointer_sdna(prop, NULL, "cs"); + RNA_def_property_ui_text(prop, "Colors", "Copy of the colors associated with the group's color set"); + RNA_def_property_update(prop, update_flag, update_cb); +} + +static void rna_def_bone_group(BlenderRNA *brna) +{ StructRNA *srna; PropertyRNA *prop; @@ -667,22 +692,8 @@ static void rna_def_bone_group(BlenderRNA *brna) /* TODO: add some runtime-collections stuff to access grouped bones */ - /* color set + colors */ - prop = RNA_def_property(srna, "color_set", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "customCol"); - RNA_def_property_enum_items(prop, prop_colorSets_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_BoneGroup_color_set_set", NULL); - RNA_def_property_ui_text(prop, "Color Set", "Custom color set to use"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); - - /* TODO: editing the colors for this should result in changes to the color type... */ - prop = RNA_def_property(srna, "colors", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "ThemeBoneColorSet"); - /* NOTE: the DNA data is not really a pointer, but this code works :) */ - RNA_def_property_pointer_sdna(prop, NULL, "cs"); - RNA_def_property_ui_text(prop, "Colors", "Copy of the colors associated with the group's color set"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); + /* color set */ + rna_def_actionbone_group_common(srna, NC_OBJECT | ND_POSE, "rna_Pose_update"); } static EnumPropertyItem prop_iksolver_items[] = { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 0e2fc6e8f11..e4d380ef48c 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2262,6 +2262,12 @@ 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", + "Draw groups and channels with colours matching their corresponding groups"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); + /* editing */ prop = RNA_def_property(srna, "use_auto_merge_keyframes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NOTRANSKEYCULL); @@ -2367,6 +2373,12 @@ 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", + "Draw groups and channels with colours matching their corresponding groups"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + /* editing */ prop = RNA_def_property(srna, "use_auto_merge_keyframes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NOTRANSKEYCULL); |