2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2009 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spgraph
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cfloat>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstring>
|
2009-07-02 01:01:18 +00:00
|
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_space_types.h"
|
2009-07-02 01:01:18 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2009-07-02 01:01:18 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_anim_api.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2019-06-16 13:32:50 +03:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
#include "graph_intern.h" /* own include */
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2021-11-05 11:32:55 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Set Up Drivers Editor
|
|
|
|
|
* \{ */
|
2018-06-21 16:57:59 +12:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
void ED_drivers_editor_init(bContext *C, ScrArea *area)
|
2018-06-21 16:57:59 +12:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-21 16:57:59 +12:00
|
|
|
/* Set mode */
|
|
|
|
|
sipo->mode = SIPO_MODE_DRIVERS;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-21 16:57:59 +12:00
|
|
|
/* Show Properties Region (or else the settings can't be edited) */
|
2020-04-03 13:25:03 +02:00
|
|
|
ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_UI);
|
2020-04-03 12:51:03 +02:00
|
|
|
if (region_props) {
|
|
|
|
|
UI_panel_category_active_set(region_props, "Drivers");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 12:51:03 +02:00
|
|
|
region_props->flag &= ~RGN_FLAG_HIDDEN;
|
2018-06-21 16:57:59 +12:00
|
|
|
/* XXX: Adjust width of this too? */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_region_visibility_change_update(C, area, region_props);
|
2018-06-21 16:57:59 +12:00
|
|
|
}
|
|
|
|
|
else {
|
2020-04-03 13:25:03 +02:00
|
|
|
printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, area);
|
2018-06-21 16:57:59 +12:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-21 16:57:59 +12:00
|
|
|
/* Adjust framing in graph region */
|
|
|
|
|
/* TODO: Have a way of not resetting this every time?
|
|
|
|
|
* (e.g. So that switching back and forth between editors doesn't keep jumping?)
|
|
|
|
|
*/
|
2020-04-03 13:25:03 +02:00
|
|
|
ARegion *region_main = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
2020-04-03 12:51:03 +02:00
|
|
|
if (region_main) {
|
2018-06-21 16:57:59 +12:00
|
|
|
/* XXX: Ideally we recenter based on the range instead... */
|
2020-04-03 12:51:03 +02:00
|
|
|
region_main->v2d.tot.xmin = -2.0f;
|
|
|
|
|
region_main->v2d.tot.ymin = -2.0f;
|
|
|
|
|
region_main->v2d.tot.xmax = 2.0f;
|
|
|
|
|
region_main->v2d.tot.ymax = 2.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 12:51:03 +02:00
|
|
|
region_main->v2d.cur = region_main->v2d.tot;
|
2018-06-21 16:57:59 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-05 11:32:55 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Active F-Curve
|
|
|
|
|
* \{ */
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2012-05-08 20:18:33 +00:00
|
|
|
bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
|
2009-07-02 01:01:18 +00:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2022-07-08 09:09:59 +10:00
|
|
|
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE |
|
|
|
|
|
ANIMFILTER_FCURVESONLY);
|
2023-07-12 13:43:00 +02:00
|
|
|
size_t items = ANIM_animdata_filter(
|
|
|
|
|
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* We take the first F-Curve only, since some other ones may have had 'active' flag set
|
|
|
|
|
* if they were from linked data.
|
|
|
|
|
*/
|
|
|
|
|
if (items) {
|
2012-05-08 20:18:33 +00:00
|
|
|
bAnimListElem *ale = (bAnimListElem *)anim_data.first;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* remove first item from list, then free the rest of the list and return the stored one */
|
|
|
|
|
BLI_remlink(&anim_data, ale);
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
return ale;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* no active F-Curve */
|
2023-07-12 13:43:00 +02:00
|
|
|
return nullptr;
|
2009-07-02 01:01:18 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-05 11:32:55 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Operator Polling Callbacks
|
|
|
|
|
* \{ */
|
2009-07-02 01:01:18 +00:00
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
bool graphop_visible_keyframes_poll(bContext *C)
|
2009-07-02 01:01:18 +00:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2011-06-21 04:01:51 +00:00
|
|
|
size_t items;
|
|
|
|
|
int filter;
|
2020-09-25 10:20:33 +02:00
|
|
|
bool found = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* firstly, check if in Graph Editor */
|
|
|
|
|
/* TODO: also check for region? */
|
2023-07-12 13:43:00 +02:00
|
|
|
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return found;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* try to init Anim-Context stuff ourselves and check */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return found;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable
|
|
|
|
|
* stopping on the first successful match
|
|
|
|
|
*/
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY);
|
2023-07-12 13:43:00 +02:00
|
|
|
items = ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2019-04-22 09:19:45 +10:00
|
|
|
if (items == 0) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return found;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
2012-05-08 20:18:33 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* visible curves for selection must fulfill the following criteria:
|
2018-11-14 12:53:15 +11:00
|
|
|
* - it has bezier keyframes
|
|
|
|
|
* - F-Curve modifiers do not interfere with the result too much
|
|
|
|
|
* (i.e. the modifier-control drawing check returns false)
|
2009-07-02 01:01:18 +00:00
|
|
|
*/
|
2023-07-12 13:43:00 +02:00
|
|
|
if (fcu->bezt == nullptr) {
|
2009-07-02 01:01:18 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-06-05 09:30:15 +02:00
|
|
|
if (BKE_fcurve_are_keyframes_usable(fcu)) {
|
2020-09-25 10:20:33 +02:00
|
|
|
found = true;
|
2010-11-17 12:02:36 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2009-07-02 01:01:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* cleanup and return findings */
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
2009-07-02 01:01:18 +00:00
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
bool graphop_editable_keyframes_poll(bContext *C)
|
2009-07-02 01:01:18 +00:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2011-06-21 04:01:51 +00:00
|
|
|
size_t items;
|
|
|
|
|
int filter;
|
2020-09-25 10:20:33 +02:00
|
|
|
bool found = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-04-29 14:53:14 +02:00
|
|
|
/* firstly, check if in Graph Editor or Dopesheet */
|
2009-07-02 01:01:18 +00:00
|
|
|
/* TODO: also check for region? */
|
2023-07-12 13:43:00 +02:00
|
|
|
if (area == nullptr || !ELEM(area->spacetype, SPACE_GRAPH, SPACE_ACTION)) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return found;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* try to init Anim-Context stuff ourselves and check */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return found;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-26 10:29:10 +00:00
|
|
|
/* loop over the editable F-Curves, and see if they're suitable
|
2009-07-02 01:01:18 +00:00
|
|
|
* stopping on the first successful match
|
|
|
|
|
*/
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE |
|
|
|
|
|
ANIMFILTER_FCURVESONLY);
|
2023-07-12 13:43:00 +02:00
|
|
|
items = ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2019-04-22 09:19:45 +10:00
|
|
|
if (items == 0) {
|
2022-02-18 16:23:22 +01:00
|
|
|
CTX_wm_operator_poll_msg_set(C, "There is no animation data to operate on");
|
2020-09-25 10:20:33 +02:00
|
|
|
return found;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
2012-05-08 20:18:33 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* editable curves must fulfill the following criteria:
|
2018-11-14 12:53:15 +11:00
|
|
|
* - it has bezier keyframes
|
|
|
|
|
* - it must not be protected from editing (this is already checked for with the edit flag
|
|
|
|
|
* - F-Curve modifiers do not interfere with the result too much
|
|
|
|
|
* (i.e. the modifier-control drawing check returns false)
|
2009-07-02 01:01:18 +00:00
|
|
|
*/
|
2023-07-12 13:43:00 +02:00
|
|
|
if (fcu->bezt == nullptr && fcu->fpt != nullptr) {
|
2020-09-24 14:04:10 +02:00
|
|
|
/* This is a baked curve, it is never editable. */
|
2009-07-02 01:01:18 +00:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-06-05 09:30:15 +02:00
|
|
|
if (BKE_fcurve_is_keyframable(fcu)) {
|
2020-09-25 10:20:33 +02:00
|
|
|
found = true;
|
2010-11-17 12:02:36 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2009-07-02 01:01:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* cleanup and return findings */
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
2009-07-02 01:01:18 +00:00
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
bool graphop_active_fcurve_poll(bContext *C)
|
2009-07-02 01:01:18 +00:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
|
|
|
|
bAnimListElem *ale;
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2020-09-25 10:20:33 +02:00
|
|
|
bool has_fcurve = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* firstly, check if in Graph Editor */
|
|
|
|
|
/* TODO: also check for region? */
|
2023-07-12 13:43:00 +02:00
|
|
|
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return has_fcurve;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* try to init Anim-Context stuff ourselves and check */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return has_fcurve;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* try to get the Active F-Curve */
|
2012-05-08 20:18:33 +00:00
|
|
|
ale = get_active_fcurve_channel(&ac);
|
2023-07-12 13:43:00 +02:00
|
|
|
if (ale == nullptr) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return has_fcurve;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 00:18:34 +10:00
|
|
|
/* Do we have a suitable F-Curves?
|
|
|
|
|
* - For most cases, NLA Control Curves are sufficiently similar to NLA
|
|
|
|
|
* curves to serve this role too. Under the hood, they are F-Curves too.
|
|
|
|
|
* The only problems which will arise here are if these need to be
|
2015-03-29 02:20:57 +13:00
|
|
|
* in an Action too (but drivers would then also be affected!)
|
|
|
|
|
*/
|
|
|
|
|
has_fcurve = ((ale->data) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE));
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
if (has_fcurve) {
|
2012-05-08 20:18:33 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
|
|
|
|
has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0;
|
2010-12-09 16:15:51 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-29 02:20:57 +13:00
|
|
|
/* free temp data... */
|
2009-07-02 01:01:18 +00:00
|
|
|
MEM_freeN(ale);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-02 01:01:18 +00:00
|
|
|
/* return success */
|
|
|
|
|
return has_fcurve;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-16 13:32:50 +03:00
|
|
|
bool graphop_active_editable_fcurve_ctx_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "active_editable_fcurve", &RNA_FCurve);
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
return ptr.data != nullptr;
|
2019-06-16 13:32:50 +03:00
|
|
|
}
|
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
bool graphop_selected_fcurve_poll(bContext *C)
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2011-06-21 04:01:51 +00:00
|
|
|
size_t items;
|
|
|
|
|
int filter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
/* firstly, check if in Graph Editor */
|
|
|
|
|
/* TODO: also check for region? */
|
2023-07-12 13:43:00 +02:00
|
|
|
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return false;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
/* try to init Anim-Context stuff ourselves and check */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return false;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 00:18:34 +10:00
|
|
|
/* Get the editable + selected F-Curves, and as long as we got some, we can return.
|
|
|
|
|
* NOTE: curve-visible flag isn't included,
|
|
|
|
|
* otherwise selecting a curve via list to edit is too cumbersome. */
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT |
|
|
|
|
|
ANIMFILTER_FCURVESONLY);
|
2023-07-12 13:43:00 +02:00
|
|
|
items = ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2019-04-22 09:19:45 +10:00
|
|
|
if (items == 0) {
|
2020-09-25 10:20:33 +02:00
|
|
|
return false;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
/* cleanup and return findings */
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
2020-09-25 10:20:33 +02:00
|
|
|
return true;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-05 11:32:55 +11:00
|
|
|
/** \} */
|