diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/blendef.h | 2 | ||||
-rw-r--r-- | source/blender/src/header_time.c | 21 | ||||
-rw-r--r-- | source/blender/src/keyframing.c | 38 |
3 files changed, 56 insertions, 5 deletions
diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index 7f1b0f234dd..50179325609 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -406,6 +406,8 @@ #define B_TL_NEXTKEY 755 #define B_TL_STOP 756 #define B_TL_PREVIEWON 757 +#define B_TL_INSERTKEY 758 +#define B_TL_DELETEKEY 759 /* NLA: 801-850 */ #define B_NLAHOME 801 diff --git a/source/blender/src/header_time.c b/source/blender/src/header_time.c index 9a77a4c44eb..a67422879d4 100644 --- a/source/blender/src/header_time.c +++ b/source/blender/src/header_time.c @@ -45,6 +45,7 @@ #include "BIF_gl.h" #include "BIF_interface.h" +#include "BIF_keyframing.h" #include "BIF_resources.h" #include "BIF_screen.h" #include "BIF_space.h" @@ -130,6 +131,17 @@ void do_time_buttons(ScrArea *sa, unsigned short event) BIF_undo_push("Set anim-preview range"); allqueue(REDRAWALL, 0); 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; } } @@ -557,6 +569,15 @@ void time_buttons(ScrArea *sa) uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER, xco, 0, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor"); + xco+= XIC+16; + + uiDefIconBut(block, BUT, B_TL_INSERTKEY, ICON_KEY_HLT, + xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Insert Keyframe for the context of the largest area (IKEY)"); + xco+= XIC+4; + uiDefIconBut(block, BUT, B_TL_DELETEKEY, ICON_KEY_DEHLT, + xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Delete Keyframe for the context of the largest area (ALTKEY-IKEY)"); + xco+= XIC+4; + /* always as last */ sa->headbutlen= xco+XIC+80; // +80 because the last button is not an icon diff --git a/source/blender/src/keyframing.c b/source/blender/src/keyframing.c index c62032cd9d6..edc7fb4999f 100644 --- a/source/blender/src/keyframing.c +++ b/source/blender/src/keyframing.c @@ -644,7 +644,7 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co /* parented objects are not supported, as the effects of the parent * are included in the matrix, which kindof beats the point */ - if ((ob) && (ob->parent==NULL)) { + if (ob->parent == NULL) { /* only Location or Rotation keyframes are supported now */ if (ELEM3(adrcode, OB_LOC_X, OB_LOC_Y, OB_LOC_Z)) { /* assumes that OB_LOC_Z > OB_LOC_Y > OB_LOC_X */ @@ -690,7 +690,7 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co return tmat[3][index]; } else if (ELEM4(adrcode, AC_QUAT_W, AC_QUAT_X, AC_QUAT_Y, AC_QUAT_Z)) { - float tmat[4][4], trimat[3][3], quat[4]; + float trimat[3][3], quat[4]; /* assumes that AC_QUAT_Z > AC_QUAT_Y > AC_QUAT_X > AC_QUAT_W */ index= adrcode - AC_QUAT_W; @@ -1478,18 +1478,46 @@ static void commonkey_context_getsbuts (ListBase *sources, bKeyingContext **ksc) /* get keyingsets for appropriate context */ -static void commonkey_context_get (ListBase *sources, bKeyingContext **ksc) +static void commonkey_context_get (ScrArea *sa, ListBase *sources, bKeyingContext **ksc) { /* check view type */ - switch (curarea->spacetype) { + switch (sa->spacetype) { /* 3d view - first one tested as most often used */ case SPACE_VIEW3D: + { commonkey_context_getv3d(sources, ksc); + } break; /* buttons view */ case SPACE_BUTS: + { commonkey_context_getsbuts(sources, ksc); + } + break; + + /* timeline view - keyframe buttons */ + case SPACE_TIME: + { + ScrArea *sab; + + /* try to find largest 3d-view available + * (mostly of the time, this is what when user will want this, + * as it's a standard feature in all other apps) + */ + sab= find_biggest_area_of_type(SPACE_VIEW3D); + if (sab) { + commonkey_context_getv3d(sources, ksc); + return; + } + + /* otherwise, try to find the biggest area + * WARNING: must check if that area is another timeline, as that would cause infinite loop + */ + sab= closest_bigger_area(); + if ((sab) && (sab->spacetype != SPACE_TIME)) + commonkey_context_get(sab, sources, ksc); + } break; } } @@ -1656,7 +1684,7 @@ void common_modifykey (short mode) /* default - check per view */ default: /* get the keyingsets and the data to add keyframes to */ - commonkey_context_get(&dsources, &ksc); + commonkey_context_get(curarea, &dsources, &ksc); break; } |