2.5 - Timeline window now displays keyframe lines again

* Keyframes for scene-linked animdata is drawn first (if 'Only Selected Data Keys' is off)
* Keyframes are also drawn for the active object
This commit is contained in:
Joshua Leung 2009-07-24 08:05:56 +00:00
parent dbd5c5b8a1
commit b2606534b6
8 changed files with 112 additions and 29 deletions

@ -386,10 +386,10 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_insert_keyframe);
WM_operatortype_append(ANIM_OT_delete_keyframe);
WM_operatortype_append(ANIM_OT_insert_keyframe_menu);
//WM_operatortype_append(ANIM_OT_delete_keyframe_menu);
WM_operatortype_append(ANIM_OT_delete_keyframe_v3d);
WM_operatortype_append(ANIM_OT_insert_keyframe_button);
WM_operatortype_append(ANIM_OT_delete_keyframe_button);
WM_operatortype_append(ANIM_OT_delete_keyframe_old); // xxx remove?
WM_operatortype_append(ANIM_OT_add_driver_button);
WM_operatortype_append(ANIM_OT_remove_driver_button);

@ -1223,7 +1223,7 @@ void ANIM_OT_delete_keyframe (wmOperatorType *ot)
* -- Joshua Leung, Jan 2009
*/
static int delete_key_old_exec (bContext *C, wmOperator *op)
static int delete_key_v3d_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
@ -1261,15 +1261,15 @@ static int delete_key_old_exec (bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
void ANIM_OT_delete_keyframe_old (wmOperatorType *ot)
void ANIM_OT_delete_keyframe_v3d (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete Keyframe";
ot->idname= "ANIM_OT_delete_keyframe_old";
ot->idname= "ANIM_OT_delete_keyframe_v3d";
/* callbacks */
ot->invoke= WM_operator_confirm;
ot->exec= delete_key_old_exec;
ot->exec= delete_key_v3d_exec;
ot->poll= ED_operator_areaactive;
@ -1347,7 +1347,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
void ANIM_OT_insert_keyframe_button (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Insert Keyframe";
ot->name= "Insert Keyframe (Buttons)";
ot->idname= "ANIM_OT_insert_keyframe_button";
/* callbacks */
@ -1355,7 +1355,7 @@ void ANIM_OT_insert_keyframe_button (wmOperatorType *ot)
ot->poll= modify_key_op_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag= OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "all", 1, "All", "Insert a keyframe for all element of the array.");
@ -1417,7 +1417,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
void ANIM_OT_delete_keyframe_button (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete Keyframe";
ot->name= "Delete Keyframe (Buttons)";
ot->idname= "ANIM_OT_delete_keyframe_button";
/* callbacks */
@ -1425,7 +1425,7 @@ void ANIM_OT_delete_keyframe_button (wmOperatorType *ot)
ot->poll= modify_key_op_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag= OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "all", 1, "All", "Delete keyfames from all elements of the array.");

@ -275,7 +275,7 @@ void ED_keymap_armature(wmWindowManager *wm)
// XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe_old", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe_v3d", IKEY, KM_PRESS, KM_ALT, 0);
/* Pose -> PoseLib ------------- */
/* only set in posemode, by space_view3d listener */

@ -110,8 +110,7 @@ void ANIM_OT_delete_keyframe(struct wmOperatorType *ot);
* required for each space.
*/
void ANIM_OT_insert_keyframe_menu(struct wmOperatorType *ot);
void ANIM_OT_delete_keyframe_menu(struct wmOperatorType *ot); // xxx unimplemented yet
void ANIM_OT_delete_keyframe_old(struct wmOperatorType *ot); // xxx rename and keep?
void ANIM_OT_delete_keyframe_v3d(struct wmOperatorType *ot);
/* Keyframe managment operators for UI buttons. */
void ANIM_OT_insert_keyframe_button(struct wmOperatorType *ot);

@ -184,7 +184,7 @@ void ED_keymap_object(wmWindowManager *wm)
// XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe_old", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe_v3d", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "GROUP_OT_group_create", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);

@ -29,6 +29,7 @@
#include <string.h>
#include <stdio.h>
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@ -37,11 +38,14 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_dlrbTree.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
#include "ED_keyframes_draw.h"
#include "ED_space_api.h"
#include "ED_screen.h"
#include "ED_util.h"
@ -106,6 +110,95 @@ static void time_draw_sfra_efra(const bContext *C, SpaceTime *stime, ARegion *ar
fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
}
/* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */
static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe)
{
ActKeyColumn *akn= NULL;
/* sanity checks */
if (ak == NULL)
return NULL;
/* check if this is a match, or whether it is in some subtree */
if (cframe < ak->cfra)
akn= time_cfra_find_ak(ak->left, cframe);
else if (cframe > ak->cfra)
akn= time_cfra_find_ak(ak->right, cframe);
/* if no match found (or found match), just use the current one */
if (akn == NULL)
return ak;
else
return akn;
}
/* helper for time_draw_keyframes() */
static void time_draw_idblock_keyframes(View2D *v2d, ID *id)
{
DLRBT_Tree keys;
ActKeyColumn *ak;
/* init binarytree-list for getting keyframes */
BLI_dlrbTree_init(&keys);
/* populate tree with keyframe nodes */
switch (GS(id->name)) {
case ID_SCE:
scene_to_keylist(NULL, (Scene *)id, &keys, NULL);
break;
case ID_OB:
ob_to_keylist(NULL, (Object *)id, &keys, NULL);
break;
}
/* build linked-list for searching */
BLI_dlrbTree_linkedlist_sync(&keys);
/* start drawing keyframes
* - we use the binary-search capabilities of the tree to only start from
* the first visible keyframe (last one can then be easily checked)
* - draw within a single GL block to be faster
*/
glBegin(GL_LINES);
for ( ak=time_cfra_find_ak(keys.root, v2d->cur.xmin);
(ak) && (ak->cfra <= v2d->cur.xmax);
ak=ak->next )
{
glVertex2f(ak->cfra, v2d->cur.ymin);
glVertex2f(ak->cfra, v2d->cur.ymax);
}
glEnd(); // GL_LINES
/* free temp stuff */
BLI_dlrbTree_free(&keys);
}
/* draw keyframe lines for timeline */
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;
/* draw scene keyframes first
* - only if we're not only showing the
*/
if ((scene) && (stime->flag & TIME_ONLYACTSEL)==0) {
/* set draw color */
glColor3ub(0xDD, 0xA7, 0x00);
time_draw_idblock_keyframes(v2d, (ID *)scene);
}
/* draw active object's keyframes */
if (ob) {
/* set draw color */
glColor3ub(0xDD, 0xD7, 0x00);
time_draw_idblock_keyframes(v2d, (ID *)ob);
}
}
/* ---------------- */
/* add handlers, stuff you only do once or on area/region changes */
static void time_main_area_init(wmWindowManager *wm, ARegion *ar)
{
@ -118,7 +211,6 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void time_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
@ -144,7 +236,10 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
UI_view2d_grid_draw(C, v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS));
UI_view2d_grid_free(grid);
/* keyframes */
time_draw_keyframes(C, stime, ar);
/* current frame */
time_draw_cfra_time(C, stime, ar);

@ -448,17 +448,6 @@ void do_time_buttons(bContext *C, void *arg, int event)
//BIF_undo_push("Set anim-preview range");
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
break;
case B_TL_INSERTKEY:
/* insert keyframe */
//common_insertkey();
//allqueue(REDRAWTIME, 1);
break;
case B_TL_DELETEKEY:
/* delete keyframe */
//common_deletekey();
//allqueue(REDRAWTIME, 1);
break;
}
}

@ -2093,7 +2093,7 @@ static void view3d_edit_objectmenu(bContext *C, uiLayout *layout, void *arg_unus
// TODO: these operators may get renamed
uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu");
uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_old");
uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d");
uiItemS(layout);
@ -3166,7 +3166,7 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un
// TODO: these operators may get renamed
uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu");
uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_old");
uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d");
uiItemS(layout);