[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19648] branches/blender2.5/blender/source /blender/editors: 2.5 Drivers:
Joshua Leung
aligorith at gmail.com
Sat Apr 11 02:29:21 CEST 2009
Revision: 19648
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19648
Author: aligorith
Date: 2009-04-11 02:29:21 +0200 (Sat, 11 Apr 2009)
Log Message:
-----------
2.5 Drivers:
* Fixed bug with setting the active F-Curve
* UI for editing drivers now works
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c 2009-04-10 21:07:32 UTC (rev 19647)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c 2009-04-11 00:29:21 UTC (rev 19648)
@@ -120,7 +120,6 @@
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- short smode;
/* try to build list of filtered items */
// XXX we don't need/supply animcontext for now, since in this case, there's nothing really essential there that isn't already covered
@@ -132,35 +131,45 @@
for (ale= anim_data.first; ale; ale= ale->next) {
/* skip if types don't match */
if (channel_type != ale->type)
- continue;
+ continue;
- /* flag setting mode
- * - depends on whether the provided channel is encountered
- */
- if (ale->data == channel_data)
- smode= ACHANNEL_SETFLAG_ADD;
- else
- smode= ACHANNEL_SETFLAG_CLEAR;
-
/* flag to set depends on type */
switch (ale->type) {
case ANIMTYPE_GROUP:
{
bActionGroup *agrp= (bActionGroup *)ale->data;
- ACHANNEL_SET_FLAG(agrp, smode, AGRP_ACTIVE);
+ ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE);
}
break;
case ANIMTYPE_FCURVE:
{
FCurve *fcu= (FCurve *)ale->data;
- ACHANNEL_SET_FLAG(fcu, smode, FCURVE_ACTIVE);
+ ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE);
}
break;
}
}
+ /* set active flag */
+ if (channel_data) {
+ switch (channel_type) {
+ case ANIMTYPE_GROUP:
+ {
+ bActionGroup *agrp= (bActionGroup *)channel_data;
+ agrp->flag |= AGRP_ACTIVE;
+ }
+ break;
+ case ANIMTYPE_FCURVE:
+ {
+ FCurve *fcu= (FCurve *)channel_data;
+ fcu->flag |= FCURVE_ACTIVE;
+ }
+ break;
+ }
+ }
+
/* clean up */
BLI_freelistN(&anim_data);
}
Modified: branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c 2009-04-10 21:07:32 UTC (rev 19647)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c 2009-04-11 00:29:21 UTC (rev 19648)
@@ -141,7 +141,7 @@
{
Scene *scene= CTX_data_scene(C);
- switch(event) {
+ switch (event) {
case B_IPO_DEPCHANGE:
{
/* rebuild depsgraph for the new deps */
@@ -158,13 +158,24 @@
//WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
}
+/* callback to copy over RNA-Paths accordingly */
+static void driver_rnapath_copy_cb (bContext *C, void *driver_v, void *strbuf_v)
+{
+ ChannelDriver *driver= (ChannelDriver *)driver_v;
+ char *stringBuf= (char *)strbuf_v;
+
+ /* copy over string */
+ if (driver->rna_path)
+ MEM_freeN(driver->rna_path);
+ driver->rna_path= BLI_strdupn(stringBuf, strlen(stringBuf));
+}
+
static void graph_panel_drivers(const bContext *C, ARegion *ar, short cntrl, bAnimListElem *ale)
{
FCurve *fcu= (FCurve *)ale->data;
ChannelDriver *driver= fcu->driver;
uiBlock *block;
uiBut *but;
- int len;
block= uiBeginBlock(C, ar, "graph_panel_drivers", UI_EMBOSS, UI_HELV);
if (uiNewPanel(C, ar, block, "Drivers", "Graph", 340, 30, 318, 254)==0) return;
@@ -178,36 +189,39 @@
uiDefButI(block, MENU, B_IPO_DEPCHANGE,
"Driver Type%t|Transform Channel%x0|Scripted Expression%x1|Rotational Difference%x2",
130,200,180,20, &driver->type, 0, 0, 0, 0, "Driver type");
+ uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Update Dependencies", 10, 180, 300, 20, NULL, 0.0, 0.0, 0, 0, "Force updates of dependencies");
/* buttons to draw depends on type of driver */
if (driver->type == DRIVER_TYPE_PYTHON) { /* PyDriver */
- uiDefBut(block, TEX, B_REDR, "Expr: ", 10,160,300,20, driver->expression, 0, 255, 0, 0, "One-liner Python Expression to use as Scripted Expression");
+ uiDefBut(block, TEX, B_REDR, "Expr: ", 10,150,300,20, driver->expression, 0, 255, 0, 0, "One-liner Python Expression to use as Scripted Expression");
if (driver->flag & DRIVER_FLAG_INVALID) {
- uiDefIconBut(block, LABEL, 1, ICON_ERROR, 10, 140, 20, 19, NULL, 0, 0, 0, 0, "");
+ uiDefIconBut(block, LABEL, 1, ICON_ERROR, 10, 130, 20, 19, NULL, 0, 0, 0, 0, "");
uiDefBut(block, LABEL, 0, "Error: invalid Python expression",
- 30,140,230,19, NULL, 0, 0, 0, 0, "");
+ 30,130,230,19, NULL, 0, 0, 0, 0, "");
}
}
else { /* Channel or RotDiff - RotDiff just has extra settings */
/* Driver Object */
- but= uiDefBut(block, TEX, B_IPO_DEPCHANGE, "OB: ", 10,160,150,20, driver->id->name+2, 0.0, 21.0, 0, 0, "Object that controls this Driver.");
- uiButSetFunc(but, test_idbutton_cb, driver->id->name, NULL);
+ uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_REDR,
+ "Ob: ", 10, 150, 150, 20, &driver->id, "Object to use as Driver target");
// XXX should we hide these technical details?
if (driver->id) {
+ static char pathBuf[512]; /* bad... evil... */
+
/* Array Index */
// XXX ideally this is grouped with the path, but that can get quite long...
- uiDefButI(block, NUM, B_IPO_DEPCHANGE, "Index: ", 170,160,140,20, &driver->array_index, 0, INT_MAX, 0, 0, "Index to the specific property used as Driver if applicable.");
+ uiDefButI(block, NUM, B_REDR, "Index: ", 170,150,140,20, &driver->array_index, 0, INT_MAX, 0, 0, "Index to the specific property used as Driver if applicable.");
- /* RNA-Path - allocate if non-existant */
- if (driver->rna_path == NULL) {
- driver->rna_path= MEM_callocN(256, "Driver RNA-Path");
- len= 255;
- }
+ /* RNA Path */
+ if (driver->rna_path == NULL)
+ pathBuf[0]= '\0';
else
- len= strlen(driver->rna_path);
- uiDefBut(block, TEX, B_IPO_DEPCHANGE, "Path: ", 10,130,300,20, driver->rna_path, 0, len, 0, 0, "RNA Path (from Driver Object) to property used as Driver.");
+ BLI_snprintf(pathBuf, 512, driver->rna_path);
+
+ but= uiDefButC(block, TEX, B_REDR, "Path: ", 10,120,300,20, pathBuf, 0, 511, 0, 0, "RNA Path (from Driver Object) to property used as Driver.");
+ uiButSetFunc(but, driver_rnapath_copy_cb, driver, pathBuf);
}
/* for rotational difference, show second target... */
More information about the Bf-blender-cvs
mailing list