2.5 merged 20773:21020
[blender.git] / source / blender / editors / animation / anim_channels.c
index c52ade1bba855db71d14228fbce0fa1575b9414c..d753f65ff502709cb794dcd202a723c73fcd542b 100644 (file)
 /* ************************************************************************** */
 /* CHANNELS API */
 
-/* -------------------------- Internal Macros ------------------------------- */
-
-/* set/clear/toggle macro 
- *     - channel - channel with a 'flag' member that we're setting
- *     - smode - 0=clear, 1=set, 2=toggle
- *     - sflag - bitflag to set
- */
-#define ACHANNEL_SET_FLAG(channel, smode, sflag) \
-       { \
-               if (smode == ACHANNEL_SETFLAG_TOGGLE)   (channel)->flag ^= (sflag); \
-               else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \
-               else                                                                    (channel)->flag &= ~(sflag); \
-       }
-       
-/* set/clear/toggle macro, where the flag is negative 
- *     - channel - channel with a 'flag' member that we're setting
- *     - smode - 0=clear, 1=set, 2=toggle
- *     - sflag - bitflag to set
- */
-#define ACHANNEL_SET_FLAG_NEG(channel, smode, sflag) \
-       { \
-               if (smode == ACHANNEL_SETFLAG_TOGGLE)   (channel)->flag ^= (sflag); \
-               else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag &= ~(sflag); \
-               else                                                                    (channel)->flag |= (sflag); \
-       }
-
 /* -------------------------- Exposed API ----------------------------------- */
 
 /* Set the given animation-channel as the active one for the active context */
-void ANIM_set_active_channel (void *data, short datatype, int filter, void *channel_data, short channel_type)
+void ANIM_set_active_channel (bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type)
 {
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        
        /* try to build list of filtered items */
-       // XXX we don't need/supply animcontext for now, since in this case, there's nothing really essential there that isn't already covered
-       ANIM_animdata_filter(NULL, &anim_data, filter, data, datatype);
+       ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
        if (anim_data.first == NULL)
                return;
                
@@ -149,6 +122,13 @@ void ANIM_set_active_channel (void *data, short datatype, int filter, void *chan
                                ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE);
                        }
                                break;
+                       case ANIMTYPE_NLATRACK:
+                       {
+                               NlaTrack *nlt= (NlaTrack *)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE);
+                       }
+                               break;
                }
        }
        
@@ -167,6 +147,12 @@ void ANIM_set_active_channel (void *data, short datatype, int filter, void *chan
                                fcu->flag |= FCURVE_ACTIVE;
                        }
                                break;
+                       case ANIMTYPE_NLATRACK:
+                       {
+                               NlaTrack *nlt= (NlaTrack *)channel_data;
+                               nlt->flag |= NLATRACK_ACTIVE;
+                       }
+                               break;
                }
        }
        
@@ -217,6 +203,10 @@ void ANIM_deselect_anim_channels (void *data, short datatype, short test, short
                                        if (ale->flag & FCURVE_SELECTED)
                                                sel= ACHANNEL_SETFLAG_CLEAR;
                                        break;
+                               case ANIMTYPE_NLATRACK:
+                                       if (ale->flag & NLATRACK_SELECTED)
+                                               sel= ACHANNEL_SETFLAG_CLEAR;
+                                       break;
                        }
                }
        }
@@ -263,6 +253,14 @@ void ANIM_deselect_anim_channels (void *data, short datatype, short test, short
                                fcu->flag &= ~FCURVE_ACTIVE;
                        }
                                break;
+                       case ANIMTYPE_NLATRACK:
+                       {
+                               NlaTrack *nlt= (NlaTrack *)ale->data;
+                               
+                               ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED);
+                               nlt->flag &= ~NLATRACK_ACTIVE;
+                       }
+                               break;
                }
        }
        
@@ -1218,6 +1216,14 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele
                                        ACHANNEL_SET_FLAG(gpl, selectmode, GP_LAYER_SELECT);
                                }
                                        break;
+                                       
+                               case ANIMTYPE_NLATRACK: /* nla-track */
+                               {
+                                       NlaTrack *nlt= (NlaTrack *)ale->data;
+                                       
+                                       ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED);
+                               }
+                                       break;
                        }
                }
                
@@ -1474,7 +1480,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
                                
                                /* if group is selected now, make group the 'active' one in the visible list */
                                if (agrp->flag & AGRP_SELECTED)
-                                       ANIM_set_active_channel(ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
+                                       ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
                        }
                }
                        break;
@@ -1520,7 +1526,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
                                
                                /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
                                if (fcu->flag & FCURVE_SELECTED)
-                                       ANIM_set_active_channel(ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
+                                       ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
                        }
                }
                        break;