Cleanup: move space_action folder to c++

I'm doing this because I want to work on the timeline integration for
simulation nodes caching. Also see #103343 for more info regarding moving
files to C++.

Pull Request: https://projects.blender.org/blender/blender/pulls/105962
This commit is contained in:
Jacques Lucke
2023-03-21 17:49:23 +01:00
parent ed7c90c13b
commit e858be84fa
11 changed files with 728 additions and 641 deletions

View File

@@ -148,6 +148,7 @@ typedef enum eKeyframeIterFlags {
* iterator callbacks then. */
KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE = (1 << 3),
} eKeyframeIterFlags;
ENUM_OPERATORS(eKeyframeIterFlags, KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE)
/** \} */

View File

@@ -23,15 +23,15 @@ set(INC_SYS
)
set(SRC
action_buttons.c
action_data.c
action_draw.c
action_edit.c
action_ops.c
action_select.c
space_action.c
action_buttons.cc
action_data.cc
action_draw.cc
action_edit.cc
action_ops.cc
action_select.cc
space_action.cc
action_intern.h
action_intern.hh
)
set(LIB

View File

@@ -5,30 +5,30 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "action_intern.h" /* own include */
#include "action_intern.hh" /* own include */
/* ******************* action editor space & buttons ************** */
/* ******************* general ******************************** */
void action_buttons_register(ARegionType *UNUSED(art))
void action_buttons_register(ARegionType * /*art*/)
{
#if 0
PanelType *pt;
/* TODO: AnimData / Actions List */
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
pt = MEM_cnew<PanelType>("spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_properties");
strcpy(pt->label, N_("Active F-Curve"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -36,7 +36,7 @@ void action_buttons_register(ARegionType *UNUSED(art))
pt->poll = action_anim_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
pt = MEM_cnew<PanelType>("spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_key_properties");
strcpy(pt->label, N_("Active Keyframe"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);

View File

@@ -5,10 +5,10 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "BLI_utildefines.h"
@@ -52,7 +52,7 @@
#include "UI_interface.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Utilities
@@ -62,7 +62,7 @@ AnimData *ED_actedit_animdata_from_context(const bContext *C, ID **r_adt_id_owne
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
Object *ob = CTX_data_active_object(C);
AnimData *adt = NULL;
AnimData *adt = nullptr;
/* Get AnimData block to use */
if (saction->mode == SACTCONT_ACTION) {
@@ -146,11 +146,11 @@ static void actedit_change_action(bContext *C, bAction *act)
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, saction, &ptr);
prop = RNA_struct_find_property(&ptr, "action");
/* NOTE: act may be NULL here, so better to just use a cast here */
/* NOTE: act may be nullptr here, so better to just use a cast here */
RNA_id_pointer_create((ID *)act, &idptr);
/* set the new pointer, and force a refresh */
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
@@ -181,7 +181,7 @@ static bool action_new_poll(bContext *C)
if (saction->mode == SACTCONT_ACTION) {
/* XXX: This assumes that actions are assigned to the active object in this mode */
if (ob) {
if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0) {
if ((ob->adt == nullptr) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
}
}
@@ -189,7 +189,7 @@ static bool action_new_poll(bContext *C)
else if (saction->mode == SACTCONT_SHAPEKEY) {
Key *key = BKE_key_from_object(ob);
if (key) {
if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0) {
if ((key->adt == nullptr) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
}
}
@@ -205,14 +205,14 @@ static bool action_new_poll(bContext *C)
return false;
}
static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
static int action_new_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr, idptr;
PropertyRNA *prop;
bAction *oldact = NULL;
AnimData *adt = NULL;
ID *adt_id_owner = NULL;
bAction *oldact = nullptr;
AnimData *adt = nullptr;
ID *adt_id_owner = nullptr;
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
@@ -225,7 +225,7 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
/* stash the old action to prevent it from being lost */
if (ptr.type == &RNA_AnimData) {
adt = ptr.data;
adt = static_cast<AnimData *>(ptr.data);
adt_id_owner = ptr.owner_id;
}
else if (ptr.type == &RNA_SpaceDopeSheetEditor) {
@@ -237,11 +237,11 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
oldact = adt->action;
}
{
bAction *action = NULL;
bAction *action = nullptr;
/* Perform stashing operation - But only if there is an action */
if (adt && oldact) {
BLI_assert(adt_id_owner != NULL);
BLI_assert(adt_id_owner != nullptr);
/* stash the action */
if (BKE_nla_action_stash(adt, ID_IS_OVERRIDE_LIBRARY(adt_id_owner))) {
/* The stash operation will remove the user already
@@ -252,8 +252,8 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
* or else the user gets decremented twice!
*/
if (ptr.type == &RNA_SpaceDopeSheetEditor) {
SpaceAction *saction = ptr.data;
saction->action = NULL;
SpaceAction *saction = static_cast<SpaceAction *>(ptr.data);
saction->action = nullptr;
}
}
else {
@@ -272,13 +272,13 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
* NOTE: we can't use actedit_change_action, as this function is also called from the NLA
*/
RNA_id_pointer_create(&action->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@@ -313,7 +313,7 @@ static bool action_pushdown_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
/* Check for AnimData, Actions, and that tweak-mode is off. */
if (adt && saction->action) {
@@ -333,7 +333,7 @@ static bool action_pushdown_poll(bContext *C)
static int action_pushdown_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
ID *adt_id_owner = NULL;
ID *adt_id_owner = nullptr;
AnimData *adt = ED_actedit_animdata_from_context(C, &adt_id_owner);
/* Do the deed... */
@@ -349,7 +349,7 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
/* action can be safely added */
BKE_nla_action_pushdown(adt, ID_IS_OVERRIDE_LIBRARY(adt_id_owner));
struct Main *bmain = CTX_data_main(C);
Main *bmain = CTX_data_main(C);
DEG_id_tag_update_ex(bmain, adt_id_owner, ID_RECALC_ANIMATION);
/* The action needs updating too, as FCurve modifiers are to be reevaluated. They won't extend
@@ -359,11 +359,11 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
/* Stop displaying this action in this editor
* NOTE: The editor itself doesn't set a user...
*/
saction->action = NULL;
saction->action = nullptr;
}
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@@ -391,7 +391,7 @@ void ACTION_OT_push_down(wmOperatorType *ot)
static int action_stash_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
ID *adt_id_owner = NULL;
ID *adt_id_owner = nullptr;
AnimData *adt = ED_actedit_animdata_from_context(C, &adt_id_owner);
/* Perform stashing operation */
@@ -410,7 +410,7 @@ static int action_stash_exec(bContext *C, wmOperator *op)
* the user-count fixes. Hence, we must unset this ref
* first before setting the new action.
*/
saction->action = NULL;
saction->action = nullptr;
}
else {
/* action has already been added - simply warn about this, and clear */
@@ -418,11 +418,11 @@ static int action_stash_exec(bContext *C, wmOperator *op)
}
/* clear action refs from editor, and then also the backing data (not necessary) */
actedit_change_action(C, NULL);
actedit_change_action(C, nullptr);
}
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@@ -461,7 +461,7 @@ void ACTION_OT_stash(wmOperatorType *ot)
static bool action_stash_create_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
/* Check tweak-mode is off (as you don't want to be tampering with the action in that case) */
/* NOTE: unlike for pushdown,
@@ -494,13 +494,13 @@ static bool action_stash_create_poll(bContext *C)
static int action_stash_create_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
ID *adt_id_owner = NULL;
ID *adt_id_owner = nullptr;
AnimData *adt = ED_actedit_animdata_from_context(C, &adt_id_owner);
/* Check for no action... */
if (saction->action == NULL) {
if (saction->action == nullptr) {
/* just create a new action */
bAction *action = action_create_new(C, NULL);
bAction *action = action_create_new(C, nullptr);
actedit_change_action(C, action);
}
else if (adt) {
@@ -513,29 +513,29 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
/* stash the action */
if (BKE_nla_action_stash(adt, ID_IS_OVERRIDE_LIBRARY(adt_id_owner))) {
bAction *new_action = NULL;
bAction *new_action = nullptr;
/* Create new action not based on the old one
* (since the "new" operator already does that). */
new_action = action_create_new(C, NULL);
new_action = action_create_new(C, nullptr);
/* The stash operation will remove the user already,
* so the flushing step later shouldn't double up
* the user-count fixes. Hence, we must unset this ref
* first before setting the new action.
*/
saction->action = NULL;
saction->action = nullptr;
actedit_change_action(C, new_action);
}
else {
/* action has already been added - simply warn about this, and clear */
BKE_report(op->reports, RPT_ERROR, "Action has already been stashed");
actedit_change_action(C, NULL);
actedit_change_action(C, nullptr);
}
}
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@@ -598,19 +598,19 @@ void ED_animedit_unlink_action(
NlaTrack *nlt, *nlt_next;
NlaStrip *strip, *nstrip;
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt_next) {
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt_next) {
nlt_next = nlt->next;
if (strstr(nlt->name, DATA_("[Action Stash]"))) {
for (strip = nlt->strips.first; strip; strip = nstrip) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = nstrip) {
nstrip = strip->next;
if (strip->act == act) {
/* Remove this strip, and the track too if it doesn't have anything else */
BKE_nlastrip_remove_and_free(&nlt->strips, strip, true);
if (nlt->strips.first == NULL) {
BLI_assert(nstrip == NULL);
if (nlt->strips.first == nullptr) {
BLI_assert(nstrip == nullptr);
BKE_nlatrack_remove_and_free(&adt->nla_tracks, nlt, true);
}
}
@@ -628,15 +628,15 @@ void ED_animedit_unlink_action(
BKE_nla_tweakmode_exit(adt);
Scene *scene = CTX_data_scene(C);
if (scene != NULL) {
if (scene != nullptr) {
scene->flag &= ~SCE_NLA_EDIT_ON;
}
}
else {
/* Unlink normally - Setting it to NULL should be enough to get the old one unlinked */
/* Unlink normally - Setting it to nullptr should be enough to get the old one unlinked */
if (area->spacetype == SPACE_ACTION) {
/* clear action editor -> action */
actedit_change_action(C, NULL);
actedit_change_action(C, nullptr);
}
else {
/* clear AnimData -> action */
@@ -648,7 +648,7 @@ void ED_animedit_unlink_action(
prop = RNA_struct_find_property(&ptr, "action");
/* clear... */
RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL, NULL);
RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL, nullptr);
RNA_property_update(C, &ptr, prop);
}
}
@@ -660,7 +660,7 @@ static bool action_unlink_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
/* Only when there's an active action, in the right modes... */
if (saction->action && adt) {
@@ -674,15 +674,15 @@ static bool action_unlink_poll(bContext *C)
static int action_unlink_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
bool force_delete = RNA_boolean_get(op->ptr, "force_delete");
if (adt && adt->action) {
ED_animedit_unlink_action(C, NULL, adt, adt->action, op->reports, force_delete);
ED_animedit_unlink_action(C, nullptr, adt, adt->action, op->reports, force_delete);
}
/* Unlink is also abused to exit NLA tweak mode. */
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@@ -733,24 +733,24 @@ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime)
{
NlaStrip *strip;
for (strip = strips->first; strip; strip = strip->next) {
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
/* Can we use this? */
if (IN_RANGE_INCL(ctime, strip->start, strip->end)) {
/* in range - use this one */
return strip;
}
if ((ctime < strip->start) && (strip->prev == NULL)) {
if ((ctime < strip->start) && (strip->prev == nullptr)) {
/* before first - use this one */
return strip;
}
if ((ctime > strip->end) && (strip->next == NULL)) {
if ((ctime > strip->end) && (strip->next == nullptr)) {
/* after last - use this one */
return strip;
}
}
/* nothing suitable found... */
return NULL;
return nullptr;
}
/* Switch NLA Strips/Actions. */
@@ -809,7 +809,7 @@ static bool action_layer_next_poll(bContext *C)
{
/* Action Editor's action editing modes only */
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
if (adt) {
/* only allow if we're in tweak-mode, and there's something above us... */
if (adt->flag & ADT_NLA_EDIT_ON) {
@@ -829,7 +829,7 @@ static bool action_layer_next_poll(bContext *C)
* to "move to an empty layer", even though this means
* that we won't actually have an action.
*/
// return (adt->tmpact != NULL);
// return (adt->tmpact != nullptr);
return true;
}
}
@@ -843,7 +843,7 @@ static bool action_layer_next_poll(bContext *C)
static int action_layer_next_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
NlaTrack *act_track;
Scene *scene = CTX_data_scene(C);
@@ -852,7 +852,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op)
/* Get active track */
act_track = BKE_nlatrack_find_tweaked(adt);
if (act_track == NULL) {
if (act_track == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Could not find current NLA Track");
return OPERATOR_CANCELLED;
}
@@ -924,7 +924,7 @@ static bool action_layer_prev_poll(bContext *C)
{
/* Action Editor's action editing modes only */
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
if (adt) {
if (adt->flag & ADT_NLA_EDIT_ON) {
/* Tweak Mode: We need to check if there are any tracks below the active one
@@ -947,7 +947,7 @@ static bool action_layer_prev_poll(bContext *C)
}
else {
/* Normal Mode: If there are any tracks, we can try moving to those */
return (adt->nla_tracks.first != NULL);
return (adt->nla_tracks.first != nullptr);
}
}
}
@@ -958,7 +958,7 @@ static bool action_layer_prev_poll(bContext *C)
static int action_layer_prev_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
NlaTrack *act_track;
NlaTrack *nlt;
@@ -966,7 +966,7 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op)
float ctime = BKE_scene_ctime_get(scene);
/* Sanity Check */
if (adt == NULL) {
if (adt == nullptr) {
BKE_report(
op->reports, RPT_ERROR, "Internal Error: Could not find Animation Data/NLA Stack to use");
return OPERATOR_CANCELLED;
@@ -982,7 +982,7 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op)
}
else {
/* Active Action - Use the top-most track */
nlt = adt->nla_tracks.last;
nlt = static_cast<NlaTrack *>(adt->nla_tracks.last);
}
/* Find previous action and hook it up */

View File

@@ -7,10 +7,10 @@
/* System includes ----------------------------------------------------- */
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -42,7 +42,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_draw.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Channel List
@@ -50,23 +50,23 @@
void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
View2D *v2d = &region->v2d;
size_t items;
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
const int height = ANIM_UI_get_channels_total_height(v2d, items);
const float pad_bottom = BLI_listbase_is_empty(ac->markers) ? 0 : UI_MARKER_MARGIN_Y;
v2d->tot.ymin = -(height + pad_bottom);
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY);
UI_view2d_sync(nullptr, ac->area, v2d, V2D_LOCK_COPY);
const float channel_step = ANIM_UI_get_channel_step();
/* Loop through channels, and set up drawing depending on their type. */
@@ -74,7 +74,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
size_t channel_index = 0;
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step, channel_index++) {
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@@ -90,7 +91,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
size_t channel_index = 0;
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step, channel_index++) {
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@@ -124,8 +126,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
{
/* Variables for coalescing the Y region of one action. */
bAction *cur_action = NULL;
AnimData *cur_adt = NULL;
bAction *cur_action = nullptr;
AnimData *cur_adt = nullptr;
float cur_ymax;
/* Walk through channels, grouping contiguous spans referencing the same action. */
@@ -133,9 +135,10 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
const float ystep = ANIM_UI_get_channel_step();
float ymin = ymax - ystep;
for (bAnimListElem *ale = anim_data->first; ale; ale = ale->next, ymax = ymin, ymin -= ystep) {
bAction *action = NULL;
AnimData *adt = NULL;
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data->first); ale;
ale = ale->next, ymax = ymin, ymin -= ystep) {
bAction *action = nullptr;
AnimData *adt = nullptr;
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
@@ -170,12 +173,12 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
View2D *v2d = &region->v2d;
bDopeSheet *ads = &saction->ads;
AnimData *adt = NULL;
AnimData *adt = nullptr;
uchar col1[4], col2[4];
uchar col1a[4], col2a[4];
@@ -196,8 +199,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
UI_GetThemeColor4ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
/* build list of channels to draw */
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(
ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
const int height = ANIM_UI_get_channels_total_height(v2d, items);
const float pad_bottom = BLI_listbase_is_empty(ac->markers) ? 0 : UI_MARKER_MARGIN_Y;
@@ -220,7 +225,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
/* first backdrop strips */
float ymax = ANIM_UI_get_first_channel_top(v2d);
const float channel_step = ANIM_UI_get_channel_step();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@@ -255,7 +261,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
break;
}
case ANIMTYPE_GROUP: {
bActionGroup *agrp = ale->data;
bActionGroup *agrp = static_cast<bActionGroup *>(ale->data);
if (show_group_colors && agrp->customCol) {
if (sel) {
immUniformColor3ubvAlpha((uchar *)agrp->cs.select, col1a[3]);
@@ -270,7 +276,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
break;
}
case ANIMTYPE_FCURVE: {
FCurve *fcu = ale->data;
FCurve *fcu = static_cast<FCurve *>(ale->data);
if (show_group_colors && fcu->grp && fcu->grp->customCol) {
immUniformColor3ubvAlpha((uchar *)fcu->grp->cs.active, sel ? col1[3] : col2[3]);
}
@@ -375,11 +381,12 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
ymax = ANIM_UI_get_first_channel_top(v2d);
struct AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create();
AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create();
const float scale_factor = ANIM_UI_get_keyframe_scale_factor();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
const float ymin = ymax - ANIM_UI_get_channel_height();
float ycenter = (ymin + ymax) / 2.0f;
@@ -393,28 +400,67 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
/* draw 'keyframes' for each specific datatype */
switch (ale->datatype) {
case ALE_ALL:
draw_summary_channel(draw_list, ale->data, ycenter, scale_factor, action_flag);
draw_summary_channel(draw_list,
static_cast<bAnimContext *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_SCE:
draw_scene_channel(draw_list, ads, ale->key_data, ycenter, scale_factor, action_flag);
draw_scene_channel(draw_list,
ads,
static_cast<Scene *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_OB:
draw_object_channel(draw_list, ads, ale->key_data, ycenter, scale_factor, action_flag);
draw_object_channel(draw_list,
ads,
static_cast<Object *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_ACT:
draw_action_channel(draw_list, adt, ale->key_data, ycenter, scale_factor, action_flag);
draw_action_channel(draw_list,
adt,
static_cast<bAction *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_GROUP:
draw_agroup_channel(draw_list, adt, ale->data, ycenter, scale_factor, action_flag);
draw_agroup_channel(draw_list,
adt,
static_cast<bActionGroup *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_FCURVE:
draw_fcurve_channel(draw_list, adt, ale->key_data, ycenter, scale_factor, action_flag);
draw_fcurve_channel(draw_list,
adt,
static_cast<FCurve *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_GPFRAME:
draw_gpl_channel(draw_list, ads, ale->data, ycenter, scale_factor, action_flag);
draw_gpl_channel(draw_list,
ads,
static_cast<bGPDlayer *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_MASKLAY:
draw_masklay_channel(draw_list, ads, ale->data, ycenter, scale_factor, action_flag);
draw_masklay_channel(draw_list,
ads,
static_cast<MaskLayer *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
}
}
@@ -630,7 +676,7 @@ static void timeline_cache_draw_single(PTCacheID *pid, float y_offset, float hei
void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
{
if ((saction->cache_display & TIME_CACHE_DISPLAY) == 0 || ob == NULL) {
if ((saction->cache_display & TIME_CACHE_DISPLAY) == 0 || ob == nullptr) {
return;
}
@@ -651,7 +697,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
continue;
}
if (pid->cache->cached_frames == NULL) {
if (pid->cache->cached_frames == nullptr) {
continue;
}

View File

@@ -5,10 +5,10 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -52,7 +52,7 @@
#include "UI_interface.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Pose Markers: Localize Markers
@@ -69,7 +69,7 @@ static bool act_markers_make_local_poll(bContext *C)
SpaceAction *sact = CTX_wm_space_action(C);
/* 1) */
if (sact == NULL) {
if (sact == nullptr) {
return 0;
}
@@ -77,7 +77,7 @@ static bool act_markers_make_local_poll(bContext *C)
if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) {
return 0;
}
if (sact->action == NULL) {
if (sact->action == nullptr) {
return 0;
}
@@ -87,25 +87,25 @@ static bool act_markers_make_local_poll(bContext *C)
}
/* 4) */
return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL;
return ED_markers_get_first_selected(ED_context_get_markers(C)) != nullptr;
}
static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
static int act_markers_make_local_exec(bContext *C, wmOperator * /*op*/)
{
ListBase *markers = ED_context_get_markers(C);
SpaceAction *sact = CTX_wm_space_action(C);
bAction *act = (sact) ? sact->action : NULL;
bAction *act = (sact) ? sact->action : nullptr;
TimeMarker *marker, *markern = NULL;
TimeMarker *marker, *markern = nullptr;
/* sanity checks */
if (ELEM(NULL, markers, act)) {
if (ELEM(nullptr, markers, act)) {
return OPERATOR_CANCELLED;
}
/* migrate markers */
for (marker = markers->first; marker; marker = markern) {
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = markern) {
markern = marker->next;
/* move if marker is selected */
@@ -120,8 +120,8 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
sact->flag |= SACTION_POSEMARKERS_SHOW;
/* notifiers - both sets, as this change affects both */
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr);
return OPERATOR_FINISHED;
}
@@ -150,9 +150,9 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot)
/* Get the min/max keyframes. */
static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
bool found = false;
/* get data to filter, from Action or Dopesheet */
@@ -160,7 +160,7 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
* Commented it, was breaking things (eg. the "auto preview range" tool). */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL */ |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* set large values to try to override */
*min = 999999999.0f;
@@ -169,14 +169,14 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
/* check if any channels to set range with */
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (ale->datatype == ALE_GPFRAME) {
bGPDlayer *gpl = ale->data;
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
bGPDframe *gpf;
/* Find gp-frame which is less than or equal to current-frame. */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (gpf = static_cast<bGPDframe *>(gpl->frames.first); gpf; gpf = gpf->next) {
if (!onlySel || (gpf->flag & GP_FRAME_SELECT)) {
const float framenum = (float)gpf->framenum;
*min = min_ff(*min, framenum);
@@ -186,11 +186,12 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
}
}
else if (ale->datatype == ALE_MASKLAY) {
MaskLayer *masklay = ale->data;
MaskLayer *masklay = static_cast<MaskLayer *>(ale->data);
MaskLayerShape *masklay_shape;
/* Find mask layer which is less than or equal to current-frame. */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
for (masklay_shape = static_cast<MaskLayerShape *>(masklay->splines_shapes.first);
masklay_shape;
masklay_shape = masklay_shape->next) {
const float framenum = (float)masklay_shape->frame;
*min = min_ff(*min, framenum);
@@ -248,7 +249,7 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
/** \name View: Automatic Preview-Range Operator
* \{ */
static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_previewrange_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
Scene *scene;
@@ -258,7 +259,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
if (ac.scene == NULL) {
if (ac.scene == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -311,21 +312,22 @@ void ACTION_OT_previewrange_set(wmOperatorType *ot)
*/
static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* NOTE: not bool, since we want prioritize individual channels over expanders. */
short found = 0;
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through all channels, finding the first one that's selected */
float ymax = ANIM_UI_get_first_channel_top(&ac->region->v2d);
const float channel_step = ANIM_UI_get_channel_step();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* must be selected... */
@@ -407,7 +409,7 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
float ymid = (ymax - ymin) / 2.0f + ymin;
float x_center;
UI_view2d_center_get(v2d, &x_center, NULL);
UI_view2d_center_get(v2d, &x_center, nullptr);
UI_view2d_center_set(v2d, x_center, ymid);
}
}
@@ -423,13 +425,13 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
/* ......... */
static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_viewall_exec(bContext *C, wmOperator * /*op*/)
{
/* whole range */
return actkeys_viewall(C, false);
}
static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_viewsel_exec(bContext *C, wmOperator * /*op*/)
{
/* only selected */
return actkeys_viewall(C, true);
@@ -506,8 +508,9 @@ void ACTION_OT_view_frame(wmOperatorType *ot)
static short copy_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter;
short ok = 0;
/* clear buffer first */
ANIM_fcurves_copybuf_free();
@@ -515,7 +518,7 @@ static short copy_action_keys(bAnimContext *ac)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
@@ -531,8 +534,8 @@ static eKeyPasteError paste_action_keys(bAnimContext *ac,
const eKeyMergeMode merge_mode,
bool flip)
{
ListBase anim_data = {NULL, NULL};
int filter;
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter;
/* filter data
* - First time we try to filter more strictly, allowing only selected channels
@@ -543,8 +546,9 @@ static eKeyPasteError paste_action_keys(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (ANIM_animdata_filter(
ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, eAnimCont_Types(ac->datatype)) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
}
/* Value offset is always None because the user cannot see the effect of it. */
@@ -614,8 +618,8 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
const eKeyPasteOffset offset_mode = eKeyPasteOffset(RNA_enum_get(op->ptr, "offset"));
const eKeyMergeMode merge_mode = eKeyMergeMode(RNA_enum_get(op->ptr, "merge"));
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
bool gpframes_inbuf = false;
@@ -668,17 +672,15 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
/* Grease Pencil needs extra update to refresh the added keyframes. */
if (ac.datatype == ANIMCONT_GPENCIL || gpframes_inbuf) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, nullptr);
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
static char *actkeys_paste_description(bContext *UNUSED(C),
wmOperatorType *UNUSED(op),
PointerRNA *ptr)
static char *actkeys_paste_description(bContext * /*C*/, wmOperatorType * /*op*/, PointerRNA *ptr)
{
/* Custom description if the 'flipped' option is used. */
if (RNA_boolean_get(ptr, "flipped")) {
@@ -686,7 +688,7 @@ static char *actkeys_paste_description(bContext *UNUSED(C),
}
/* Use the default description in the other cases. */
return NULL;
return nullptr;
}
void ACTION_OT_paste(wmOperatorType *ot)
@@ -738,7 +740,7 @@ static const EnumPropertyItem prop_actkeys_insertkey_types[] = {
{2, "SEL", 0, "Only Selected Channels", ""},
/* XXX not in all cases. */
{3, "GROUP", 0, "In Active Group", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void insert_gpencil_key(bAnimContext *ac,
@@ -770,10 +772,10 @@ static void insert_fcurve_key(bAnimContext *ac,
ToolSettings *ts = scene->toolsettings;
/* Read value from property the F-Curve represents, or from the curve only?
* - ale->id != NULL:
* - ale->id != nullptr:
* Typically, this means that we have enough info to try resolving the path.
*
* - ale->owner != NULL:
* - ale->owner != nullptr:
* If this is set, then the path may not be resolvable from the ID alone,
* so it's easier for now to just read the F-Curve directly.
* (TODO: add the full-blown PointerRNA relative parsing case here...)
@@ -782,12 +784,12 @@ static void insert_fcurve_key(bAnimContext *ac,
insert_keyframe(ac->bmain,
reports,
ale->id,
NULL,
((fcu->grp) ? (fcu->grp->name) : (NULL)),
nullptr,
((fcu->grp) ? (fcu->grp->name) : (nullptr)),
fcu->rna_path,
fcu->array_index,
&anim_eval_context,
ts->keyframe_type,
eBezTriple_KeyframeType(ts->keyframe_type),
nla_cache,
flag);
}
@@ -801,7 +803,8 @@ static void insert_fcurve_key(bAnimContext *ac,
}
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
insert_vert_fcurve(
fcu, cfra, curval, eBezTriple_KeyframeType(ts->keyframe_type), eInsertKeyFlags(0));
}
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -810,17 +813,17 @@ static void insert_fcurve_key(bAnimContext *ac,
/* this function is responsible for inserting new keyframes */
static void insert_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase nla_cache = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ListBase nla_cache = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
eInsertKeyFlags flag;
eGP_GetFrame_Mode add_frame_mode;
bGPdata *gpd_old = NULL;
bGPdata *gpd_old = nullptr;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
@@ -832,7 +835,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
filter |= ANIMFILTER_ACTGROUPED;
}
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Init keyframing flag. */
flag = ANIM_get_keyframing_flags(scene, true);
@@ -848,7 +851,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
/* insert keyframes */
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
ac->depsgraph, (float)scene->r.cfra);
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GPLAYER:
insert_gpencil_key(ac, ale, add_frame_mode, &gpd_old);
@@ -894,9 +897,9 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
if (ac.datatype == ANIMCONT_GPENCIL) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
}
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@@ -928,18 +931,18 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot)
static bool duplicate_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
bool changed = false;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
changed |= duplicate_fcurve_keys((FCurve *)ale->key_data);
}
@@ -965,7 +968,7 @@ static bool duplicate_action_keys(bAnimContext *ac)
/* ------------------- */
static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_duplicate_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -980,7 +983,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1008,18 +1011,18 @@ void ACTION_OT_duplicate(wmOperatorType *ot)
static bool delete_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
bool changed_final = false;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
bool changed = false;
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -1038,7 +1041,7 @@ static bool delete_action_keys(bAnimContext *ac)
/* Only delete curve too if it won't be doing anything anymore */
if (BKE_fcurve_is_empty(fcu)) {
ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
ale->key_data = NULL;
ale->key_data = nullptr;
}
}
@@ -1056,7 +1059,7 @@ static bool delete_action_keys(bAnimContext *ac)
/* ------------------- */
static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_delete_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -1071,7 +1074,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1101,17 +1104,17 @@ void ACTION_OT_delete(wmOperatorType *ot)
static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_SEL | ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through filtered data and clean curves */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
clean_fcurve(ac, ale, thresh, clean_chan);
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -1147,7 +1150,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op)
clean_action_keys(&ac, thresh, clean_chan);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1182,17 +1185,17 @@ void ACTION_OT_clean(wmOperatorType *ot)
/* Evaluates the curves between each selected keyframe on each frame, and keys the value. */
static void sample_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
ale->update |= ANIM_UPDATE_DEPS;
@@ -1222,7 +1225,7 @@ static int actkeys_sample_exec(bContext *C, wmOperator *op)
sample_action_keys(&ac);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1275,23 +1278,23 @@ static const EnumPropertyItem prop_actkeys_expo_types[] = {
0,
"Clear Cyclic (F-Modifier)",
"Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* this function is responsible for setting extrapolation mode for keyframes */
static void setexpo_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_SEL | ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through setting mode per F-Curve */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
if (mode >= 0) {
@@ -1311,9 +1314,9 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
}
else if (mode == CLEAR_CYCLIC_EXPO) {
/* remove all the modifiers fitting this description */
FModifier *fcm, *fcn = NULL;
FModifier *fcm, *fcn = nullptr;
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
for (fcm = static_cast<FModifier *>(fcu->modifiers.first); fcm; fcm = fcn) {
fcn = fcm->next;
if (fcm->type == FMODIFIER_TYPE_CYCLES) {
@@ -1354,7 +1357,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
setexpo_action_keys(&ac, mode);
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1410,7 +1413,7 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_ipo(mode));
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1464,7 +1467,7 @@ static int actkeys_easing_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_easing(mode));
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1499,9 +1502,9 @@ void ACTION_OT_easing_type(wmOperatorType *ot)
/* this function is responsible for setting handle-type of selected keyframes */
static void sethandles_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
@@ -1509,19 +1512,19 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting flags for handles
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr)) {
/* change type of selected handles */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, edit_cb, BKE_fcurve_handles_recalc);
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -1555,7 +1558,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
sethandles_action_keys(&ac, mode);
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1588,29 +1591,30 @@ void ACTION_OT_handle_type(wmOperatorType *ot)
/* this function is responsible for setting keyframe type for keyframes */
static void setkeytype_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode);
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting BezTriple interpolation
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GPLAYER:
ED_gpencil_layer_frames_keytype_set(ale->data, mode);
ED_gpencil_layer_frames_keytype_set(static_cast<bGPDlayer *>(ale->data), mode);
ale->update |= ANIM_UPDATE_DEPS;
break;
case ANIMTYPE_FCURVE:
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, NULL);
ANIM_fcurve_keyframes_loop(
nullptr, static_cast<FCurve *>(ale->key_data), nullptr, set_cb, nullptr);
ale->update |= ANIM_UPDATE_DEPS | ANIM_UPDATE_HANDLES;
break;
@@ -1647,7 +1651,7 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
setkeytype_action_keys(&ac, mode);
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1688,13 +1692,13 @@ static bool actkeys_framejump_poll(bContext *C)
}
/* snap current-frame indicator to 'average time' of selected keyframe */
static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_framejump_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditData ked = {{NULL}};
eAnimFilter_Flags filter;
KeyframeEditData ked = {{nullptr}};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1704,15 +1708,15 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
/* init edit data */
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->datatype) {
case ALE_GPFRAME: {
bGPDlayer *gpl = ale->data;
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
bGPDframe *gpf;
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (gpf = static_cast<bGPDframe *>(gpl->frames.first); gpf; gpf = gpf->next) {
/* only if selected */
if (!(gpf->flag & GP_FRAME_SELECT)) {
continue;
@@ -1728,13 +1732,14 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
case ALE_FCURVE: {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, bezt_calc_average, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, bezt_calc_average, nullptr);
}
break;
}
@@ -1803,17 +1808,17 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = {
0,
"Selection to Nearest Marker",
"Snap selected keyframes to the nearest marker"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* this function is responsible for snapping keyframes to frame-times */
static void snap_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc edit_cb;
/* filter data */
@@ -1824,38 +1829,40 @@ static void snap_action_keys(bAnimContext *ac, short mode)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
}
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_snap(mode);
ked.scene = ac->scene;
if (mode == ACTKEYS_SNAP_NEAREST_MARKER) {
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
ked.list.last = (ac->markers) ? ac->markers->last : NULL;
ked.list.first = (ac->markers) ? ac->markers->first : nullptr;
ked.list.last = (ac->markers) ? ac->markers->last : nullptr;
}
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_layer_snap_frames(ale->data, ac->scene, mode);
ED_gpencil_layer_snap_frames(static_cast<bGPDlayer *>(ale->data), ac->scene, mode);
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_masklayer_snap_frames(ale->data, ac->scene, mode);
ED_masklayer_snap_frames(static_cast<MaskLayer *>(ale->data), ac->scene, mode);
}
else if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(
ale->key_data, SELECT, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
fcurve, SELECT, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(
ale->key_data, SELECT, false); /* only use handles in graph editor */
fcurve, SELECT, false); /* only use handles in graph editor */
}
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -1884,7 +1891,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
snap_action_keys(&ac, mode);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1931,17 +1938,17 @@ static const EnumPropertyItem prop_actkeys_mirror_types[] = {
0,
"By Times Over First Selected Marker",
"Flip times of selected keyframes using the first selected marker as the reference point"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* this function is responsible for mirroring keyframes */
static void mirror_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc edit_cb;
/* get beztriple editing callbacks */
@@ -1965,25 +1972,27 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_layer_mirror_frames(ale->data, ac->scene, mode);
ED_gpencil_layer_mirror_frames(static_cast<bGPDlayer *>(ale->data), ac->scene, mode);
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
/* TODO */
}
else if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, edit_cb, BKE_fcurve_handles_recalc);
}
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -2012,7 +2021,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
mirror_action_keys(&ac, mode);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}

View File

@@ -1,135 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup spaction
*/
#pragma once
struct ARegion;
struct ARegionType;
struct Object;
struct Scene;
struct SpaceAction;
struct bAnimContext;
struct bContext;
struct wmOperatorType;
/* internal exports only */
/* **************************************** */
/* space_action.c / action_buttons.c */
void action_buttons_register(struct ARegionType *art);
/* ***************************************** */
/* action_draw.c */
/**
* Left hand part.
*/
void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *region);
/**
* Draw keyframes in each channel.
*/
void draw_channel_strips(struct bAnimContext *ac,
struct SpaceAction *saction,
struct ARegion *region);
void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct Scene *scene);
/* ***************************************** */
/* action_select.c */
void ACTION_OT_select_all(struct wmOperatorType *ot);
void ACTION_OT_select_box(struct wmOperatorType *ot);
void ACTION_OT_select_lasso(struct wmOperatorType *ot);
void ACTION_OT_select_circle(struct wmOperatorType *ot);
void ACTION_OT_select_column(struct wmOperatorType *ot);
void ACTION_OT_select_linked(struct wmOperatorType *ot);
void ACTION_OT_select_more(struct wmOperatorType *ot);
void ACTION_OT_select_less(struct wmOperatorType *ot);
void ACTION_OT_select_leftright(struct wmOperatorType *ot);
void ACTION_OT_clickselect(struct wmOperatorType *ot);
/* defines for left-right select tool */
enum eActKeys_LeftRightSelect_Mode {
ACTKEYS_LRSEL_TEST = 0,
ACTKEYS_LRSEL_LEFT,
ACTKEYS_LRSEL_RIGHT,
};
/* defines for column-select mode */
enum eActKeys_ColumnSelect_Mode {
ACTKEYS_COLUMNSEL_KEYS = 0,
ACTKEYS_COLUMNSEL_CFRA,
ACTKEYS_COLUMNSEL_MARKERS_COLUMN,
ACTKEYS_COLUMNSEL_MARKERS_BETWEEN,
};
/* ***************************************** */
/* action_edit.c */
void ACTION_OT_previewrange_set(struct wmOperatorType *ot);
void ACTION_OT_view_all(struct wmOperatorType *ot);
void ACTION_OT_view_selected(struct wmOperatorType *ot);
void ACTION_OT_view_frame(struct wmOperatorType *ot);
void ACTION_OT_copy(struct wmOperatorType *ot);
void ACTION_OT_paste(struct wmOperatorType *ot);
void ACTION_OT_keyframe_insert(struct wmOperatorType *ot);
void ACTION_OT_duplicate(struct wmOperatorType *ot);
void ACTION_OT_delete(struct wmOperatorType *ot);
void ACTION_OT_clean(struct wmOperatorType *ot);
void ACTION_OT_sample(struct wmOperatorType *ot);
void ACTION_OT_keyframe_type(struct wmOperatorType *ot);
void ACTION_OT_handle_type(struct wmOperatorType *ot);
void ACTION_OT_interpolation_type(struct wmOperatorType *ot);
void ACTION_OT_extrapolation_type(struct wmOperatorType *ot);
void ACTION_OT_easing_type(struct wmOperatorType *ot);
void ACTION_OT_frame_jump(struct wmOperatorType *ot);
void ACTION_OT_snap(struct wmOperatorType *ot);
void ACTION_OT_mirror(struct wmOperatorType *ot);
void ACTION_OT_new(struct wmOperatorType *ot);
void ACTION_OT_unlink(struct wmOperatorType *ot);
void ACTION_OT_push_down(struct wmOperatorType *ot);
void ACTION_OT_stash(struct wmOperatorType *ot);
void ACTION_OT_stash_and_create(struct wmOperatorType *ot);
void ACTION_OT_layer_next(struct wmOperatorType *ot);
void ACTION_OT_layer_prev(struct wmOperatorType *ot);
void ACTION_OT_markers_make_local(struct wmOperatorType *ot);
/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/
enum eActKeys_Snap_Mode {
ACTKEYS_SNAP_CFRA = 1,
ACTKEYS_SNAP_NEAREST_FRAME,
ACTKEYS_SNAP_NEAREST_SECOND,
ACTKEYS_SNAP_NEAREST_MARKER,
};
/* defines for mirror keyframes
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
*/
enum eActKeys_Mirror_Mode {
ACTKEYS_MIRROR_CFRA = 1,
ACTKEYS_MIRROR_YAXIS,
ACTKEYS_MIRROR_XAXIS,
ACTKEYS_MIRROR_MARKER,
};
/* ***************************************** */
/* action_ops.c */
void action_operatortypes(void);
void action_keymap(struct wmKeyConfig *keyconf);

View File

@@ -0,0 +1,133 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup spaction
*/
#pragma once
struct ARegion;
struct ARegionType;
struct Object;
struct Scene;
struct SpaceAction;
struct bAnimContext;
struct bContext;
struct wmOperatorType;
/* internal exports only */
/* **************************************** */
/* space_action.c / action_buttons.c */
void action_buttons_register(ARegionType *art);
/* ***************************************** */
/* action_draw.c */
/**
* Left hand part.
*/
void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region);
/**
* Draw keyframes in each channel.
*/
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region);
void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene);
/* ***************************************** */
/* action_select.c */
void ACTION_OT_select_all(wmOperatorType *ot);
void ACTION_OT_select_box(wmOperatorType *ot);
void ACTION_OT_select_lasso(wmOperatorType *ot);
void ACTION_OT_select_circle(wmOperatorType *ot);
void ACTION_OT_select_column(wmOperatorType *ot);
void ACTION_OT_select_linked(wmOperatorType *ot);
void ACTION_OT_select_more(wmOperatorType *ot);
void ACTION_OT_select_less(wmOperatorType *ot);
void ACTION_OT_select_leftright(wmOperatorType *ot);
void ACTION_OT_clickselect(wmOperatorType *ot);
/* defines for left-right select tool */
enum eActKeys_LeftRightSelect_Mode {
ACTKEYS_LRSEL_TEST = 0,
ACTKEYS_LRSEL_LEFT,
ACTKEYS_LRSEL_RIGHT,
};
/* defines for column-select mode */
enum eActKeys_ColumnSelect_Mode {
ACTKEYS_COLUMNSEL_KEYS = 0,
ACTKEYS_COLUMNSEL_CFRA,
ACTKEYS_COLUMNSEL_MARKERS_COLUMN,
ACTKEYS_COLUMNSEL_MARKERS_BETWEEN,
};
/* ***************************************** */
/* action_edit.c */
void ACTION_OT_previewrange_set(wmOperatorType *ot);
void ACTION_OT_view_all(wmOperatorType *ot);
void ACTION_OT_view_selected(wmOperatorType *ot);
void ACTION_OT_view_frame(wmOperatorType *ot);
void ACTION_OT_copy(wmOperatorType *ot);
void ACTION_OT_paste(wmOperatorType *ot);
void ACTION_OT_keyframe_insert(wmOperatorType *ot);
void ACTION_OT_duplicate(wmOperatorType *ot);
void ACTION_OT_delete(wmOperatorType *ot);
void ACTION_OT_clean(wmOperatorType *ot);
void ACTION_OT_sample(wmOperatorType *ot);
void ACTION_OT_keyframe_type(wmOperatorType *ot);
void ACTION_OT_handle_type(wmOperatorType *ot);
void ACTION_OT_interpolation_type(wmOperatorType *ot);
void ACTION_OT_extrapolation_type(wmOperatorType *ot);
void ACTION_OT_easing_type(wmOperatorType *ot);
void ACTION_OT_frame_jump(wmOperatorType *ot);
void ACTION_OT_snap(wmOperatorType *ot);
void ACTION_OT_mirror(wmOperatorType *ot);
void ACTION_OT_new(wmOperatorType *ot);
void ACTION_OT_unlink(wmOperatorType *ot);
void ACTION_OT_push_down(wmOperatorType *ot);
void ACTION_OT_stash(wmOperatorType *ot);
void ACTION_OT_stash_and_create(wmOperatorType *ot);
void ACTION_OT_layer_next(wmOperatorType *ot);
void ACTION_OT_layer_prev(wmOperatorType *ot);
void ACTION_OT_markers_make_local(wmOperatorType *ot);
/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/
enum eActKeys_Snap_Mode {
ACTKEYS_SNAP_CFRA = 1,
ACTKEYS_SNAP_NEAREST_FRAME,
ACTKEYS_SNAP_NEAREST_SECOND,
ACTKEYS_SNAP_NEAREST_MARKER,
};
/* defines for mirror keyframes
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
*/
enum eActKeys_Mirror_Mode {
ACTKEYS_MIRROR_CFRA = 1,
ACTKEYS_MIRROR_YAXIS,
ACTKEYS_MIRROR_XAXIS,
ACTKEYS_MIRROR_MARKER,
};
/* ***************************************** */
/* action_ops.c */
void action_operatortypes(void);
void action_keymap(wmKeyConfig *keyconf);

View File

@@ -5,15 +5,15 @@
* \ingroup spaction
*/
#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include "DNA_space_types.h"
#include "ED_anim_api.h"
#include "ED_transform.h"
#include "action_intern.h"
#include "action_intern.hh"
#include "RNA_access.h"

View File

@@ -5,10 +5,10 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
@@ -46,14 +46,14 @@
#include "WM_api.h"
#include "WM_types.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Keyframes Stuff
* \{ */
static bAnimListElem *actkeys_find_list_element_at_position(bAnimContext *ac,
int filter,
eAnimFilter_Flags filter,
float region_x,
float region_y)
{
@@ -68,16 +68,16 @@ static bAnimListElem *actkeys_find_list_element_at_position(bAnimContext *ac,
ANIM_UI_get_first_channel_top(v2d),
view_x,
view_y,
NULL,
nullptr,
&channel_index);
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
bAnimListElem *ale = BLI_findlink(&anim_data, channel_index);
if (ale != NULL) {
bAnimListElem *ale = static_cast<bAnimListElem *>(BLI_findlink(&anim_data, channel_index));
if (ale != nullptr) {
BLI_remlink(&anim_data, ale);
ale->next = ale->prev = NULL;
ale->next = ale->prev = nullptr;
}
ANIM_animdata_freelist(&anim_data);
@@ -85,14 +85,14 @@ static bAnimListElem *actkeys_find_list_element_at_position(bAnimContext *ac,
}
static void actkeys_list_element_to_keylist(bAnimContext *ac,
struct AnimKeylist *keylist,
AnimKeylist *keylist,
bAnimListElem *ale)
{
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
bDopeSheet *ads = NULL;
bDopeSheet *ads = nullptr;
if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
ads = ac->data;
ads = static_cast<bDopeSheet *>(ac->data);
}
if (ale->key_data) {
@@ -152,7 +152,7 @@ static void actkeys_find_key_in_list_element(bAnimContext *ac,
View2D *v2d = &ac->region->v2d;
struct AnimKeylist *keylist = ED_keylist_create();
AnimKeylist *keylist = ED_keylist_create();
actkeys_list_element_to_keylist(ac, keylist, ale);
ED_keylist_prepare_for_direct_access(keylist);
@@ -183,7 +183,7 @@ static void actkeys_find_key_in_list_element(bAnimContext *ac,
}
static void actkeys_find_key_at_position(bAnimContext *ac,
int filter,
eAnimFilter_Flags filter,
float region_x,
float region_y,
bAnimListElem **r_ale,
@@ -196,7 +196,7 @@ static void actkeys_find_key_at_position(bAnimContext *ac,
*r_found = false;
*r_ale = actkeys_find_list_element_at_position(ac, filter, region_x, region_y);
if (*r_ale != NULL) {
if (*r_ale != nullptr) {
actkeys_find_key_in_list_element(
ac, *r_ale, region_x, r_selx, r_frame, r_found, r_is_selected);
}
@@ -209,11 +209,12 @@ static bool actkeys_is_key_at_position(bAnimContext *ac, float region_x, float r
bool found;
bool is_selected;
int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS;
eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS;
actkeys_find_key_at_position(
ac, filter, region_x, region_y, &ale, &selx, &frame, &found, &is_selected);
if (ale != NULL) {
if (ale != nullptr) {
MEM_freeN(ale);
}
return found;
@@ -238,39 +239,40 @@ static bool actkeys_is_key_at_position(bAnimContext *ac, float region_x, float r
*/
static void deselect_action_keys(bAnimContext *ac, short test, short sel)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc test_cb, sel_cb;
/* determine type-based settings */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
/* filter data */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* init BezTriple looping data */
test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
if (ED_gpencil_layer_frame_select_check(ale->data)) {
if (ED_gpencil_layer_frame_select_check(static_cast<bGPDlayer *>(ale->data))) {
sel = SELECT_SUBTRACT;
break;
}
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
if (ED_masklayer_frame_select_check(ale->data)) {
if (ED_masklayer_frame_select_check(static_cast<MaskLayer *>(ale->data))) {
sel = SELECT_SUBTRACT;
break;
}
}
else {
if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, test_cb, nullptr)) {
sel = SELECT_SUBTRACT;
break;
}
@@ -282,16 +284,17 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel)
sel_cb = ANIM_editkeyframes_select(sel);
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_layer_frame_select_set(ale->data, sel);
ED_gpencil_layer_frame_select_set(static_cast<bGPDlayer *>(ale->data), sel);
ale->update |= ANIM_UPDATE_DEPS;
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_masklayer_frame_select_set(ale->data, sel);
ED_masklayer_frame_select_set(static_cast<MaskLayer *>(ale->data), sel);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, sel_cb, nullptr);
}
}
@@ -332,9 +335,9 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
}
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(eAnimCont_Types(ac.datatype)))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -377,13 +380,13 @@ enum {
ACTKEYS_BORDERSEL_CHANNELS,
} /*eActKeys_BoxSelect_Mode*/;
typedef struct BoxSelectData {
struct BoxSelectData {
bAnimContext *ac;
short selectmode;
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
} BoxSelectData;
};
static void box_select_elem(
BoxSelectData *sel_data, bAnimListElem *ale, float xmin, float xmax, bool summary)
@@ -403,20 +406,23 @@ static void box_select_elem(
}
#endif
case ANIMTYPE_GPLAYER: {
ED_gpencil_layer_frames_select_box(ale->data, xmin, xmax, sel_data->selectmode);
ED_gpencil_layer_frames_select_box(
static_cast<bGPDlayer *>(ale->data), xmin, xmax, sel_data->selectmode);
ale->update |= ANIM_UPDATE_DEPS;
break;
}
case ANIMTYPE_MASKDATABLOCK: {
Mask *mask = ale->data;
Mask *mask = static_cast<Mask *>(ale->data);
MaskLayer *masklay;
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
for (masklay = static_cast<MaskLayer *>(mask->masklayers.first); masklay;
masklay = masklay->next) {
ED_masklayer_frames_select_box(masklay, xmin, xmax, sel_data->selectmode);
}
break;
}
case ANIMTYPE_MASKLAYER: {
ED_masklayer_frames_select_box(ale->data, xmin, xmax, sel_data->selectmode);
ED_masklayer_frames_select_box(
static_cast<MaskLayer *>(ale->data), xmin, xmax, sel_data->selectmode);
break;
}
default: {
@@ -425,8 +431,9 @@ static void box_select_elem(
}
if (ale->type == ANIMTYPE_SUMMARY) {
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
box_select_elem(sel_data, ale2, xmin, xmax, true);
@@ -438,7 +445,7 @@ static void box_select_elem(
if (!ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
ANIM_animchannel_keyframes_loop(
&sel_data->ked, ac->ads, ale, sel_data->ok_cb, sel_data->select_cb, NULL);
&sel_data->ked, ac->ads, ale, sel_data->ok_cb, sel_data->select_cb, nullptr);
}
}
}
@@ -446,11 +453,14 @@ static void box_select_elem(
static void box_select_action(bAnimContext *ac, const rcti rect, short mode, short selectmode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
BoxSelectData sel_data{};
sel_data.ac = ac;
sel_data.selectmode = selectmode;
BoxSelectData sel_data = {.ac = ac, .selectmode = selectmode};
View2D *v2d = &ac->region->v2d;
rctf rectf;
@@ -461,7 +471,7 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Get beztriple editing/validation functions. */
sel_data.select_cb = ANIM_editkeyframes_select(selectmode);
@@ -470,7 +480,7 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
sel_data.ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
}
else {
sel_data.ok_cb = NULL;
sel_data.ok_cb = nullptr;
}
/* init editing data */
@@ -480,7 +490,8 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
const float channel_step = ANIM_UI_get_channel_step();
/* loop over data, doing box select */
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
@@ -544,7 +555,7 @@ static int actkeys_box_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
@@ -577,9 +588,9 @@ static int actkeys_box_select_exec(bContext *C, wmOperator *op)
box_select_action(&ac, rect, mode, selectmode);
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -624,14 +635,14 @@ void ACTION_OT_select_box(wmOperatorType *ot)
* original Graph Editor implementation of these to do it this way.
* \{ */
typedef struct RegionSelectData {
struct RegionSelectData {
bAnimContext *ac;
short mode;
short selectmode;
KeyframeEditData ked;
KeyframeEditFunc ok_cb, select_cb;
} RegionSelectData;
};
static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, bool summary)
{
@@ -649,23 +660,28 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b
}
#endif
case ANIMTYPE_GPLAYER: {
ED_gpencil_layer_frames_select_region(
&sel_data->ked, ale->data, sel_data->mode, sel_data->selectmode);
ED_gpencil_layer_frames_select_region(&sel_data->ked,
static_cast<bGPDlayer *>(ale->data),
sel_data->mode,
sel_data->selectmode);
ale->update |= ANIM_UPDATE_DEPS;
break;
}
case ANIMTYPE_MASKDATABLOCK: {
Mask *mask = ale->data;
Mask *mask = static_cast<Mask *>(ale->data);
MaskLayer *masklay;
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
for (masklay = static_cast<MaskLayer *>(mask->masklayers.first); masklay;
masklay = masklay->next) {
ED_masklayer_frames_select_region(
&sel_data->ked, masklay, sel_data->mode, sel_data->selectmode);
}
break;
}
case ANIMTYPE_MASKLAYER: {
ED_masklayer_frames_select_region(
&sel_data->ked, ale->data, sel_data->mode, sel_data->selectmode);
ED_masklayer_frames_select_region(&sel_data->ked,
static_cast<MaskLayer *>(ale->data),
sel_data->mode,
sel_data->selectmode);
break;
}
default: {
@@ -674,8 +690,9 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b
}
if (ale->type == ANIMTYPE_SUMMARY) {
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
region_select_elem(sel_data, ale2, true);
@@ -687,7 +704,7 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b
if (!ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
ANIM_animchannel_keyframes_loop(
&sel_data->ked, ac->ads, ale, sel_data->ok_cb, sel_data->select_cb, NULL);
&sel_data->ked, ac->ads, ale, sel_data->ok_cb, sel_data->select_cb, nullptr);
}
}
}
@@ -696,11 +713,14 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b
static void region_select_action_keys(
bAnimContext *ac, const rctf *rectf_view, short mode, short selectmode, void *data)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
RegionSelectData sel_data = {.ac = ac, .mode = mode, .selectmode = selectmode};
RegionSelectData sel_data{};
sel_data.ac = ac;
sel_data.mode = mode;
sel_data.selectmode = selectmode;
View2D *v2d = &ac->region->v2d;
rctf rectf, scaled_rectf;
@@ -710,7 +730,7 @@ static void region_select_action_keys(
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Get beztriple editing/validation functions. */
sel_data.select_cb = ANIM_editkeyframes_select(selectmode);
@@ -719,12 +739,12 @@ static void region_select_action_keys(
/* init editing data */
memset(&sel_data.ked, 0, sizeof(KeyframeEditData));
if (mode == BEZT_OK_CHANNEL_LASSO) {
KeyframeEdit_LassoData *data_lasso = data;
KeyframeEdit_LassoData *data_lasso = static_cast<KeyframeEdit_LassoData *>(data);
data_lasso->rectf_scaled = &scaled_rectf;
sel_data.ked.data = data_lasso;
}
else if (mode == BEZT_OK_CHANNEL_CIRCLE) {
KeyframeEdit_CircleData *data_circle = data;
KeyframeEdit_CircleData *data_circle = static_cast<KeyframeEdit_CircleData *>(data);
data_circle->rectf_scaled = &scaled_rectf;
sel_data.ked.data = data;
}
@@ -736,7 +756,8 @@ static void region_select_action_keys(
const float channel_step = ANIM_UI_get_channel_step();
/* loop over data, doing region select */
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
@@ -799,11 +820,11 @@ static int actkeys_lassoselect_exec(bContext *C, wmOperator *op)
data_lasso.rectf_view = &rect_fl;
data_lasso.mcoords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcoords_len);
if (data_lasso.mcoords == NULL) {
if (data_lasso.mcoords == nullptr) {
return OPERATOR_CANCELLED;
}
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
@@ -819,9 +840,9 @@ static int actkeys_lassoselect_exec(bContext *C, wmOperator *op)
MEM_freeN((void *)data_lasso.mcoords);
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -866,8 +887,9 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
const eSelectOp sel_op = ED_select_op_modal(
eSelectOp(RNA_enum_get(op->ptr, "mode")),
WM_gesture_is_modal_first(static_cast<wmGesture *>(op->customdata)));
const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
deselect_action_keys(&ac, 0, SELECT_SUBTRACT);
@@ -887,9 +909,9 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data);
/* send notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -937,7 +959,7 @@ static const EnumPropertyItem prop_column_select_types[] = {
0,
"Between Min/Max Selected Markers",
""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* ------------------- */
@@ -947,12 +969,12 @@ static const EnumPropertyItem prop_column_select_types[] = {
* graph_select.c should de-duplicate. */
static void markers_selectkeys_between(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
float min, max;
/* get extreme markers */
@@ -969,29 +991,31 @@ static void markers_selectkeys_between(bAnimContext *ac)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* select keys in-between */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GPLAYER:
ED_gpencil_layer_frames_select_box(ale->data, min, max, SELECT_ADD);
ED_gpencil_layer_frames_select_box(
static_cast<bGPDlayer *>(ale->data), min, max, SELECT_ADD);
ale->update |= ANIM_UPDATE_DEPS;
break;
case ANIMTYPE_MASKLAYER:
ED_masklayer_frames_select_box(ale->data, min, max, SELECT_ADD);
ED_masklayer_frames_select_box(static_cast<MaskLayer *>(ale->data), min, max, SELECT_ADD);
break;
case ANIMTYPE_FCURVE: {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, fcurve, ok_cb, select_cb, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcurve, ok_cb, select_cb, nullptr);
}
break;
}
@@ -1009,36 +1033,37 @@ static void markers_selectkeys_between(bAnimContext *ac)
/* Selects all visible keyframes in the same frames as the specified elements */
static void columnselect_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
Scene *scene = ac->scene;
CfraElem *ce;
KeyframeEditFunc select_cb, ok_cb;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
/* build list of columns */
switch (mode) {
case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */
if (ac->datatype == ANIMCONT_GPENCIL) {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
ED_gpencil_layer_make_cfra_list(ale->data, &ked.list, 1);
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
ED_gpencil_layer_make_cfra_list(static_cast<bGPDlayer *>(ale->data), &ked.list, 1);
}
}
else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (ale->datatype == ALE_GPFRAME) {
ED_gpencil_layer_make_cfra_list(ale->data, &ked.list, 1);
ED_gpencil_layer_make_cfra_list(static_cast<bGPDlayer *>(ale->data), &ked.list, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, bezt_to_cfraelem, nullptr);
}
}
}
@@ -1047,7 +1072,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
case ACTKEYS_COLUMNSEL_CFRA: /* current frame */
/* make a single CfraElem for storing this */
ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
ce = MEM_cnew<CfraElem>("cfraElem");
BLI_addtail(&ked.list, ce);
ce->cfra = (float)scene->r.cfra;
@@ -1069,15 +1094,15 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
* based on the keys found to be selected above
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* loop over cfraelems (stored in the KeyframeEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
for (ce = ked.list.first; ce; ce = ce->next) {
for (ce = static_cast<CfraElem *>(ked.list.first); ce; ce = ce->next) {
/* set frame for validation callback to refer to */
if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
@@ -1088,14 +1113,15 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
/* select elements with frame number matching cfraelem */
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, ce->cfra, SELECT_ADD);
ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale->data), ce->cfra, SELECT_ADD);
ale->update |= ANIM_UPDATE_DEPS;
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frame(ale->data, ce->cfra, SELECT_ADD);
ED_mask_select_frame(static_cast<MaskLayer *>(ale->data), ce->cfra, SELECT_ADD);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
}
}
}
@@ -1130,9 +1156,9 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op)
}
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -1162,13 +1188,13 @@ void ACTION_OT_select_column(wmOperatorType *ot)
/** \name Select Linked Operator
* \{ */
static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_select_linked_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
@@ -1181,15 +1207,15 @@ static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* check if anything selected? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, ok_cb, nullptr)) {
/* select every keyframe in this curve then */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL);
ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr);
}
}
@@ -1197,9 +1223,9 @@ static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -1228,11 +1254,11 @@ void ACTION_OT_select_linked(wmOperatorType *ot)
/* Common code to perform selection */
static void select_moreless_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc build_cb;
/* init selmap building data */
@@ -1241,9 +1267,9 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
/* TODO: other types. */
if (ale->datatype != ALE_FCURVE) {
@@ -1252,20 +1278,20 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
/* only continue if F-Curve has keyframes */
FCurve *fcu = (FCurve *)ale->key_data;
if (fcu->bezt == NULL) {
if (fcu->bezt == nullptr) {
continue;
}
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more");
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, build_cb, nullptr);
/* based on this map, adjust the selection status of the keyframes */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, bezt_selmap_flush, nullptr);
/* free the selmap used here */
MEM_freeN(ked.data);
ked.data = NULL;
ked.data = nullptr;
}
/* Cleanup */
@@ -1274,7 +1300,7 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
/* ----------------- */
static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_select_more_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -1287,9 +1313,9 @@ static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
select_moreless_action_keys(&ac, SELMAP_MORE);
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -1311,7 +1337,7 @@ void ACTION_OT_select_more(wmOperatorType *ot)
/* ----------------- */
static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_select_less_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -1324,9 +1350,9 @@ static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
select_moreless_action_keys(&ac, SELMAP_LESS);
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
if (ANIM_animdata_can_have_greasepencil(eAnimCont_Types(ac.datatype))) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -1359,19 +1385,19 @@ static const EnumPropertyItem prop_actkeys_leftright_select_types[] = {
{ACTKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
{ACTKEYS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
{ACTKEYS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* --------------------------------- */
static void actkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
Scene *scene = ac->scene;
/* if select mode is replace, deselect all keyframes (and channels) first */
@@ -1399,29 +1425,32 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* select keys */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GPLAYER:
ED_gpencil_layer_frames_select_box(ale->data, ked.f1, ked.f2, select_mode);
ED_gpencil_layer_frames_select_box(
static_cast<bGPDlayer *>(ale->data), ked.f1, ked.f2, select_mode);
ale->update |= ANIM_UPDATE_DEPS;
break;
case ANIMTYPE_MASKLAYER:
ED_masklayer_frames_select_box(ale->data, ked.f1, ked.f2, select_mode);
ED_masklayer_frames_select_box(
static_cast<MaskLayer *>(ale->data), ked.f1, ked.f2, select_mode);
break;
case ANIMTYPE_FCURVE: {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, fcurve, ok_cb, select_cb, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcurve, ok_cb, select_cb, nullptr);
}
break;
}
@@ -1439,7 +1468,7 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se
ListBase *markers = ED_animcontext_get_markers(ac);
TimeMarker *marker;
for (marker = markers->first; marker; marker = marker->next) {
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
if (((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < scene->r.cfra)) ||
((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= scene->r.cfra))) {
marker->flag |= SELECT;
@@ -1486,8 +1515,8 @@ static int actkeys_select_leftright_exec(bContext *C, wmOperator *op)
actkeys_select_leftright(&ac, leftright, selectmode);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1570,7 +1599,7 @@ static void actkeys_mselect_single(bAnimContext *ac,
short select_mode,
float selx)
{
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc select_cb, ok_cb;
/* get functions for selecting keyframes */
@@ -1581,28 +1610,28 @@ static void actkeys_mselect_single(bAnimContext *ac,
/* select the nominated keyframe on the given frame */
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, selx, select_mode);
ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale->data), selx, select_mode);
ale->update |= ANIM_UPDATE_DEPS;
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frame(ale->data, selx, select_mode);
ED_mask_select_frame(static_cast<MaskLayer *>(ale->data), selx, select_mode);
}
else {
if (ale->type == ANIMTYPE_SUMMARY && ale->datatype == ALE_ALL) {
ListBase anim_data = {NULL, NULL};
int filter;
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter;
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop over all keys that are represented by this summary key. */
LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
if (ale2->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale2->data, selx, select_mode);
ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale2->data), selx, select_mode);
ale2->update |= ANIM_UPDATE_DEPS;
}
else if (ale2->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frame(ale2->data, selx, select_mode);
ED_mask_select_frame(static_cast<MaskLayer *>(ale2->data), selx, select_mode);
}
}
@@ -1611,7 +1640,7 @@ static void actkeys_mselect_single(bAnimContext *ac,
}
if (!ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL);
ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, nullptr);
}
}
}
@@ -1623,12 +1652,12 @@ static void actkeys_mselect_single(bAnimContext *ac,
/* Option 3) Selects all visible keyframes in the same frame as the mouse click */
static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float selx)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc select_cb, ok_cb;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
/* set up BezTriple edit callbacks */
select_cb = ANIM_editkeyframes_select(select_mode);
@@ -1638,16 +1667,16 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
* based on the keys found to be selected above
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
/* select elements with frame number matching cfra */
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frame(ale->data, selx, select_mode);
ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale->data), selx, select_mode);
ale->update |= ANIM_UPDATE_DEPS;
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frame(ale->data, selx, select_mode);
ED_mask_select_frame(static_cast<MaskLayer *>(ale->data), selx, select_mode);
}
else {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
@@ -1660,7 +1689,8 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
ked.f1 = selx;
}
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
}
}
@@ -1681,27 +1711,27 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
/* select all keyframes in this channel */
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frames(ale->data, select_mode);
ED_gpencil_select_frames(static_cast<bGPDlayer *>(ale->data), select_mode);
ale->update = ANIM_UPDATE_DEPS;
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frames(ale->data, select_mode);
ED_mask_select_frames(static_cast<MaskLayer *>(ale->data), select_mode);
}
else {
if (ale->type == ANIMTYPE_SUMMARY && ale->datatype == ALE_ALL) {
ListBase anim_data = {NULL, NULL};
int filter;
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter;
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
if (ale2->type == ANIMTYPE_GPLAYER) {
ED_gpencil_select_frames(ale2->data, select_mode);
ED_gpencil_select_frames(static_cast<bGPDlayer *>(ale2->data), select_mode);
ale2->update |= ANIM_UPDATE_DEPS;
}
else if (ale2->type == ANIMTYPE_MASKLAYER) {
ED_mask_select_frames(ale2->data, select_mode);
ED_mask_select_frames(static_cast<MaskLayer *>(ale2->data), select_mode);
}
}
@@ -1710,7 +1740,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
}
if (!ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
ANIM_animchannel_keyframes_loop(NULL, ac->ads, ale, NULL, select_cb, NULL);
ANIM_animchannel_keyframes_loop(nullptr, ac->ads, ale, nullptr, select_cb, nullptr);
}
}
}
@@ -1725,9 +1755,10 @@ static int mouse_action_keys(bAnimContext *ac,
const bool same_channel,
bool wait_to_deselect_others)
{
int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS;
eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS;
bAnimListElem *ale = NULL;
bAnimListElem *ale = nullptr;
bool found = false;
bool is_selected = false;
float frame = 0.0f; /* frame of keyframe under mouse - NLA corrections not applied/included */
@@ -1763,22 +1794,28 @@ static int mouse_action_keys(bAnimContext *ac,
ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
/* Highlight Action-Group or F-Curve? */
if (ale != NULL && ale->data) {
if (ale != nullptr && ale->data) {
if (ale->type == ANIMTYPE_GROUP) {
bActionGroup *agrp = ale->data;
bActionGroup *agrp = static_cast<bActionGroup *>(ale->data);
agrp->flag |= AGRP_SELECTED;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
ANIM_set_active_channel(
ac, ac->data, eAnimCont_Types(ac->datatype), filter, agrp, ANIMTYPE_GROUP);
}
else if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
FCurve *fcu = ale->data;
FCurve *fcu = static_cast<FCurve *>(ale->data);
fcu->flag |= FCURVE_SELECTED;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
ANIM_set_active_channel(ac,
ac->data,
eAnimCont_Types(ac->datatype),
filter,
fcu,
eAnim_ChannelType(ale->type));
}
else if (ale->type == ANIMTYPE_GPLAYER) {
bGPdata *gpd = (bGPdata *)ale->id;
bGPDlayer *gpl = ale->data;
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
ED_gpencil_set_active_channel(gpd, gpl);
}
@@ -1789,9 +1826,9 @@ static int mouse_action_keys(bAnimContext *ac,
ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
/* Highlight GPencil Layer */
if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) {
if (ale != nullptr && ale->data != nullptr && ale->type == ANIMTYPE_GPLAYER) {
bGPdata *gpd = (bGPdata *)ale->id;
bGPDlayer *gpl = ale->data;
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
ED_gpencil_set_active_channel(gpd, gpl);
}
@@ -1800,8 +1837,8 @@ static int mouse_action_keys(bAnimContext *ac,
/* deselect all other channels first */
ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR);
if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_MASKLAYER) {
MaskLayer *masklay = ale->data;
if (ale != nullptr && ale->data != nullptr && ale->type == ANIMTYPE_MASKLAYER) {
MaskLayer *masklay = static_cast<MaskLayer *>(ale->data);
masklay->flag |= MASK_LAYERFLAG_SELECT;
}
@@ -1810,7 +1847,7 @@ static int mouse_action_keys(bAnimContext *ac,
}
/* only select keyframes if we clicked on a valid channel and hit something */
if (ale != NULL) {
if (ale != nullptr) {
if (found) {
/* apply selection to keyframes */
if (column) {
@@ -1875,8 +1912,8 @@ static int actkeys_clickselect_exec(bContext *C, wmOperator *op)
&ac, mval, selectmode, deselect_all, column, channel, wait_to_deselect_others);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
/* for tweak grab to work */
return ret_value | OPERATOR_PASS_THROUGH;

View File

@@ -5,8 +5,8 @@
* \ingroup spaction
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "DNA_action_types.h"
#include "DNA_anim_types.h"
@@ -44,7 +44,7 @@
#include "BLO_read_write.h"
#include "action_intern.h" /* own include */
#include "action_intern.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Default Callbacks for Action Space
@@ -55,7 +55,7 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
SpaceAction *saction;
ARegion *region;
saction = MEM_callocN(sizeof(SpaceAction), "initaction");
saction = MEM_cnew<SpaceAction>("initaction");
saction->spacetype = SPACE_ACTION;
saction->autosnap = SACTSNAP_FRAME;
@@ -72,14 +72,14 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
saction->cache_display |= TIME_CACHE_RIGIDBODY;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for action");
region = MEM_cnew<ARegion>("header for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* channel list region */
region = MEM_callocN(sizeof(ARegion), "channel region for action");
region = MEM_cnew<ARegion>("channel region for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_CHANNELS;
region->alignment = RGN_ALIGN_LEFT;
@@ -89,14 +89,14 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
/* ui buttons */
region = MEM_callocN(sizeof(ARegion), "buttons region for action");
region = MEM_cnew<ARegion>("buttons region for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_RIGHT;
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for action");
region = MEM_cnew<ARegion>("main region for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
@@ -127,21 +127,21 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
}
/* not spacelink itself */
static void action_free(SpaceLink *UNUSED(sl))
static void action_free(SpaceLink * /*sl*/)
{
// SpaceAction *saction = (SpaceAction *) sl;
}
/* spacetype; init callback */
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
static void action_init(wmWindowManager * /*wm*/, ScrArea *area)
{
SpaceAction *saction = area->spacedata.first;
SpaceAction *saction = static_cast<SpaceAction *>(area->spacedata.first);
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
}
static SpaceLink *action_duplicate(SpaceLink *sl)
{
SpaceAction *sactionn = MEM_dupallocN(sl);
SpaceAction *sactionn = static_cast<SpaceAction *>(MEM_dupallocN(sl));
memset(&sactionn->runtime, 0x0, sizeof(sactionn->runtime));
@@ -192,7 +192,7 @@ static void action_main_region_draw(const bContext *C, ARegion *region)
/* Draw the manually set intended playback frame range highlight in the Action editor. */
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && saction->action) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
ANIM_draw_action_framerange(adt, saction->action, v2d, -FLT_MAX, FLT_MAX);
}
@@ -246,7 +246,7 @@ static void action_main_region_draw_overlay(const bContext *C, ARegion *region)
ED_time_scrub_draw_current_frame(region, scene, saction->flag & SACTION_DRAWTIME);
/* scrollers */
UI_view2d_scrollers_draw(v2d, NULL);
UI_view2d_scrollers_draw(v2d, nullptr);
}
/* add handlers, stuff you only do once or on area/region changes */
@@ -293,7 +293,7 @@ static void action_channel_region_draw(const bContext *C, ARegion *region)
}
/* add handlers, stuff you only do once or on area/region changes */
static void action_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void action_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
@@ -360,7 +360,7 @@ static void action_channel_region_listener(const wmRegionListenerParams *params)
static void saction_channel_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
wmMsgBus *mbus = params->message_bus;
bScreen *screen = params->screen;
ScrArea *area = params->area;
ARegion *region = params->region;
@@ -368,11 +368,10 @@ static void saction_channel_region_message_subscribe(const wmRegionMessageSubscr
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
/* All dopesheet filter settings, etc. affect the drawing of this editor,
* also same applies for all animation-related datatypes that may appear here,
@@ -477,7 +476,7 @@ static void action_main_region_listener(const wmRegionListenerParams *params)
static void saction_main_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
wmMsgBus *mbus = params->message_bus;
Scene *scene = params->scene;
bScreen *screen = params->screen;
ScrArea *area = params->area;
@@ -486,11 +485,10 @@ static void saction_main_region_message_subscribe(const wmRegionMessageSubscribe
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
/* Timeline depends on scene properties. */
{
@@ -578,7 +576,7 @@ static void action_listener(const wmSpaceTypeListenerParams *params)
case ND_FRAME_RANGE:
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
Scene *scene = wmn->reference;
Scene *scene = static_cast<Scene *>(wmn->reference);
region->v2d.tot.xmin = (float)(scene->r.sfra - 4);
region->v2d.tot.xmax = (float)(scene->r.efra + 4);
break;
@@ -801,7 +799,7 @@ static void action_refresh(const bContext *C, ScrArea *area)
* or else they don't update #28962.
*/
ED_area_tag_redraw(area);
for (region = area->regionbase.first; region; region = region->next) {
for (region = static_cast<ARegion *>(area->regionbase.first); region; region = region->next) {
ED_region_tag_redraw(region);
}
}
@@ -810,9 +808,7 @@ static void action_refresh(const bContext *C, ScrArea *area)
/* XXX re-sizing y-extents of tot should go here? */
}
static void action_id_remap(ScrArea *UNUSED(area),
SpaceLink *slink,
const struct IDRemapper *mappings)
static void action_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings)
{
SpaceAction *sact = (SpaceAction *)slink;
@@ -828,13 +824,13 @@ static void action_id_remap(ScrArea *UNUSED(area),
*/
static int action_space_subtype_get(ScrArea *area)
{
SpaceAction *sact = area->spacedata.first;
SpaceAction *sact = static_cast<SpaceAction *>(area->spacedata.first);
return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : SACTCONT_DOPESHEET;
}
static void action_space_subtype_set(ScrArea *area, int value)
{
SpaceAction *sact = area->spacedata.first;
SpaceAction *sact = static_cast<SpaceAction *>(area->spacedata.first);
if (value == SACTCONT_TIMELINE) {
if (sact->mode != SACTCONT_TIMELINE) {
sact->mode_prev = sact->mode;
@@ -846,14 +842,14 @@ static void action_space_subtype_set(ScrArea *area, int value)
}
}
static void action_space_subtype_item_extend(bContext *UNUSED(C),
static void action_space_subtype_item_extend(bContext * /*C*/,
EnumPropertyItem **item,
int *totitem)
{
RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items);
}
static void action_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
static void action_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
{
SpaceAction *saction = (SpaceAction *)sl;
memset(&saction->runtime, 0x0, sizeof(saction->runtime));
@@ -877,7 +873,7 @@ static void action_blend_write(BlendWriter *writer, SpaceLink *sl)
BLO_write_struct(writer, SpaceAction, sl);
}
static void action_main_region_view2d_changed(const bContext *UNUSED(C), ARegion *region)
static void action_main_region_view2d_changed(const bContext * /*C*/, ARegion *region)
{
/* V2D_KEEPTOT_STRICT cannot be used to clamp scrolling
* because it also clamps the x-axis to 0. */
@@ -886,7 +882,7 @@ static void action_main_region_view2d_changed(const bContext *UNUSED(C), ARegion
void ED_spacetype_action(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action");
SpaceType *st = MEM_cnew<SpaceType>("spacetype action");
ARegionType *art;
st->spaceid = SPACE_ACTION;
@@ -909,7 +905,7 @@ void ED_spacetype_action(void)
st->blend_write = action_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_WINDOW;
art->init = action_main_region_init;
art->draw = action_main_region_draw;
@@ -922,7 +918,7 @@ void ED_spacetype_action(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@@ -934,7 +930,7 @@ void ED_spacetype_action(void)
BLI_addhead(&st->regiontypes, art);
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
@@ -947,7 +943,7 @@ void ED_spacetype_action(void)
BLI_addhead(&st->regiontypes, art);
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI;