2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-02-21 10:38:58 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-21 10:38:58 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation, Joshua Leung
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_graph/graph_buttons.c
|
|
|
|
* \ingroup spgraph
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2011-09-20 07:39:25 +00:00
|
|
|
#include "BLF_translation.h"
|
2011-07-02 03:17:09 +00:00
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_depsgraph.h"
|
2009-03-15 10:39:02 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2009-09-16 19:36:17 +00:00
|
|
|
#include "BKE_main.h"
|
2013-08-11 08:29:56 +00:00
|
|
|
#include "BKE_global.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
#include "BKE_screen.h"
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
#include "BKE_unit.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "ED_anim_api.h"
|
|
|
|
#include "ED_keyframing.h"
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
#include "graph_intern.h" // own include
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2009-02-22 09:30:18 +00:00
|
|
|
/* ******************* graph editor space & buttons ************** */
|
|
|
|
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
#define B_REDR 1
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2009-02-22 09:30:18 +00:00
|
|
|
/* -------------- */
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
bAnimContext ac;
|
2012-05-08 20:18:33 +00:00
|
|
|
bAnimListElem *elem = NULL;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
/* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
|
|
|
|
* to work correctly is able to be correctly retrieved. There's no point showing empty panels?
|
|
|
|
*/
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* try to find 'active' F-Curve */
|
2012-05-08 20:18:33 +00:00
|
|
|
elem = get_active_fcurve_channel(&ac);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (elem == NULL)
|
2009-05-19 17:13:33 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (fcu)
|
2012-05-08 20:18:33 +00:00
|
|
|
*fcu = (FCurve *)elem->data;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ale)
|
2012-05-08 20:18:33 +00:00
|
|
|
*ale = elem;
|
2009-05-19 17:13:33 +00:00
|
|
|
else
|
|
|
|
MEM_freeN(elem);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static int graph_panel_poll(const bContext *C, PanelType *UNUSED(pt))
|
2009-05-19 17:13:33 +00:00
|
|
|
{
|
|
|
|
return graph_panel_context(C, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2009-10-27 11:46:46 +00:00
|
|
|
/* -------------- */
|
|
|
|
|
|
|
|
/* Graph Editor View Settings */
|
|
|
|
static void graph_panel_view(const bContext *C, Panel *pa)
|
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
|
|
|
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-10-27 11:46:46 +00:00
|
|
|
PointerRNA spaceptr, sceneptr;
|
2011-11-23 19:05:52 +00:00
|
|
|
uiLayout *col, *sub, *row;
|
2009-10-27 11:46:46 +00:00
|
|
|
|
|
|
|
/* get RNA pointers for use when creating the UI elements */
|
|
|
|
RNA_id_pointer_create(&scene->id, &sceneptr);
|
|
|
|
RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
|
|
|
|
|
|
|
|
/* 2D-Cursor */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
|
2009-10-27 11:46:46 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
sub = uiLayoutColumn(col, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
|
|
|
|
uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
sub = uiLayoutColumn(col, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutSplit(sub, 0.7f, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
|
|
|
|
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutSplit(sub, 0.7f, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
|
|
|
|
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
|
2009-10-27 11:46:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ******************* active F-Curve ************** */
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static void graph_panel_properties(const bContext *C, Panel *pa)
|
|
|
|
{
|
|
|
|
bAnimListElem *ale;
|
|
|
|
FCurve *fcu;
|
2009-11-08 06:43:08 +00:00
|
|
|
PointerRNA fcu_ptr;
|
|
|
|
uiLayout *layout = pa->layout;
|
2011-11-23 19:05:52 +00:00
|
|
|
uiLayout *col, *row, *sub;
|
2013-07-28 06:37:58 +00:00
|
|
|
// uiBlock *block; // UNUSED
|
2009-11-08 06:43:08 +00:00
|
|
|
char name[256];
|
|
|
|
int icon = 0;
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
if (!graph_panel_context(C, &ale, &fcu))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
2009-11-08 06:43:08 +00:00
|
|
|
|
2013-07-28 06:37:58 +00:00
|
|
|
// UNUSED
|
|
|
|
// block = uiLayoutGetBlock(layout);
|
|
|
|
// uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
|
2009-02-21 11:22:06 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
/* F-Curve pointer */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
/* user-friendly 'name' for F-Curve */
|
2012-03-03 21:42:21 +00:00
|
|
|
/* TODO: only show the path if this is invalid? */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
icon = getname_anim_fcurve(name, ale->id, fcu);
|
|
|
|
uiItemL(col, name, icon);
|
2009-11-08 06:43:08 +00:00
|
|
|
|
2009-11-17 22:46:42 +00:00
|
|
|
/* RNA-Path Editing - only really should be enabled when things aren't working */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
|
|
|
|
uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
|
|
|
|
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
|
2009-11-17 22:46:42 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
/* color settings */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
|
2009-11-08 06:43:08 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(col, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
|
2009-11-08 06:43:08 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
sub = uiLayoutRow(row, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM));
|
|
|
|
uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
|
2009-02-21 11:22:06 +00:00
|
|
|
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
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
|
2009-02-22 09:30:18 +00:00
|
|
|
*/
|
2012-05-08 20:18:33 +00:00
|
|
|
for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) {
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
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
|
|
|
|
*/
|
2012-05-08 20:18:33 +00:00
|
|
|
*prevbezt = (i > 0) ? b - 1 : b;
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
*bezt = b;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not found */
|
|
|
|
return 0;
|
|
|
|
}
|
2009-05-19 17:13:33 +00:00
|
|
|
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
/* update callback for active keyframe properties - base updates stuff */
|
2011-09-29 05:03:21 +00:00
|
|
|
static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr))
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
2011-09-29 05:03:21 +00:00
|
|
|
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
FCurve *fcu = (FCurve *)fcu_ptr;
|
|
|
|
|
|
|
|
/* make sure F-Curve and its handles are still valid after this editing */
|
|
|
|
sort_time_fcurve(fcu);
|
2011-09-29 05:03:21 +00:00
|
|
|
testhandles_fcurve(fcu, use_handle);
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update callback for active keyframe properties - handle-editing wrapper */
|
|
|
|
static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
|
|
|
|
{
|
|
|
|
BezTriple *bezt = (BezTriple *)bezt_ptr;
|
|
|
|
|
|
|
|
/* since editing the handles, make sure they're set to types which are receptive to editing
|
|
|
|
* see transform_conversions.c :: createTransGraphEditData(), last step in second loop
|
|
|
|
*/
|
|
|
|
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
|
|
|
|
/* by changing to aligned handles, these can now be moved... */
|
2012-05-08 20:18:33 +00:00
|
|
|
bezt->h1 = HD_ALIGN;
|
|
|
|
bezt->h2 = HD_ALIGN;
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now call standard updates */
|
|
|
|
graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
|
|
|
|
}
|
|
|
|
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
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);
|
2013-07-27 11:55:38 +00:00
|
|
|
/* uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); */
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
|
|
|
|
/* only show this info if there are keyframes to edit */
|
|
|
|
if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr;
|
|
|
|
PropertyRNA *fcu_prop = NULL;
|
|
|
|
uiBut *but;
|
|
|
|
int unit = B_UNIT_NONE;
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
|
|
|
|
/* RNA pointer to keyframe, to allow editing */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr);
|
|
|
|
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
/* get property that F-Curve affects, for some unit-conversion magic */
|
|
|
|
RNA_id_pointer_create(ale->id, &id_ptr);
|
Bugfix [#34836] Crash when driver variable has path == 'data'
Most of the places which relied on RNA_path_resolve() did so believing that if
it returned true, that it had found a valid property, and that the returned
pointer+property combination would be what the path referred to. However, it
turns out that if the property at the end of the path turns out to be a
"pointer" property (e.g. "data" for Object.data), this would automatically
become the pointer part, while the prop part would be set to null. Hence, if a
user accidentally (or otherwise) specifies a path for the single-property driver
variable type like this, then Blender would crash.
This commit introduces two convenience functions - RNA_path_resolve_property()
and RNA_path_resolve_property_full() - which mirror/wrap the existing
RNA_path_resolve() functions. The only difference though is that these include a
check to ensure that what was found from resolving the path was in fact a
property (they only return true iff this is the case), and make it explicitly
clear in the name that this is what they will do so that there's no further
confusion. It is possible to do without these wrapper functions by doing these
checks inline, but the few cases that had been patched already were pretty
hideous looking specimens. Using these just make it clearer and simpler for all.
I've also beefed up the docs on these a bit, and changed these to using bools.
2013-04-22 13:22:07 +00:00
|
|
|
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop)) {
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
/* determine the unit for this property */
|
|
|
|
unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
/* interpolation */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
|
2014-03-22 02:50:24 +13:00
|
|
|
|
|
|
|
/* easing type */
|
|
|
|
if (bezt->ipo > BEZT_IPO_BEZ)
|
|
|
|
uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0);
|
|
|
|
|
|
|
|
/* easing extra */
|
|
|
|
switch (bezt->ipo) {
|
|
|
|
case BEZT_IPO_BACK:
|
|
|
|
col = uiLayoutColumn(layout, 1);
|
|
|
|
uiItemR(col, &bezt_ptr, "back", 0, NULL, 0);
|
|
|
|
break;
|
|
|
|
case BEZT_IPO_ELASTIC:
|
|
|
|
col = uiLayoutColumn(layout, 1);
|
|
|
|
uiItemR(col, &bezt_ptr, "amplitude", 0, NULL, 0);
|
|
|
|
uiItemR(col, &bezt_ptr, "period", 0, NULL, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
/* numerical coordinate editing
|
2012-05-08 20:18:33 +00:00
|
|
|
* - we use the button-versions of the calls so that we can attach special update handlers
|
|
|
|
* and unit conversion magic that cannot be achieved using a purely RNA-approach
|
Graph Editor "Active Keyframe" settings
This commit makes some tweaks to the way that the "active keyframe"
settings in the Properties region in the Graph Editor work (for the
better, hopefully).
Basically, the problem was that previously, these were clunky and non-
intuitive to use, since they were just directly displaying the RNA
properties for those keyframes for editing purposes. But due to
limitations of RNA (i.e. from a RNA pointer to a keyframe, you
couldn't see which F-Curve you came from), several things were
impossible, notably:
1) Doing proper updates, including validating that the handles are in
a valid state - that requires access to the F-Curve to provide to the
F-Curve-based curve validity checking functions
2) Having the values of the keyframes display in whatever unit that
the property the F-Curve affects displays as - for this, you once
again need to know the F-Curve in order to resolve the property that
it affects; also the fact that only a single unit could be set for RNA
properties further limited things
This commit basically gets around these problems by moving away from a
layout-engine based approach to one where we attach custom update
callbacks and also override the units of the y-co widgets when
creating the widgets for these, thus allowing the buttons to work in
the ways that animators expect.
2011-08-06 07:01:07 +00:00
|
|
|
*/
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
/* keyframe itself */
|
|
|
|
{
|
|
|
|
uiItemL(col, IFACE_("Key:"), ICON_NONE);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2013-12-11 21:06:00 +11:00
|
|
|
but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame:"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-05-08 20:18:33 +00:00
|
|
|
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
|
|
|
|
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2013-12-11 21:06:00 +11:00
|
|
|
but = uiDefButR(block, NUM, B_REDR, IFACE_("Value:"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-05-08 20:18:33 +00:00
|
|
|
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
|
|
|
|
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
|
|
|
|
uiButSetUnitType(but, unit);
|
|
|
|
}
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* previous handle - only if previous was Bezier interpolation */
|
|
|
|
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
|
|
|
|
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2013-12-11 21:06:00 +11:00
|
|
|
but = uiDefButR(block, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-05-08 20:18:33 +00:00
|
|
|
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
|
|
|
|
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2013-12-11 21:06:00 +11:00
|
|
|
but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-05-08 20:18:33 +00:00
|
|
|
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
|
|
|
|
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
|
|
|
uiButSetUnitType(but, unit);
|
|
|
|
}
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* next handle - only if current is Bezier interpolation */
|
|
|
|
if (bezt->ipo == BEZT_IPO_BEZ) {
|
|
|
|
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2013-12-11 21:06:00 +11:00
|
|
|
but = uiDefButR(block, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-05-08 20:18:33 +00:00
|
|
|
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
|
|
|
|
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2013-12-11 21:06:00 +11:00
|
|
|
but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-05-08 20:18:33 +00:00
|
|
|
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
|
|
|
|
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
|
|
|
uiButSetUnitType(but, unit);
|
|
|
|
}
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
}
|
2010-12-28 06:18:56 +00:00
|
|
|
else {
|
|
|
|
if ((fcu->bezt == NULL) && (fcu->modifiers.first)) {
|
|
|
|
/* modifiers only - so no keyframes to be active */
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(layout, IFACE_("F-Curve only has F-Modifiers"), ICON_NONE);
|
|
|
|
uiItemL(layout, IFACE_("See Modifiers panel below"), ICON_INFO);
|
2010-12-28 06:18:56 +00:00
|
|
|
}
|
|
|
|
else if (fcu->fpt) {
|
|
|
|
/* samples only */
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(layout, IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"),
|
|
|
|
ICON_NONE);
|
2010-12-28 06:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-03 21:42:21 +00:00
|
|
|
uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
|
2010-12-28 06:18:56 +00:00
|
|
|
}
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
MEM_freeN(ale);
|
2009-02-21 10:38:58 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 03:49:22 +00:00
|
|
|
/* ******************* drivers ******************************** */
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
#define B_IPO_DEPCHANGE 10
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int event)
|
2009-02-22 09:30:18 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-04-11 00:29:21 +00:00
|
|
|
switch (event) {
|
2009-02-22 09:30:18 +00:00
|
|
|
case B_IPO_DEPCHANGE:
|
|
|
|
{
|
|
|
|
/* rebuild depsgraph for the new deps */
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(bmain);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* default for now */
|
2012-05-08 20:18:33 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2009-04-11 06:48:39 +00:00
|
|
|
/* callback to remove the active driver */
|
2012-05-08 20:18:33 +00:00
|
|
|
static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg))
|
2009-04-11 06:48:39 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
bAnimListElem *ale = (bAnimListElem *)ale_v;
|
|
|
|
ID *id = ale->id;
|
|
|
|
FCurve *fcu = ale->data;
|
2010-12-28 05:45:15 +00:00
|
|
|
ReportList *reports = CTX_wm_reports(C);
|
2009-04-11 06:48:39 +00:00
|
|
|
|
|
|
|
/* try to get F-Curve that driver lives on, and ID block which has this AnimData */
|
|
|
|
if (ELEM(NULL, id, fcu))
|
|
|
|
return;
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* call API method to remove this driver */
|
2010-12-28 05:45:15 +00:00
|
|
|
ANIM_remove_driver(reports, id, fcu->rna_path, fcu->array_index, 0);
|
2009-04-11 06:48:39 +00:00
|
|
|
}
|
|
|
|
|
2009-04-16 12:38:44 +00:00
|
|
|
/* callback to add a target variable to the active driver */
|
2012-05-08 20:18:33 +00:00
|
|
|
static void driver_add_var_cb(bContext *UNUSED(C), void *driver_v, void *UNUSED(arg))
|
2009-04-16 12:38:44 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
ChannelDriver *driver = (ChannelDriver *)driver_v;
|
2009-04-16 12:38:44 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* add a new variable */
|
|
|
|
driver_add_new_variable(driver);
|
2009-04-16 12:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* callback to remove target variable from active driver */
|
2012-05-08 20:18:33 +00:00
|
|
|
static void driver_delete_var_cb(bContext *UNUSED(C), void *driver_v, void *dvar_v)
|
2009-04-16 12:38:44 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
ChannelDriver *driver = (ChannelDriver *)driver_v;
|
|
|
|
DriverVar *dvar = (DriverVar *)dvar_v;
|
2009-04-16 12:38:44 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* remove the active variable */
|
|
|
|
driver_free_variable(driver, dvar);
|
2009-04-16 12:38:44 +00:00
|
|
|
}
|
|
|
|
|
2009-04-11 06:48:39 +00:00
|
|
|
/* callback to reset the driver's flags */
|
2012-05-08 20:18:33 +00:00
|
|
|
static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg))
|
2009-04-11 06:48:39 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
FCurve *fcu = (FCurve *)fcu_v;
|
|
|
|
ChannelDriver *driver = fcu->driver;
|
2009-04-11 06:48:39 +00:00
|
|
|
|
|
|
|
/* clear invalid flags */
|
2012-10-20 05:08:26 +00:00
|
|
|
fcu->flag &= ~FCURVE_DISABLED;
|
2009-04-11 06:48:39 +00:00
|
|
|
driver->flag &= ~DRIVER_FLAG_INVALID;
|
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* drivers panel poll */
|
2010-10-16 02:40:31 +00:00
|
|
|
static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
|
2009-05-19 17:13:33 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sipo->mode != SIPO_MODE_DRIVERS)
|
2009-05-19 17:13:33 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return graph_panel_context(C, NULL, NULL);
|
|
|
|
}
|
Animato - Drivers with Multiple Targets:
Drivers now support multiple targets which act as 'variables'. The targets have a short 'name' (see later), and reference some property (in much the same way as F-Curves do, using RNA-Paths) which acts as the 'value'.
These named variables can then be used in a Python Expression which relates them to each other for more fine-grained control over the result of the driver. By using only the names of these variables in the expressions, we are able to define expressions/relationships in a much more readable way, as data access is separated from data use. This makes the underlying relationships easier to understand.
By default, if no Python Expression is given, the variables are simply averaged together, so old files won't break. :)
For example, check the following diagram (thanks Cessen/Nathan V from Peach team):
http://download.blender.org/ftp/incoming/250_drivers_mockup_cessen.png
TODO List:
* Depsgraph building for new driver relationships doesn't work yet. This needs to be recoded again, but this new system makes this much easier, since the targets are clearly defined (i.e. no need to parse py expressions to get list of objects)
* Graph Editor interface for editing these needs to be rewritten
* Python function for evaluating these expressions is needed (Campbell?)
2009-04-16 07:37:06 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* settings for 'single property' driver variable type */
|
2010-10-16 02:40:31 +00:00
|
|
|
static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVar *dvar)
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
DriverTarget *dtar = &dvar->targets[0];
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
PointerRNA dtar_ptr;
|
|
|
|
uiLayout *row, *col;
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize RNA pointer to the target */
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
|
|
|
|
|
|
|
/* Target ID */
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(row, ((dtar->flag & DTAR_FLAG_INVALID) && !dtar->id));
|
2012-05-08 20:18:33 +00:00
|
|
|
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
|
|
|
|
/* Target Property */
|
|
|
|
if (dtar->id) {
|
|
|
|
PointerRNA root_ptr;
|
|
|
|
|
|
|
|
/* get pointer for resolving the property selected */
|
|
|
|
RNA_id_pointer_create(dtar->id, &root_ptr);
|
|
|
|
|
2011-03-28 02:34:55 +00:00
|
|
|
/* rna path */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID));
|
2012-03-03 21:42:21 +00:00
|
|
|
uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path"));
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* settings for 'rotation difference' driver variable type */
|
2010-10-16 02:40:31 +00:00
|
|
|
static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *dvar)
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
DriverTarget *dtar = &dvar->targets[0];
|
|
|
|
DriverTarget *dtar2 = &dvar->targets[1];
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
Object *ob1 = (Object *)dtar->id;
|
|
|
|
Object *ob2 = (Object *)dtar2->id;
|
|
|
|
PointerRNA dtar_ptr, dtar2_ptr;
|
|
|
|
uiLayout *col;
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize RNA pointer to the target */
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
|
|
|
RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr);
|
|
|
|
|
|
|
|
/* Bone 1 */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:"));
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
if (dtar->id && ob1->pose) {
|
|
|
|
PointerRNA tar_ptr;
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
|
|
|
|
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
|
|
|
}
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(col, (dtar2->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:"));
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
if (dtar2->id && ob2->pose) {
|
|
|
|
PointerRNA tar_ptr;
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
|
|
|
|
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
|
|
|
}
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
}
|
|
|
|
|
2010-01-05 11:59:12 +00:00
|
|
|
/* settings for 'location difference' driver variable type */
|
2010-10-16 02:40:31 +00:00
|
|
|
static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *dvar)
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
{
|
2013-02-28 07:13:33 +00:00
|
|
|
DriverTarget *dtar = &dvar->targets[0];
|
2012-05-08 20:18:33 +00:00
|
|
|
DriverTarget *dtar2 = &dvar->targets[1];
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
Object *ob1 = (Object *)dtar->id;
|
|
|
|
Object *ob2 = (Object *)dtar2->id;
|
|
|
|
PointerRNA dtar_ptr, dtar2_ptr;
|
|
|
|
uiLayout *col;
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize RNA pointer to the target */
|
2013-02-28 07:13:33 +00:00
|
|
|
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr);
|
|
|
|
|
|
|
|
/* Bone 1 */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:"));
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
if (dtar->id && ob1->pose) {
|
|
|
|
PointerRNA tar_ptr;
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
|
|
|
|
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
|
|
|
}
|
2013-02-28 11:00:06 +00:00
|
|
|
|
|
|
|
uiLayoutSetRedAlert(col, false); /* we can clear it again now - it's only needed when creating the ID/Bone fields */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(col, (dtar2->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:"));
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
if (dtar2->id && ob2->pose) {
|
|
|
|
PointerRNA tar_ptr;
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
|
|
|
|
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
|
|
|
}
|
2010-01-05 11:59:12 +00:00
|
|
|
|
2013-02-28 11:00:06 +00:00
|
|
|
uiLayoutSetRedAlert(col, false); /* we can clear it again now - it's only needed when creating the ID/Bone fields */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
|
2010-01-05 11:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* settings for 'transform channel' driver variable type */
|
2010-10-16 02:40:31 +00:00
|
|
|
static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar *dvar)
|
2010-01-05 11:59:12 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
DriverTarget *dtar = &dvar->targets[0];
|
2010-01-05 11:59:12 +00:00
|
|
|
Object *ob = (Object *)dtar->id;
|
|
|
|
PointerRNA dtar_ptr;
|
2011-11-23 19:05:52 +00:00
|
|
|
uiLayout *col, *sub;
|
2010-01-05 11:59:12 +00:00
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize RNA pointer to the target */
|
2010-01-05 11:59:12 +00:00
|
|
|
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
|
|
|
|
|
|
|
/* properties */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2013-02-28 07:13:33 +00:00
|
|
|
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
|
2012-05-08 20:18:33 +00:00
|
|
|
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:"));
|
2010-01-05 11:59:12 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
if (dtar->id && ob->pose) {
|
|
|
|
PointerRNA tar_ptr;
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr);
|
|
|
|
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
|
|
|
}
|
2010-01-05 11:59:12 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
sub = uiLayoutColumn(layout, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE);
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* driver settings for active F-Curve (only for 'Drivers' mode) */
|
|
|
|
static void graph_panel_drivers(const bContext *C, Panel *pa)
|
2009-02-22 09:30:18 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
bAnimListElem *ale;
|
|
|
|
FCurve *fcu;
|
|
|
|
ChannelDriver *driver;
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
DriverVar *dvar;
|
2009-04-16 12:38:44 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
PointerRNA driver_ptr;
|
|
|
|
uiLayout *col;
|
2009-02-22 09:30:18 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* Get settings from context */
|
|
|
|
if (!graph_panel_context(C, &ale, &fcu))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
2012-05-08 20:18:33 +00:00
|
|
|
driver = fcu->driver;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* set event handler for panel */
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(pa->layout); // xxx?
|
2009-05-19 17:13:33 +00:00
|
|
|
uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* general actions - management */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(col);
|
2014-03-08 12:31:58 +13:00
|
|
|
but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
|
|
|
|
0, 0, 10 * UI_UNIT_X, 22,
|
|
|
|
NULL, 0.0, 0.0, 0, 0,
|
|
|
|
TIP_("Force updates of dependencies"));
|
2012-05-08 20:18:33 +00:00
|
|
|
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
|
|
|
|
|
2014-03-08 12:31:58 +13:00
|
|
|
but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"),
|
|
|
|
0, 0, 10 * UI_UNIT_X, 18,
|
|
|
|
NULL, 0.0, 0.0, 0, 0,
|
|
|
|
TIP_("Remove this driver"));
|
2012-05-08 20:18:33 +00:00
|
|
|
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* driver-level settings - type, expressions, and errors */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
|
2009-04-16 12:38:44 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(col);
|
|
|
|
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
|
|
|
|
if (driver->type == DRIVER_TYPE_PYTHON) {
|
2014-03-08 12:31:58 +13:00
|
|
|
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
|
|
|
|
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* expression */
|
|
|
|
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* errors? */
|
2013-08-11 08:29:56 +00:00
|
|
|
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
|
2014-03-08 12:31:58 +13:00
|
|
|
uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
|
2013-08-11 08:29:56 +00:00
|
|
|
}
|
|
|
|
else if (driver->flag & DRIVER_FLAG_INVALID) {
|
2014-03-08 12:31:58 +13:00
|
|
|
uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Explicit bpy-references are evil. Warn about these to prevent errors */
|
|
|
|
/* TODO: put these in a box? */
|
|
|
|
if (bpy_data_expr_error || bpy_ctx_expr_error) {
|
|
|
|
uiItemL(col, IFACE_("WARNING: Driver expression may not work correctly"), ICON_HELP);
|
|
|
|
|
|
|
|
if (bpy_data_expr_error) {
|
|
|
|
uiItemL(col, IFACE_("TIP: Use variables instead of bpy.data paths (see below)"), ICON_ERROR);
|
|
|
|
}
|
|
|
|
if (bpy_ctx_expr_error) {
|
|
|
|
uiItemL(col, IFACE_("TIP: bpy.context is not safe for renderfarm usage"), ICON_ERROR);
|
|
|
|
}
|
2013-08-11 08:29:56 +00:00
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* errors? */
|
|
|
|
if (driver->flag & DRIVER_FLAG_INVALID)
|
2012-10-20 05:08:26 +00:00
|
|
|
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
|
2014-03-22 16:56:17 +13:00
|
|
|
|
|
|
|
/* Warnings about a lack of variables
|
|
|
|
* NOTE: The lack of variables is generally a bad thing, since it indicates
|
|
|
|
* that the driver doesn't work at all. This particular scenario arises
|
|
|
|
* primarily when users mistakenly try to use drivers for procedural
|
|
|
|
* property animation
|
|
|
|
*/
|
|
|
|
if (BLI_listbase_is_empty(&driver->variables)) {
|
|
|
|
uiItemL(col, IFACE_("ERROR: Driver is useless without any inputs"), ICON_ERROR);
|
|
|
|
|
|
|
|
if (!BLI_listbase_is_empty(&fcu->modifiers)) {
|
|
|
|
uiItemL(col, IFACE_("TIP: Use F-Curves for procedural animation instead"), ICON_INFO);
|
|
|
|
uiItemL(col, IFACE_("F-Modifiers can generate curves for those too"), ICON_INFO);
|
|
|
|
}
|
|
|
|
}
|
2012-05-08 20:18:33 +00:00
|
|
|
}
|
2010-01-19 23:38:26 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
/* debug setting */
|
|
|
|
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
|
2010-01-19 23:38:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* value of driver */
|
|
|
|
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
2014-04-01 11:34:00 +11:00
|
|
|
uiLayout *row = uiLayoutRow(col, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
char valBuf[32];
|
2010-01-19 23:38:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
|
2010-01-19 23:38:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
|
|
|
|
uiItemL(row, valBuf, ICON_NONE);
|
|
|
|
}
|
2009-04-16 12:38:44 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* add driver variables */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(col);
|
2014-03-08 12:31:58 +13:00
|
|
|
but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"),
|
|
|
|
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
|
|
|
NULL, 0.0, 0.0, 0, 0,
|
|
|
|
TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly"));
|
2012-05-08 20:18:33 +00:00
|
|
|
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
|
2009-04-16 12:38:44 +00:00
|
|
|
|
|
|
|
/* loop over targets, drawing them */
|
2012-05-08 20:18:33 +00:00
|
|
|
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
PointerRNA dvar_ptr;
|
2009-10-14 11:57:26 +00:00
|
|
|
uiLayout *box, *row;
|
2009-04-17 02:13:35 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* sub-layout column for this variable's settings */
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, true);
|
2009-04-11 00:29:21 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* header panel */
|
2012-05-08 20:18:33 +00:00
|
|
|
box = uiLayoutBox(col);
|
|
|
|
/* first row context info for driver */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(row);
|
|
|
|
/* variable name */
|
|
|
|
uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* remove button */
|
|
|
|
uiBlockSetEmboss(block, UI_EMBOSSN);
|
|
|
|
but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
|
|
|
|
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
|
|
|
|
uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
|
|
|
|
uiBlockSetEmboss(block, UI_EMBOSS);
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* variable type */
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
|
2009-10-14 11:57:26 +00:00
|
|
|
|
Durian Request: Drivers Recode
Highlights:
* Support for Multi-Target Variables
This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that.
* New Variable Types
With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones).
* New Driver Types
In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to.
* Fix for Driver F-Curve colouring bug
Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used.
Notes:
* This commit breaks existing 2.5 files with drivers (in other words, they are lost forever).
* Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later.
* Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
|
|
|
/* variable type settings */
|
2012-05-08 20:18:33 +00:00
|
|
|
box = uiLayoutBox(col);
|
|
|
|
/* controls to draw depends on the type of variable */
|
|
|
|
switch (dvar->type) {
|
|
|
|
case DVAR_TYPE_SINGLE_PROP: /* single property */
|
|
|
|
graph_panel_driverVar__singleProp(box, ale->id, dvar);
|
|
|
|
break;
|
|
|
|
case DVAR_TYPE_ROT_DIFF: /* rotational difference */
|
|
|
|
graph_panel_driverVar__rotDiff(box, ale->id, dvar);
|
|
|
|
break;
|
|
|
|
case DVAR_TYPE_LOC_DIFF: /* location difference */
|
|
|
|
graph_panel_driverVar__locDiff(box, ale->id, dvar);
|
|
|
|
break;
|
|
|
|
case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
|
|
|
|
graph_panel_driverVar__transChan(box, ale->id, dvar);
|
|
|
|
break;
|
|
|
|
}
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
/* value of variable */
|
|
|
|
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
|
|
|
char valBuf[32];
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
box = uiLayoutBox(col);
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(box, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemL(row, IFACE_("Value:"), ICON_NONE);
|
2012-10-20 05:08:26 +00:00
|
|
|
|
2012-11-20 23:35:03 +00:00
|
|
|
if ((dvar->type == DVAR_TYPE_ROT_DIFF) ||
|
2012-11-23 06:35:06 +00:00
|
|
|
(dvar->type == DVAR_TYPE_TRANSFORM_CHAN &&
|
|
|
|
dvar->targets[0].transChan >= DTAR_TRANSCHAN_ROTX &&
|
|
|
|
dvar->targets[0].transChan < DTAR_TRANSCHAN_SCALEX))
|
|
|
|
{
|
2012-11-20 23:35:03 +00:00
|
|
|
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval));
|
2012-11-23 06:35:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-11-20 23:35:03 +00:00
|
|
|
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
|
2012-11-23 06:35:06 +00:00
|
|
|
}
|
2013-02-28 07:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemL(row, valBuf, ICON_NONE);
|
|
|
|
}
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2009-05-19 17:13:33 +00:00
|
|
|
MEM_freeN(ale);
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 05:08:26 +00:00
|
|
|
/* ******************* F-Modifiers ******************************** */
|
|
|
|
/* All the drawing code is in editors/animation/fmodifier_ui.c */
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
#define B_FMODIFIER_REDRAW 20
|
2009-03-15 10:39:02 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event)
|
2009-02-22 09:30:18 +00:00
|
|
|
{
|
2009-03-16 11:11:44 +00:00
|
|
|
switch (event) {
|
|
|
|
case B_FMODIFIER_REDRAW: // XXX this should send depsgraph updates too
|
2009-10-14 11:57:26 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION, NULL); // XXX need a notifier specially for F-Modifiers
|
|
|
|
break;
|
2009-03-15 10:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static void graph_panel_modifiers(const bContext *C, Panel *pa)
|
2009-02-22 09:30:18 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
bAnimListElem *ale;
|
|
|
|
FCurve *fcu;
|
2009-03-15 10:39:02 +00:00
|
|
|
FModifier *fcm;
|
2009-07-02 12:41:03 +00:00
|
|
|
uiLayout *col, *row;
|
2009-02-22 09:30:18 +00:00
|
|
|
uiBlock *block;
|
2009-03-16 11:11:44 +00:00
|
|
|
|
2009-07-02 12:41:03 +00:00
|
|
|
if (!graph_panel_context(C, &ale, &fcu))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(pa->layout);
|
2009-05-19 17:13:33 +00:00
|
|
|
uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL);
|
2009-03-16 11:11:44 +00:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* 'add modifier' button at top of panel */
|
2009-07-02 12:41:03 +00:00
|
|
|
{
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(pa->layout, false);
|
2012-05-08 20:18:33 +00:00
|
|
|
block = uiLayoutGetBlock(row);
|
2009-07-02 12:41:03 +00:00
|
|
|
|
2012-10-20 05:08:26 +00:00
|
|
|
/* this is an operator button which calls a 'add modifier' operator...
|
|
|
|
* a menu might be nicer but would be tricky as we need some custom filtering
|
|
|
|
*/
|
2012-03-03 21:42:21 +00:00
|
|
|
uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"),
|
2013-06-27 11:29:53 +00:00
|
|
|
0.5 * UI_UNIT_X, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, TIP_("Adds a new F-Curve Modifier for the active F-Curve"));
|
2010-03-18 13:04:46 +00:00
|
|
|
|
|
|
|
/* copy/paste (as sub-row)*/
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(row, true);
|
2012-05-08 20:18:33 +00:00
|
|
|
uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy");
|
|
|
|
uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste");
|
2009-07-02 12:41:03 +00:00
|
|
|
}
|
2009-03-15 10:39:02 +00:00
|
|
|
|
|
|
|
/* draw each modifier */
|
2012-05-08 20:18:33 +00:00
|
|
|
for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
|
2014-04-01 11:34:00 +11:00
|
|
|
col = uiLayoutColumn(pa->layout, true);
|
2009-07-02 12:41:03 +00:00
|
|
|
|
2009-12-24 14:01:22 +00:00
|
|
|
ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
|
2009-07-02 12:41:03 +00:00
|
|
|
}
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
MEM_freeN(ale);
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 03:49:22 +00:00
|
|
|
/* ******************* general ******************************** */
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
void graph_buttons_register(ARegionType *art)
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
PanelType *pt;
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
|
2009-10-27 11:46:46 +00:00
|
|
|
strcpy(pt->idname, "GRAPH_PT_view");
|
2012-03-03 21:42:21 +00:00
|
|
|
strcpy(pt->label, N_("View Properties"));
|
2013-03-27 19:09:50 +00:00
|
|
|
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-05-08 20:18:33 +00:00
|
|
|
pt->draw = graph_panel_view;
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
pt->flag |= PNL_DEFAULT_CLOSED;
|
2009-10-27 11:46:46 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
2009-05-19 17:13:33 +00:00
|
|
|
strcpy(pt->idname, "GRAPH_PT_properties");
|
2012-03-03 21:42:21 +00:00
|
|
|
strcpy(pt->label, N_("Active F-Curve"));
|
2013-03-27 19:09:50 +00:00
|
|
|
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-05-08 20:18:33 +00:00
|
|
|
pt->draw = graph_panel_properties;
|
|
|
|
pt->poll = graph_panel_poll;
|
2009-05-19 17:13:33 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
strcpy(pt->idname, "GRAPH_PT_key_properties");
|
2012-03-03 21:42:21 +00:00
|
|
|
strcpy(pt->label, N_("Active Keyframe"));
|
2013-03-27 19:09:50 +00:00
|
|
|
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-05-08 20:18:33 +00:00
|
|
|
pt->draw = graph_panel_key_properties;
|
|
|
|
pt->poll = graph_panel_poll;
|
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.
2010-05-20 11:49:53 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
|
2009-05-19 17:13:33 +00:00
|
|
|
strcpy(pt->idname, "GRAPH_PT_drivers");
|
2012-03-03 21:42:21 +00:00
|
|
|
strcpy(pt->label, N_("Drivers"));
|
2013-03-27 19:09:50 +00:00
|
|
|
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-05-08 20:18:33 +00:00
|
|
|
pt->draw = graph_panel_drivers;
|
|
|
|
pt->poll = graph_panel_drivers_poll;
|
2009-05-19 17:13:33 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
|
2009-05-19 17:13:33 +00:00
|
|
|
strcpy(pt->idname, "GRAPH_PT_modifiers");
|
2012-03-03 21:42:21 +00:00
|
|
|
strcpy(pt->label, N_("Modifiers"));
|
2013-03-27 19:09:50 +00:00
|
|
|
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-05-08 20:18:33 +00:00
|
|
|
pt->draw = graph_panel_modifiers;
|
|
|
|
pt->poll = graph_panel_poll;
|
2009-05-19 17:13:33 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
2009-02-21 10:38:58 +00:00
|
|
|
}
|
|
|
|
|
2013-07-28 17:06:31 +00:00
|
|
|
static int graph_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
2012-05-08 20:18:33 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegion *ar = graph_has_buttons_region(sa);
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar)
|
2009-09-14 19:12:29 +00:00
|
|
|
ED_region_toggle_hidden(C, ar);
|
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-06-22 04:23:06 +00:00
|
|
|
void GRAPH_OT_properties(wmOperatorType *ot)
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Properties";
|
|
|
|
ot->idname = "GRAPH_OT_properties";
|
|
|
|
ot->description = "Toggle display properties panel";
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2013-07-28 17:06:31 +00:00
|
|
|
ot->exec = graph_properties_toggle_exec;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_graphedit_active;
|
2011-04-21 15:53:30 +00:00
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2009-02-21 10:38:58 +00:00
|
|
|
}
|