diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-01-19 02:31:46 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-01-19 02:31:46 +0300 |
commit | 56660fab4b3aabd931e5ceefbff4cc226969a8e2 (patch) | |
tree | 56d274cfe319dd9566a8e2c51dbef7d8aefd18e6 /source/blender/editors/space_time/space_time.c | |
parent | b6421418e49fe9b6e7db99e072f7b9cd074028c7 (diff) |
Timeline: Keyframe Drawing for All Selected Objects
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.
Diffstat (limited to 'source/blender/editors/space_time/space_time.c')
-rw-r--r-- | source/blender/editors/space_time/space_time.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index eb578e093df..4f9f4975629 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -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); } } |