Timeline: Keyframe Drawing for All Selected Objects
authorJoshua Leung <aligorith@gmail.com>
Mon, 18 Jan 2010 23:31:46 +0000 (23:31 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 18 Jan 2010 23:31:46 +0000 (23:31 +0000)
When 'Only Selected' is ON, or the Active Object is in PoseMode, only the keyframes for the active Object are drawn (*).

Otherwise, the keyframes for the scene (sequence+nodes+world), and the selected Objects (including the Active Object) are drawn.

(*) I've also made some changes here to try and get only the selected bones showing here, but some further changes are still needed for that to be able to work.

---

Also, fixed bug in makesrna caused by missing newlines for error prints. This resulted in all error-output from makesrna appearing on a single line.

source/blender/editors/space_time/space_time.c
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_space.c

index eb578e093df1d9380c97ae28122d20045c2c2459..4f9f49756298d4728b2a7a0ed8c2b6d041448693 100644 (file)
@@ -113,21 +113,28 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe)
 }
 
 /* helper for time_draw_keyframes() */
-static void time_draw_idblock_keyframes(View2D *v2d, ID *id)
+static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
 {
+       bDopeSheet ads;
        DLRBT_Tree keys;
        ActKeyColumn *ak;
        
        /* init binarytree-list for getting keyframes */
        BLI_dlrbTree_init(&keys);
        
+       /* init dopesheet settings */
+       // FIXME: the ob_to_keylist function currently doesn't take this into account...
+       memset(&ads, 0, sizeof(bDopeSheet));
+       if (onlysel)
+               ads.filterflag |= ADS_FILTER_ONLYSEL;
+       
        /* populate tree with keyframe nodes */
        switch (GS(id->name)) {
                case ID_SCE:
-                       scene_to_keylist(NULL, (Scene *)id, &keys, NULL);
+                       scene_to_keylist(&ads, (Scene *)id, &keys, NULL);
                        break;
                case ID_OB:
-                       ob_to_keylist(NULL, (Object *)id, &keys, NULL);
+                       ob_to_keylist(&ads, (Object *)id, &keys, NULL);
                        break;
        }
                
@@ -159,21 +166,47 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_active_object(C);
        View2D *v2d= &ar->v2d;
+       short onlysel= (stime->flag & TIME_ONLYACTSEL);
        
        /* draw scene keyframes first 
-        *      - only if we're not only showing the 
+        *      - don't try to do this when only drawing active/selected data keyframes,
+        *        since this can become quite slow
         */
-       if ((scene) && (stime->flag & TIME_ONLYACTSEL)==0) {
+       if (scene && onlysel==0) {
                /* set draw color */
                glColor3ub(0xDD, 0xA7, 0x00);
-               time_draw_idblock_keyframes(v2d, (ID *)scene);
+               time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
        }
        
-       /* draw active object's keyframes */
-       if (ob) {
-               /* set draw color */
-               glColor3ub(0xDD, 0xD7, 0x00);
-               time_draw_idblock_keyframes(v2d, (ID *)ob);
+       /* draw keyframes from selected objects 
+        *      - only do the active object if in posemode (i.e. showing only keyframes for the bones)
+        *        OR the onlysel flag was set, which means that only active object's keyframes should
+        *        be considered
+        */
+       glColor3ub(0xDD, 0xD7, 0x00);
+       
+       if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
+               /* draw keyframes for active object only */
+               time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);
+       }
+       else {
+               short active_done = 0;
+               
+               /* draw keyframes from all selected objects */
+               CTX_DATA_BEGIN(C, Object*, obsel, selected_objects) 
+               {
+                       /* last arg is 0, since onlysel doesn't apply here... */
+                       time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
+                       
+                       /* if this object is the active one, set flag so that we don't draw again */
+                       if (obsel == ob)
+                               active_done= 1;
+               }
+               CTX_DATA_END;
+               
+               /* if active object hasn't been done yet, draw it... */
+               if (ob && (active_done == 0))
+                       time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
        }
 }
 
index 3ca30709d3461071ccb500863b06a33cf5f3fdd8..b139de873ad7d0cf74357b54f6ee526fafea5a15 100644 (file)
@@ -52,7 +52,7 @@ static int replace_if_different(char *tmpfile)
 
 #define REN_IF_DIFF \
        if(rename(tmpfile, orgfile) != 0) { \
-               fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"", __FILE__, __LINE__, tmpfile, orgfile); \
+               fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"\n", __FILE__, __LINE__, tmpfile, orgfile); \
                return -1; \
        } \
        remove(tmpfile); \
@@ -79,7 +79,7 @@ static int replace_if_different(char *tmpfile)
 
        if(fp_new==NULL) {
                /* shouldn't happen, just to be safe */
-               fprintf(stderr, "%s:%d, open error: \"%s\"", __FILE__, __LINE__, tmpfile);
+               fprintf(stderr, "%s:%d, open error: \"%s\"\n", __FILE__, __LINE__, tmpfile);
                return -1;
        }
 
index 35c8c7ac3459207cbcc2761c04c655632df27af4..165f09d337a4c630460b8b2bf60102544cd271f8 100644 (file)
@@ -1517,7 +1517,7 @@ static void rna_def_space_time(BlenderRNA *brna)
        /* Other options */     
        prop= RNA_def_property(srna, "only_selected", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ONLYACTSEL);
-       RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes only from active/selected channels."); 
+       RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes for active Object and/or its selected channels only.");        
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
        
        prop= RNA_def_property(srna, "show_cframe_indicator", PROP_BOOLEAN, PROP_NONE);