[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28880] trunk/blender/source/blender/ editors/space_graph/graph_buttons.c: Durian Request: Panel for editing Keyframe values numerically
Joshua Leung
aligorith at gmail.com
Thu May 20 13:49:53 CEST 2010
Revision: 28880
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28880
Author: aligorith
Date: 2010-05-20 13:49:53 +0200 (Thu, 20 May 2010)
Log Message:
-----------
Durian Request: Panel for editing Keyframe values numerically
This panel allows editing of the coordinates of the 'first selected keyframe' on the Active F-Curve. That is, if you've got keyframes A (5), B (7), and C (12), and B & C are both selected, then the 'active keyframe' will be B.
While I still think it's more efficient to use the cursor for batch-setting a bunch of keyframes, there are currently problems using that for sub-frame placement on the x-axis.
Notes:
- There is none of the averaging crap from before, where no accurate value could ever be set.
- Take care when setting the values of the handles, since getting correct F-Curve recalc flushing working via the RNA stuff is VERY TRICKY, and has been left out for now to get something workable. I recommend setting the values numerically, then grabbing these keyframes and immediately cancelling, to get these updates done.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_graph/graph_buttons.c
Modified: trunk/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_buttons.c 2010-05-20 11:04:15 UTC (rev 28879)
+++ trunk/blender/source/blender/editors/space_graph/graph_buttons.c 2010-05-20 11:49:53 UTC (rev 28880)
@@ -208,11 +208,88 @@
uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
uiItemR(subrow, &fcu_ptr, "color", 0, "", 0);
- /* TODO: the following settings could be added here
- * - Access details (ID-block + RNA-Path + Array Index)
- * - ...
+ MEM_freeN(ale);
+}
+
+/* ******************* active Keyframe ************** */
+
+/* get 'active' keyframe for panel editing */
+static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezTriple **prevbezt)
+{
+ BezTriple *b;
+ int i;
+
+ /* zero the pointers */
+ *bezt = *prevbezt = NULL;
+
+ /* sanity checks */
+ if ((fcu->bezt == NULL) || (fcu->totvert == 0))
+ return 0;
+
+ /* find first selected keyframe for now, and call it the active one
+ * - this is a reasonable assumption, given that whenever anyone
+ * wants to edit numerically, there is likely to only be 1 vert selected
*/
+ for (i=0, b=fcu->bezt; i < fcu->totvert; i++, b++) {
+ if (BEZSELECTED(b)) {
+ /* found
+ * - 'previous' is either the one before, of the keyframe itself (which is still fine)
+ * XXX: we can just make this null instead if needed
+ */
+ *prevbezt = (i > 0) ? b-1 : b;
+ *bezt = b;
+
+ return 1;
+ }
+ }
+
+ /* not found */
+ return 0;
+}
+static void graph_panel_key_properties(const bContext *C, Panel *pa)
+{
+ bAnimListElem *ale;
+ FCurve *fcu;
+ BezTriple *bezt, *prevbezt;
+
+ uiLayout *layout = pa->layout;
+ uiLayout *col;
+ uiBlock *block;
+
+ if (!graph_panel_context(C, &ale, &fcu))
+ return;
+
+ block = uiLayoutGetBlock(layout);
+ uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
+
+ /* only show this info if there are keyframes to edit */
+ if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
+ PointerRNA bezt_ptr;
+
+ /* RNA pointer to keyframe, to allow editing */
+ RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr);
+
+ /* interpolation */
+ col= uiLayoutColumn(layout, 0);
+ uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, 0);
+
+ /* numerical coordinate editing */
+ col= uiLayoutColumn(layout, 1);
+ /* keyframe itself */
+ uiItemR(col, &bezt_ptr, "co", 0, "Key", 0);
+
+ /* previous handle - only if previous was Bezier interpolation */
+ if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ))
+ uiItemR(col, &bezt_ptr, "handle1", 0, NULL, 0);
+
+ /* next handle - only if current is Bezier interpolation */
+ if (bezt->ipo == BEZT_IPO_BEZ)
+ uiItemR(col, &bezt_ptr, "handle2", 0, NULL, 0);
+ }
+ else
+ uiItemL(layout, "No active keyframe on F-Curve", 0);
+
MEM_freeN(ale);
}
@@ -631,6 +708,7 @@
strcpy(pt->idname, "GRAPH_PT_view");
strcpy(pt->label, "View Properties");
pt->draw= graph_panel_view;
+ pt->flag |= PNL_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
@@ -639,7 +717,15 @@
pt->draw= graph_panel_properties;
pt->poll= graph_panel_poll;
BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
+ strcpy(pt->idname, "GRAPH_PT_key_properties");
+ strcpy(pt->label, "Active Keyframe");
+ pt->draw= graph_panel_key_properties;
+ pt->poll= graph_panel_poll;
+ BLI_addtail(&art->paneltypes, pt);
+
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
strcpy(pt->idname, "GRAPH_PT_drivers");
strcpy(pt->label, "Drivers");
More information about the Bf-blender-cvs
mailing list