Durian request:
authorMatt Ebb <matt@mke3.net>
Thu, 17 Dec 2009 04:55:15 +0000 (04:55 +0000)
committerMatt Ebb <matt@mke3.net>
Thu, 17 Dec 2009 04:55:15 +0000 (04:55 +0000)
Extend the 'only selected' property in the graph editor to only show curves
from selected sequence strips and nodes as well.

source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/space_graph/space_graph.c
source/blender/makesrna/intern/rna_action.c

index f9130e24a0866d5c42938f6a68f93cdcf1654465..3ed9ab8778e0b3fb897330a3462532c60bcbb9ca 100644 (file)
@@ -175,6 +175,7 @@ struct bNode        *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int inte
 struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
 void                   nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
 
+struct bNode   *nodeFindNodebyName(struct bNodeTree *ntree, const char *name);
 int                    nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex);
 
 struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
index a50b03861d7691a7d15e8c645535f5fa1428d65c..e6b468e0dc09bcbc7d48920f725d7a488201fa2a 100644 (file)
@@ -192,6 +192,8 @@ void seq_update_muting(struct Editing *ed);
 
 void clear_scene_in_allseqs(struct Scene *sce);
 
+struct Sequence *get_seq_by_name(struct Scene *scene, const char *name);
+
 struct Sequence *active_seq_get(struct Scene *scene);
 void active_seq_set(struct Scene *scene, struct Sequence *seq);
 
index a27c3b6494bf314726b3228924b37ef353e0ec9e..84ef4fb6d1c84a0f4636d1d7b1865ffecdc95027 100644 (file)
@@ -767,6 +767,17 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup)
        }
        
 }
+/* finds a node based on its name */
+bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name)
+{
+       bNode *node=NULL;
+       
+       for(node= ntree->nodes.first; node; node= node->next) {
+               if (strcmp(name, node->name) == 0)
+                       break;
+       }
+       return node;
+}
 
 /* finds a node based on given socket */
 int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex)
index a7b9cf7f74c8e3bba14a257fde65d4df17fb8e7e..e36e8dc49c4cf95ca6cff161093546ef1a3e3d29 100644 (file)
@@ -3575,6 +3575,21 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs)
 }
 
 
+Sequence *get_seq_by_name(Scene *scene, const char *name)
+{
+       Sequence *seq=NULL;
+       Editing *ed= seq_give_editing(scene, FALSE);
+       
+       if(ed==NULL) return NULL;
+       
+       for (seq=ed->seqbase.first; seq; seq=seq->next) {
+               if (strcmp(name, seq->name+2) == 0)
+                       break;
+       }
+       return seq;
+}
+
+
 Sequence *active_seq_get(Scene *scene)
 {
        Editing *ed= seq_give_editing(scene, FALSE);
index 544157c40305e3d1f38712143c6c765bd49d396c..fc5e7e1898bcb4ac28c05ca28160113589aee534 100644 (file)
@@ -68,6 +68,7 @@
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_space_types.h"
+#include "DNA_sequence_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_windowmanager_types.h"
@@ -85,6 +86,8 @@
 #include "BKE_key.h"
 #include "BKE_object.h"
 #include "BKE_material.h"
+#include "BKE_node.h"
+#include "BKE_sequencer.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
@@ -754,6 +757,65 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
  
 /* ----------------------------------------- */
 
+static int skip_fcurve_selected_data(FCurve *fcu, ID *owner_id)
+{
+       if (GS(owner_id->name) == ID_OB) {
+               Object *ob= (Object *)owner_id;
+               
+               /* only consider if F-Curve involves pose.bones */
+               if ((fcu->rna_path) && strstr(fcu->rna_path, "bones")) {
+                       bPoseChannel *pchan;
+                       char *bone_name;
+                       
+                       /* get bone-name, and check if this bone is selected */
+                       bone_name= BLI_getQuotedStr(fcu->rna_path, "bones[");
+                       pchan= get_pose_channel(ob->pose, bone_name);
+                       if (bone_name) MEM_freeN(bone_name);
+                       
+                       /* can only add this F-Curve if it is selected */
+                       if ((pchan) && (pchan->bone) && (pchan->bone->flag & BONE_SELECTED)==0)
+                               return 1;
+               }
+       }
+       else if (GS(owner_id->name) == ID_SCE) {
+               Scene *sce = (Scene *)owner_id;
+               
+               /* only consider if F-Curve involves sequence_editor.sequences */
+               if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
+                       Sequence *seq;
+                       char *seq_name;
+                       
+                       /* get strip name, and check if this strip is selected */
+                       seq_name= BLI_getQuotedStr(fcu->rna_path, "sequences_all[");
+                       seq = get_seq_by_name(sce, seq_name);
+                       if (seq_name) MEM_freeN(seq_name);
+                       
+                       /* can only add this F-Curve if it is selected */
+                       if ((seq) && (seq->flag & SELECT)==0)
+                               return 1;
+               }
+       }
+       else if (GS(owner_id->name) == ID_NT) {
+               bNodeTree *ntree = (bNodeTree *)owner_id;
+               
+               /* check for selected  nodes */
+               if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
+                       bNode *node;
+                       char *node_name;
+                       
+                       /* get strip name, and check if this strip is selected */
+                       node_name= BLI_getQuotedStr(fcu->rna_path, "nodes[");
+                       node = nodeFindNodebyName(ntree, node_name);
+                       if (node_name) MEM_freeN(node_name);
+                       
+                       /* can only add this F-Curve if it is selected */
+                       if ((node) && (node->flag & NODE_SELECT)==0)
+                               return 1;
+               }
+       }
+       return 0;
+}
+
 /* find the next F-Curve that is usable for inclusion */
 static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id)
 {
@@ -771,27 +833,11 @@ static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bAct
                 *        carefully checking the entire path
                 *      - this will also affect things like Drivers, and also works for Bone Constraints
                 */
-               if ( ((ads) && (ads->filterflag & ADS_FILTER_ONLYSEL)) && 
-                        ((owner_id) && (GS(owner_id->name) == ID_OB)) ) 
-               {
-                       Object *ob= (Object *)owner_id;
-                       
-                       /* only consider if F-Curve involves pose.bones */
-                       if ((fcu->rna_path) && strstr(fcu->rna_path, "bones")) {
-                               bPoseChannel *pchan;
-                               char *bone_name;
-                               
-                               /* get bone-name, and check if this bone is selected */
-                               bone_name= BLI_getQuotedStr(fcu->rna_path, "bones[");
-                               pchan= get_pose_channel(ob->pose, bone_name);
-                               if (bone_name) MEM_freeN(bone_name);
-                               
-                               /* can only add this F-Curve if it is selected */
-                               if ((pchan) && (pchan->bone) && (pchan->bone->flag & BONE_SELECTED)==0)
-                                       continue;
-                       }
+               if ( ((ads) && (ads->filterflag & ADS_FILTER_ONLYSEL)) && (owner_id) ) {
+                       if (skip_fcurve_selected_data(fcu, owner_id))
+                               continue;
                }
-               
+                               
                /* only include if visible (Graph Editor check, not channels check) */
                if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
                        /* only work with this channel and its subchannels if it is editable */
index 3023ec89258ffe5e693fc41fc3a4cd6b0532aa71..f00215e73137f7668ec6f56219df15c1266b9e84 100644 (file)
@@ -387,6 +387,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_OB_ACTIVE:
                                case ND_FRAME:
                                case ND_MARKERS:
+                               case ND_SEQUENCER_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -405,6 +406,11 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
                        }
                        break;
                case NC_NODE:
+                       switch(wmn->data) {
+                               case ND_NODE_SELECT:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
                        switch(wmn->action) {
                                case NA_EDITED:
                                        ED_region_tag_redraw(ar);
index 0568652488dbf585385c326f27ba4a10fcb90519..4cb7080f05e2f2691c0e659c8b4498a4a49ade5f 100644 (file)
@@ -56,7 +56,7 @@ static void rna_def_dopesheet(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "only_selected", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYSEL);
-       RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected Objects.");
+       RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data.");
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);