Cleanup: Move space nla files to C++

See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/108998
This commit is contained in:
Guillermo Venegas
2023-06-15 14:10:43 +02:00
committed by Hans Goudey
parent 973562ec0c
commit dd648b5942
9 changed files with 617 additions and 698 deletions

View File

@@ -25,15 +25,15 @@ set(INC_SYS
)
set(SRC
nla_buttons.c
nla_channels.c
nla_draw.c
nla_edit.c
nla_ops.c
nla_select.c
space_nla.c
nla_buttons.cc
nla_channels.cc
nla_draw.cc
nla_edit.cc
nla_ops.cc
nla_select.cc
space_nla.cc
nla_intern.h
nla_intern.hh
)
set(LIB

View File

@@ -6,10 +6,10 @@
* \ingroup spnla
*/
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "DNA_anim_types.h"
@@ -38,13 +38,13 @@
#include "UI_interface.h"
#include "UI_resources.h"
#include "nla_intern.h" /* own include */
#include "nla_intern.hh" /* own include */
/* ******************* nla editor space & buttons ************** */
/* -------------- */
static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(event))
static void do_nla_region_buttons(bContext *C, void * /*arg*/, int /*event*/)
{
// Scene *scene = CTX_data_scene(C);
#if 0
@@ -53,8 +53,8 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(eve
}
#endif
/* default for now */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM, nullptr);
}
bool nla_panel_context(const bContext *C,
@@ -63,10 +63,8 @@ bool nla_panel_context(const bContext *C,
PointerRNA *strip_ptr)
{
bAnimContext ac;
bAnimListElem *ale = NULL;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
short found = 0; /* not bool, since we need to indicate "found but not ideal" status */
int filter;
/* For now, only draw if we could init the anim-context info
* (necessary for all animation-related tools)
@@ -79,15 +77,16 @@ bool nla_panel_context(const bContext *C,
* - we need the channels flag to get the active AnimData block when there are no NLA Tracks
*/
/* XXX: double-check active! */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ACTIVE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_ACTIVE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
switch (ale->type) {
case ANIMTYPE_NLATRACK: /* NLA Track - The primary data type which should get caught */
{
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
/* found it, now set the pointers */
@@ -136,14 +135,14 @@ bool nla_panel_context(const bContext *C,
if (ale->adt && adt_ptr) {
ID *id;
if ((ale->data == NULL) || (ale->type == ANIMTYPE_OBJECT)) {
if ((ale->data == nullptr) || (ale->type == ANIMTYPE_OBJECT)) {
/* ale->data is not an ID block! */
id = ale->id;
}
else {
/* ale->data is always the proper ID block we need,
* but ale->id may not be (i.e. for textures) */
id = (ID *)ale->data;
id = static_cast<ID *>(ale->data);
}
/* AnimData pointer */
@@ -178,86 +177,80 @@ bool nla_panel_context(const bContext *C,
bool ANIM_nla_context_track_ptr(const bContext *C, PointerRNA *r_ptr)
{
return nla_panel_context(C, NULL, r_ptr, NULL);
return nla_panel_context(C, nullptr, r_ptr, nullptr);
}
bool ANIM_nla_context_strip_ptr(const bContext *C, PointerRNA *r_ptr)
{
return nla_panel_context(C, NULL, NULL, r_ptr);
return nla_panel_context(C, nullptr, nullptr, r_ptr);
}
NlaTrack *ANIM_nla_context_track(const bContext *C)
{
PointerRNA track_ptr;
if (!ANIM_nla_context_track_ptr(C, &track_ptr)) {
return NULL;
return nullptr;
}
NlaTrack *track = track_ptr.data;
return track;
return static_cast<NlaTrack *>(track_ptr.data);
}
NlaStrip *ANIM_nla_context_strip(const bContext *C)
{
PointerRNA strip_ptr;
if (!ANIM_nla_context_strip_ptr(C, &strip_ptr)) {
return NULL;
return nullptr;
}
NlaStrip *strip = strip_ptr.data;
return strip;
return static_cast<NlaStrip *>(strip_ptr.data);
}
#if 0
static bool nla_panel_poll(const bContext *C, PanelType *pt)
{
return nla_panel_context(C, NULL, NULL);
return nla_panel_context(C, nullptr, nullptr);
}
#endif
static bool nla_animdata_panel_poll(const bContext *C, PanelType *UNUSED(pt))
static bool nla_animdata_panel_poll(const bContext *C, PanelType * /*pt*/)
{
PointerRNA ptr;
PointerRNA strip_ptr;
return (nla_panel_context(C, &ptr, NULL, &strip_ptr) && (ptr.data != NULL) &&
return (nla_panel_context(C, &ptr, nullptr, &strip_ptr) && (ptr.data != nullptr) &&
(ptr.owner_id != strip_ptr.owner_id));
}
static bool nla_strip_panel_poll(const bContext *C, PanelType *UNUSED(pt))
static bool nla_strip_panel_poll(const bContext *C, PanelType * /*pt*/)
{
PointerRNA ptr;
return (nla_panel_context(C, NULL, NULL, &ptr) && (ptr.data != NULL));
return (nla_panel_context(C, nullptr, nullptr, &ptr) && (ptr.data != nullptr));
}
static bool nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt))
static bool nla_strip_actclip_panel_poll(const bContext *C, PanelType * /*pt*/)
{
PointerRNA ptr;
NlaStrip *strip;
if (!nla_panel_context(C, NULL, NULL, &ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &ptr)) {
return 0;
}
if (ptr.data == NULL) {
if (ptr.data == nullptr) {
return 0;
}
strip = ptr.data;
return (strip->type == NLASTRIP_TYPE_CLIP);
NlaStrip *strip = static_cast<NlaStrip *>(ptr.data);
return eNlaStrip_Type(strip->type) == NLASTRIP_TYPE_CLIP;
}
static bool nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
static bool nla_strip_eval_panel_poll(const bContext *C, PanelType * /*pt*/)
{
PointerRNA ptr;
NlaStrip *strip;
if (!nla_panel_context(C, NULL, NULL, &ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &ptr)) {
return 0;
}
if (ptr.data == NULL) {
if (ptr.data == nullptr) {
return 0;
}
strip = ptr.data;
NlaStrip *strip = static_cast<NlaStrip *>(ptr.data);
if (strip->type == NLASTRIP_TYPE_SOUND) {
return 0;
@@ -279,7 +272,7 @@ static void nla_panel_animdata(const bContext *C, Panel *panel)
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, &adt_ptr, NULL, &strip_ptr)) {
if (!nla_panel_context(C, &adt_ptr, nullptr, &strip_ptr)) {
return;
}
@@ -290,7 +283,7 @@ static void nla_panel_animdata(const bContext *C, Panel *panel)
/* adt = adt_ptr.data; */
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
@@ -320,15 +313,15 @@ static void nla_panel_animdata(const bContext *C, Panel *panel)
/* action */
row = uiLayoutRow(layout, true);
uiTemplateID(row,
(bContext *)C,
C,
&adt_ptr,
"action",
"ACTION_OT_new",
NULL,
nullptr,
"NLA_OT_action_unlink",
UI_TEMPLATE_ID_FILTER_ALL,
false,
NULL);
nullptr);
/* extrapolation */
row = uiLayoutRow(layout, true);
@@ -351,12 +344,12 @@ static void nla_panel_stripname(const bContext *C, Panel *panel)
uiLayout *row;
uiBlock *block;
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
/* Strip Properties ------------------------------------- */
/* strip type */
@@ -390,12 +383,12 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
uiBlock *block;
short showEvalProps = 1;
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
/* Strip Properties ------------------------------------- */
/* strip type */
@@ -419,8 +412,8 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
if (showEvalProps) {
/* extrapolation */
column = uiLayoutColumn(layout, false);
uiItemR(column, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
uiItemR(column, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
uiItemR(column, &strip_ptr, "extrapolation", 0, nullptr, ICON_NONE);
uiItemR(column, &strip_ptr, "blend_type", 0, nullptr, ICON_NONE);
/* Blend in/out + auto-blending:
* - blend in/out can only be set when auto-blending is off.
@@ -435,7 +428,7 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
row = uiLayoutRow(column, true);
uiLayoutSetActive(row, RNA_boolean_get(&strip_ptr, "use_animated_influence") == false);
uiItemR(row, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); /* XXX as toggle? */
uiItemR(row, &strip_ptr, "use_auto_blend", 0, nullptr, ICON_NONE); /* XXX as toggle? */
/* settings */
column = uiLayoutColumnWithHeading(layout, true, IFACE_("Playback"));
@@ -443,9 +436,9 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
uiLayoutSetActive(row,
!(RNA_boolean_get(&strip_ptr, "use_animated_influence") ||
RNA_boolean_get(&strip_ptr, "use_animated_time")));
uiItemR(row, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
uiItemR(row, &strip_ptr, "use_reverse", 0, nullptr, ICON_NONE);
uiItemR(column, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE);
uiItemR(column, &strip_ptr, "use_animated_time_cyclic", 0, nullptr, ICON_NONE);
}
}
@@ -458,19 +451,19 @@ static void nla_panel_actclip(const bContext *C, Panel *panel)
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
/* Strip Properties ------------------------------------- */
/* action pointer */
row = uiLayoutRow(layout, true);
uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION);
uiItemR(row, &strip_ptr, "action", 0, nullptr, ICON_ACTION);
/* action extents */
column = uiLayoutColumn(layout, true);
@@ -485,7 +478,7 @@ static void nla_panel_actclip(const bContext *C, Panel *panel)
column = uiLayoutColumn(layout, true);
uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == false);
uiItemR(column, &strip_ptr, "scale", 0, IFACE_("Playback Scale"), ICON_NONE);
uiItemR(column, &strip_ptr, "repeat", 0, NULL, ICON_NONE);
uiItemR(column, &strip_ptr, "repeat", 0, nullptr, ICON_NONE);
}
/* evaluation settings for active NLA-Strip */
@@ -497,12 +490,12 @@ static void nla_panel_animated_influence_header(const bContext *C, Panel *panel)
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
col = uiLayoutColumn(layout, true);
uiItemR(col, &strip_ptr, "use_animated_influence", 0, "", ICON_NONE);
@@ -516,16 +509,16 @@ static void nla_panel_evaluation(const bContext *C, Panel *panel)
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, RNA_boolean_get(&strip_ptr, "use_animated_influence"));
uiItemR(layout, &strip_ptr, "influence", 0, NULL, ICON_NONE);
uiItemR(layout, &strip_ptr, "influence", 0, nullptr, ICON_NONE);
}
static void nla_panel_animated_strip_time_header(const bContext *C, Panel *panel)
@@ -536,12 +529,12 @@ static void nla_panel_animated_strip_time_header(const bContext *C, Panel *panel
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
col = uiLayoutColumn(layout, true);
uiItemR(col, &strip_ptr, "use_animated_time", 0, "", ICON_NONE);
@@ -554,24 +547,24 @@ static void nla_panel_animated_strip_time(const bContext *C, Panel *panel)
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, RNA_boolean_get(&strip_ptr, "use_animated_time"));
uiItemR(layout, &strip_ptr, "strip_time", 0, NULL, ICON_NONE);
uiItemR(layout, &strip_ptr, "strip_time", 0, nullptr, ICON_NONE);
}
#define NLA_FMODIFIER_PANEL_PREFIX "NLA"
static void nla_fmodifier_panel_id(void *fcm_link, char *r_name)
{
FModifier *fcm = (FModifier *)fcm_link;
eFModifier_Types type = fcm->type;
FModifier *fcm = static_cast<FModifier *>(fcm_link);
eFModifier_Types type = eFModifier_Types(fcm->type);
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
BLI_snprintf(r_name, BKE_ST_MAXNAME, "%s_PT_%s", NLA_FMODIFIER_PANEL_PREFIX, fmi->name);
}
@@ -580,18 +573,17 @@ static void nla_fmodifier_panel_id(void *fcm_link, char *r_name)
static void nla_panel_modifiers(const bContext *C, Panel *panel)
{
PointerRNA strip_ptr;
NlaStrip *strip;
uiLayout *row;
uiBlock *block;
/* check context and also validity of pointer */
if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
if (!nla_panel_context(C, nullptr, nullptr, &strip_ptr)) {
return;
}
strip = strip_ptr.data;
NlaStrip *strip = static_cast<NlaStrip *>(strip_ptr.data);
block = uiLayoutGetBlock(panel->layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
/* 'add modifier' button at top of panel */
{
@@ -617,7 +609,7 @@ void nla_buttons_register(ARegionType *art)
{
PanelType *pt;
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel animdata");
pt = MEM_cnew<PanelType>("spacetype nla panel animdata");
strcpy(pt->idname, "NLA_PT_animdata");
strcpy(pt->label, N_("Animation Data"));
strcpy(pt->category, "Edited Action");
@@ -627,7 +619,7 @@ void nla_buttons_register(ARegionType *art)
pt->poll = nla_animdata_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties");
pt = MEM_cnew<PanelType>("spacetype nla panel properties");
strcpy(pt->idname, "NLA_PT_stripname");
strcpy(pt->label, N_("Active Strip Name"));
strcpy(pt->category, "Strip");
@@ -637,7 +629,7 @@ void nla_buttons_register(ARegionType *art)
pt->poll = nla_strip_panel_poll;
BLI_addtail(&art->paneltypes, pt);
PanelType *pt_properties = pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties");
PanelType *pt_properties = pt = MEM_cnew<PanelType>("spacetype nla panel properties");
strcpy(pt->idname, "NLA_PT_properties");
strcpy(pt->label, N_("Active Strip"));
strcpy(pt->category, "Strip");
@@ -646,7 +638,7 @@ void nla_buttons_register(ARegionType *art)
pt->poll = nla_strip_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties");
pt = MEM_cnew<PanelType>("spacetype nla panel properties");
strcpy(pt->idname, "NLA_PT_actionclip");
strcpy(pt->label, N_("Action Clip"));
strcpy(pt->category, "Strip");
@@ -656,7 +648,7 @@ void nla_buttons_register(ARegionType *art)
pt->poll = nla_strip_actclip_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel evaluation");
pt = MEM_cnew<PanelType>("spacetype nla panel evaluation");
strcpy(pt->idname, "NLA_PT_evaluation");
strcpy(pt->parent_id, "NLA_PT_properties");
strcpy(pt->label, N_("Animated Influence"));
@@ -670,7 +662,7 @@ void nla_buttons_register(ARegionType *art)
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel animated strip time");
pt = MEM_cnew<PanelType>("spacetype nla panel animated strip time");
strcpy(pt->idname, "NLA_PT_animated_strip_time");
strcpy(pt->parent_id, "NLA_PT_properties");
strcpy(pt->label, N_("Animated Strip Time"));
@@ -684,7 +676,7 @@ void nla_buttons_register(ARegionType *art)
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers");
pt = MEM_cnew<PanelType>("spacetype nla panel modifiers");
strcpy(pt->idname, "NLA_PT_modifiers");
strcpy(pt->label, N_("Modifiers"));
strcpy(pt->category, "Modifiers");

View File

@@ -6,10 +6,10 @@
* \ingroup spnla
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
@@ -45,7 +45,7 @@
#include "UI_view2d.h"
#include "nla_intern.h" /* own include */
#include "nla_intern.hh" /* own include */
/* *********************************************** */
/* Operators for NLA channels-list which need to be different
@@ -62,21 +62,19 @@
static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index, short selectmode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
int notifierFlags = 0;
/* get the channel that was clicked on */
/* filter channels */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* get channel from index */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
bAnimListElem *ale = static_cast<bAnimListElem *>(BLI_findlink(&anim_data, channel_index));
if (ale == nullptr) {
/* channel not found */
if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n",
@@ -91,7 +89,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index,
/* WARNING: must keep this in sync with the equivalent function in anim_channels_edit.c */
switch (ale->type) {
case ANIMTYPE_SCENE: {
Scene *sce = (Scene *)ale->data;
Scene *sce = static_cast<Scene *>(ale->data);
AnimData *adt = sce->adt;
/* set selection status */
@@ -114,7 +112,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index,
}
case ANIMTYPE_OBJECT: {
ViewLayer *view_layer = ac->view_layer;
Base *base = (Base *)ale->data;
Base *base = static_cast<Base *>(ale->data);
Object *ob = base->object;
AnimData *adt = ob->adt;
@@ -204,7 +202,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index,
break;
}
case ANIMTYPE_NLATRACK: {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
if (nlaedit_is_tweakmode_on(ac) == 0) {
/* set selection */
@@ -221,7 +219,8 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index,
/* if NLA-Track is selected now,
* make NLA-Track the 'active' one in the visible list */
if (nlt->flag & NLATRACK_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
ANIM_set_active_channel(
ac, ac->data, eAnimCont_Types(ac->datatype), filter, nlt, ANIMTYPE_NLATRACK);
}
/* notifier flags - channel was selected */
@@ -290,7 +289,6 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index,
static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
SpaceNla *snla;
ARegion *region;
View2D *v2d;
int channel_index;
@@ -304,7 +302,7 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
}
/* get useful pointers from animation context data */
snla = (SpaceNla *)ac.sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac.sl);
region = ac.region;
v2d = &region->v2d;
@@ -324,14 +322,14 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
NLACHANNEL_FIRST_TOP(&ac),
x,
y,
NULL,
nullptr,
&channel_index);
/* handle mouse-click in the relevant channel then */
notifierFlags = mouse_nla_channels(C, &ac, channel_index, selectmode);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL);
WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, nullptr);
return OPERATOR_FINISHED;
}
@@ -365,8 +363,8 @@ void NLA_OT_channels_click(wmOperatorType *ot)
static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ID *id = NULL;
AnimData *adt = NULL;
ID *id = nullptr;
AnimData *adt = nullptr;
int channel_index = RNA_int_get(op->ptr, "channel_index");
/* get editor data */
@@ -376,10 +374,10 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
/* get anim-channel to use (or more specifically, the animdata block behind it) */
if (channel_index == -1) {
PointerRNA adt_ptr = {NULL};
PointerRNA adt_ptr = {nullptr};
/* active animdata block */
if (nla_panel_context(C, &adt_ptr, NULL, NULL) == 0 || (adt_ptr.data == NULL)) {
if (nla_panel_context(C, &adt_ptr, nullptr, nullptr) == 0 || (adt_ptr.data == nullptr)) {
BKE_report(op->reports,
RPT_ERROR,
"No active AnimData block to use "
@@ -389,22 +387,20 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
}
id = adt_ptr.owner_id;
adt = adt_ptr.data;
adt = static_cast<AnimData *>(adt_ptr.data);
}
else {
/* indexed channel */
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* filter channels */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* get channel from index */
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
bAnimListElem *ale = static_cast<bAnimListElem *>(BLI_findlink(&anim_data, channel_index));
if (ale == nullptr) {
BKE_reportf(op->reports, RPT_ERROR, "No animation channel found at index %d", channel_index);
ANIM_animdata_freelist(&anim_data);
return OPERATOR_CANCELLED;
@@ -427,7 +423,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
}
/* double-check that we are free to push down here... */
if (adt == NULL) {
if (adt == nullptr) {
BKE_report(op->reports, RPT_WARNING, "Internal Error - AnimData block is not valid");
return OPERATOR_CANCELLED;
}
@@ -437,7 +433,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
"Cannot push down actions while tweaking a strip's action, exit tweak mode first");
return OPERATOR_CANCELLED;
}
if (adt->action == NULL) {
if (adt->action == nullptr) {
BKE_report(op->reports, RPT_WARNING, "No active action to push down");
return OPERATOR_CANCELLED;
}
@@ -445,7 +441,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
/* 'push-down' action - only usable when not in Tweak-mode. */
BKE_nla_action_pushdown(adt, ID_IS_OVERRIDE_LIBRARY(id));
struct Main *bmain = CTX_data_main(C);
Main *bmain = CTX_data_main(C);
DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION);
/* The action needs updating too, as FCurve modifiers are to be reevaluated. They won't extend
@@ -453,7 +449,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
DEG_id_tag_update_ex(bmain, &adt->action->id, ID_RECALC_ANIMATION);
/* set notifier that things have 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;
}
@@ -490,7 +486,7 @@ static bool nla_action_unlink_poll(bContext *C)
{
if (ED_operator_nla_active(C)) {
PointerRNA adt_ptr;
return (nla_panel_context(C, &adt_ptr, NULL, NULL) && (adt_ptr.data != NULL));
return (nla_panel_context(C, &adt_ptr, nullptr, nullptr) && (adt_ptr.data != nullptr));
}
/* something failed... */
@@ -500,16 +496,15 @@ static bool nla_action_unlink_poll(bContext *C)
static int nla_action_unlink_exec(bContext *C, wmOperator *op)
{
PointerRNA adt_ptr;
AnimData *adt;
/* check context and also validity of pointer */
if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) {
if (!nla_panel_context(C, &adt_ptr, nullptr, nullptr)) {
return OPERATOR_CANCELLED;
}
/* get animdata */
adt = adt_ptr.data;
if (adt == NULL) {
AnimData *adt = static_cast<AnimData *>(adt_ptr.data);
if (adt == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -558,23 +553,21 @@ void NLA_OT_action_unlink(wmOperatorType *ot)
bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
AnimData *lastAdt = NULL;
ListBase anim_data = {nullptr, nullptr};
AnimData *lastAdt = nullptr;
bool added = false;
/* get a list of the (selected) NLA Tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* add tracks... */
for (ale = anim_data.first; ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
NlaTrack *new_track = NULL;
NlaTrack *new_track = nullptr;
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
@@ -588,7 +581,7 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel)
ale->update = ANIM_UPDATE_DEPS;
added = true;
}
else if ((lastAdt == NULL) || (adt != lastAdt)) {
else if ((lastAdt == nullptr) || (adt != lastAdt)) {
/* add one track to the top of the owning AnimData's stack,
* then don't add anymore to this stack */
new_track = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride);
@@ -609,18 +602,18 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel)
bool nlaedit_add_tracks_empty(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool added = false;
/* get a list of the selected AnimData blocks in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA |
ANIMFILTER_SEL | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_ANIMDATA | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* check if selected AnimData blocks are empty, and add tracks if so... */
for (ale = anim_data.first; ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
AnimData *adt = ale->adt;
NlaTrack *new_track;
@@ -666,7 +659,7 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(CTX_data_main(C));
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -705,13 +698,11 @@ void NLA_OT_tracks_add(wmOperatorType *ot)
/* ******************** Delete Tracks Operator ***************************** */
/* Delete selected NLA Tracks */
static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_delete_tracks_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -719,14 +710,14 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* delete tracks */
for (ale = anim_data.first; ale; ale = ale->next) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
@@ -754,7 +745,7 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
DEG_relations_tag_update(ac.bmain);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -786,10 +777,9 @@ void NLA_OT_tracks_delete(wmOperatorType *ot)
* common use case, we now have a nice shortcut again.
*/
static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_objects_add_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
SpaceNla *snla;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -797,7 +787,7 @@ static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
}
/* ensure that filters are set so that the effect will be immediately visible */
snla = (SpaceNla *)ac.sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac.sl);
if (snla && snla->ads) {
snla->ads->filterflag &= ~ADS_FILTER_NLA_NOACT;
}
@@ -810,7 +800,7 @@ static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
/* done */
return OPERATOR_FINISHED;

View File

@@ -6,11 +6,11 @@
* \ingroup spnla
*/
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "DNA_anim_types.h"
#include "DNA_node_types.h"
@@ -43,7 +43,7 @@
#include "UI_resources.h"
#include "UI_view2d.h"
#include "nla_intern.h" /* own include */
#include "nla_intern.hh" /* own include */
#include "nla_private.h"
/* *********************************************** */
@@ -79,12 +79,12 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
static void nla_action_draw_keyframes(
View2D *v2d, AnimData *adt, bAction *act, float y, float ymin, float ymax)
{
if (act == NULL) {
if (act == nullptr) {
return;
}
/* get a list of the keyframes with NLA-scaling applied */
struct AnimKeylist *keylist = ED_keylist_create();
AnimKeylist *keylist = ED_keylist_create();
action_to_keylist(adt, act, keylist, 0);
if (ED_keylist_is_empty(keylist)) {
@@ -173,7 +173,7 @@ static void nla_actionclip_draw_markers(
{
const bAction *act = strip->act;
if (ELEM(NULL, act, act->markers.first)) {
if (ELEM(nullptr, act, act->markers.first)) {
return;
}
@@ -323,7 +323,6 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uin
/* influence -------------------------- */
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
FCurve *fcu = BKE_fcurve_find(&strip->fcurves, "influence", 0);
float cfra;
/* plot the curve (over the strip's main region) */
if (fcu) {
@@ -332,7 +331,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uin
/* sample at 1 frame intervals, and draw
* - min y-val is yminc, max is y-maxc, so clamp in those regions
*/
for (cfra = strip->start; cfra <= strip->end; cfra += 1.0f) {
for (float cfra = strip->start; cfra <= strip->end; cfra += 1.0f) {
float y = evaluate_fcurve(fcu, cfra); /* assume this to be in 0-1 range */
CLAMP(y, 0.0f, 1.0f);
immVertex2f(pos, cfra, ((y * yheight) + yminc));
@@ -411,7 +410,7 @@ static uint nla_draw_use_dashed_outlines(const float color[4], bool muted)
*/
static bool is_nlastrip_enabled(AnimData *adt, NlaTrack *nlt, NlaStrip *strip)
{
/** This shouldn't happen. If passed NULL, then just treat strip as enabled. */
/** This shouldn't happen. If passed nullptr, then just treat strip as enabled. */
BLI_assert(adt);
if (!adt) {
return true;
@@ -461,7 +460,7 @@ static void nla_draw_strip(SpaceNla *snla,
/* only need to draw here if there's no strip before since
* it only applies in such a situation
*/
if (strip->prev == NULL) {
if (strip->prev == nullptr) {
/* set the drawing color to the color of the strip, but with very faint alpha */
immUniformColor3fvAlpha(color, 0.15f);
@@ -473,7 +472,7 @@ static void nla_draw_strip(SpaceNla *snla,
/* this only draws after the strip */
case NLASTRIP_EXTEND_HOLD_FORWARD:
/* only need to try and draw if the next strip doesn't occur immediately after */
if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) {
if ((strip->next == nullptr) || (IS_EQF(strip->next->start, strip->end) == 0)) {
/* set the drawing color to the color of the strip, but this time less faint */
immUniformColor3fvAlpha(color, 0.3f);
@@ -495,16 +494,12 @@ static void nla_draw_strip(SpaceNla *snla,
/* strip is in normal track */
UI_draw_roundbox_corner_set(UI_CNR_ALL); /* all corners rounded */
UI_draw_roundbox_4fv(
&(const rctf){
.xmin = strip->start,
.xmax = strip->end,
.ymin = yminc,
.ymax = ymaxc,
},
true,
0.0f,
color);
rctf rect;
rect.xmin = strip->start;
rect.xmax = strip->end;
rect.ymin = yminc;
rect.ymax = ymaxc;
UI_draw_roundbox_4fv(&rect, true, 0.0f, color);
/* restore current vertex format & program (roundbox trashes it) */
shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -560,16 +555,12 @@ static void nla_draw_strip(SpaceNla *snla,
}
else {
/* non-muted - draw solid, rounded outline */
UI_draw_roundbox_4fv(
&(const rctf){
.xmin = strip->start,
.xmax = strip->end,
.ymin = yminc,
.ymax = ymaxc,
},
false,
0.0f,
color);
rctf rect;
rect.xmin = strip->start;
rect.xmax = strip->end;
rect.ymin = yminc;
rect.ymax = ymaxc;
UI_draw_roundbox_4fv(&rect, false, 0.0f, color);
/* restore current vertex format & program (roundbox trashes it) */
shdr_pos = nla_draw_use_dashed_outlines(color, muted);
@@ -672,12 +663,11 @@ static void nla_draw_strip_text(AnimData *adt,
* - padding of 2 'units' on either side
*/
/* TODO: make this centered? */
rctf rect = {
.xmin = xminc,
.ymin = yminc,
.xmax = xmaxc,
.ymax = ymaxc,
};
rctf rect;
rect.xmin = xminc;
rect.ymin = yminc;
rect.xmax = xmaxc;
rect.ymax = ymaxc;
/* add this string to the cache of texts to draw */
UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
@@ -688,7 +678,7 @@ static void nla_draw_strip_text(AnimData *adt,
* for now, only used when transforming strips.
*/
static void nla_draw_strip_frames_text(
NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc)
NlaTrack * /*nlt*/, NlaStrip *strip, View2D *v2d, float /*yminc*/, float ymaxc)
{
const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
const uchar col[4] = {220, 220, 220, 255}; /* light gray */
@@ -720,12 +710,12 @@ static void nla_draw_strip_frames_text(
static ListBase get_visible_nla_strips(NlaTrack *nlt, View2D *v2d)
{
if (BLI_listbase_is_empty(&nlt->strips)) {
ListBase empty = {NULL, NULL};
ListBase empty = {nullptr, nullptr};
return empty;
}
NlaStrip *first = NULL;
NlaStrip *last = NULL;
NlaStrip *first = nullptr;
NlaStrip *last = nullptr;
/* Find the first strip that is within the bounds of the view. */
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
@@ -735,7 +725,7 @@ static ListBase get_visible_nla_strips(NlaTrack *nlt, View2D *v2d)
}
}
const bool has_strips_within_bounds = first != NULL;
const bool has_strips_within_bounds = first != nullptr;
if (has_strips_within_bounds) {
/* Find the last visible strip. */
@@ -760,8 +750,8 @@ static ListBase get_visible_nla_strips(NlaTrack *nlt, View2D *v2d)
* if the view is adjacent to a strip that should have its extendmode
* rendered.
*/
NlaStrip *first_strip = nlt->strips.first;
NlaStrip *last_strip = nlt->strips.last;
NlaStrip *first_strip = static_cast<NlaStrip *>(nlt->strips.first);
NlaStrip *last_strip = static_cast<NlaStrip *>(nlt->strips.last);
if (first_strip && v2d->cur.xmax < first_strip->start &&
first_strip->extendmode == NLASTRIP_EXTEND_HOLD)
{
@@ -804,10 +794,11 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
const float text_margin_x = (8 * UI_SCALE_FAC) * pixelx;
/* build list of channels to draw */
ListBase anim_data = {NULL, NULL};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
size_t items = ANIM_animdata_filter(
ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
@@ -821,7 +812,9 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
/* Loop through channels, and set up drawing depending on their type. */
float ymax = NLACHANNEL_FIRST_TOP(ac);
for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) {
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla))
{
float ymin = ymax - NLACHANNEL_HEIGHT(snla);
float ycenter = (ymax + ymin) / 2.0f;
@@ -832,7 +825,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
switch (ale->type) {
case ANIMTYPE_NLATRACK: {
AnimData *adt = ale->adt;
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
ListBase visible_nla_strips = get_visible_nla_strips(nlt, v2d);
/* Draw each visible strip in the track. */
@@ -862,7 +855,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
/* Draw the manually set intended playback frame range highlight. */
if (ale->data) {
ANIM_draw_action_framerange(adt, ale->data, v2d, ymin, ymax);
ANIM_draw_action_framerange(adt, static_cast<bAction *>(ale->data), v2d, ymin, ymax);
}
uint pos = GPU_vertformat_attr_add(
@@ -877,7 +870,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
/* get colors for drawing */
float color[4];
nla_action_get_color(adt, ale->data, color);
nla_action_get_color(adt, static_cast<bAction *>(ale->data), color);
immUniformColor4fv(color);
/* draw slightly shifted up for greater separation from standard channels,
@@ -895,7 +888,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
case NLASTRIP_EXTEND_HOLD_FORWARD: {
float r_start;
float r_end;
BKE_action_get_frame_range(ale->data, &r_start, &r_end);
BKE_action_get_frame_range(static_cast<bAction *>(ale->data), &r_start, &r_end);
immRectf(pos, r_end, ymin + NLACHANNEL_SKIP, v2d->cur.xmax, ymax - NLACHANNEL_SKIP);
break;
@@ -907,8 +900,12 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
immUnbindProgram();
/* draw keyframes in the action */
nla_action_draw_keyframes(
v2d, adt, ale->data, ycenter, ymin + NLACHANNEL_SKIP, ymax - NLACHANNEL_SKIP);
nla_action_draw_keyframes(v2d,
adt,
static_cast<bAction *>(ale->data),
ycenter,
ymin + NLACHANNEL_SKIP,
ymax - NLACHANNEL_SKIP);
GPU_blend(GPU_BLEND_NONE);
break;
@@ -926,18 +923,16 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *region)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
SpaceNla *snla = (SpaceNla *)ac->sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac->sl);
View2D *v2d = &region->v2d;
size_t items;
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
@@ -950,15 +945,16 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *region)
/* 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);
/* draw channels */
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
float ymax = NLACHANNEL_FIRST_TOP(ac);
for (ale = anim_data.first; ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) {
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++)
{
float ymin = ymax - NLACHANNEL_HEIGHT(snla);
/* check if visible */
@@ -978,8 +974,9 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *region)
GPU_blend(GPU_BLEND_ALPHA);
/* Loop through channels, and set up drawing depending on their type. */
for (ale = anim_data.first; ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) {
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++)
{
float ymin = ymax - NLACHANNEL_HEIGHT(snla);
/* check if visible */

View File

@@ -6,9 +6,9 @@
* \ingroup spnla
*/
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
@@ -50,7 +50,7 @@
#include "UI_interface.h"
#include "UI_view2d.h"
#include "nla_intern.h"
#include "nla_intern.hh"
#include "nla_private.h"
/* -------------------------------------------------------------------- */
@@ -59,17 +59,16 @@
void ED_nla_postop_refresh(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
/* get blocks to work on */
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) {
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* performing auto-blending, extend-mode validation, etc. */
BKE_nla_validate_state(ale->data);
BKE_nla_validate_state(static_cast<AnimData *>(ale->data));
ale->update |= ANIM_UPDATE_DEPS;
}
@@ -95,9 +94,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action");
const bool use_upper_stack_evaluation = RNA_boolean_get(op->ptr, "use_upper_stack_evaluation");
@@ -109,8 +106,9 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
}
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* if no blocks, popup error? */
if (BLI_listbase_is_empty(&anim_data)) {
@@ -119,8 +117,8 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
}
/* for each AnimData block with NLA-data, try setting it in tweak-mode */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
AnimData *adt = static_cast<AnimData *>(ale->data);
if (use_upper_stack_evaluation) {
adt->flag |= ADT_NLA_EVAL_UPPER_TRACKS;
@@ -155,7 +153,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
ac.scene->flag |= SCE_NLA_EDIT_ON;
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
}
else {
BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweak mode on");
@@ -208,13 +206,12 @@ void NLA_OT_tweakmode_enter(wmOperatorType *ot)
bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* if no blocks, popup error? */
if (BLI_listbase_is_empty(&anim_data)) {
@@ -223,12 +220,12 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo)
}
/* For each AnimData block with NLA-data, try exiting tweak-mode. */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
AnimData *adt = static_cast<AnimData *>(ale->data);
/* clear solo flags */
if ((do_solo) & (adt->flag & ADT_NLA_SOLO_TRACK) && (adt->flag & ADT_NLA_EDIT_ON)) {
BKE_nlatrack_solo_toggle(adt, NULL);
BKE_nlatrack_solo_toggle(adt, nullptr);
}
/* To be sure that we're doing everything right, just exit tweak-mode. */
@@ -247,7 +244,7 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo)
ac->scene->flag &= ~SCE_NLA_EDIT_ON;
/* set notifier that things have changed */
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
}
/* done */
@@ -314,15 +311,13 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot)
/* Get the min/max strip extents */
static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const bool only_sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool found_bounds = false;
/* get data to filter */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* set large values to try to override */
*min = 999999999.0f;
@@ -331,16 +326,15 @@ static void get_nlastrip_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) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* only consider selected strips? */
if ((only_sel == false) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
/* extend range if appropriate */
*min = min_ff(*min, strip->start);
*max = max_ff(*max, strip->end);
*min = std::min(*min, strip->start);
*max = std::max(*max, strip->end);
found_bounds = true;
}
@@ -354,8 +348,8 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
/* set default range if nothing happened */
if (found_bounds == false) {
if (ac->scene) {
*min = (float)ac->scene->r.sfra;
*max = (float)ac->scene->r.efra;
*min = float(ac->scene->r.sfra);
*max = float(ac->scene->r.efra);
}
else {
*min = -5;
@@ -370,7 +364,7 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const
/** \name Automatic Preview-Range Operator
* \{ */
static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_previewrange_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
Scene *scene;
@@ -381,7 +375,7 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
if (ac.scene == NULL) {
if (ac.scene == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -430,23 +424,23 @@ void NLA_OT_previewrange_set(wmOperatorType *ot)
*/
static bool nla_channels_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
SpaceNla *snla = (SpaceNla *)ac->sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac->sl);
/* 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 |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
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 = NLACHANNEL_FIRST_TOP(ac);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) {
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla))
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* must be selected... */
@@ -499,7 +493,7 @@ static int nlaedit_viewall(bContext *C, const bool only_sel)
/* view all -> the summary channel is usually the shows everything,
* and resides right at the top... */
v2d->cur.ymax = 0.0f;
v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
v2d->cur.ymin = float(-BLI_rcti_size_y(&v2d->mask));
}
else {
/* locate first selected channel (or the active one), and frame those */
@@ -511,7 +505,7 @@ static int nlaedit_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);
}
}
@@ -527,13 +521,13 @@ static int nlaedit_viewall(bContext *C, const bool only_sel)
/* ......... */
static int nlaedit_viewall_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_viewall_exec(bContext *C, wmOperator * /*op*/)
{
/* whole range */
return nlaedit_viewall(C, false);
}
static int nlaedit_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_viewsel_exec(bContext *C, wmOperator * /*op*/)
{
/* only selected */
return nlaedit_viewall(C, true);
@@ -611,9 +605,9 @@ void NLA_OT_view_frame(wmOperatorType *ot)
/* Get a list of the editable tracks being shown in the NLA. */
static int nlaedit_get_editable_tracks(bAnimContext *ac, ListBase *anim_data)
{
const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
return ANIM_animdata_filter(ac, anim_data, filter, ac->data, ac->datatype);
const eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
return ANIM_animdata_filter(ac, anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
}
static int nlaedit_add_actionclip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -624,7 +618,7 @@ static int nlaedit_add_actionclip_invoke(bContext *C, wmOperator *op, const wmEv
return OPERATOR_CANCELLED;
}
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
const size_t items = nlaedit_get_editable_tracks(&ac, &anim_data);
if (items == 0) {
@@ -643,27 +637,22 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
Scene *scene;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
bAction *act;
float cfra;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
scene = ac.scene;
cfra = (float)scene->r.cfra;
Scene *scene = ac.scene;
float cfra = float(scene->r.cfra);
/* get action to use */
act = BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action"));
bAction *act = static_cast<bAction *>(
BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action")));
if (act == NULL) {
if (act == nullptr) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");
// printf("Add strip - actname = '%s'\n", actname);
return OPERATOR_CANCELLED;
@@ -688,10 +677,11 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
/* for every active track,
* try to add strip to free space in track or to the top of the stack if no space */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
NlaStrip *strip = NULL;
NlaStrip *strip = nullptr;
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
/* Sanity check: only apply actions of the right type for this ID.
@@ -737,7 +727,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(ac.bmain);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -781,9 +771,7 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool done = false;
@@ -793,21 +781,21 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each track, find pairs of strips to add transitions to */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
NlaStrip *s1, *s2;
/* get initial pair of strips */
if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) {
if (ELEM(nlt->strips.first, nullptr, nlt->strips.last)) {
continue;
}
s1 = nlt->strips.first;
s1 = static_cast<NlaStrip *>(nlt->strips.first);
s2 = s1->next;
/* loop over strips */
@@ -835,7 +823,7 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
}
/* allocate new strip */
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
strip = MEM_cnew<NlaStrip>("NlaStrip");
BLI_insertlinkafter(&nlt->strips, s1, strip);
/* set the type */
@@ -873,7 +861,7 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -906,40 +894,35 @@ void NLA_OT_transition_add(wmOperatorType *ot)
/** \name Add Sound Clip Operator
* \{ */
static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_add_sound_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
Scene *scene;
int cfra;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
scene = ac.scene;
cfra = scene->r.cfra;
Scene *scene = ac.scene;
int cfra = scene->r.cfra;
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each track, add sound clips if it belongs to a speaker */
/* TODO: what happens if there aren't any tracks,
* well that's a more general problem for later. */
for (ale = anim_data.first; ale; ale = ale->next) {
Object *ob = (Object *)ale->id; /* may not be object until we actually check! */
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
Object *ob = reinterpret_cast<Object *>(
ale->id); /* may not be object until we actually check! */
AnimData *adt = ale->adt;
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
/* does this belong to speaker - assumed to live on Object level only */
@@ -948,7 +931,7 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
}
/* create a new strip, and offset it to start on the current frame */
strip = BKE_nla_add_soundstrip(bmain, ac.scene, ob->data);
NlaStrip *strip = BKE_nla_add_soundstrip(bmain, ac.scene, static_cast<Speaker *>(ob->data));
strip->start += cfra;
strip->end += cfra;
@@ -974,7 +957,7 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1004,13 +987,11 @@ void NLA_OT_soundclip_add(wmOperatorType *ot)
* \{ */
/* add the specified action as new strip */
static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_add_meta_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1018,15 +999,14 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each track, find pairs of strips to add transitions to */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
NlaStrip *strip;
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
/* No making meta-strips in non-local tracks of override data. */
@@ -1037,7 +1017,7 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
BKE_nlastrips_make_metas(&nlt->strips, 0);
/* name the metas */
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* auto-name this strip if selected (that means it is a meta) */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
BKE_nlastrip_validate_name(adt, strip);
@@ -1052,7 +1032,7 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1081,13 +1061,11 @@ void NLA_OT_meta_add(wmOperatorType *ot)
* Separate out the strips held by the selected meta-strips.
* \{ */
static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_remove_meta_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1095,13 +1073,13 @@ static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each track, find pairs of strips to add transitions to */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
/* No removing meta-strips from non-local tracks of override data. */
@@ -1119,7 +1097,7 @@ static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1153,9 +1131,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool linked = RNA_boolean_get(op->ptr, "linked");
bool done = false;
@@ -1166,15 +1142,15 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
}
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* duplicate strips in tracks starting from the last one so that we're
* less likely to duplicate strips we just duplicated...
*/
for (ale = anim_data.last; ale; ale = ale->prev) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH_BACKWARD (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
NlaStrip *strip, *nstrip, *next;
NlaTrack *track;
@@ -1184,7 +1160,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
* strip ends up in a valid (local) track. */
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
for (strip = nlt->strips.first; strip; strip = next) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = next) {
next = strip->next;
/* if selected, split the strip at its midpoint */
@@ -1223,7 +1199,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
}
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1232,7 +1208,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
nlaedit_duplicate_exec(C, op);
@@ -1271,13 +1247,11 @@ void NLA_OT_duplicate(wmOperatorType *ot)
* Deletes the selected NLA-Strips.
* \{ */
static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_delete_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1285,13 +1259,13 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, delete all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
NlaStrip *strip, *nstrip;
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
@@ -1299,7 +1273,7 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
continue;
}
for (strip = nlt->strips.first; strip; strip = nstrip) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = nstrip) {
nstrip = strip->next;
/* if selected, delete */
@@ -1328,7 +1302,7 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
DEG_relations_tag_update(ac.bmain);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1435,13 +1409,11 @@ static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip)
/* ----- */
static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_split_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1449,13 +1421,13 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, split all selected strips into two strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
AnimData *adt = ale->adt;
NlaStrip *strip, *next;
@@ -1464,7 +1436,7 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
continue;
}
for (strip = nlt->strips.first; strip; strip = next) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = next) {
next = strip->next;
/* if selected, split the strip at its midpoint */
@@ -1472,7 +1444,7 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
/* splitting method depends on the type of strip */
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* action-clip */
nlaedit_split_strip_actclip(ac.bmain, adt, nlt, strip, (float)ac.scene->r.cfra);
nlaedit_split_strip_actclip(ac.bmain, adt, nlt, strip, float(ac.scene->r.cfra));
break;
case NLASTRIP_TYPE_META: /* meta-strips need special handling */
@@ -1493,7 +1465,7 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1524,13 +1496,11 @@ void NLA_OT_split(wmOperatorType *ot)
* Toggles whether strips are muted or not.
* \{ */
static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_toggle_mute_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1538,17 +1508,16 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* go over all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
/* For every selected strip, toggle muting. */
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* just flip the mute flag for now */
/* TODO: have a pre-pass to check if mute all or unmute all? */
@@ -1565,7 +1534,7 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1598,9 +1567,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1608,16 +1575,16 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* consider each track in turn */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
NlaStrip *strip, *stripN = NULL;
NlaStrip *area = NULL, *sb = NULL;
NlaStrip *strip, *stripN = nullptr;
NlaStrip *area = nullptr, *sb = nullptr;
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
@@ -1633,7 +1600,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
* and this island has two strips inside it, then we should be able to just swap these still...
*/
if (BLI_listbase_is_empty(&nlt->strips) == false) {
NlaStrip *mstrip = (NlaStrip *)nlt->strips.first;
NlaStrip *mstrip = static_cast<NlaStrip *>(nlt->strips.first);
if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) &&
(BLI_listbase_count_at_most(&mstrip->strips, 3) == 2))
@@ -1646,16 +1613,16 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
/* get two selected strips only (these will be metas due to prev step) to operate on
* - only allow swapping 2, as with more the context becomes unclear
*/
for (strip = nlt->strips.first; strip; strip = stripN) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = stripN) {
stripN = strip->next;
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* first or second strip? */
if (area == NULL) {
if (area == nullptr) {
/* store as first */
area = strip;
}
else if (sb == NULL) {
else if (sb == nullptr) {
/* store as second */
sb = strip;
}
@@ -1674,11 +1641,11 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
"Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected",
nlt->name);
}
else if (area == NULL) {
else if (area == nullptr) {
/* no warning as this is just a common case,
* and it may get annoying when doing multiple tracks */
}
else if (sb == NULL) {
else if (sb == nullptr) {
/* too few selected warning */
BKE_reportf(
op->reports,
@@ -1749,8 +1716,8 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1779,13 +1746,11 @@ void NLA_OT_swap(wmOperatorType *ot)
* Tries to move the selected strips into the track above if possible.
* \{ */
static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_move_up_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1793,22 +1758,22 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* since we're potentially moving strips from lower tracks to higher tracks, we should
* loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks
*/
for (ale = anim_data.last; ale; ale = ale->prev) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH_BACKWARD (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
NlaTrack *nltn = nlt->next;
NlaStrip *strip, *stripn;
NlaStrip *stripn;
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
/* if this track has no tracks after it, skip for now... */
if (nltn == NULL) {
if (nltn == nullptr) {
continue;
}
@@ -1820,7 +1785,7 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
}
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
for (NlaStrip *strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = stripn) {
stripn = strip->next;
if (strip->flag & NLASTRIP_FLAG_SELECT) {
@@ -1842,8 +1807,8 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1872,13 +1837,11 @@ void NLA_OT_move_up(wmOperatorType *ot)
* Tries to move the selected strips into the track above if possible.
* \{ */
static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_move_down_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -1886,22 +1849,22 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* loop through the tracks in normal order, since we're pushing strips down,
* strips won't get operated on twice
*/
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
NlaTrack *nltp = nlt->prev;
NlaStrip *strip, *stripn;
NlaStrip *stripn;
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
/* if this track has no tracks before it, skip for now... */
if (nltp == NULL) {
if (nltp == nullptr) {
continue;
}
@@ -1913,7 +1876,7 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
}
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
for (NlaStrip *strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = stripn) {
stripn = strip->next;
if (strip->flag & NLASTRIP_FLAG_SELECT) {
@@ -1935,8 +1898,8 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -1969,9 +1932,7 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
const bool active_only = RNA_boolean_get(op->ptr, "active");
/* get editor data */
@@ -1980,19 +1941,18 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
if (active_only) {
filter |= ANIMFILTER_ACTIVE;
}
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 each NLA-Track, apply scale of all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* strip selection/active status check */
if (active_only) {
if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
@@ -2007,7 +1967,7 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
/* must be action-clip only (transitions don't have scale) */
if (strip->type == NLASTRIP_TYPE_CLIP) {
if (strip->act == NULL) {
if (strip->act == nullptr) {
continue;
}
@@ -2023,7 +1983,7 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
ANIM_animdata_freelist(&anim_data);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -2060,14 +2020,12 @@ void NLA_OT_action_sync_length(wmOperatorType *ot)
* Ensure that each strip has its own action.
* \{ */
static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_make_single_user_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool copied = false;
/* get editor data */
@@ -2076,29 +2034,28 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* Ensure that each action used only has a single user
* - This is done in reverse order so that the original strips are
* likely to still get to keep their action
*/
for (ale = anim_data.last; ale; ale = ale->prev) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH_BACKWARD (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
for (strip = nlt->strips.last; strip; strip = strip->prev) {
LISTBASE_FOREACH_BACKWARD (NlaStrip *, strip, &nlt->strips) {
/* must be action-clip only (as only these have actions) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
if (strip->act == NULL) {
if (strip->act == nullptr) {
continue;
}
/* multi-user? */
if (ID_REAL_USERS(strip->act) > 1) {
/* make a new copy of the action for us to use (it will have 1 user already) */
bAction *new_action = (bAction *)BKE_id_copy(bmain, &strip->act->id);
bAction *new_action = reinterpret_cast<bAction *>(BKE_id_copy(bmain, &strip->act->id));
/* decrement user count of our existing action */
id_us_min(&strip->act->id);
@@ -2122,7 +2079,7 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -2157,7 +2114,7 @@ void NLA_OT_make_single_user(wmOperatorType *ot)
static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt)
{
/* NLA-strip which has this scaling is stored in ked->data */
NlaStrip *strip = (NlaStrip *)ked->data;
NlaStrip *strip = static_cast<NlaStrip *>(ked->data);
/* adjust all the times */
bezt->vec[0][0] = nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP);
@@ -2168,17 +2125,15 @@ static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt)
return 0;
}
static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_apply_scale_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool copied = false;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -2186,27 +2141,27 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, apply scale of all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* strip must be selected, and must be action-clip only
* (transitions don't have scale) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
if (strip->act == NULL || ID_IS_OVERRIDE_LIBRARY(strip->act) || ID_IS_LINKED(strip->act)) {
if (strip->act == nullptr || ID_IS_OVERRIDE_LIBRARY(strip->act) ||
ID_IS_LINKED(strip->act)) {
continue;
}
/* if the referenced action is used by other strips,
* make this strip use its own copy */
if (strip->act->id.us > 1) {
/* make a copy of the Action to work on */
bAction *act = (bAction *)BKE_id_copy(bmain, &strip->act->id);
bAction *act = reinterpret_cast<bAction *>(BKE_id_copy(bmain, &strip->act->id));
/* set this as the new referenced action,
* decrementing the users of the old one */
@@ -2223,7 +2178,7 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
ac.ads,
strip->act,
ALE_ACT,
NULL,
nullptr,
bezt_apply_nlamapping,
BKE_fcurve_handles_recalc);
@@ -2259,7 +2214,7 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -2288,13 +2243,11 @@ void NLA_OT_apply_scale(wmOperatorType *ot)
* Reset the scaling of the selected strips to 1.0f.
* \{ */
static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
static int nlaedit_clear_scale_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -2302,22 +2255,21 @@ static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, reset scale of all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* strip must be selected, and must be action-clip only
* (transitions don't have scale) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
PointerRNA strip_ptr;
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
RNA_pointer_create(nullptr, &RNA_NlaStrip, strip, &strip_ptr);
RNA_float_set(&strip_ptr, "scale", 1.0f);
}
}
@@ -2330,7 +2282,7 @@ static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -2367,16 +2319,14 @@ static const EnumPropertyItem prop_nlaedit_snap_types[] = {
/* XXX as single entry? */
{NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Selection to Nearest Second", ""},
{NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Selection to Nearest Marker", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int nlaedit_snap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
Scene *scene;
int mode = RNA_enum_get(op->ptr, "type");
@@ -2388,22 +2338,22 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* get some necessary vars */
scene = ac.scene;
secf = (float)FPS;
secf = float(FPS);
bool any_added = false;
/* since we may add tracks, perform this in reverse order */
for (ale = anim_data.last; ale; ale = ale->prev) {
ListBase tmp_strips = {NULL, NULL};
LISTBASE_FOREACH_BACKWARD (bAnimListElem *, ale, &anim_data) {
ListBase tmp_strips = {nullptr, nullptr};
AnimData *adt = ale->adt;
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip, *stripn;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
NlaStrip *stripn;
NlaTrack *track;
const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale->id);
@@ -2414,7 +2364,7 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
/* apply the snapping to all the temp meta-strips, then put them in a separate list to be added
* back to the original only if they still fit
*/
for (strip = nlt->strips.first; strip; strip = stripn) {
for (NlaStrip *strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = stripn) {
stripn = strip->next;
if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
@@ -2427,7 +2377,7 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
/* calculate new start position based on snapping mode */
switch (mode) {
case NLAEDIT_SNAP_CFRA: /* to current frame */
strip->start = (float)scene->r.cfra;
strip->start = float(scene->r.cfra);
break;
case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */
strip->start = floorf(start + 0.5f);
@@ -2436,7 +2386,7 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
strip->start = floorf(start / secf + 0.5f) * secf;
break;
case NLAEDIT_SNAP_NEAREST_MARKER: /* to nearest marker */
strip->start = (float)ED_markers_find_nearest_marker_time(ac.markers, start);
strip->start = float(ED_markers_find_nearest_marker_time(ac.markers, start));
break;
default: /* just in case... no snapping */
strip->start = start;
@@ -2456,7 +2406,7 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
}
/* try adding each meta-strip back to the track one at a time, to make sure they'll fit */
for (strip = tmp_strips.first; strip; strip = stripn) {
for (NlaStrip *strip = static_cast<NlaStrip *>(tmp_strips.first); strip; strip = stripn) {
stripn = strip->next;
/* remove from temp-strips list */
@@ -2492,9 +2442,9 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
ED_nla_postop_refresh(&ac);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
if (any_added) {
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr);
}
/* done */
@@ -2529,15 +2479,15 @@ void NLA_OT_snap(wmOperatorType *ot)
* \{ */
static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C,
PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
PointerRNA * /*ptr*/,
PropertyRNA * /*prop*/,
bool *r_free)
{
EnumPropertyItem *item = NULL;
EnumPropertyItem *item = nullptr;
int totitem = 0;
int i = 0;
if (C == NULL) {
if (C == nullptr) {
return rna_enum_fmodifier_type_items;
}
@@ -2547,7 +2497,7 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C,
int index;
/* check if modifier is valid for this context */
if (fmi == NULL) {
if (fmi == nullptr) {
continue;
}
if (i == FMODIFIER_TYPE_CYCLES) { /* we already have repeat... */
@@ -2570,9 +2520,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
FModifier *fcm;
int type = RNA_enum_get(op->ptr, "type");
@@ -2584,21 +2532,20 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, add the specified modifier to all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
/* No adding f-modifiers to strips in non-local tracks of override data. */
continue;
}
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* can F-Modifier be added to the current strip? */
if (active_only) {
/* if not active, cannot add since we're only adding to active strip */
@@ -2619,7 +2566,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
}
/* add F-Modifier of specified type to selected, and make it the active one */
fcm = add_fmodifier(&strip->modifiers, type, NULL);
fcm = add_fmodifier(&strip->modifiers, type, nullptr);
if (fcm) {
set_active_fmodifier(&strip->modifiers, fcm);
@@ -2640,7 +2587,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
ANIM_animdata_freelist(&anim_data);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -2685,9 +2632,7 @@ void NLA_OT_fmodifier_add(wmOperatorType *ot)
static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
bool ok = false;
/* get editor data */
@@ -2699,16 +2644,15 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
ANIM_fmodifiers_copybuf_free();
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, add the specified modifier to all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* only add F-Modifier if on active strip? */
if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
@@ -2765,9 +2709,8 @@ void NLA_OT_fmodifier_copy(wmOperatorType *ot)
static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter, ok = 0;
ListBase anim_data = {nullptr, nullptr};
int ok = 0;
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
const bool replace = RNA_boolean_get(op->ptr, "replace");
@@ -2778,21 +2721,20 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
}
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* for each NLA-Track, add the specified modifier to all selected strips */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt)) {
/* No pasting in non-local tracks of override data. */
continue;
}
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* can F-Modifier be added to the current strip? */
if (active_only) {
/* if not active, cannot add since we're only adding to active strip */
@@ -2808,7 +2750,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
}
/* paste FModifiers from buffer */
ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace, NULL);
ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace, nullptr);
ale->update |= ANIM_UPDATE_DEPS;
}
}
@@ -2819,7 +2761,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
/* successful or not? */
if (ok) {
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}

View File

@@ -6,8 +6,8 @@
* \ingroup spnla
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "DNA_scene_types.h"
@@ -22,7 +22,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "nla_intern.h" /* own include */
#include "nla_intern.hh" /* own include */
/* ************************** poll callbacks for operators **********************************/
@@ -41,7 +41,7 @@ bool nlaop_poll_tweakmode_off(bContext *C)
}
scene = CTX_data_scene(C);
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
if ((scene == nullptr) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
}
@@ -63,7 +63,7 @@ bool nlaop_poll_tweakmode_on(bContext *C)
}
scene = CTX_data_scene(C);
if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) {
if ((scene == nullptr) || !(scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
}

View File

@@ -6,8 +6,8 @@
* \ingroup spnla
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
@@ -35,7 +35,7 @@
#include "UI_interface.h"
#include "UI_view2d.h"
#include "nla_intern.h" /* own include */
#include "nla_intern.hh" /* own include */
/* ******************** Utilities ***************************************** */
@@ -80,25 +80,22 @@ enum {
*/
static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
short smode;
/* determine type-based settings */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY);
/* 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));
/* See if we should be selecting or deselecting */
if (test == DESELECT_STRIPS_TEST) {
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
/* if any strip is selected, break out, since we should now be deselecting */
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
sel = SELECT_SUBTRACT;
break;
@@ -115,12 +112,11 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
smode = selmodes_to_flagmodes(sel);
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
/* apply same selection to all strips */
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
/* set selection */
if (test != DESELECT_STRIPS_CLEARACTIVE) {
ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT);
@@ -169,7 +165,7 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
}
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -211,11 +207,9 @@ enum {
static void box_select_nla_strips(bAnimContext *ac, rcti rect, short mode, short selectmode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
SpaceNla *snla = (SpaceNla *)ac->sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac->sl);
View2D *v2d = &ac->region->v2d;
rctf rectf;
@@ -224,27 +218,28 @@ static void box_select_nla_strips(bAnimContext *ac, rcti rect, short mode, short
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* convert selection modes to selection modes */
selectmode = selmodes_to_flagmodes(selectmode);
/* loop over data, doing box select */
float ymax = NLACHANNEL_FIRST_TOP(ac);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) {
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= NLACHANNEL_STEP(snla))
{
float ymin = ymax - NLACHANNEL_HEIGHT(snla);
/* perform vertical suitability check (if applicable) */
if ((mode == NLA_BOXSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
/* loop over data selecting (only if NLA-Track) */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
/* only select strips if they fall within the required ranges (if applicable) */
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if ((mode == NLA_BOXSEL_CHANNELS) ||
BKE_nlastrip_within_bounds(strip, rectf.xmin, rectf.xmax)) {
/* set selection */
@@ -267,22 +262,28 @@ static void box_select_nla_strips(bAnimContext *ac, rcti rect, short mode, short
static void nlaedit_strip_at_region_position(
bAnimContext *ac, float region_x, float region_y, bAnimListElem **r_ale, NlaStrip **r_strip)
{
*r_ale = NULL;
*r_strip = NULL;
*r_ale = nullptr;
*r_strip = nullptr;
SpaceNla *snla = (SpaceNla *)ac->sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac->sl);
View2D *v2d = &ac->region->v2d;
float view_x, view_y;
int channel_index;
UI_view2d_region_to_view(v2d, region_x, region_y, &view_x, &view_y);
UI_view2d_listview_view_to_cell(
0, NLACHANNEL_STEP(snla), 0, NLACHANNEL_FIRST_TOP(ac), view_x, view_y, NULL, &channel_index);
UI_view2d_listview_view_to_cell(0,
NLACHANNEL_STEP(snla),
0,
NLACHANNEL_FIRST_TOP(ac),
view_x,
view_y,
nullptr,
&channel_index);
ListBase anim_data = {NULL, NULL};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click
* (that is the size of keyframe icons, so user should be expecting similar tolerances)
@@ -291,10 +292,10 @@ static void nlaedit_strip_at_region_position(
const float xmin = UI_view2d_region_to_view_x(v2d, region_x - 7);
const float xmax = UI_view2d_region_to_view_x(v2d, region_x + 7);
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) {
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
float best_distance = MAXFRAMEF;
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
@@ -330,8 +331,8 @@ static bool nlaedit_mouse_is_over_strip(bAnimContext *ac, const int mval[2])
NlaStrip *strip;
nlaedit_strip_at_region_position(ac, mval[0], mval[1], &ale, &strip);
if (ale != NULL) {
BLI_assert(strip != NULL);
if (ale != nullptr) {
BLI_assert(strip != nullptr);
MEM_freeN(ale);
return true;
}
@@ -363,7 +364,7 @@ static int nlaedit_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_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_SUBTRACT);
@@ -396,7 +397,7 @@ static int nlaedit_box_select_exec(bContext *C, wmOperator *op)
box_select_nla_strips(&ac, rect, mode, selectmode);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -438,7 +439,7 @@ static const EnumPropertyItem prop_nlaedit_leftright_select_types[] = {
{NLAEDIT_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
{NLAEDIT_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
{NLAEDIT_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* ------------------- */
@@ -448,16 +449,14 @@ static void nlaedit_select_leftright(bContext *C,
short leftright,
short select_mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
ListBase anim_data = {nullptr, nullptr};
Scene *scene = ac->scene;
float xmin, xmax;
/* if currently in tweak-mode, exit tweak-mode first */
if (scene->flag & SCE_NLA_EDIT_ON) {
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL, NULL);
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
}
/* if select mode is replace, deselect all keyframes (and channels) first */
@@ -473,26 +472,26 @@ static void nlaedit_select_leftright(bContext *C,
/* get range, and get the right flag-setting mode */
if (leftright == NLAEDIT_LRSEL_LEFT) {
xmin = MINAFRAMEF;
xmax = (float)(scene->r.cfra + 0.1f);
xmax = float(scene->r.cfra + 0.1f);
}
else {
xmin = (float)(scene->r.cfra - 0.1f);
xmin = float(scene->r.cfra - 0.1f);
xmax = MAXFRAMEF;
}
select_mode = selmodes_to_flagmodes(select_mode);
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* select strips on the side where most data occurs */
for (ale = anim_data.first; ale; ale = ale->next) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
/* check each strip to see if it is appropriate */
for (strip = nlt->strips.first; strip; strip = strip->next) {
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT);
}
@@ -533,8 +532,8 @@ static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op)
nlaedit_select_leftright(C, &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;
}
@@ -608,8 +607,8 @@ static int mouse_nla_strips(bContext *C,
{
Scene *scene = ac->scene;
bAnimListElem *ale = NULL;
NlaStrip *strip = NULL;
bAnimListElem *ale = nullptr;
NlaStrip *strip = nullptr;
int ret_value = OPERATOR_FINISHED;
nlaedit_strip_at_region_position(ac, mval[0], mval[1], &ale, &strip);
@@ -618,7 +617,7 @@ static int mouse_nla_strips(bContext *C,
* now that we've found our target...
*/
if (scene->flag & SCE_NLA_EDIT_ON) {
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL, NULL);
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
}
if (select_mode != SELECT_REPLACE) {
@@ -628,7 +627,7 @@ static int mouse_nla_strips(bContext *C,
/* For replacing selection, if we have something to select, we have to clear existing selection.
* The same goes if we found nothing to select, and deselect_all is true
* (deselect on nothing behavior). */
if ((strip != NULL && select_mode == SELECT_REPLACE) || (strip == NULL && deselect_all)) {
if ((strip != nullptr && select_mode == SELECT_REPLACE) || (strip == nullptr && deselect_all)) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
@@ -645,9 +644,9 @@ static int mouse_nla_strips(bContext *C,
}
/* only select strip if we clicked on a valid channel and hit something */
if (ale != NULL) {
if (ale != nullptr) {
/* select the strip accordingly (if a matching one was found) */
if (strip != NULL) {
if (strip != nullptr) {
select_mode = selmodes_to_flagmodes(select_mode);
ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT);
@@ -662,12 +661,13 @@ static int mouse_nla_strips(bContext *C,
/* Highlight NLA-Track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaTrack *nlt = static_cast<NlaTrack *>(ale->data);
nlt->flag |= NLATRACK_SELECTED;
int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS;
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS;
ANIM_set_active_channel(
ac, ac->data, eAnimCont_Types(ac->datatype), filter, nlt, ANIMTYPE_NLATRACK);
}
}
}
@@ -704,7 +704,7 @@ static int nlaedit_clickselect_exec(bContext *C, wmOperator *op)
ret_value = mouse_nla_strips(C, &ac, mval, selectmode, deselect_all, wait_to_deselect_others);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, nullptr);
/* for tweak grab to work */
return ret_value | OPERATOR_PASS_THROUGH;

View File

@@ -6,8 +6,8 @@
* \ingroup spnla
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "DNA_collection_types.h"
#include "DNA_scene_types.h"
@@ -39,7 +39,7 @@
#include "BLO_read_write.h"
#include "nla_intern.h" /* own include */
#include "nla_intern.hh" /* own include */
/* ******************** default callbacks for nla space ***************** */
@@ -48,26 +48,26 @@ static SpaceLink *nla_create(const ScrArea *area, const Scene *scene)
ARegion *region;
SpaceNla *snla;
snla = MEM_callocN(sizeof(SpaceNla), "initnla");
snla = MEM_cnew<SpaceNla>("initnla");
snla->spacetype = SPACE_NLA;
/* allocate DopeSheet data for NLA Editor */
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
snla->ads->source = (ID *)scene;
snla->ads = MEM_cnew<bDopeSheet>("NlaEdit DopeSheet");
snla->ads->source = (ID *)(scene);
/* set auto-snapping settings */
snla->autosnap = SACTSNAP_FRAME;
snla->flag = SNLA_SHOW_MARKERS;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for nla");
region = MEM_cnew<ARegion>("header for nla");
BLI_addtail(&snla->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 list for nla");
region = MEM_cnew<ARegion>("channel list for nla");
BLI_addtail(&snla->regionbase, region);
region->regiontype = RGN_TYPE_CHANNELS;
region->alignment = RGN_ALIGN_LEFT;
@@ -77,21 +77,21 @@ static SpaceLink *nla_create(const ScrArea *area, const Scene *scene)
region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
/* ui buttons */
region = MEM_callocN(sizeof(ARegion), "buttons region for nla");
region = MEM_cnew<ARegion>("buttons region for nla");
BLI_addtail(&snla->regionbase, region);
region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_RIGHT;
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for nla");
region = MEM_cnew<ARegion>("main region for nla");
BLI_addtail(&snla->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
region->v2d.tot.xmin = (float)(scene->r.sfra - 10);
region->v2d.tot.ymin = (float)(-area->winy) / 3.0f;
region->v2d.tot.xmax = (float)(scene->r.efra + 10);
region->v2d.tot.xmin = float(scene->r.sfra - 10);
region->v2d.tot.ymin = float(-area->winy) / 3.0f;
region->v2d.tot.xmax = float(scene->r.efra + 10);
region->v2d.tot.ymax = 0.0f;
region->v2d.cur = region->v2d.tot;
@@ -111,13 +111,13 @@ static SpaceLink *nla_create(const ScrArea *area, const Scene *scene)
region->v2d.align = V2D_ALIGN_NO_POS_Y;
region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
return (SpaceLink *)snla;
return reinterpret_cast<SpaceLink *>(snla);
}
/* Doesn't free the space-link itself. */
static void nla_free(SpaceLink *sl)
{
SpaceNla *snla = (SpaceNla *)sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
if (snla->ads) {
BLI_freelistN(&snla->ads->chanbase);
@@ -128,13 +128,13 @@ static void nla_free(SpaceLink *sl)
/* spacetype; init callback */
static void nla_init(wmWindowManager *wm, ScrArea *area)
{
SpaceNla *snla = (SpaceNla *)area->spacedata.first;
SpaceNla *snla = static_cast<SpaceNla *>(area->spacedata.first);
/* init dopesheet data if non-existent (i.e. for old files) */
if (snla->ads == NULL) {
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
if (snla->ads == nullptr) {
snla->ads = MEM_cnew<bDopeSheet>("NlaEdit DopeSheet");
wmWindow *win = WM_window_find_by_area(wm, area);
snla->ads->source = win ? (ID *)WM_window_get_active_scene(win) : NULL;
snla->ads->source = win ? reinterpret_cast<ID *>(WM_window_get_active_scene(win)) : nullptr;
}
ED_area_tag_refresh(area);
@@ -142,12 +142,12 @@ static void nla_init(wmWindowManager *wm, ScrArea *area)
static SpaceLink *nla_duplicate(SpaceLink *sl)
{
SpaceNla *snlan = MEM_dupallocN(sl);
SpaceNla *snlan = static_cast<SpaceNla *>(MEM_dupallocN(sl));
/* clear or remove stuff from old */
snlan->ads = MEM_dupallocN(snlan->ads);
snlan->ads = static_cast<bDopeSheet *>(MEM_dupallocN(snlan->ads));
return (SpaceLink *)snlan;
return reinterpret_cast<SpaceLink *>(snlan);
}
/* add handlers, stuff you only do once or on area/region changes */
@@ -195,7 +195,7 @@ static void nla_channel_region_draw(const bContext *C, ARegion *region)
UI_view2d_view_restore(C);
/* 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 */
@@ -274,11 +274,11 @@ static void nla_main_region_draw_overlay(const bContext *C, ARegion *region)
ED_time_scrub_draw_current_frame(region, scene, snla->flag & SNLA_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 */
static void nla_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void nla_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
@@ -403,7 +403,7 @@ static void nla_main_region_listener(const wmRegionListenerParams *params)
static void nla_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;
@@ -412,11 +412,10 @@ static void nla_main_region_message_subscribe(const wmRegionMessageSubscribePara
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceNLA, 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. */
{
@@ -481,7 +480,7 @@ static void nla_channel_region_listener(const wmRegionListenerParams *params)
static void nla_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;
@@ -489,11 +488,10 @@ static void nla_channel_region_message_subscribe(const wmRegionMessageSubscribeP
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceNLA, 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,
* so just whitelist the entire struct for updates
@@ -553,28 +551,28 @@ static void nla_listener(const wmSpaceTypeListenerParams *params)
}
}
static void nla_id_remap(ScrArea *UNUSED(area),
SpaceLink *slink,
const struct IDRemapper *mappings)
static void nla_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings)
{
SpaceNla *snla = (SpaceNla *)slink;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(slink);
if (snla->ads == NULL) {
if (snla->ads == nullptr) {
return;
}
BKE_id_remapper_apply(mappings, (ID **)&snla->ads->filter_grp, ID_REMAP_APPLY_DEFAULT);
BKE_id_remapper_apply(mappings, (ID **)&snla->ads->source, ID_REMAP_APPLY_DEFAULT);
BKE_id_remapper_apply(
mappings, reinterpret_cast<ID **>(&snla->ads->filter_grp), ID_REMAP_APPLY_DEFAULT);
BKE_id_remapper_apply(
mappings, reinterpret_cast<ID **>(&snla->ads->source), ID_REMAP_APPLY_DEFAULT);
}
static void nla_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
{
SpaceNla *snla = (SpaceNla *)sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
BLO_read_data_address(reader, &snla->ads);
}
static void nla_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceNla *snla = (SpaceNla *)sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
bDopeSheet *ads = snla->ads;
if (ads) {
@@ -585,7 +583,7 @@ static void nla_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, Spac
static void nla_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
SpaceNla *snla = (SpaceNla *)sl;
SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
BLO_write_struct(writer, SpaceNla, snla);
if (snla->ads) {
@@ -595,7 +593,7 @@ static void nla_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ED_spacetype_nla(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla");
SpaceType *st = MEM_cnew<SpaceType>("spacetype nla");
ARegionType *art;
st->spaceid = SPACE_NLA;
@@ -614,7 +612,7 @@ void ED_spacetype_nla(void)
st->blend_write = nla_space_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art = MEM_cnew<ARegionType>("spacetype nla region");
art->regionid = RGN_TYPE_WINDOW;
art->init = nla_main_region_init;
art->draw = nla_main_region_draw;
@@ -626,7 +624,7 @@ void ED_spacetype_nla(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art = MEM_cnew<ARegionType>("spacetype nla region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@@ -637,7 +635,7 @@ void ED_spacetype_nla(void)
BLI_addhead(&st->regiontypes, art);
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art = MEM_cnew<ARegionType>("spacetype nla region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
@@ -650,7 +648,7 @@ void ED_spacetype_nla(void)
BLI_addhead(&st->regiontypes, art);
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
art = MEM_cnew<ARegionType>("spacetype nla region");
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI;