2011-07-30 09:24:10 +00:00
|
|
|
/*
|
|
|
|
* 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,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edinterface
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
2009-04-03 23:30:32 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2009-04-03 23:30:32 +00:00
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
2009-07-12 02:06:15 +00:00
|
|
|
#include "BLI_string.h"
|
2011-10-20 09:47:05 +00:00
|
|
|
#include "BLI_string_utf8.h"
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-04-03 23:30:32 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_fcurve.h"
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
#include "BKE_global.h"
|
2018-06-07 12:47:00 +02:00
|
|
|
#include "BKE_main.h"
|
2014-11-16 20:24:38 +13:00
|
|
|
#include "BKE_nla.h"
|
2009-04-03 23:30:32 +00:00
|
|
|
|
WIP COW Fix: Insert keyframe operators/api now queries depsgraph for evaluated data
When using copy on write, insert keyframe operators were reading from old
bmain data instead of COW data. This meant that inserting keyframes would
often read old/stale data, resulting in invalid keyframes getting created
(e.g. from last transform operation, instead of actual current state).
This commit makes it so that keyframing operators will ask depsgraph for
the evaluated copy of the data, so that it can read values from that. It
introduces a new function - `DEG_get_evaluated_rna_pointer()`, which when
working correctly/fully, should work just like the other `DEG_get_evaluated_*()`
functions, except it lets you pass in an RNA Pointer.
However, currently, this is only done for Pose Bones (as a dirty hack, since this
is an important/pivotal requirement for production) and/or datablock
properties directly (since we can just use the DEG_get_evaluated_id() directly).
on the datablock.
Committing to a branch for now as this all needs more testing. More work to come
later at a more sane time of day!
2018-05-18 20:36:48 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph_build.h"
|
|
|
|
|
2009-07-08 12:30:09 +00:00
|
|
|
#include "ED_keyframing.h"
|
|
|
|
|
2009-04-03 23:30:32 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2009-04-03 23:30:32 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "interface_intern.h"
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static FCurve *ui_but_get_fcurve(
|
|
|
|
uiBut *but, AnimData **adt, bAction **action, bool *r_driven, bool *r_special)
|
2009-04-03 23:30:32 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* for entire array buttons we check the first component, it's not perfect
|
|
|
|
* but works well enough in typical cases */
|
|
|
|
int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex;
|
2013-01-31 16:19:44 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return rna_get_fcurve_context_ui(
|
|
|
|
but->block->evil_C, &but->rnapoin, but->rnaprop, rnaindex, adt, action, r_driven, r_special);
|
2009-07-12 02:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ui_but_anim_flag(uiBut *but, float cfra)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
AnimData *adt;
|
|
|
|
bAction *act;
|
|
|
|
FCurve *fcu;
|
|
|
|
bool driven;
|
|
|
|
bool special;
|
|
|
|
|
|
|
|
but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
|
|
|
|
but->drawflag &= ~UI_BUT_ANIMATED_CHANGED;
|
|
|
|
|
|
|
|
/* NOTE: "special" is reserved for special F-Curves stored on the animation data
|
|
|
|
* itself (which are used to animate properties of the animation data).
|
|
|
|
* We count those as "animated" too for now
|
|
|
|
*/
|
|
|
|
fcu = ui_but_get_fcurve(but, &adt, &act, &driven, &special);
|
|
|
|
|
|
|
|
if (fcu) {
|
|
|
|
if (!driven) {
|
|
|
|
but->flag |= UI_BUT_ANIMATED;
|
|
|
|
|
|
|
|
/* T41525 - When the active action is a NLA strip being edited,
|
|
|
|
* we need to correct the frame number to "look inside" the
|
|
|
|
* remapped action
|
|
|
|
*/
|
|
|
|
if (adt) {
|
|
|
|
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
|
|
|
|
but->flag |= UI_BUT_ANIMATED_KEY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: this feature is totally broken and useless with NLA */
|
|
|
|
if (adt == NULL || adt->nla_tracks.first == NULL) {
|
|
|
|
if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, cfra)) {
|
|
|
|
but->drawflag |= UI_BUT_ANIMATED_CHANGED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
but->flag |= UI_BUT_DRIVEN;
|
|
|
|
}
|
|
|
|
}
|
2018-06-16 18:26:34 +02:00
|
|
|
}
|
2018-06-16 14:48:21 +02:00
|
|
|
|
2018-06-16 18:26:34 +02:00
|
|
|
void ui_but_anim_decorate_update_from_flag(uiBut *but)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(UI_but_is_decorator(but) && but->prev);
|
|
|
|
int flag = but->prev->flag;
|
|
|
|
if (flag & UI_BUT_DRIVEN) {
|
|
|
|
but->icon = ICON_DECORATE_DRIVER;
|
|
|
|
}
|
|
|
|
else if (flag & UI_BUT_ANIMATED_KEY) {
|
|
|
|
but->icon = ICON_DECORATE_KEYFRAME;
|
|
|
|
}
|
|
|
|
else if (flag & UI_BUT_ANIMATED) {
|
|
|
|
but->icon = ICON_DECORATE_ANIMATE;
|
|
|
|
}
|
|
|
|
else if (flag & UI_BUT_OVERRIDEN) {
|
|
|
|
but->icon = ICON_DECORATE_OVERRIDE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
but->icon = ICON_DECORATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int flag_copy = (UI_BUT_DISABLED | UI_BUT_INACTIVE);
|
|
|
|
but->flag = (but->flag & ~flag_copy) | (flag & flag_copy);
|
2009-07-12 02:06:15 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 13:37:04 +01:00
|
|
|
/**
|
|
|
|
* \a str can be NULL to only perform check if \a but has an expression at all.
|
|
|
|
* \return if button has an expression.
|
|
|
|
*/
|
2014-01-20 11:13:53 +11:00
|
|
|
bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
|
2009-07-12 02:06:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
FCurve *fcu;
|
|
|
|
ChannelDriver *driver;
|
|
|
|
bool driven, special;
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
fcu = ui_but_get_fcurve(but, NULL, NULL, &driven, &special);
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (fcu && driven) {
|
|
|
|
driver = fcu->driver;
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
|
|
|
|
if (str) {
|
|
|
|
BLI_strncpy(str, driver->expression, maxlen);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2009-07-12 02:06:15 +00:00
|
|
|
}
|
|
|
|
|
2014-01-20 11:13:53 +11:00
|
|
|
bool ui_but_anim_expression_set(uiBut *but, const char *str)
|
2009-07-12 02:06:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
FCurve *fcu;
|
|
|
|
ChannelDriver *driver;
|
|
|
|
bool driven, special;
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
fcu = ui_but_get_fcurve(but, NULL, NULL, &driven, &special);
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (fcu && driven) {
|
|
|
|
driver = fcu->driver;
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (driver && (driver->type == DRIVER_TYPE_PYTHON)) {
|
|
|
|
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* tag driver as needing to be recompiled */
|
|
|
|
BKE_driver_invalidate_expression(driver, true, false);
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* clear invalid flags which may prevent this from working */
|
|
|
|
driver->flag &= ~DRIVER_FLAG_INVALID;
|
|
|
|
fcu->flag &= ~FCURVE_DISABLED;
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* this notifier should update the Graph Editor and trigger depsgraph refresh? */
|
|
|
|
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2009-07-12 02:06:15 +00:00
|
|
|
}
|
|
|
|
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
/* create new expression for button (i.e. a "scripted driver"), if it can be created... */
|
2014-01-20 11:13:53 +11:00
|
|
|
bool ui_but_anim_expression_create(uiBut *but, const char *str)
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bContext *C = but->block->evil_C;
|
|
|
|
ID *id;
|
|
|
|
FCurve *fcu;
|
|
|
|
char *path;
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
/* button must have RNA-pointer to a numeric-capable property */
|
|
|
|
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
|
|
|
|
if (G.debug & G_DEBUG) {
|
|
|
|
printf("ERROR: create expression failed - button has no RNA info attached\n");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RNA_property_array_check(but->rnaprop) != 0) {
|
|
|
|
if (but->rnaindex == -1) {
|
|
|
|
if (G.debug & G_DEBUG) {
|
|
|
|
printf("ERROR: create expression failed - can't create expression for entire array\n");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure we have animdata for this */
|
|
|
|
/* FIXME: until materials can be handled by depsgraph,
|
|
|
|
* don't allow drivers to be created for them */
|
|
|
|
id = (ID *)but->rnapoin.id.data;
|
|
|
|
if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
|
|
|
|
if (G.debug & G_DEBUG) {
|
|
|
|
printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get path */
|
|
|
|
path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
|
|
|
|
if (path == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create driver */
|
|
|
|
fcu = verify_driver_fcurve(id, path, but->rnaindex, 1);
|
|
|
|
if (fcu) {
|
|
|
|
ChannelDriver *driver = fcu->driver;
|
|
|
|
|
|
|
|
if (driver) {
|
|
|
|
/* set type of driver */
|
|
|
|
driver->type = DRIVER_TYPE_PYTHON;
|
|
|
|
|
|
|
|
/* set the expression */
|
|
|
|
/* TODO: need some way of identifying variables used */
|
|
|
|
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
|
|
|
|
|
|
|
|
/* updates */
|
|
|
|
BKE_driver_invalidate_expression(driver, true, false);
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, NULL);
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(path);
|
|
|
|
|
|
|
|
return ok;
|
First stages of easier "expressions" creation...
It is now possible to create "scripted expression" drivers by simply
clicking on some property, and typing some short Python expression
prefixed with a '#'. This will result in a scripted expression driver,
with the typed-in text being created.
For example, you can click on X-Location of the default cube, and
type:
#sin(frame)
and a new driver will be created for the x-location of the cube. This
will use the current frame value, and modulate this with a sine wave.
Do note though, that the current frame is a special case here. In the
current implementation, a special "frame" driver variable, which
references the current scene frame is created automatically, so that
this simple and (assumed) common case will work straight out of the
box.
Future improvements:
- Explore possibilities of semi-automated extraction of variables from
such expressions, resulting in automated variable extraction. (Doing
away with variables completely is definitely 100% off the agenda
though)
- Look into some ways of defining some shorthands for referencing
local data (possibly related to variable extraction?)
2011-07-04 03:12:28 +00:00
|
|
|
}
|
|
|
|
|
2010-01-12 03:01:19 +00:00
|
|
|
void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
|
2009-07-12 02:06:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
ID *id;
|
|
|
|
bAction *action;
|
|
|
|
FCurve *fcu;
|
|
|
|
bool driven;
|
|
|
|
bool special;
|
|
|
|
|
|
|
|
fcu = ui_but_get_fcurve(but, NULL, &action, &driven, &special);
|
|
|
|
|
|
|
|
if (fcu == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (special) {
|
|
|
|
/* NLA Strip property */
|
|
|
|
if (IS_AUTOKEY_ON(scene)) {
|
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
|
|
|
ReportList *reports = CTX_wm_reports(C);
|
|
|
|
ToolSettings *ts = scene->toolsettings;
|
|
|
|
|
|
|
|
insert_keyframe_direct(
|
|
|
|
depsgraph, reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0);
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (driven) {
|
|
|
|
/* Driver - Try to insert keyframe using the driver's input as the frame,
|
|
|
|
* making it easier to set up corrective drivers
|
|
|
|
*/
|
|
|
|
if (IS_AUTOKEY_ON(scene)) {
|
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
|
|
|
ReportList *reports = CTX_wm_reports(C);
|
|
|
|
ToolSettings *ts = scene->toolsettings;
|
|
|
|
|
|
|
|
insert_keyframe_direct(depsgraph,
|
|
|
|
reports,
|
|
|
|
but->rnapoin,
|
|
|
|
but->rnaprop,
|
|
|
|
fcu,
|
|
|
|
cfra,
|
|
|
|
ts->keyframe_type,
|
|
|
|
NULL,
|
|
|
|
INSERTKEY_DRIVER);
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
id = but->rnapoin.id.data;
|
|
|
|
|
|
|
|
/* TODO: this should probably respect the keyingset only option for anim */
|
|
|
|
if (autokeyframe_cfra_can_key(scene, id)) {
|
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
|
|
|
ReportList *reports = CTX_wm_reports(C);
|
|
|
|
ToolSettings *ts = scene->toolsettings;
|
|
|
|
short flag = ANIM_get_keyframing_flags(scene, 1);
|
|
|
|
|
|
|
|
fcu->flag &= ~FCURVE_SELECTED;
|
|
|
|
|
|
|
|
/* Note: We use but->rnaindex instead of fcu->array_index,
|
|
|
|
* because a button may control all items of an array at once.
|
|
|
|
* E.g., color wheels (see T42567). */
|
|
|
|
BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1));
|
|
|
|
insert_keyframe(bmain,
|
|
|
|
depsgraph,
|
|
|
|
reports,
|
|
|
|
id,
|
|
|
|
action,
|
|
|
|
((fcu->grp) ? (fcu->grp->name) : (NULL)),
|
|
|
|
fcu->rna_path,
|
|
|
|
but->rnaindex,
|
|
|
|
cfra,
|
|
|
|
ts->keyframe_type,
|
|
|
|
NULL,
|
|
|
|
flag);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
|
|
|
}
|
|
|
|
}
|
2009-04-03 23:30:32 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 04:51:04 +00:00
|
|
|
void ui_but_anim_copy_driver(bContext *C)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* this operator calls UI_context_active_but_prop_get */
|
|
|
|
WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
|
2009-09-25 04:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ui_but_anim_paste_driver(bContext *C)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* this operator calls UI_context_active_but_prop_get */
|
|
|
|
WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
|
2009-09-25 04:51:04 +00:00
|
|
|
}
|
2018-06-16 14:48:21 +02:00
|
|
|
|
|
|
|
void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy))
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
uiBut *but = arg_but;
|
|
|
|
but = but->prev;
|
|
|
|
|
|
|
|
/* FIXME(campbell), swapping active pointer is weak. */
|
|
|
|
SWAP(struct uiHandleButtonData *, but->active, but->next->active);
|
|
|
|
wm->op_undo_depth++;
|
|
|
|
|
|
|
|
if (but->flag & UI_BUT_DRIVEN) {
|
|
|
|
/* pass */
|
|
|
|
/* TODO: report? */
|
|
|
|
}
|
|
|
|
else if (but->flag & UI_BUT_ANIMATED_KEY) {
|
|
|
|
PointerRNA props_ptr;
|
|
|
|
wmOperatorType *ot = WM_operatortype_find("ANIM_OT_keyframe_delete_button", false);
|
|
|
|
WM_operator_properties_create_ptr(&props_ptr, ot);
|
|
|
|
RNA_boolean_set(&props_ptr, "all", but->rnaindex == -1);
|
|
|
|
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
|
|
|
|
WM_operator_properties_free(&props_ptr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PointerRNA props_ptr;
|
|
|
|
wmOperatorType *ot = WM_operatortype_find("ANIM_OT_keyframe_insert_button", false);
|
|
|
|
WM_operator_properties_create_ptr(&props_ptr, ot);
|
|
|
|
RNA_boolean_set(&props_ptr, "all", but->rnaindex == -1);
|
|
|
|
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
|
|
|
|
WM_operator_properties_free(&props_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
SWAP(struct uiHandleButtonData *, but->active, but->next->active);
|
|
|
|
wm->op_undo_depth--;
|
2018-06-16 14:48:21 +02:00
|
|
|
}
|