== Action Editor - Group Colours for Channels ==
authorJoshua Leung <aligorith@gmail.com>
Wed, 16 Apr 2008 11:02:08 +0000 (11:02 +0000)
committerJoshua Leung <aligorith@gmail.com>
Wed, 16 Apr 2008 11:02:08 +0000 (11:02 +0000)
It is now possible for Action Channels to be displayed using the colour of its group. The colour for an Action Group is only set when it is auto-created by keyframing (controls to tweak this may/may-not be added, time permitting).

To enable the display of these colours, the View -> 'Use Group Colors' must be enabled. However, this is disabled by default.

source/blender/makesdna/DNA_action_types.h
source/blender/src/drawaction.c
source/blender/src/editaction.c
source/blender/src/header_action.c

index 9fef59b948f76dffae9534e07e022bae30fe715b..26b7e3c1013ff8e54977ee3165339c330f876e3e 100644 (file)
@@ -233,7 +233,9 @@ typedef enum SACTION_FLAG {
                /* don't include keyframes that are out of view */
        SACTION_HORIZOPTIMISEON = (1<<5),
                /* hack for moving pose-markers (temp flag)  */
-       SACTION_POSEMARKERS_MOVE = (1<<6)
+       SACTION_POSEMARKERS_MOVE = (1<<6),
+               /* draw action channels using group colours (where applicable) */
+       SACTION_DRAWGCOLORS = (1<<7)
 } SACTION_FLAG;        
 
 /* SpaceAction AutoSnap Settings (also used by SpaceNLA) */
index 1d3ece58db7e25a93b1bb33e4faebd023aeda18c..c761bed1fec1eeba68d60f63025efa56950bef0d 100644 (file)
@@ -462,6 +462,7 @@ static void draw_channel_names(void)
                if ( IN_RANGE(yminc, G.v2d->cur.ymin, G.v2d->cur.ymax) ||
                         IN_RANGE(ymaxc, G.v2d->cur.ymin, G.v2d->cur.ymax) ) 
                {
+                       bActionGroup *grp = NULL;
                        short indent= 0, offset= 0, sel= 0, group=0;
                        int expand= -1, protect = -1, special= -1, mute = -1;
                        char name[32];
@@ -495,6 +496,8 @@ static void draw_channel_names(void)
                                        bActionChannel *achan= (bActionChannel *)ale->data;
                                        
                                        group= (ale->grp) ? 1 : 0;
+                                       grp= ale->grp;
+                                       
                                        indent = 0;
                                        special = -1;
                                        
@@ -524,7 +527,9 @@ static void draw_channel_names(void)
                                        bConstraintChannel *conchan = (bConstraintChannel *)ale->data;
                                        
                                        indent = 2;
+                                       
                                        group= (ale->grp) ? 1 : 0;
+                                       grp= ale->grp;
                                        
                                        if (EDITABLE_CONCHAN(conchan))
                                                protect = ICON_UNLOCKED;
@@ -548,7 +553,9 @@ static void draw_channel_names(void)
                                        
                                        indent = 2;
                                        protect = -1; // for now, until this can be supported by others
+                                       
                                        group= (ale->grp) ? 1 : 0;
+                                       grp= ale->grp;
                                        
                                        if (icu->flag & IPO_MUTE)
                                                mute = ICON_MUTE_IPO_ON;
@@ -581,7 +588,9 @@ static void draw_channel_names(void)
                                        
                                        indent = 1;
                                        special = geticon_ipo_blocktype(achan->ipo->blocktype);
+                                       
                                        group= (ale->grp) ? 1 : 0;
+                                       grp= ale->grp;
                                        
                                        if (FILTER_IPO_ACHAN(achan))    
                                                expand = ICON_TRIA_DOWN;
@@ -598,7 +607,9 @@ static void draw_channel_names(void)
                                        
                                        indent = 1;
                                        special = ICON_CONSTRAINT;
+                                       
                                        group= (ale->grp) ? 1 : 0;
+                                       grp= ale->grp;
                                        
                                        if (FILTER_CON_ACHAN(achan))    
                                                expand = ICON_TRIA_DOWN;
@@ -625,8 +636,28 @@ static void draw_channel_names(void)
                                offset = 0;
                        }
                        else {
-                               /* for normal channels */
-                               BIF_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40));
+                               /* for normal channels 
+                                *      - use 3 shades of color group/standard colour for 3 indention level
+                                *      - use standard colour if enabled
+                                */
+                               if ((G.saction->flag & SACTION_DRAWGCOLORS) && (grp)) {
+                                       char cp[3];
+                                       
+                                       if (indent == 2) {
+                                               VECCOPY(cp, grp->cs.solid);
+                                       }
+                                       else if (indent == 1) {
+                                               VECCOPY(cp, grp->cs.select);
+                                       }
+                                       else {
+                                               VECCOPY(cp, grp->cs.active);
+                                       }
+                                       
+                                       glColor3ub(cp[0], cp[1], cp[2]);
+                               }
+                               else
+                                       BIF_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40));
+                               
                                indent += group;
                                offset = 7 * indent;
                                glRectf(x+offset,  yminc, (float)NAMEWIDTH, ymaxc);
index 6a0d50826e9f15c0a0ba359e0b0608d72152cbea..b344f94b6bdbecdf071a5de28effc8d39bc84167 100644 (file)
@@ -1150,8 +1150,38 @@ void verify_pchan2achan_grouping (bAction *act, bPose *pose, char name[])
                        grp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
                        
                        grp->flag |= (AGRP_ACTIVE|AGRP_SELECTED|AGRP_EXPANDED);
+                       
+                       /* copy name */
                        sprintf(grp->name, agrp->name);
                        
+                       /* deal with group-color copying */
+                       if (agrp->customCol) {
+                               if (agrp->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[(agrp->customCol - 1)];
+                                       
+                                       memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
+                               }
+                               else {
+                                       /* init custom colours with a generic multi-colour rgb set, if not initialised already */
+                                       if (agrp->cs.solid[0] == 0) {
+                                               /* define for setting colors in theme below */
+                                               #define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
+                                               
+                                               SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255);
+                                               SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255);
+                                               SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
+                                               
+                                               #undef SETCOL
+                                       }
+                                       else {
+                                               /* just copy color set specified */
+                                               memcpy(&grp->cs, &agrp->cs, sizeof(ThemeWireColor));
+                                       }
+                               }
+                       }
+                       
                        BLI_addtail(&act->groups, grp);
                }
                
index 584e68263a3b4f67c47abdf4beecc248cee9a101..19cb8e7f343bda0ea10aa3126623fe89043a1d4a 100644 (file)
@@ -97,7 +97,8 @@ enum {
        ACTMENU_VIEW_TIME,
        ACTMENU_VIEW_NOHIDE,
        ACTMENU_VIEW_TRANSDELDUPS,
-       ACTMENU_VIEW_HORIZOPTIMISE
+       ACTMENU_VIEW_HORIZOPTIMISE,
+       ACTMENU_VIEW_GCOLORS
 };
 
 enum {
@@ -347,6 +348,9 @@ static void do_action_viewmenu(void *arg, int event)
                case ACTMENU_VIEW_HORIZOPTIMISE: /* Include keyframes not in view (horizontally) when preparing to draw */
                        G.saction->flag ^= SACTION_HORIZOPTIMISEON;
                        break;
+               case ACTMENU_VIEW_GCOLORS: /* Draw grouped-action channels using its group's color */
+                       G.saction->flag ^= SACTION_DRAWGCOLORS;
+                       break;
        }
        allqueue(REDRAWVIEW3D, 0);
 }
@@ -393,6 +397,11 @@ static uiBlock *action_viewmenu(void *arg_unused)
                                         menuwidth, 19, NULL, 0.0, 0.0, 1, 
                                         ACTMENU_VIEW_NOHIDE, "");
                                         
+       uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_DRAWGCOLORS)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
+                                        "Use Group Colors|", 0, yco-=20, 
+                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 
+                                        ACTMENU_VIEW_GCOLORS, "");
+                                        
                // this option may get removed in future
        uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_HORIZOPTIMISEON)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
                                         "Cull Out-of-View Keys (Time)|", 0, yco-=20,