style cleanup: follow style guide for formatting of if/for/while loops, and else...
[blender.git] / source / blender / editors / space_nla / nla_channels.c
index 265616020d5ca2421baaff59d69fda5358add9b7..c242a1c1323d33c64881b863f935084224f1adf0 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -81,13 +79,14 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
+       
        View2D *v2d= &ac->ar->v2d;
        int notifierFlags = 0;
        
        /* get the channel that was clicked on */
                /* filter channels */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
-       filter= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
+       ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
        
                /* get channel from index */
        ale= BLI_findlink(&anim_data, channel_index);
@@ -179,6 +178,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
                case ANIMTYPE_DSMESH:
                case ANIMTYPE_DSTEX:
                case ANIMTYPE_DSLAT:
+               case ANIMTYPE_DSSPK:
                {
                        /* sanity checking... */
                        if (ale->adt) {
@@ -301,9 +301,10 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
 static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        bAnimContext ac;
+       SpaceNla *snla;
        ARegion *ar;
        View2D *v2d;
-       int mval[2], channel_index;
+       int channel_index;
        int notifierFlags = 0;
        short selectmode;
        float x, y;
@@ -313,13 +314,10 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
                return OPERATOR_CANCELLED;
                
        /* get useful pointers from animation context data */
+       snla= (SpaceNla *)ac.sl;
        ar= ac.ar;
        v2d= &ar->v2d;
        
-       /* get mouse coordinates (in region coordinates) */
-       mval[0]= (event->x - ar->winrct.xmin);
-       mval[1]= (event->y - ar->winrct.ymin);
-       
        /* select mode is either replace (deselect all, then add) or add/extend */
        if (RNA_boolean_get(op->ptr, "extend"))
                selectmode= SELECT_INVERT;
@@ -331,8 +329,8 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
         *              so that the tops of channels get caught ok. Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use
         *              NLACHANNEL_HEIGHT_HALF.
         */
-       UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-       UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP, 0, (float)NLACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
+       UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
+       UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index);
        
        /* handle mouse-click in the relevant channel then */
        notifierFlags= mouse_nla_channels(&ac, x, channel_index, selectmode);
@@ -346,16 +344,16 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
 void NLA_OT_channels_click (wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Mouse Click on NLA Channels";
-       ot->idname= "NLA_OT_channels_click";
-       ot->description= "Handle clicks to select NLA channels";
+       ot->name = "Mouse Click on NLA Channels";
+       ot->idname = "NLA_OT_channels_click";
+       ot->description = "Handle clicks to select NLA channels";
        
        /* api callbacks */
-       ot->invoke= nlachannels_mouseclick_invoke;
-       ot->poll= ED_operator_nla_active;
+       ot->invoke = nlachannels_mouseclick_invoke;
+       ot->poll = ED_operator_nla_active;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* id-props */
        RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
@@ -383,12 +381,12 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
                
        /* get a list of the AnimData blocks being shown in the NLA */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_SEL);
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* add tracks... */
        for (ale= anim_data.first; ale; ale= ale->next) {
-               if(ale->type == ANIMTYPE_NLATRACK) {
+               if (ale->type == ANIMTYPE_NLATRACK) {
                        NlaTrack *nlt= (NlaTrack *)ale->data;
                        AnimData *adt= ale->adt;
                        
@@ -420,19 +418,19 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op)
 void NLA_OT_tracks_add (wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Add Track(s)";
-       ot->idname= "NLA_OT_tracks_add";
-       ot->description= "Add NLA-Tracks above/after the selected tracks";
+       ot->name = "Add Track(s)";
+       ot->idname = "NLA_OT_tracks_add";
+       ot->description = "Add NLA-Tracks above/after the selected tracks";
        
        /* api callbacks */
-       ot->exec= nlaedit_add_tracks_exec;
-       ot->poll= nlaop_poll_tweakmode_off;
+       ot->exec = nlaedit_add_tracks_exec;
+       ot->poll = nlaop_poll_tweakmode_off;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* properties */
-       RNA_def_boolean(ot->srna, "above_selected", 0, "Above Selected", "Add a new NLA Track above every existing selected one.");
+       RNA_def_boolean(ot->srna, "above_selected", 0, "Above Selected", "Add a new NLA Track above every existing selected one");
 }
 
 /* ******************** Delete Tracks Operator ***************************** */
@@ -451,12 +449,12 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op))
                return OPERATOR_CANCELLED;
                
        /* get a list of the AnimData blocks being shown in the NLA */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_SEL);
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* delete tracks */
        for (ale= anim_data.first; ale; ale= ale->next) {
-               if(ale->type == ANIMTYPE_NLATRACK) {
+               if (ale->type == ANIMTYPE_NLATRACK) {
                        NlaTrack *nlt= (NlaTrack *)ale->data;
                        AnimData *adt= ale->adt;
                        
@@ -484,16 +482,16 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op))
 void NLA_OT_delete_tracks (wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Delete Tracks";
-       ot->idname= "NLA_OT_delete_tracks";
-       ot->description= "Delete selected NLA-Tracks and the strips they contain";
+       ot->name = "Delete Tracks";
+       ot->idname = "NLA_OT_delete_tracks";
+       ot->description = "Delete selected NLA-Tracks and the strips they contain";
        
        /* api callbacks */
-       ot->exec= nlaedit_delete_tracks_exec;
-       ot->poll= nlaop_poll_tweakmode_off;
+       ot->exec = nlaedit_delete_tracks_exec;
+       ot->poll = nlaop_poll_tweakmode_off;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 /* *********************************************** */