Action Group Colors for Bones (Part 2)
[blender.git] / source / blender / blenkernel / intern / action.c
index 233647c9ec6598aadeca60e79eb239da06b432f8..b3d2e3371f49f2eb32743f4409bfb6dc20fad018 100644 (file)
@@ -252,6 +252,31 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
        }
 }
 
+/* Sync colors used for action/bone group with theme settings */
+void action_group_colors_sync(bActionGroup *grp)
+{
+       /* only do color copying if using a custom color (i.e. not default color)  */
+       if (grp->customCol) {
+               if (grp->customCol > 0) {
+                       /* copy theme colors on-to group's custom color in case user tries to edit color */
+                       bTheme *btheme = U.themes.first;
+                       ThemeWireColor *col_set = &btheme->tarm[(grp->customCol - 1)];
+                       
+                       memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
+               }
+               else {
+                       /* init custom colors with a generic multi-color rgb set, if not initialized already
+                        * (for custom color set) */
+                       if (grp->cs.solid[0] == 0) {
+                               /* define for setting colors in theme below */
+                               rgba_char_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255);
+                               rgba_char_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255);
+                               rgba_char_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
+                       }
+               }
+       }
+}
+
 /* Add a new action group with the given name to the action */
 bActionGroup *action_groups_add_new(bAction *act, const char name[])
 {
@@ -409,10 +434,9 @@ void action_groups_clear_tempflags(bAction *act)
 
 /* *************** Pose channels *************** */
 
-/* usually used within a loop, so we got a N^2 slowdown */
 bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
 {
-       if (ELEM(NULL, pose, name) || (name[0] == 0))
+       if (ELEM(NULL, pose, name) || (name[0] == '\0'))
                return NULL;
        
        if (pose->chanhash)