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

@ -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

@ -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");

@ -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;

@ -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 */

@ -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;
}

@ -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;

@ -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;