Revision: 16760 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16760 Author: aligorith Date: 2008-09-27 06:51:42 +0200 (Sat, 27 Sep 2008)
Log Message: ----------- Keyframing: * Tidied up code a bit to remove an extra var declaration that may have been causing problems with Visual Keying * Added buttons to Insert/Delete keyframes from current frame into Timeline header. Note that it preferentially works will insert keyframes for a 3d-view (if it exists), otherwise it "should" take the largest area available. Modified Paths: -------------- trunk/blender/source/blender/include/blendef.h trunk/blender/source/blender/src/header_time.c trunk/blender/source/blender/src/keyframing.c Modified: trunk/blender/source/blender/include/blendef.h =================================================================== --- trunk/blender/source/blender/include/blendef.h 2008-09-27 00:36:18 UTC (rev 16759) +++ trunk/blender/source/blender/include/blendef.h 2008-09-27 04:51:42 UTC (rev 16760) @@ -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 Modified: trunk/blender/source/blender/src/header_time.c =================================================================== --- trunk/blender/source/blender/src/header_time.c 2008-09-27 00:36:18 UTC (rev 16759) +++ trunk/blender/source/blender/src/header_time.c 2008-09-27 04:51:42 UTC (rev 16760) @@ -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 @@ 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 @@ 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 Modified: trunk/blender/source/blender/src/keyframing.c =================================================================== --- trunk/blender/source/blender/src/keyframing.c 2008-09-27 00:36:18 UTC (rev 16759) +++ trunk/blender/source/blender/src/keyframing.c 2008-09-27 04:51:42 UTC (rev 16760) @@ -644,7 +644,7 @@ /* 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 @@ 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,19 +1478,47 @@ /* 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 @@ /* 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; } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs