[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18710] branches/blender2.5/blender/source /blender/editors: Graph Editor: Bringing back editing tools
Joshua Leung
aligorith at gmail.com
Wed Jan 28 07:33:11 CET 2009
Revision: 18710
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18710
Author: aligorith
Date: 2009-01-28 07:32:47 +0100 (Wed, 28 Jan 2009)
Log Message:
-----------
Graph Editor: Bringing back editing tools
* Snap + Mirror Keyframes (Shift-S and Shift-M)
* Set Handle/Interpolation type
* Snap current frame to selected keyframes (Ctrl-Shift-S) from the DopeSheet
* Toggle visibility of all handles (Ctrl H) from AnimSys2 branch also ported
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_edit.c
branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_intern.h
branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_select.c
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c 2009-01-28 03:22:37 UTC (rev 18709)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c 2009-01-28 06:32:47 UTC (rev 18710)
@@ -197,7 +197,7 @@
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= ale->key_data;
- /* make sure keyframes in IPO-curve are all in order, and handles are in valid positions */
+ /* make sure keyframes in F-curve are all in order, and handles are in valid positions */
sort_time_fcurve(fcu);
testhandles_fcurve(fcu);
}
@@ -308,6 +308,16 @@
return 0;
}
+static short snap_bezier_horizontal(BeztEditData *bed, BezTriple *bezt)
+{
+ if (bezt->f2 & SELECT) {
+ bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
+ if ((bezt->h1==HD_AUTO) || (bezt->h1==HD_VECT)) bezt->h1= HD_ALIGN;
+ if ((bezt->h2==HD_AUTO) || (bezt->h2==HD_VECT)) bezt->h2= HD_ALIGN;
+ }
+ return 0;
+}
+
// calchandles_ipocurve
BeztEditFunc ANIM_editkeyframes_snap(short type)
{
@@ -321,6 +331,8 @@
return snap_bezier_nearmarker;
case SNAP_KEYS_NEARSEC: /* snap to nearest second */
return snap_bezier_nearestsec;
+ case SNAP_KEYS_HORIZONTAL: /* snap handles to same value */
+ return snap_bezier_horizontal;
default: /* just in case */
return snap_bezier_nearest;
}
Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h 2009-01-28 03:22:37 UTC (rev 18709)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h 2009-01-28 06:32:47 UTC (rev 18710)
@@ -73,6 +73,7 @@
SNAP_KEYS_NEARFRAME,
SNAP_KEYS_NEARSEC,
SNAP_KEYS_NEARMARKER,
+ SNAP_KEYS_HORIZONTAL,
} eEditKeyframes_Snap;
/* mirroring tools */
Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_edit.c 2009-01-28 03:22:37 UTC (rev 18709)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_edit.c 2009-01-28 06:32:47 UTC (rev 18710)
@@ -889,6 +889,8 @@
RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", "");
}
+#endif // XXX code to be sanitied for new system
+
/* ******************** Set Interpolation-Type Operator *********************** */
/* defines for set ipo-type for selected keyframes tool */
@@ -947,11 +949,11 @@
return OPERATOR_FINISHED;
}
-void GRAPHEDIT_OT_keyframes_ipotype (wmOperatorType *ot)
+void GRAPHEDIT_OT_keyframes_interpolation_type (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Set Keyframe Interpolation";
- ot->idname= "GRAPHEDIT_OT_keyframes_ipotype";
+ ot->idname= "GRAPHEDIT_OT_keyframes_interpolation_type";
/* api callbacks */
ot->invoke= WM_menu_invoke;
@@ -992,6 +994,7 @@
/* loop through setting flags for handles
* Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here...
*/
+ // XXX we might need to supply BeztEditData to get it to only affect selected handles
for (ale= anim_data.first; ale; ale= ale->next) {
if (mode == -1) {
BeztEditFunc toggle_cb;
@@ -1137,10 +1140,11 @@
/* defines for snap keyframes tool */
EnumPropertyItem prop_graphkeys_snap_types[] = {
- {graphkeys_SNAP_CFRA, "CFRA", "Current frame", ""},
- {graphkeys_SNAP_NEAREST_FRAME, "NEAREST_FRAME", "Nearest Frame", ""}, // XXX as single entry?
- {graphkeys_SNAP_NEAREST_SECOND, "NEAREST_SECOND", "Nearest Second", ""}, // XXX as single entry?
- {graphkeys_SNAP_NEAREST_MARKER, "NEAREST_MARKER", "Nearest Marker", ""},
+ {GRAPHKEYS_SNAP_CFRA, "CFRA", "Current frame", ""},
+ {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", "Nearest Frame", ""}, // XXX as single entry?
+ {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", "Nearest Second", ""}, // XXX as single entry?
+ {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", "Nearest Marker", ""},
+ {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", "Flatten Handles", ""},
{0, NULL, NULL, NULL}
};
@@ -1227,10 +1231,10 @@
/* defines for mirror keyframes tool */
EnumPropertyItem prop_graphkeys_mirror_types[] = {
- {graphkeys_MIRROR_CFRA, "CFRA", "Current frame", ""},
- {graphkeys_MIRROR_YAXIS, "YAXIS", "Vertical Axis", ""},
- {graphkeys_MIRROR_XAXIS, "XAXIS", "Horizontal Axis", ""},
- {graphkeys_MIRROR_MARKER, "MARKER", "First Selected Marker", ""},
+ {GRAPHKEYS_MIRROR_CFRA, "CFRA", "Current frame", ""},
+ {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", "Vertical Axis", ""},
+ {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", "Horizontal Axis", ""},
+ {GRAPHKEYS_MIRROR_MARKER, "MARKER", "First Selected Marker", ""},
{0, NULL, NULL, NULL}
};
@@ -1252,7 +1256,7 @@
/* for 'first selected marker' mode, need to find first selected marker first! */
// XXX should this be made into a helper func in the API?
- if (mode == graphkeys_MIRROR_MARKER) {
+ if (mode == GRAPHKEYS_MIRROR_MARKER) {
Scene *scene= ac->scene;
TimeMarker *marker= NULL;
@@ -1334,4 +1338,3 @@
}
/* ************************************************************************** */
-#endif // XXX code to be sanitied for new system
Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_intern.h 2009-01-28 03:22:37 UTC (rev 18709)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_intern.h 2009-01-28 06:32:47 UTC (rev 18710)
@@ -72,6 +72,45 @@
/* ***************************************** */
/* ipo_edit.c */
+void GRAPHEDIT_OT_set_previewrange(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_view_all(struct wmOperatorType *ot);
+
+void GRAPHEDIT_OT_keyframes_copy(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_paste(struct wmOperatorType *ot);
+
+void GRAPHEDIT_OT_keyframes_delete(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_clean(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_sample(struct wmOperatorType *ot);
+
+void GRAPHEDIT_OT_keyframes_handletype(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_interpolation_type(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_expotype(struct wmOperatorType *ot);
+
+void GRAPHEDIT_OT_keyframes_cfrasnap(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_snap(struct wmOperatorType *ot);
+void GRAPHEDIT_OT_keyframes_mirror(struct wmOperatorType *ot);
+
+/* defines for snap keyframes
+ * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
+ */
+enum {
+ GRAPHKEYS_SNAP_CFRA = 1,
+ GRAPHKEYS_SNAP_NEAREST_FRAME,
+ GRAPHKEYS_SNAP_NEAREST_SECOND,
+ GRAPHKEYS_SNAP_NEAREST_MARKER,
+ GRAPHKEYS_SNAP_HORIZONTAL,
+} eGraphKeys_Snap_Mode;
+
+/* defines for mirror keyframes
+ * NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
+ */
+enum {
+ GRAPHKEYS_MIRROR_CFRA = 1,
+ GRAPHKEYS_MIRROR_YAXIS,
+ GRAPHKEYS_MIRROR_XAXIS,
+ GRAPHKEYS_MIRROR_MARKER,
+} eGraphKeys_Mirror_Mode;
+
/* ***************************************** */
/* ipo_ops.c */
void graphedit_keymap(struct wmWindowManager *wm);
Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c 2009-01-28 03:22:37 UTC (rev 18709)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c 2009-01-28 06:32:47 UTC (rev 18710)
@@ -46,6 +46,8 @@
#include "UI_interface.h"
#include "UI_view2d.h"
+#include "ED_screen.h"
+
#include "BIF_transform.h"
#include "ipo_intern.h"
@@ -56,11 +58,48 @@
#include "WM_api.h"
#include "WM_types.h"
+/* ************************** view-based operators **********************************/
+// XXX this probably shouldn't be here..
+/* Toggle Handles ----------------------------------------------------------------- */
+
+static int view_toggle_handles_exec (bContext *C, wmOperator *op)
+{
+ SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
+ ARegion *ar= CTX_wm_region(C);
+
+ if (sipo == NULL)
+ return OPERATOR_CANCELLED;
+
+ /* toggle flag to hide handles */
+ sipo->flag ^= SIPO_NOHANDLES;
+
+ /* request refresh of keys area */
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+void GRAPHEDIT_OT_view_togglehandles (wmOperatorType *ot)
+{
+ /* identification */
+ ot->name= "Show/Hide All Handles";
+ ot->idname= "GRAPHEDIT_OT_view_toggle_handles";
+
+ /* callbacks */
+ ot->exec= view_toggle_handles_exec;
+ ot->poll= ED_operator_areaactive;
+}
+
/* ************************** registration - operator types **********************************/
void graphedit_operatortypes(void)
{
+ /* view */
+ WM_operatortype_append(GRAPHEDIT_OT_view_togglehandles);
+ //WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
+ //WM_operatortype_append(GRAPHEDIT_OT_view_all);
+
/* keyframes */
/* selection */
WM_operatortype_append(GRAPHEDIT_OT_keyframes_clickselect);
@@ -68,22 +107,19 @@
WM_operatortype_append(GRAPHEDIT_OT_keyframes_borderselect);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_columnselect);
-#if 0 // XXX code to be sanitied for new system
/* editing */
WM_operatortype_append(GRAPHEDIT_OT_keyframes_snap);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_mirror);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_cfrasnap);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_handletype);
- WM_operatortype_append(GRAPHEDIT_OT_keyframes_ipotype);
+ WM_operatortype_append(GRAPHEDIT_OT_keyframes_interpolation_type);
+#if 0 // XXX code to be sanitied for new system
WM_operatortype_append(GRAPHEDIT_OT_keyframes_expotype);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_sample);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_clean);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_delete);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_copy);
WM_operatortype_append(GRAPHEDIT_OT_keyframes_paste);
-
- WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
- WM_operatortype_append(GRAPHEDIT_OT_view_all);
#endif // XXX code to be sanitied for new system
}
@@ -91,6 +127,9 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list