diff options
Diffstat (limited to 'source/blender/editors')
32 files changed, 420 insertions, 389 deletions
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index c31239f0e9c..5530a1e0416 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -34,18 +34,18 @@ set(INC set(SRC - outliner_collections.c - outliner_context.c - outliner_dragdrop.c - outliner_draw.c - outliner_edit.c - outliner_ops.c - outliner_select.c - outliner_sync.c - outliner_tools.c - outliner_tree.c - outliner_utils.c - space_outliner.c + outliner_collections.cc + outliner_context.cc + outliner_dragdrop.cc + outliner_draw.cc + outliner_edit.cc + outliner_ops.cc + outliner_select.cc + outliner_sync.cc + outliner_tools.cc + outliner_tree.cc + outliner_utils.cc + space_outliner.cc tree/common.cc tree/tree_display.cc tree/tree_display_data.cc @@ -68,7 +68,7 @@ set(SRC tree/tree_element_scene_objects.cc tree/tree_element_view_layer.cc - outliner_intern.h + outliner_intern.hh tree/tree_display.h tree/tree_display.hh tree/tree_element.h diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.cc index 946d7a0538d..222191e50ee 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -49,7 +49,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "outliner_intern.h" /* own include */ +#include "outliner_intern.hh" /* own include */ /* -------------------------------------------------------------------- */ /** \name Utility API @@ -85,7 +85,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te) } if (tselem->type == TSE_LAYER_COLLECTION) { - LayerCollection *lc = te->directdata; + LayerCollection *lc = reinterpret_cast<LayerCollection *>(te->directdata); return lc->collection; } if (ELEM(tselem->type, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) { @@ -101,7 +101,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te) TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *customdata) { - struct IDsSelectedData *data = customdata; + struct IDsSelectedData *data = reinterpret_cast<IDsSelectedData *>(customdata); TreeStoreElem *tselem = TREESTORE(te); if (outliner_is_collection_tree_element(te)) { @@ -118,7 +118,7 @@ TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *cu TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *customdata) { - struct IDsSelectedData *data = customdata; + struct IDsSelectedData *data = reinterpret_cast<IDsSelectedData *>(customdata); TreeStoreElem *tselem = TREESTORE(te); if (outliner_is_collection_tree_element(te)) { @@ -196,7 +196,7 @@ struct CollectionNewData { static TreeTraversalAction collection_find_selected_to_add(TreeElement *te, void *customdata) { - struct CollectionNewData *data = customdata; + struct CollectionNewData *data = reinterpret_cast<CollectionNewData *>(customdata); Collection *collection = outliner_collection_from_tree_element(te); if (!collection) { @@ -220,10 +220,7 @@ static int collection_new_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - struct CollectionNewData data = { - .error = false, - .collection = NULL, - }; + CollectionNewData data{}; if (RNA_boolean_get(op->ptr, "nested")) { outliner_build_tree(bmain, scene, view_layer, space_outliner, region); @@ -295,7 +292,7 @@ struct CollectionEditData { static TreeTraversalAction collection_find_data_to_edit(TreeElement *te, void *customdata) { - struct CollectionEditData *data = customdata; + CollectionEditData *data = reinterpret_cast<CollectionEditData *>(customdata); Collection *collection = outliner_collection_from_tree_element(te); if (!collection) { @@ -321,10 +318,9 @@ void outliner_collection_delete( { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new(__func__); @@ -336,7 +332,8 @@ void outliner_collection_delete( /* Effectively delete the collections. */ GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + Collection *collection = reinterpret_cast<Collection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); /* Test in case collection got deleted as part of another one. */ if (BLI_findindex(&bmain->collections, collection) != -1) { @@ -440,12 +437,12 @@ struct CollectionObjectsSelectData { static TreeTraversalAction outliner_find_first_selected_layer_collection(TreeElement *te, void *customdata) { - struct CollectionObjectsSelectData *data = customdata; + CollectionObjectsSelectData *data = reinterpret_cast<CollectionObjectsSelectData *>(customdata); TreeStoreElem *tselem = TREESTORE(te); switch (tselem->type) { case TSE_LAYER_COLLECTION: - data->layer_collection = te->directdata; + data->layer_collection = reinterpret_cast<LayerCollection *>(te->directdata); return TRAVERSE_BREAK; case TSE_R_LAYER: case TSE_SCENE_COLLECTION_BASE: @@ -460,9 +457,7 @@ static LayerCollection *outliner_active_layer_collection(bContext *C) { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct CollectionObjectsSelectData data = { - .layer_collection = NULL, - }; + CollectionObjectsSelectData data{}; outliner_tree_traverse(space_outliner, &space_outliner->tree, @@ -536,7 +531,7 @@ struct CollectionDuplicateData { static TreeTraversalAction outliner_find_first_selected_collection(TreeElement *te, void *customdata) { - struct CollectionDuplicateData *data = customdata; + CollectionDuplicateData *data = reinterpret_cast<CollectionDuplicateData *>(customdata); TreeStoreElem *tselem = TREESTORE(te); switch (tselem->type) { @@ -555,9 +550,7 @@ static TreeElement *outliner_active_collection(bContext *C) { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct CollectionDuplicateData data = { - .te = NULL, - }; + CollectionDuplicateData data = {}; outliner_tree_traverse(space_outliner, &space_outliner->tree, @@ -619,7 +612,8 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op) "it won't be linked to any view layer"); } - const eDupli_ID_Flags dupli_flags = USER_DUP_OBJECT | (linked ? 0 : U.dupflag); + const eDupli_ID_Flags dupli_flags = (eDupli_ID_Flags)(USER_DUP_OBJECT | + (linked ? 0 : U.dupflag)); BKE_collection_duplicate(bmain, parent, collection, dupli_flags, LIB_ID_DUPLICATE_IS_ROOT_ID); DEG_relations_tag_update(bmain); @@ -674,10 +668,10 @@ static int collection_link_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Collection *active_collection = CTX_data_layer_collection(C)->collection; SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; if ((ID_IS_LINKED(active_collection) || ID_IS_OVERRIDE_LIBRARY(active_collection)) || ((active_collection->flag & COLLECTION_IS_MASTER) && @@ -696,7 +690,8 @@ static int collection_link_exec(bContext *C, wmOperator *op) /* Effectively link the collections. */ GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + Collection *collection = reinterpret_cast<Collection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); BKE_collection_child_add(bmain, active_collection, collection); id_fake_user_clear(&collection->id); } @@ -738,10 +733,9 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new(__func__); @@ -755,7 +749,8 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op)) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + Collection *collection = reinterpret_cast<Collection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); while (BKE_collection_cycle_find(active_lc->collection, collection)) { active_lc = BKE_layer_collection_activate_parent(view_layer, active_lc); @@ -764,7 +759,8 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op)) /* Effectively instance the collections. */ GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + Collection *collection = reinterpret_cast<Collection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); Object *ob = ED_object_add_type( C, OB_EMPTY, collection->id.name + 2, scene->cursor.location, NULL, false, 0); ob->instance_collection = collection; @@ -805,14 +801,14 @@ void OUTLINER_OT_collection_instance(wmOperatorType *ot) static TreeTraversalAction layer_collection_find_data_to_edit(TreeElement *te, void *customdata) { - struct CollectionEditData *data = customdata; + CollectionEditData *data = reinterpret_cast<CollectionEditData *>(customdata); TreeStoreElem *tselem = TREESTORE(te); if (!(tselem && tselem->type == TSE_LAYER_COLLECTION)) { return TRAVERSE_CONTINUE; } - LayerCollection *lc = te->directdata; + LayerCollection *lc = reinterpret_cast<LayerCollection *>(te->directdata); if (lc->collection->flag & COLLECTION_IS_MASTER) { /* skip - showing warning/error message might be misleading @@ -836,10 +832,9 @@ static bool collections_view_layer_poll(bContext *C, bool clear, int flag) } Scene *scene = CTX_data_scene(C); - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new(__func__); bool result = false; @@ -852,7 +847,8 @@ static bool collections_view_layer_poll(bContext *C, bool clear, int flag) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - LayerCollection *lc = BLI_gsetIterator_getKey(&collections_to_edit_iter); + LayerCollection *lc = reinterpret_cast<LayerCollection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); if (clear && (lc->flag & flag)) { result = true; @@ -902,10 +898,9 @@ static int collection_view_layer_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; bool clear = strstr(op->idname, "clear") != NULL; int flag = strstr(op->idname, "holdout") ? LAYER_COLLECTION_HOLDOUT : strstr(op->idname, "indirect_only") ? LAYER_COLLECTION_INDIRECT_ONLY : @@ -922,7 +917,8 @@ static int collection_view_layer_exec(bContext *C, wmOperator *op) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - LayerCollection *lc = BLI_gsetIterator_getKey(&collections_to_edit_iter); + LayerCollection *lc = reinterpret_cast<LayerCollection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); BKE_layer_collection_set_flag(lc, flag, !clear); } @@ -1040,10 +1036,9 @@ static int collection_isolate_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); const bool extend = RNA_boolean_get(op->ptr, "extend"); - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new(__func__); outliner_tree_traverse(space_outliner, &space_outliner->tree, @@ -1054,7 +1049,8 @@ static int collection_isolate_exec(bContext *C, wmOperator *op) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); if (extend) { BKE_layer_collection_isolate_global(scene, view_layer, layer_collection, true); @@ -1137,10 +1133,9 @@ static int collection_visibility_exec(bContext *C, wmOperator *op) SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); const bool is_inside = strstr(op->idname, "inside") != NULL; const bool show = strstr(op->idname, "show") != NULL; - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new(__func__); outliner_tree_traverse(space_outliner, @@ -1152,7 +1147,8 @@ static int collection_visibility_exec(bContext *C, wmOperator *op) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); BKE_layer_collection_set_visible(view_layer, layer_collection, show, is_inside); } BLI_gset_free(data.collections_to_edit, NULL); @@ -1284,10 +1280,9 @@ static int collection_flag_exec(bContext *C, wmOperator *op) const bool is_render = strstr(op->idname, "render"); const bool clear = strstr(op->idname, "show") || strstr(op->idname, "enable"); int flag = is_render ? COLLECTION_HIDE_RENDER : COLLECTION_HIDE_VIEWPORT; - struct CollectionEditData data = { - .scene = scene, - .space_outliner = space_outliner, - }; + CollectionEditData data{}; + data.scene = scene; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new(__func__); const bool has_layer_collection = space_outliner->outlinevis == SO_VIEW_LAYER; @@ -1300,7 +1295,8 @@ static int collection_flag_exec(bContext *C, wmOperator *op) &data); GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); Collection *collection = layer_collection->collection; if (ID_IS_LINKED(collection)) { continue; @@ -1328,7 +1324,8 @@ static int collection_flag_exec(bContext *C, wmOperator *op) &data); GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + Collection *collection = reinterpret_cast<Collection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); if (ID_IS_LINKED(collection)) { continue; } @@ -1430,7 +1427,7 @@ struct OutlinerHideEditData { static TreeTraversalAction outliner_hide_find_data_to_edit(TreeElement *te, void *customdata) { - struct OutlinerHideEditData *data = customdata; + OutlinerHideEditData *data = reinterpret_cast<OutlinerHideEditData *>(customdata); TreeStoreElem *tselem = TREESTORE(te); if (tselem == NULL) { @@ -1438,7 +1435,7 @@ static TreeTraversalAction outliner_hide_find_data_to_edit(TreeElement *te, void } if (tselem->type == TSE_LAYER_COLLECTION) { - LayerCollection *lc = te->directdata; + LayerCollection *lc = reinterpret_cast<LayerCollection *>(te->directdata); if (lc->collection->flag & COLLECTION_IS_MASTER) { /* Skip - showing warning/error message might be misleading @@ -1464,11 +1461,10 @@ static int outliner_hide_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - struct OutlinerHideEditData data = { - .scene = scene, - .view_layer = view_layer, - .space_outliner = space_outliner, - }; + OutlinerHideEditData data{}; + data.scene = scene; + data.view_layer = view_layer; + data.space_outliner = space_outliner; data.collections_to_edit = BLI_gset_ptr_new("outliner_hide_exec__collections_to_edit"); data.bases_to_edit = BLI_gset_ptr_new("outliner_hide_exec__bases_to_edit"); @@ -1481,14 +1477,15 @@ static int outliner_hide_exec(bContext *C, wmOperator *UNUSED(op)) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { - LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>( + BLI_gsetIterator_getKey(&collections_to_edit_iter)); BKE_layer_collection_set_visible(view_layer, layer_collection, false, false); } BLI_gset_free(data.collections_to_edit, NULL); GSetIterator bases_to_edit_iter; GSET_ITER (bases_to_edit_iter, data.bases_to_edit) { - Base *base = BLI_gsetIterator_getKey(&bases_to_edit_iter); + Base *base = reinterpret_cast<Base *>(BLI_gsetIterator_getKey(&bases_to_edit_iter)); base->flag |= BASE_HIDDEN; } BLI_gset_free(data.bases_to_edit, NULL); @@ -1521,7 +1518,8 @@ static int outliner_unhide_all_exec(bContext *C, wmOperator *UNUSED(op)) ViewLayer *view_layer = CTX_data_view_layer(C); /* Unhide all the collections. */ - LayerCollection *lc_master = view_layer->layer_collections.first; + LayerCollection *lc_master = reinterpret_cast<LayerCollection *>( + view_layer->layer_collections.first); LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { BKE_layer_collection_set_flag(lc_iter, LAYER_COLLECTION_HIDE, false); } @@ -1565,9 +1563,7 @@ static int outliner_color_tag_set_exec(bContext *C, wmOperator *op) SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); const short color_tag = RNA_enum_get(op->ptr, "color"); - struct IDsSelectedData selected = { - .selected_array = {NULL, NULL}, - }; + IDsSelectedData selected{}; outliner_tree_traverse(space_outliner, &space_outliner->tree, diff --git a/source/blender/editors/space_outliner/outliner_context.c b/source/blender/editors/space_outliner/outliner_context.cc index d61bb17f661..857d8d4e095 100644 --- a/source/blender/editors/space_outliner/outliner_context.c +++ b/source/blender/editors/space_outliner/outliner_context.cc @@ -27,7 +27,7 @@ #include "DNA_space_types.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" static void outliner_context_selected_ids_recursive(const ListBase *subtree, bContextDataResult *result) diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.cc index 85fee590447..0cee0c45eae 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -58,7 +58,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" static Collection *collection_parent_from_ID(ID *id); @@ -157,7 +157,7 @@ static TreeElement *outliner_drop_insert_find(bContext *C, return te_hovered; } *r_insert_type = TE_INSERT_BEFORE; - return te_hovered->subtree.first; + return reinterpret_cast<TreeElement *>(te_hovered->subtree.first); } *r_insert_type = TE_INSERT_AFTER; return te_hovered; @@ -172,8 +172,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C, /* Mouse doesn't hover any item (ignoring x-axis), * so it's either above list bounds or below. */ - TreeElement *first = space_outliner->tree.first; - TreeElement *last = space_outliner->tree.last; + TreeElement *first = reinterpret_cast<TreeElement *>(space_outliner->tree.first); + TreeElement *last = reinterpret_cast<TreeElement *>(space_outliner->tree.last); if (view_mval[1] < last->ys) { *r_insert_type = TE_INSERT_AFTER; @@ -430,10 +430,11 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - ListBase *lb = event->customdata; - wmDrag *drag = lb->first; + ListBase *lb = reinterpret_cast<ListBase *>(event->customdata); + wmDrag *drag = reinterpret_cast<wmDrag *>(lb->first); - parent_drop_set_parents(C, op->reports, drag->ids.first, par, PAR_OBJECT, event->alt); + parent_drop_set_parents( + C, op->reports, reinterpret_cast<wmDragID *>(drag->ids.first), par, PAR_OBJECT, event->alt); return OPERATOR_FINISHED; } @@ -504,8 +505,8 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven return OPERATOR_CANCELLED; } - ListBase *lb = event->customdata; - wmDrag *drag = lb->first; + ListBase *lb = reinterpret_cast<ListBase *>(event->customdata); + wmDrag *drag = reinterpret_cast<wmDrag *>(lb->first); LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) { if (GS(drag_id->id->name) == ID_OB) { @@ -686,7 +687,7 @@ static void datastack_drop_data_init(wmDrag *drag, TreeStoreElem *tselem, void *directdata) { - StackDropData *drop_data = MEM_callocN(sizeof(*drop_data), "datastack drop data"); + StackDropData *drop_data = MEM_cnew<StackDropData>("datastack drop data"); drop_data->ob_parent = ob; drop_data->pchan_parent = pchan; @@ -836,7 +837,7 @@ static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) bool changed = outliner_flag_set( &space_outliner->tree, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false); - StackDropData *drop_data = drag->poin; + StackDropData *drop_data = reinterpret_cast<StackDropData *>(drag->poin); if (!drop_data) { return false; } @@ -874,7 +875,7 @@ static char *datastack_drop_tooltip(bContext *UNUSED(C), const int UNUSED(xy[2]), struct wmDropBox *UNUSED(drop)) { - StackDropData *drop_data = drag->poin; + StackDropData *drop_data = reinterpret_cast<StackDropData *>(drag->poin); switch (drop_data->drop_action) { case DATA_STACK_DROP_REORDER: return BLI_strdup(TIP_("Reorder")); @@ -951,20 +952,28 @@ static void datastack_drop_copy(bContext *C, StackDropData *drop_data) switch (drop_data->drag_tselem->type) { case TSE_MODIFIER: if (drop_data->ob_parent->type == OB_GPENCIL && ob_dst->type == OB_GPENCIL) { - ED_object_gpencil_modifier_copy_to_object(ob_dst, drop_data->drag_directdata); + ED_object_gpencil_modifier_copy_to_object( + ob_dst, reinterpret_cast<GpencilModifierData *>(drop_data->drag_directdata)); } else if (drop_data->ob_parent->type != OB_GPENCIL && ob_dst->type != OB_GPENCIL) { ED_object_modifier_copy_to_object( - C, ob_dst, drop_data->ob_parent, drop_data->drag_directdata); + C, + ob_dst, + drop_data->ob_parent, + reinterpret_cast<ModifierData *>(drop_data->drag_directdata)); } break; case TSE_CONSTRAINT: if (tselem->type == TSE_POSE_CHANNEL) { ED_object_constraint_copy_for_pose( - bmain, ob_dst, drop_data->drop_te->directdata, drop_data->drag_directdata); + bmain, + ob_dst, + reinterpret_cast<bPoseChannel *>(drop_data->drop_te->directdata), + reinterpret_cast<bConstraint *>(drop_data->drag_directdata)); } else { - ED_object_constraint_copy_for_object(bmain, ob_dst, drop_data->drag_directdata); + ED_object_constraint_copy_for_object( + bmain, ob_dst, reinterpret_cast<bConstraint *>(drop_data->drag_directdata)); } break; case TSE_GPENCIL_EFFECT: { @@ -972,7 +981,8 @@ static void datastack_drop_copy(bContext *C, StackDropData *drop_data) return; } - ED_object_shaderfx_copy(ob_dst, drop_data->drag_directdata); + ED_object_shaderfx_copy(ob_dst, + reinterpret_cast<ShaderFxData *>(drop_data->drag_directdata)); break; } } @@ -998,11 +1008,16 @@ static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropDa if (ob->type == OB_GPENCIL) { index = outliner_get_insert_index( drag_te, drop_te, insert_type, &ob->greasepencil_modifiers); - ED_object_gpencil_modifier_move_to_index(reports, ob, drop_data->drag_directdata, index); + ED_object_gpencil_modifier_move_to_index( + reports, + ob, + reinterpret_cast<GpencilModifierData *>(drop_data->drag_directdata), + index); } else { index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->modifiers); - ED_object_modifier_move_to_index(reports, ob, drop_data->drag_directdata, index); + ED_object_modifier_move_to_index( + reports, ob, reinterpret_cast<ModifierData *>(drop_data->drag_directdata), index); } break; case TSE_CONSTRAINT: @@ -1013,12 +1028,14 @@ static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropDa else { index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->constraints); } - ED_object_constraint_move_to_index(ob, drop_data->drag_directdata, index); + ED_object_constraint_move_to_index( + ob, reinterpret_cast<bConstraint *>(drop_data->drag_directdata), index); break; case TSE_GPENCIL_EFFECT: index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->shader_fx); - ED_object_shaderfx_move_to_index(reports, ob, drop_data->drag_directdata, index); + ED_object_shaderfx_move_to_index( + reports, ob, reinterpret_cast<ShaderFxData *>(drop_data->drag_directdata), index); } } @@ -1028,9 +1045,9 @@ static int datastack_drop_invoke(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_CANCELLED; } - ListBase *lb = event->customdata; - wmDrag *drag = lb->first; - StackDropData *drop_data = drag->poin; + ListBase *lb = reinterpret_cast<ListBase *>(event->customdata); + wmDrag *drag = reinterpret_cast<wmDrag *>(lb->first); + StackDropData *drop_data = reinterpret_cast<StackDropData *>(drag->poin); switch (drop_data->drop_action) { case DATA_STACK_DROP_LINK: @@ -1111,7 +1128,7 @@ static bool collection_drop_init( return false; } - wmDragID *drag_id = drag->ids.first; + wmDragID *drag_id = reinterpret_cast<wmDragID *>(drag->ids.first); if (drag_id == NULL) { return false; } @@ -1258,8 +1275,8 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE return OPERATOR_CANCELLED; } - ListBase *lb = event->customdata; - wmDrag *drag = lb->first; + ListBase *lb = reinterpret_cast<ListBase *>(event->customdata); + wmDrag *drag = reinterpret_cast<wmDrag *>(lb->first); CollectionDrop data; if (!collection_drop_init(C, drag, event->xy, event->ctrl, &data)) { @@ -1419,9 +1436,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, } /* Gather all selected elements. */ - struct IDsSelectedData selected = { - .selected_array = {NULL, NULL}, - }; + IDsSelectedData selected{}; if (GS(data.drag_id->name) == ID_OB) { outliner_tree_traverse(space_outliner, diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.cc index 8bcd50161bd..49a6d2a55f5 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -78,7 +78,7 @@ #include "RNA_access.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" #include "tree/tree_display.h" /* Disable - this is far too slow - campbell. */ @@ -142,9 +142,7 @@ static void restrictbutton_recursive_ebone(bArmature *arm, int flag, bool set_flag) { - EditBone *ebone; - - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) { if (set_flag) { ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); @@ -159,8 +157,7 @@ static void restrictbutton_recursive_ebone(bArmature *arm, static void restrictbutton_recursive_bone(Bone *bone_parent, int flag, bool set_flag) { - Bone *bone; - for (bone = bone_parent->childbase.first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, &bone_parent->childbase) { if (set_flag) { bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); bone->flag |= flag; @@ -282,7 +279,8 @@ static void outliner_object_set_flag_recursive_fn(bContext *C, Object *ob_parent = ob ? ob : base->object; - for (Object *ob_iter = bmain->objects.first; ob_iter; ob_iter = ob_iter->id.next) { + for (Object *ob_iter = reinterpret_cast<Object *>(bmain->objects.first); ob_iter; + ob_iter = reinterpret_cast<Object *>(ob_iter->id.next)) { if (BKE_object_is_child_recursive(ob_parent, ob_iter)) { if (ob) { RNA_id_pointer_create(&ob_iter->id, &ptr); @@ -316,8 +314,8 @@ static void outliner_object_set_flag_recursive_fn(bContext *C, */ static void outliner__object_set_flag_recursive_fn(bContext *C, void *poin, void *poin2) { - Object *ob = poin; - char *propname = poin2; + Object *ob = reinterpret_cast<Object *>(poin); + char *propname = reinterpret_cast<char *>(poin2); outliner_object_set_flag_recursive_fn(C, NULL, ob, propname); } @@ -326,8 +324,8 @@ static void outliner__object_set_flag_recursive_fn(bContext *C, void *poin, void */ static void outliner__base_set_flag_recursive_fn(bContext *C, void *poin, void *poin2) { - Base *base = poin; - char *propname = poin2; + Base *base = reinterpret_cast<Base *>(poin); + char *propname = reinterpret_cast<char *>(poin2); outliner_object_set_flag_recursive_fn(C, base, NULL, propname); } @@ -491,8 +489,10 @@ void outliner_collection_isolate_flag(Scene *scene, PointerRNA ptr; const bool is_hide = strstr(propname, "hide_") != NULL; - LayerCollection *top_layer_collection = layer_collection ? view_layer->layer_collections.first : - NULL; + LayerCollection *top_layer_collection = layer_collection ? + reinterpret_cast<LayerCollection *>( + view_layer->layer_collections.first) : + NULL; Collection *top_collection = collection ? scene->master_collection : NULL; bool was_isolated = (value == is_hide); @@ -556,7 +556,7 @@ void outliner_collection_isolate_flag(Scene *scene, else { CollectionParent *parent; Collection *child = collection; - while ((parent = child->parents.first)) { + while ((parent = reinterpret_cast<CollectionParent *>(child->parents.first))) { if (parent->collection->flag & COLLECTION_IS_MASTER) { break; } @@ -635,8 +635,8 @@ static void view_layer__layer_collection_set_flag_recursive_fn(bContext *C, void *poin, void *poin2) { - LayerCollection *layer_collection = poin; - char *propname = poin2; + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>(poin); + char *propname = reinterpret_cast<char *>(poin2); outliner_collection_set_flag_recursive_fn(C, layer_collection, NULL, propname); } @@ -646,8 +646,8 @@ static void view_layer__layer_collection_set_flag_recursive_fn(bContext *C, */ static void view_layer__collection_set_flag_recursive_fn(bContext *C, void *poin, void *poin2) { - LayerCollection *layer_collection = poin; - char *propname = poin2; + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>(poin); + char *propname = reinterpret_cast<char *>(poin2); outliner_collection_set_flag_recursive_fn( C, layer_collection, layer_collection->collection, propname); } @@ -658,8 +658,8 @@ static void view_layer__collection_set_flag_recursive_fn(bContext *C, void *poin */ static void scenes__collection_set_flag_recursive_fn(bContext *C, void *poin, void *poin2) { - Collection *collection = poin; - char *propname = poin2; + Collection *collection = reinterpret_cast<Collection *>(poin); + char *propname = reinterpret_cast<char *>(poin2); outliner_collection_set_flag_recursive_fn(C, NULL, collection, propname); } @@ -669,7 +669,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); struct wmMsgBus *mbus = CTX_wm_message_bus(C); BLI_mempool *ts = space_outliner->treestore; - TreeStoreElem *tselem = tsep; + TreeStoreElem *tselem = reinterpret_cast<TreeStoreElem *>(tsep); if (ts && tselem) { TreeElement *te = outliner_find_tree_element(&space_outliner->tree, tselem); @@ -733,7 +733,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) switch (tselem->type) { case TSE_DEFGROUP: { Object *ob = (Object *)tselem->id; - bDeformGroup *vg = te->directdata; + bDeformGroup *vg = reinterpret_cast<bDeformGroup *>(te->directdata); BKE_object_defgroup_unique_name(vg, ob); WM_msg_publish_rna_prop(mbus, &ob->id, vg, VertexGroup, name); break; @@ -747,7 +747,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) case TSE_EBONE: { bArmature *arm = (bArmature *)tselem->id; if (arm->edbo) { - EditBone *ebone = te->directdata; + EditBone *ebone = reinterpret_cast<EditBone *>(te->directdata); char newname[sizeof(ebone->name)]; /* restore bone name */ @@ -765,7 +765,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) outliner_viewcontext_init(C, &tvc); bArmature *arm = (bArmature *)tselem->id; - Bone *bone = te->directdata; + Bone *bone = reinterpret_cast<Bone *>(te->directdata); char newname[sizeof(bone->name)]; /* always make current object active */ @@ -785,7 +785,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) Object *ob = (Object *)tselem->id; bArmature *arm = (bArmature *)ob->data; - bPoseChannel *pchan = te->directdata; + bPoseChannel *pchan = reinterpret_cast<bPoseChannel *>(te->directdata); char newname[sizeof(pchan->name)]; /* always make current pose-bone active */ @@ -796,14 +796,15 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) /* restore bone name */ BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); - ED_armature_bone_rename(bmain, ob->data, oldname, newname); + ED_armature_bone_rename( + bmain, reinterpret_cast<bArmature *>(ob->data), oldname, newname); WM_msg_publish_rna_prop(mbus, &arm->id, pchan->bone, Bone, name); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); break; } case TSE_POSEGRP: { Object *ob = (Object *)tselem->id; /* id = object. */ - bActionGroup *grp = te->directdata; + bActionGroup *grp = reinterpret_cast<bActionGroup *>(te->directdata); BLI_uniquename(&ob->pose->agroups, grp, @@ -817,7 +818,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) } case TSE_GP_LAYER: { bGPdata *gpd = (bGPdata *)tselem->id; /* id = GP Datablock */ - bGPDlayer *gpl = te->directdata; + bGPDlayer *gpl = reinterpret_cast<bGPDlayer *>(te->directdata); /* always make layer active */ BKE_gpencil_layer_active_set(gpd, gpl); @@ -833,7 +834,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) } case TSE_R_LAYER: { Scene *scene = (Scene *)tselem->id; - ViewLayer *view_layer = te->directdata; + ViewLayer *view_layer = reinterpret_cast<ViewLayer *>(te->directdata); /* Restore old name. */ char newname[sizeof(view_layer->name)]; @@ -983,8 +984,9 @@ static bool outliner_restrict_properties_collection_set(Scene *scene, RestrictPropertiesActive *props_active) { TreeStoreElem *tselem = TREESTORE(te); - LayerCollection *layer_collection = (tselem->type == TSE_LAYER_COLLECTION) ? te->directdata : - NULL; + LayerCollection *layer_collection = (tselem->type == TSE_LAYER_COLLECTION) ? + reinterpret_cast<LayerCollection *>(te->directdata) : + NULL; Collection *collection = outliner_collection_from_tree_element(te); if (collection->flag & COLLECTION_IS_MASTER) { @@ -1097,7 +1099,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, ELEM(space_outliner->outlinevis, SO_SCENES, SO_VIEW_LAYER)) { if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) { /* View layer render toggle. */ - ViewLayer *layer = te->directdata; + ViewLayer *layer = reinterpret_cast<ViewLayer *>(te->directdata); bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, @@ -1321,7 +1323,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; Object *ob = (Object *)tselem->id; - bArmature *arm = ob->data; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); RNA_pointer_create(&arm->id, &RNA_Bone, bone, &ptr); @@ -1471,7 +1473,8 @@ static void outliner_draw_restrictbuts(uiBlock *block, scene, te, &collection_ptr, &layer_collection_ptr, &props, &props_active)) { LayerCollection *layer_collection = (tselem->type == TSE_LAYER_COLLECTION) ? - te->directdata : + reinterpret_cast<LayerCollection *>( + te->directdata) : NULL; Collection *collection = outliner_collection_from_tree_element(te); @@ -1903,7 +1906,7 @@ static void outliner_draw_rnabuts( if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) { if (tselem->type == TSE_RNA_PROPERTY) { ptr = &te->rnaptr; - prop = te->directdata; + prop = reinterpret_cast<PropertyRNA *>(te->directdata); if (!TSELEM_OPEN(tselem, space_outliner)) { if (RNA_property_type(prop) == PROP_POINTER) { @@ -1947,7 +1950,7 @@ static void outliner_draw_rnabuts( } else if (tselem->type == TSE_RNA_ARRAY_ELEM) { ptr = &te->rnaptr; - prop = te->directdata; + prop = reinterpret_cast<PropertyRNA *>(te->directdata); uiDefAutoButR(block, ptr, @@ -2257,7 +2260,7 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) data.drag_id = tselem->id; break; case TSE_CONSTRAINT: { - bConstraint *con = te->directdata; + bConstraint *con = reinterpret_cast<bConstraint *>(te->directdata); data.drag_id = tselem->id; switch ((eBConstraint_Types)con->type) { case CONSTRAINT_TYPE_CAMERASOLVER: @@ -2370,8 +2373,10 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) data.drag_id = tselem->id; if (ob->type != OB_GPENCIL) { - ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); - const ModifierTypeInfo *modifier_type = BKE_modifier_get_info(md->type); + ModifierData *md = reinterpret_cast<ModifierData *>( + BLI_findlink(&ob->modifiers, tselem->nr)); + const ModifierTypeInfo *modifier_type = reinterpret_cast<const ModifierTypeInfo *>( + BKE_modifier_get_info((ModifierType)md->type)); if (modifier_type != NULL) { data.icon = modifier_type->icon; } @@ -2381,7 +2386,8 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) } else { /* grease pencil modifiers */ - GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, tselem->nr); + GpencilModifierData *md = reinterpret_cast<GpencilModifierData *>( + BLI_findlink(&ob->greasepencil_modifiers, tselem->nr)); switch ((GpencilModifierType)md->type) { case eGpencilModifierType_Noise: data.icon = ICON_MOD_NOISE; @@ -2880,18 +2886,15 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle, const float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float ufac = 0.25f * UI_UNIT_X; float offset_x = (float)offsx + UI_UNIT_X * 0.35f; + rctf rect{}; + BLI_rctf_init(&rect, + offset_x + ufac, + offset_x + UI_UNIT_X - ufac, + (float)ys - UI_UNIT_Y * 0.2f + ufac, + (float)ys - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac); UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_aa( - &(const rctf){ - .xmin = offset_x + ufac, - .xmax = offset_x + UI_UNIT_X - ufac, - .ymin = (float)ys - UI_UNIT_Y * 0.2f + ufac, - .ymax = (float)ys - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac, - }, - true, - (float)UI_UNIT_Y / 2.0f - ufac, - color); + UI_draw_roundbox_aa(&rect, true, (float)UI_UNIT_Y / 2.0f - ufac, color); /* Now the numbers. */ uchar text_col[4]; @@ -2904,7 +2907,7 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle, /* We treat +99 as 4 digits to make sure the (eyeballed) alignment looks nice. */ int num_digits = 4; - char number_text[4] = "+99\0"; + char number_text[4] = "+99"; if (num_elements < 100) { BLI_snprintf(number_text, sizeof(number_text), "%d", num_elements); num_digits = num_elements < 10 ? 1 : 2; @@ -2939,28 +2942,12 @@ static void outliner_draw_active_indicator(const float minx, { const float ufac = UI_UNIT_X / 20.0f; const float radius = UI_UNIT_Y / 4.0f; + rctf rect{}; + BLI_rctf_init(&rect, minx, maxx, miny + ufac, maxy - ufac); UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_aa( - &(const rctf){ - .xmin = minx, - .xmax = maxx, - .ymin = miny + ufac, - .ymax = maxy - ufac, - }, - true, - radius, - icon_color); - UI_draw_roundbox_aa( - &(const rctf){ - .xmin = minx, - .xmax = maxx, - .ymin = miny + ufac, - .ymax = maxy - ufac, - }, - false, - radius, - icon_border); + UI_draw_roundbox_aa(&rect, true, radius, icon_color); + UI_draw_roundbox_aa(&rect, false, radius, icon_border); GPU_blend(GPU_BLEND_ALPHA); /* Roundbox disables. */ } @@ -3027,11 +3014,11 @@ int tree_element_id_type_to_index(TreeElement *te) return id_index + OB_TYPE_MAX; } -typedef struct MergedIconRow { +struct MergedIconRow { eOLDrawState active[INDEX_ID_MAX + OB_TYPE_MAX]; int num_elements[INDEX_ID_MAX + OB_TYPE_MAX]; TreeElement *tree_element[INDEX_ID_MAX + OB_TYPE_MAX]; -} MergedIconRow; +}; static void outliner_draw_iconrow(bContext *C, uiBlock *block, @@ -3323,7 +3310,7 @@ static void outliner_draw_tree_element(bContext *C, if (ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION) || ((tselem->type == TSE_RNA_STRUCT) && RNA_struct_is_ID(te->rnaptr.type))) { - const BIFIconID lib_icon = UI_icon_from_library(tselem->id); + const BIFIconID lib_icon = (BIFIconID)UI_icon_from_library(tselem->id); if (lib_icon != ICON_NONE) { UI_icon_draw_alpha( (float)startx + offsx + 2 * ufac, (float)*starty + 2 * ufac, lib_icon, alpha_fac); @@ -3356,7 +3343,7 @@ static void outliner_draw_tree_element(bContext *C, GPU_blend(GPU_BLEND_ALPHA); - MergedIconRow merged = {{0}}; + MergedIconRow merged{}; outliner_draw_iconrow(C, block, fstyle, diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.cc index 8ddd58bcc18..94eb2bee375 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -73,7 +73,7 @@ #include "GPU_material.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" static void outliner_show_active(SpaceOutliner *space_outliner, ARegion *region, @@ -258,7 +258,7 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE } /* Store last expanded tselem and x coordinate of disclosure triangle */ - OpenCloseData *toggle_data = MEM_callocN(sizeof(OpenCloseData), "open_close_data"); + OpenCloseData *toggle_data = MEM_cnew<OpenCloseData>("open_close_data"); toggle_data->prev_tselem = tselem; toggle_data->open = open; toggle_data->x_location = te->xs; @@ -575,10 +575,10 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); const short id_type = (short)RNA_enum_get(op->ptr, "id_type"); - ID *old_id = BLI_findlink(which_libbase(CTX_data_main(C), id_type), - RNA_enum_get(op->ptr, "old_id")); - ID *new_id = BLI_findlink(which_libbase(CTX_data_main(C), id_type), - RNA_enum_get(op->ptr, "new_id")); + ID *old_id = reinterpret_cast<ID *>( + BLI_findlink(which_libbase(CTX_data_main(C), id_type), RNA_enum_get(op->ptr, "old_id"))); + ID *new_id = reinterpret_cast<ID *>( + BLI_findlink(which_libbase(CTX_data_main(C), id_type), RNA_enum_get(op->ptr, "new_id"))); /* check for invalid states */ if (space_outliner == NULL) { @@ -671,9 +671,9 @@ static const EnumPropertyItem *outliner_id_itemf(bContext *C, int i = 0; short id_type = (short)RNA_enum_get(ptr, "id_type"); - ID *id = which_libbase(CTX_data_main(C), id_type)->first; + ID *id = reinterpret_cast<ID *>(which_libbase(CTX_data_main(C), id_type)->first); - for (; id; id = id->next) { + for (; id; id = reinterpret_cast<ID *>(id->next)) { item_tmp.identifier = item_tmp.name = id->name + 2; item_tmp.value = i++; RNA_enum_item_add(&item, &totitem, &item_tmp); @@ -709,7 +709,7 @@ void OUTLINER_OT_id_remap(wmOperatorType *ot) prop = RNA_def_enum(ot->srna, "old_id", DummyRNA_NULL_items, 0, "Old ID", "Old ID to replace"); RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, outliner_id_itemf); - RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE | PROP_HIDDEN); + RNA_def_property_flag(prop, (PropertyFlag)(PROP_ENUM_NO_TRANSLATE | PROP_HIDDEN)); ot->prop = RNA_def_enum(ot->srna, "new_id", @@ -1739,19 +1739,19 @@ static void tree_element_to_path(TreeElement *te, /* step 1: flatten out hierarchy of parents into a flat chain */ for (tem = te->parent; tem; tem = tem->parent) { - ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); + ld = MEM_cnew<LinkData>("LinkData for tree_element_to_path()"); ld->data = tem; BLI_addhead(&hierarchy, ld); } /* step 2: step down hierarchy building the path * (NOTE: addhead in previous loop was needed so that we can loop like this) */ - for (ld = hierarchy.first; ld; ld = ld->next) { + for (ld = reinterpret_cast<LinkData *>(hierarchy.first); ld; ld = ld->next) { /* get data */ tem = (TreeElement *)ld->data; tse = TREESTORE(tem); ptr = &tem->rnaptr; - prop = tem->directdata; + prop = reinterpret_cast<PropertyRNA *>(tem->directdata); /* check if we're looking for first ID, or appending to path */ if (*id) { @@ -1812,7 +1812,7 @@ static void tree_element_to_path(TreeElement *te, /* ptr->data not ptr->owner_id seems to be the one we want, * since ptr->data is sometimes the owner of this ID? */ if (RNA_struct_is_ID(ptr->type)) { - *id = ptr->data; + *id = reinterpret_cast<ID *>(ptr->data); /* clear path */ if (*path) { @@ -1828,7 +1828,7 @@ static void tree_element_to_path(TreeElement *te, if (*id) { /* add the active property to the path */ ptr = &te->rnaptr; - prop = te->directdata; + prop = reinterpret_cast<PropertyRNA *>(te->directdata); /* array checks */ if (tselem->type == TSE_RNA_ARRAY_ELEM) { @@ -1888,7 +1888,7 @@ static void do_outliner_drivers_editop(SpaceOutliner *space_outliner, /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && - RNA_property_animateable(&te->rnaptr, te->directdata)) { + RNA_property_animateable(&te->rnaptr, reinterpret_cast<PropertyRNA *>(te->directdata))) { /* get id + path + index info from the selected element */ tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); } @@ -1901,7 +1901,8 @@ static void do_outliner_drivers_editop(SpaceOutliner *space_outliner, /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { /* entire array was selected, so add drivers for all */ - arraylen = RNA_property_array_length(&te->rnaptr, te->directdata); + arraylen = RNA_property_array_length(&te->rnaptr, + reinterpret_cast<PropertyRNA *>(te->directdata)); } else { arraylen = array_index; @@ -2051,7 +2052,8 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* try to find one from scene */ if (scene->active_keyingset > 0) { - ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + ks = reinterpret_cast<KeyingSet *>( + BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); } /* Add if none found */ @@ -2083,7 +2085,7 @@ static void do_outliner_keyingset_editop(SpaceOutliner *space_outliner, /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && - RNA_property_animateable(&te->rnaptr, te->directdata)) { + RNA_property_animateable(&te->rnaptr, reinterpret_cast<PropertyRNA *>(te->directdata))) { /* get id + path + index info from the selected element */ tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); } @@ -2336,7 +2338,7 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) /* properties */ PropertyRNA *prop = RNA_def_int(ot->srna, "num_deleted", 0, 0, INT_MAX, "", "", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); + RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN)); RNA_def_boolean(ot->srna, "do_local_ids", diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.hh index 24e86e06f68..24e86e06f68 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.hh diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.cc index 7e5b0c90714..4664a3150a1 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.cc @@ -25,7 +25,7 @@ #include "ED_screen.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" /* ************************** registration **********************************/ diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.cc index 855975eb2dc..0db83ba250b 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -79,7 +79,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" /** * \note changes to selection are by convention and not essential. @@ -165,7 +165,7 @@ static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *ba */ static void do_outliner_item_mode_toggle_generic(bContext *C, TreeViewContext *tvc, Base *base) { - const int active_mode = tvc->obact->mode; + const eObjectMode active_mode = (eObjectMode)tvc->obact->mode; ED_undo_group_begin(C); if (ED_object_mode_set(C, OB_MODE_OBJECT)) { @@ -222,7 +222,7 @@ static void tree_element_viewlayer_activate(bContext *C, TreeElement *te) return; } - ViewLayer *view_layer = te->directdata; + ViewLayer *view_layer = reinterpret_cast<ViewLayer *>(te->directdata); wmWindow *win = CTX_wm_window(C); Scene *scene = WM_window_get_active_scene(win); @@ -241,7 +241,7 @@ static void do_outliner_object_select_recursive(ViewLayer *view_layer, { Base *base; - for (base = FIRSTBASE(view_layer); base; base = base->next) { + for (base = reinterpret_cast<Base *>(FIRSTBASE(view_layer)); base; base = base->next) { Object *ob = base->object; if ((((base->flag & BASE_VISIBLE_DEPSGRAPH) != 0) && BKE_object_is_child_recursive(ob_parent, ob))) { @@ -252,8 +252,7 @@ static void do_outliner_object_select_recursive(ViewLayer *view_layer, static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, bool select) { - Bone *bone; - for (bone = bone_parent->childbase.first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, &bone_parent->childbase) { if (select && PBONE_SELECTABLE(arm, bone)) { bone->flag |= BONE_SELECTED; } @@ -325,7 +324,7 @@ static void tree_element_object_activate(bContext *C, if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { if (base != NULL) { Object *obact = OBACT(view_layer); - const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT; + const eObjectMode object_mode = obact ? (eObjectMode)obact->mode : OB_MODE_OBJECT; if (base && !BKE_object_is_mode_compat(base->object, object_mode)) { if (object_mode == OB_MODE_OBJECT) { struct Main *bmain = CTX_data_main(C); @@ -421,7 +420,7 @@ static void tree_element_camera_activate(bContext *C, Scene *scene, TreeElement scene->camera = ob; Main *bmain = CTX_data_main(C); - wmWindowManager *wm = bmain->wm.first; + wmWindowManager *wm = reinterpret_cast<wmWindowManager *>(bmain->wm.first); WM_windows_scene_data_sync(&wm->windows, scene); DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); @@ -461,7 +460,7 @@ static void tree_element_defgroup_activate(bContext *C, TreeElement *te, TreeSto static void tree_element_gplayer_activate(bContext *C, TreeElement *te, TreeStoreElem *tselem) { bGPdata *gpd = (bGPdata *)tselem->id; - bGPDlayer *gpl = te->directdata; + bGPDlayer *gpl = reinterpret_cast<bGPDlayer *>(te->directdata); /* We can only have a single "active" layer at a time * and there must always be an active layer... */ @@ -489,8 +488,8 @@ static void tree_element_posechannel_activate(bContext *C, bool recursive) { Object *ob = (Object *)tselem->id; - bArmature *arm = ob->data; - bPoseChannel *pchan = te->directdata; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); + bPoseChannel *pchan = reinterpret_cast<bPoseChannel *>(te->directdata); if (!(pchan->bone->flag & BONE_HIDDEN_P)) { if (set != OL_SETSEL_EXTEND) { @@ -506,13 +505,12 @@ static void tree_element_posechannel_activate(bContext *C, continue; } - bPoseChannel *pchannel; - for (pchannel = ob_iter->pose->chanbase.first; pchannel; pchannel = pchannel->next) { + LISTBASE_FOREACH (bPoseChannel *, pchannel, &ob_iter->pose->chanbase) { pchannel->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } if (ob != ob_iter) { - DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT); + DEG_id_tag_update(reinterpret_cast<ID *>(ob_iter->data), ID_RECALC_SELECT); } } MEM_freeN(objects); @@ -545,14 +543,14 @@ static void tree_element_bone_activate(bContext *C, bool recursive) { bArmature *arm = (bArmature *)tselem->id; - Bone *bone = te->directdata; + Bone *bone = reinterpret_cast<Bone *>(te->directdata); if (!(bone->flag & BONE_HIDDEN_P)) { Object *ob = OBACT(view_layer); if (ob) { if (set != OL_SETSEL_EXTEND) { /* single select forces all other bones to get unselected */ - for (Bone *bone_iter = arm->bonebase.first; bone_iter != NULL; + for (Bone *bone_iter = reinterpret_cast<Bone *>(arm->bonebase.first); bone_iter != NULL; bone_iter = bone_iter->next) { bone_iter->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); do_outliner_bone_select_recursive(arm, bone_iter, false); @@ -594,13 +592,18 @@ static void tree_element_ebone_activate(bContext *C, bool recursive) { bArmature *arm = (bArmature *)tselem->id; - EditBone *ebone = te->directdata; + EditBone *ebone = reinterpret_cast<EditBone *>(te->directdata); if (set == OL_SETSEL_NORMAL) { if (!(ebone->flag & BONE_HIDDEN_A)) { uint bases_len = 0; - Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data( - view_layer, NULL, &bases_len); + + ObjectsInModeParams ob_params{}; + ob_params.object_mode = OB_MODE_EDIT; + ob_params.no_dup_data = true; + + Base **bases = BKE_view_layer_array_from_bases_in_mode_params( + view_layer, NULL, &bases_len, &ob_params); ED_armature_edit_deselect_all_multi_ex(bases, bases_len); MEM_freeN(bases); @@ -701,7 +704,7 @@ static void tree_element_sequence_dup_activate(Scene *scene, TreeElement *UNUSED #if 0 select_single_seq(seq, 1); #endif - Sequence *p = ed->seqbasep->first; + Sequence *p = reinterpret_cast<Sequence *>(ed->seqbasep->first); while (p) { if ((!p->strip) || (!p->strip->stripdata) || (p->strip->stripdata->name[0] == '\0')) { p = p->next; @@ -720,7 +723,8 @@ static void tree_element_sequence_dup_activate(Scene *scene, TreeElement *UNUSED static void tree_element_master_collection_activate(const bContext *C) { ViewLayer *view_layer = CTX_data_view_layer(C); - LayerCollection *layer_collection = view_layer->layer_collections.first; + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>( + view_layer->layer_collections.first); BKE_layer_collection_activate(view_layer, layer_collection); /* A very precise notifier - ND_LAYER alone is quite vague, we want to avoid unnecessary work * when only the active collection changes. */ @@ -730,7 +734,7 @@ static void tree_element_master_collection_activate(const bContext *C) static void tree_element_layer_collection_activate(bContext *C, TreeElement *te) { Scene *scene = CTX_data_scene(C); - LayerCollection *layer_collection = te->directdata; + LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>(te->directdata); ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, layer_collection); BKE_layer_collection_activate(view_layer, layer_collection); /* A very precise notifier - ND_LAYER alone is quite vague, we want to avoid unnecessary work @@ -854,7 +858,7 @@ static eOLDrawState tree_element_bone_state_get(const ViewLayer *view_layer, const TreeStoreElem *tselem) { const bArmature *arm = (const bArmature *)tselem->id; - const Bone *bone = te->directdata; + const Bone *bone = reinterpret_cast<Bone *>(te->directdata); const Object *ob = OBACT(view_layer); if (ob && ob->data == arm) { if (bone->flag & BONE_SELECTED) { @@ -866,7 +870,7 @@ static eOLDrawState tree_element_bone_state_get(const ViewLayer *view_layer, static eOLDrawState tree_element_ebone_state_get(const TreeElement *te) { - const EditBone *ebone = te->directdata; + const EditBone *ebone = reinterpret_cast<EditBone *>(te->directdata); if (ebone->flag & BONE_SELECTED) { return OL_DRAWSEL_NORMAL; } @@ -910,7 +914,7 @@ static eOLDrawState tree_element_posechannel_state_get(const Object *ob_pose, const TreeStoreElem *tselem) { const Object *ob = (const Object *)tselem->id; - const bPoseChannel *pchan = te->directdata; + const bPoseChannel *pchan = reinterpret_cast<bPoseChannel *>(te->directdata); if (ob == ob_pose && ob->pose) { if (pchan->bone->flag & BONE_SELECTED) { return OL_DRAWSEL_NORMAL; @@ -926,7 +930,7 @@ static eOLDrawState tree_element_viewlayer_state_get(const bContext *C, const Tr return OL_DRAWSEL_NONE; } - const ViewLayer *view_layer = te->directdata; + const ViewLayer *view_layer = reinterpret_cast<ViewLayer *>(te->directdata); if (CTX_data_view_layer(C) == view_layer) { return OL_DRAWSEL_NORMAL; @@ -1223,7 +1227,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE /* Expand the selected constraint in the properties editor. */ if (tselem->type != TSE_CONSTRAINT_BASE) { - BKE_constraint_panel_expand(te->directdata); + BKE_constraint_panel_expand(reinterpret_cast<bConstraint *>(te->directdata)); } break; } @@ -1236,7 +1240,8 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE Object *ob = (Object *)tselem->id; if (ob->type == OB_GPENCIL) { - BKE_gpencil_modifier_panel_expand(te->directdata); + BKE_gpencil_modifier_panel_expand( + reinterpret_cast<GpencilModifierData *>(te->directdata)); } else { ModifierData *md = (ModifierData *)te->directdata; @@ -1269,12 +1274,12 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE context = BCONTEXT_SHADERFX; if (tselem->type != TSE_GPENCIL_EFFECT_BASE) { - BKE_shaderfx_panel_expand(te->directdata); + BKE_shaderfx_panel_expand(reinterpret_cast<ShaderFxData *>(te->directdata)); } break; case TSE_BONE: { bArmature *arm = (bArmature *)tselem->id; - Bone *bone = te->directdata; + Bone *bone = reinterpret_cast<Bone *>(te->directdata); RNA_pointer_create(&arm->id, &RNA_Bone, bone, &ptr); context = BCONTEXT_BONE; @@ -1282,7 +1287,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE } case TSE_EBONE: { bArmature *arm = (bArmature *)tselem->id; - EditBone *ebone = te->directdata; + EditBone *ebone = reinterpret_cast<EditBone *>(te->directdata); RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &ptr); context = BCONTEXT_BONE; @@ -1290,8 +1295,8 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE } case TSE_POSE_CHANNEL: { Object *ob = (Object *)tselem->id; - bArmature *arm = ob->data; - bPoseChannel *pchan = te->directdata; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); + bPoseChannel *pchan = reinterpret_cast<bPoseChannel *>(te->directdata); RNA_pointer_create(&arm->id, &RNA_PoseBone, pchan, &ptr); context = BCONTEXT_BONE; @@ -1299,7 +1304,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE } case TSE_POSE_BASE: { Object *ob = (Object *)tselem->id; - bArmature *arm = ob->data; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr); context = BCONTEXT_DATA; @@ -1307,7 +1312,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE } case TSE_R_LAYER_BASE: case TSE_R_LAYER: { - ViewLayer *view_layer = te->directdata; + ViewLayer *view_layer = reinterpret_cast<ViewLayer *>(te->directdata); RNA_pointer_create(tselem->id, &RNA_ViewLayer, view_layer, &ptr); context = BCONTEXT_VIEW_LAYER; @@ -1316,7 +1321,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE case TSE_POSEGRP_BASE: case TSE_POSEGRP: { Object *ob = (Object *)tselem->id; - bArmature *arm = ob->data; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr); context = BCONTEXT_DATA; @@ -1392,7 +1397,7 @@ static void do_outliner_item_activate_tree_element(bContext *C, Collection *gr = (Collection *)tselem->id; if (extend) { - int sel = BA_SELECT; + eObjectSelect_Mode sel = BA_SELECT; FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (gr, object) { Base *base = BKE_view_layer_base_find(tvc->view_layer, object); if (base && (base->flag & BASE_SELECTED)) { @@ -1730,7 +1735,7 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op) ARegion *region = CTX_wm_region(C); rctf rectf; - const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); + const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode"); const bool select = (sel_op != SEL_OP_SUB); if (SEL_OP_USE_PRE_DESELECT(sel_op)) { outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 0); @@ -1816,7 +1821,7 @@ static TreeElement *outliner_find_rightmost_visible_child(SpaceOutliner *space_o { while (te->subtree.last) { if (TSELEM_OPEN(TREESTORE(te), space_outliner)) { - te = te->subtree.last; + te = reinterpret_cast<TreeElement *>(te->subtree.last); } else { break; @@ -1860,7 +1865,7 @@ static TreeElement *outliner_find_next_element(SpaceOutliner *space_outliner, Tr TreeStoreElem *tselem = TREESTORE(te); if (TSELEM_OPEN(tselem, space_outliner) && te->subtree.first) { - te = te->subtree.first; + te = reinterpret_cast<TreeElement *>(te->subtree.first); } else if (te->next) { te = te->next; @@ -1897,7 +1902,7 @@ static TreeElement *outliner_walk_right(SpaceOutliner *space_outliner, /* Only walk down a level if the element is open and not toggling expand */ if (!toggle_all && TSELEM_OPEN(tselem, space_outliner) && !BLI_listbase_is_empty(&te->subtree)) { - te = te->subtree.first; + te = reinterpret_cast<TreeElement *>(te->subtree.first); } else { outliner_item_openclose(space_outliner, te, true, toggle_all); @@ -1948,7 +1953,7 @@ static TreeElement *find_walk_select_start_element(SpaceOutliner *space_outliner /* If no active element exists, use the first element in the tree */ if (!active_te) { - active_te = space_outliner->tree.first; + active_te = reinterpret_cast<TreeElement *>(space_outliner->tree.first); *changed = true; } diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.cc index d95a0dde858..e4af3030f7b 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.cc @@ -50,7 +50,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" void ED_outliner_select_sync_from_object_tag(bContext *C) { @@ -93,7 +93,8 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C) Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); - for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (bScreen *screen = reinterpret_cast<bScreen *>(bmain->screens.first); screen; + screen = reinterpret_cast<bScreen *>(screen->id.next)) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_OUTLINER) { @@ -274,7 +275,7 @@ static void outliner_select_sync_to_pose_bone(TreeElement *te, GSet *selected_pbones) { Object *ob = (Object *)tselem->id; - bArmature *arm = ob->data; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); bPoseChannel *pchan = (bPoseChannel *)te->directdata; short bone_flag = pchan->bone->flag; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.cc index 4849da16685..910c0ed0230 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -95,7 +95,7 @@ #include "SEQ_relations.h" #include "SEQ_sequencer.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" static CLG_LogRef LOG = {"ed.outliner.tools"}; @@ -488,7 +488,7 @@ static bool scene_fn(bContext *C, static int outliner_scene_operation_exec(bContext *C, wmOperator *op) { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - const eOutliner_PropSceneOps event = RNA_enum_get(op->ptr, "type"); + const eOutliner_PropSceneOps event = (eOutliner_PropSceneOps)RNA_enum_get(op->ptr, "type"); if (outliner_do_scene_operation(C, event, &space_outliner->tree, scene_fn) == false) { return OPERATOR_CANCELLED; @@ -641,7 +641,8 @@ static uiBlock *merged_element_search_menu(bContext *C, ARegion *region, void *d NULL); /* Center the menu on the cursor */ - UI_block_bounds_set_popup(block, 6, (const int[2]){-(menu_width / 2), 0}); + const int offset[2] = {-(menu_width / 2), 0}; + UI_block_bounds_set_popup(block, 6, offset); return block; } @@ -650,7 +651,7 @@ void merged_element_search_menu_invoke(bContext *C, TreeElement *parent_te, TreeElement *activate_te) { - MergedSearchData *select_data = MEM_callocN(sizeof(MergedSearchData), "merge_search_data"); + MergedSearchData *select_data = MEM_cnew<MergedSearchData>("merge_search_data"); select_data->parent_element = parent_te; select_data->select_element = activate_te; @@ -810,7 +811,7 @@ static void id_override_library_create_fn(bContext *C, { BLI_assert(TSE_IS_REAL_ID(tselem)); ID *id_root = tselem->id; - OutlinerLibOverrideData *data = user_data; + OutlinerLibOverrideData *data = reinterpret_cast<OutlinerLibOverrideData *>(user_data); const bool do_hierarchy = data->do_hierarchy; bool success = false; @@ -903,7 +904,7 @@ static void id_override_library_reset_fn(bContext *C, { BLI_assert(TSE_IS_REAL_ID(tselem)); ID *id_root = tselem->id; - OutlinerLibOverrideData *data = user_data; + OutlinerLibOverrideData *data = reinterpret_cast<OutlinerLibOverrideData *>(user_data); const bool do_hierarchy = data->do_hierarchy; if (ID_IS_OVERRIDE_LIBRARY_REAL(id_root)) { @@ -934,7 +935,7 @@ static void id_override_library_resync_fn(bContext *C, { BLI_assert(TSE_IS_REAL_ID(tselem)); ID *id_root = tselem->id; - OutlinerLibOverrideData *data = user_data; + OutlinerLibOverrideData *data = reinterpret_cast<OutlinerLibOverrideData *>(user_data); const bool do_hierarchy_enforce = data->do_resync_hierarchy_enforce; if (ID_IS_OVERRIDE_LIBRARY_REAL(id_root)) { @@ -953,13 +954,10 @@ static void id_override_library_resync_fn(bContext *C, te->store_elem->id->tag |= LIB_TAG_DOIT; } - BKE_lib_override_library_resync(bmain, - scene, - CTX_data_view_layer(C), - id_root, - NULL, - do_hierarchy_enforce, - &(struct BlendFileReadReport){.reports = reports}); + BlendFileReadReport report{}; + report.reports = reports; + BKE_lib_override_library_resync( + bmain, scene, CTX_data_view_layer(C), id_root, NULL, do_hierarchy_enforce, &report); WM_event_add_notifier(C, NC_WINDOW, NULL); } @@ -1341,7 +1339,7 @@ static void data_select_linked_fn(int event, if (event == OL_DOP_SELECT_LINKED) { if (RNA_struct_is_ID(te->rnaptr.type)) { bContext *C = (bContext *)C_v; - ID *id = te->rnaptr.data; + ID *id = reinterpret_cast<ID *>(te->rnaptr.data); ED_object_select_linked_by_id(C, id); } @@ -1350,7 +1348,7 @@ static void data_select_linked_fn(int event, static void constraint_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v) { - bContext *C = C_v; + bContext *C = reinterpret_cast<bContext *>(C_v); Main *bmain = CTX_data_main(C); bConstraint *constraint = (bConstraint *)te->directdata; Object *ob = (Object *)outliner_search_back(te, ID_OB); @@ -1445,7 +1443,8 @@ static Base *outliner_batch_delete_hierarchy( } object = base->object; - for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) { + for (child_base = reinterpret_cast<Base *>(view_layer->object_bases.first); child_base; + child_base = base_next) { base_next = child_base->next; for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent) { @@ -1967,7 +1966,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) TreeElement *te = get_target_element(space_outliner); get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel); - eOutlinerIdOpTypes event = RNA_enum_get(op->ptr, "type"); + eOutlinerIdOpTypes event = (eOutlinerIdOpTypes)RNA_enum_get(op->ptr, "type"); switch (event) { case OUTLINER_IDOP_UNLINK: { /* unlink datablock from its parent */ @@ -2050,24 +2049,27 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE: { + OutlinerLibOverrideData override_data{}; outliner_do_libdata_operation(C, op->reports, scene, space_outliner, &space_outliner->tree, id_override_library_create_fn, - &(OutlinerLibOverrideData){.do_hierarchy = false}); + &override_data); ED_undo_push(C, "Overridden Data"); break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE_HIERARCHY: { + OutlinerLibOverrideData override_data{}; + override_data.do_hierarchy = true; outliner_do_libdata_operation(C, op->reports, scene, space_outliner, &space_outliner->tree, id_override_library_create_fn, - &(OutlinerLibOverrideData){.do_hierarchy = true}); + &override_data); ED_undo_push(C, "Overridden Data Hierarchy"); break; } @@ -2082,58 +2084,67 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET: { + OutlinerLibOverrideData override_data{}; outliner_do_libdata_operation(C, op->reports, scene, space_outliner, &space_outliner->tree, id_override_library_reset_fn, - &(OutlinerLibOverrideData){.do_hierarchy = false}); + &override_data); ED_undo_push(C, "Reset Overridden Data"); break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET_HIERARCHY: { + OutlinerLibOverrideData override_data{}; + override_data.do_hierarchy = true; outliner_do_libdata_operation(C, op->reports, scene, space_outliner, &space_outliner->tree, id_override_library_reset_fn, - &(OutlinerLibOverrideData){.do_hierarchy = true}); + &override_data); ED_undo_push(C, "Reset Overridden Data Hierarchy"); break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_RESYNC_HIERARCHY: { + OutlinerLibOverrideData override_data{}; + override_data.do_hierarchy = true; outliner_do_libdata_operation(C, op->reports, scene, space_outliner, &space_outliner->tree, id_override_library_resync_fn, - &(OutlinerLibOverrideData){.do_hierarchy = true}); + &override_data); ED_undo_push(C, "Resync Overridden Data Hierarchy"); break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_RESYNC_HIERARCHY_ENFORCE: { - outliner_do_libdata_operation( - C, - op->reports, - scene, - space_outliner, - &space_outliner->tree, - id_override_library_resync_fn, - &(OutlinerLibOverrideData){.do_hierarchy = true, .do_resync_hierarchy_enforce = true}); + OutlinerLibOverrideData override_data{}; + override_data.do_hierarchy = true; + override_data.do_resync_hierarchy_enforce = true; + outliner_do_libdata_operation(C, + op->reports, + scene, + space_outliner, + &space_outliner->tree, + id_override_library_resync_fn, + &override_data); ED_undo_push(C, "Resync Overridden Data Hierarchy"); break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY_DELETE_HIERARCHY: { + OutlinerLibOverrideData override_data{}; + override_data.do_hierarchy = true; outliner_do_libdata_operation(C, op->reports, scene, space_outliner, &space_outliner->tree, id_override_library_delete_fn, - &(OutlinerLibOverrideData){.do_hierarchy = true}); + &override_data); ED_undo_push(C, "Delete Overridden Data Hierarchy"); break; } @@ -2320,7 +2331,7 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op) TreeElement *te = get_target_element(space_outliner); get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel); - eOutlinerLibOpTypes event = RNA_enum_get(op->ptr, "type"); + eOutlinerLibOpTypes event = (eOutlinerLibOpTypes)RNA_enum_get(op->ptr, "type"); switch (event) { case OL_LIB_RENAME: { outliner_do_libdata_operation( @@ -2438,7 +2449,8 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel); /* get action to use */ - act = BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action")); + act = reinterpret_cast<bAction *>( + BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action"))); if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid action to add"); @@ -2545,7 +2557,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) } /* perform the core operation */ - eOutliner_AnimDataOps event = RNA_enum_get(op->ptr, "type"); + eOutliner_AnimDataOps event = (eOutliner_AnimDataOps)RNA_enum_get(op->ptr, "type"); switch (event) { case OUTLINER_ANIMOP_CLEAR_ADT: /* Remove Animation Data - this may remove the active action, in some cases... */ @@ -2635,7 +2647,7 @@ static const EnumPropertyItem prop_constraint_op_types[] = { static int outliner_constraint_operation_exec(bContext *C, wmOperator *op) { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - eOutliner_PropConstraintOps event = RNA_enum_get(op->ptr, "type"); + eOutliner_PropConstraintOps event = (eOutliner_PropConstraintOps)RNA_enum_get(op->ptr, "type"); outliner_do_data_operation( space_outliner, TSE_CONSTRAINT, event, &space_outliner->tree, constraint_fn, C); @@ -2682,7 +2694,7 @@ static const EnumPropertyItem prop_modifier_op_types[] = { static int outliner_modifier_operation_exec(bContext *C, wmOperator *op) { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - eOutliner_PropModifierOps event = RNA_enum_get(op->ptr, "type"); + eOutliner_PropModifierOps event = (eOutliner_PropModifierOps)RNA_enum_get(op->ptr, "type"); outliner_do_data_operation( space_outliner, TSE_MODIFIER, event, &space_outliner->tree, modifier_fn, C); @@ -2725,7 +2737,7 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) TreeElement *te = get_target_element(space_outliner); get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel); - eOutliner_PropDataOps event = RNA_enum_get(op->ptr, "type"); + eOutliner_PropDataOps event = (eOutliner_PropDataOps)RNA_enum_get(op->ptr, "type"); switch (datalevel) { case TSE_POSE_CHANNEL: { outliner_do_data_operation( diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.cc index e461eb4c69e..de0f7a0f9df 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -76,7 +76,7 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" #include "tree/tree_display.h" #include "tree/tree_element.h" @@ -102,7 +102,7 @@ static void outliner_storage_cleanup(SpaceOutliner *space_outliner) BLI_mempool_iter iter; BLI_mempool_iternew(ts, &iter); - while ((tselem = BLI_mempool_iterstep(&iter))) { + while ((tselem = reinterpret_cast<TreeStoreElem *>(BLI_mempool_iterstep(&iter)))) { tselem->used = 0; } @@ -112,7 +112,7 @@ static void outliner_storage_cleanup(SpaceOutliner *space_outliner) space_outliner->storeflag &= ~SO_TREESTORE_CLEANUP; BLI_mempool_iternew(ts, &iter); - while ((tselem = BLI_mempool_iterstep(&iter))) { + while ((tselem = reinterpret_cast<TreeStoreElem *>(BLI_mempool_iterstep(&iter)))) { if (tselem->id == NULL) { unused++; } @@ -132,9 +132,9 @@ static void outliner_storage_cleanup(SpaceOutliner *space_outliner) BLI_mempool *new_ts = BLI_mempool_create( sizeof(TreeStoreElem), BLI_mempool_len(ts) - unused, 512, BLI_MEMPOOL_ALLOW_ITER); BLI_mempool_iternew(ts, &iter); - while ((tselem = BLI_mempool_iterstep(&iter))) { + while ((tselem = reinterpret_cast<TreeStoreElem *>(BLI_mempool_iterstep(&iter)))) { if (tselem->id) { - tsenew = BLI_mempool_alloc(new_ts); + tsenew = reinterpret_cast<TreeStoreElem *>(BLI_mempool_alloc(new_ts)); *tsenew = *tselem; } } @@ -163,8 +163,8 @@ static void check_persistent( sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER); } if (space_outliner->runtime->treehash == NULL) { - space_outliner->runtime->treehash = BKE_outliner_treehash_create_from_treestore( - space_outliner->treestore); + space_outliner->runtime->treehash = reinterpret_cast<GHash *>( + BKE_outliner_treehash_create_from_treestore(space_outliner->treestore)); } /* find any unused tree element in treestore and mark it as used @@ -178,7 +178,7 @@ static void check_persistent( } /* add 1 element to treestore */ - tselem = BLI_mempool_alloc(space_outliner->treestore); + tselem = reinterpret_cast<TreeStoreElem *>(BLI_mempool_alloc(space_outliner->treestore)); tselem->type = type; tselem->nr = type ? nr : 0; tselem->id = id; @@ -314,7 +314,7 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner, outliner_add_element(space_outliner, &te->subtree, ob->data, te, TSE_SOME_ID, 0); if (ob->pose) { - bArmature *arm = ob->data; + bArmature *arm = reinterpret_cast<bArmature *>(ob->data); TreeElement *tenla = outliner_add_element( space_outliner, &te->subtree, ob, te, TSE_POSE_BASE, 0); tenla->name = IFACE_("Pose"); @@ -360,7 +360,7 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner, } } /* make hierarchy */ - TreeElement *ten = tenla->subtree.first; + TreeElement *ten = reinterpret_cast<TreeElement *>(tenla->subtree.first); while (ten) { TreeElement *nten = ten->next, *par; tselem = TREESTORE(ten); @@ -715,13 +715,15 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, ebone->temp.p = ten; } /* make hierarchy */ - TreeElement *ten = arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp.p : NULL; + TreeElement *ten = arm->edbo->first ? reinterpret_cast<TreeElement *>( + ((EditBone *)arm->edbo->first)->temp.p) : + NULL; while (ten) { TreeElement *nten = ten->next, *par; EditBone *ebone = (EditBone *)ten->directdata; if (ebone->parent) { BLI_remlink(&te->subtree, ten); - par = ebone->parent->temp.p; + par = reinterpret_cast<TreeElement *>(ebone->parent->temp.p); BLI_addtail(&par->subtree, ten); ten->parent = par; } @@ -855,12 +857,12 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, short type, short index) { - ID *id = idv; + ID *id = reinterpret_cast<ID *>(idv); if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id = ((PointerRNA *)idv)->owner_id; if (!id) { - id = ((PointerRNA *)idv)->data; + id = reinterpret_cast<ID *>(((PointerRNA *)idv)->data); } } else if (type == TSE_GP_LAYER) { @@ -881,7 +883,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, BLI_assert(TREESTORE_ID_TYPE(id)); } - TreeElement *te = MEM_callocN(sizeof(TreeElement), __func__); + TreeElement *te = MEM_cnew<TreeElement>(__func__); /* add to the visual tree */ BLI_addtail(lb, te); /* add to the storage */ @@ -1047,7 +1049,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, CLAMP_MAX(tot, tot_limit); /* auto open these cases */ - if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) { + if (!parent || (RNA_property_type(reinterpret_cast<PropertyRNA *>(parent->directdata))) == + PROP_POINTER) { if (!tselem->used) { tselem->flag &= ~TSE_CLOSED; } @@ -1057,7 +1060,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, for (int a = 0; a < tot; a++) { PointerRNA propptr; RNA_property_collection_lookup_int(ptr, iterprop, a, &propptr); - if (!(RNA_property_flag(propptr.data) & PROP_HIDDEN)) { + if (!(RNA_property_flag(reinterpret_cast<PropertyRNA *>(propptr.data)) & PROP_HIDDEN)) { outliner_add_element( space_outliner, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a); } @@ -1075,7 +1078,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, PropertyRNA *iterprop = RNA_struct_iterator_property(ptr->type); RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); - PropertyRNA *prop = propptr.data; + PropertyRNA *prop = reinterpret_cast<PropertyRNA *>(propptr.data); PropertyType proptype = RNA_property_type(prop); te->name = RNA_property_ui_name(prop); @@ -1132,7 +1135,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, } } else if (type == TSE_RNA_ARRAY_ELEM) { - PropertyRNA *prop = parent->directdata; + PropertyRNA *prop = reinterpret_cast<PropertyRNA *>(parent->directdata); te->directdata = prop; te->rnaptr = *ptr; @@ -1140,7 +1143,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, char c = RNA_property_array_item_char(prop, index); - te->name = MEM_callocN(sizeof(char[20]), "OutlinerRNAArrayName"); + te->name = reinterpret_cast<char *>(MEM_callocN(sizeof(char[20]), "OutlinerRNAArrayName")); if (c) { sprintf((char *)te->name, " %c", c); } @@ -1203,7 +1206,7 @@ void outliner_make_object_parent_hierarchy(ListBase *lb) { /* build hierarchy */ /* XXX also, set extents here... */ - TreeElement *te = lb->first; + TreeElement *te = reinterpret_cast<TreeElement *>(lb->first); while (te) { TreeElement *ten = te->next; TreeStoreElem *tselem = TREESTORE(te); @@ -1233,7 +1236,8 @@ typedef struct tTreeSort { /* alphabetical comparator, trying to put objects first */ static int treesort_alpha_ob(const void *v1, const void *v2) { - const tTreeSort *x1 = v1, *x2 = v2; + const tTreeSort *x1 = reinterpret_cast<const tTreeSort *>(v1); + const tTreeSort *x2 = reinterpret_cast<const tTreeSort *>(v2); /* first put objects last (hierarchy) */ int comp = (x1->idcode == ID_OB); @@ -1271,7 +1275,8 @@ static int treesort_alpha_ob(const void *v1, const void *v2) /* Move children that are not in the collection to the end of the list. */ static int treesort_child_not_in_collection(const void *v1, const void *v2) { - const tTreeSort *x1 = v1, *x2 = v2; + const tTreeSort *x1 = reinterpret_cast<const tTreeSort *>(v1); + const tTreeSort *x2 = reinterpret_cast<const tTreeSort *>(v2); /* Among objects first come the ones in the collection, followed by the ones not on it. * This way we can have the dashed lines in a separate style connecting the former. */ @@ -1284,7 +1289,8 @@ static int treesort_child_not_in_collection(const void *v1, const void *v2) /* alphabetical comparator */ static int treesort_alpha(const void *v1, const void *v2) { - const tTreeSort *x1 = v1, *x2 = v2; + const tTreeSort *x1 = reinterpret_cast<const tTreeSort *>(v1); + const tTreeSort *x2 = reinterpret_cast<const tTreeSort *>(v2); int comp = BLI_strcasecmp_natural(x1->name, x2->name); @@ -1341,24 +1347,25 @@ static int treesort_obtype_alpha(const void *v1, const void *v2) /* sort happens on each subtree individual */ static void outliner_sort(ListBase *lb) { - TreeElement *te = lb->last; - if (te == NULL) { + TreeElement *last_te = reinterpret_cast<TreeElement *>(lb->last); + if (last_te == NULL) { return; } - TreeStoreElem *tselem = TREESTORE(te); + TreeStoreElem *last_tselem = TREESTORE(last_te); /* Sorting rules; only object lists, ID lists, or deform-groups. */ - if (ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || - ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB))) { + if (ELEM(last_tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || + ((last_tselem->type == TSE_SOME_ID) && (last_te->idcode == ID_OB))) { int totelem = BLI_listbase_count(lb); if (totelem > 1) { - tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); + tTreeSort *tear = reinterpret_cast<tTreeSort *>( + MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array")); tTreeSort *tp = tear; int skip = 0; - for (te = lb->first; te; te = te->next, tp++) { - tselem = TREESTORE(te); + LISTBASE_FOREACH (TreeElement *, te, lb) { + TreeStoreElem *tselem = TREESTORE(te); tp->te = te; tp->name = te->name; tp->idcode = te->idcode; @@ -1371,6 +1378,7 @@ static void outliner_sort(ListBase *lb) } tp->id = tselem->id; + tp++; } /* just sort alphabetically */ @@ -1407,26 +1415,28 @@ static void outliner_sort(ListBase *lb) static void outliner_collections_children_sort(ListBase *lb) { - TreeElement *te = lb->last; - if (te == NULL) { + TreeElement *last_te = reinterpret_cast<TreeElement *>(lb->last); + if (last_te == NULL) { return; } - TreeStoreElem *tselem = TREESTORE(te); + TreeStoreElem *last_tselem = TREESTORE(last_te); /* Sorting rules: only object lists. */ - if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) { + if ((last_tselem->type == TSE_SOME_ID) && (last_te->idcode == ID_OB)) { int totelem = BLI_listbase_count(lb); if (totelem > 1) { - tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); + tTreeSort *tear = reinterpret_cast<tTreeSort *>( + MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array")); tTreeSort *tp = tear; - for (te = lb->first; te; te = te->next, tp++) { - tselem = TREESTORE(te); + LISTBASE_FOREACH (TreeElement *, te, lb) { + TreeStoreElem *tselem = TREESTORE(te); tp->te = te; tp->name = te->name; tp->idcode = te->idcode; tp->id = tselem->id; + tp++; } qsort(tear, totelem, sizeof(tTreeSort), treesort_child_not_in_collection); @@ -1506,9 +1516,8 @@ static TreeElement *outliner_find_first_desired_element_at_y_recursive( } if (TSELEM_OPEN(te->store_elem, space_outliner)) { - TreeElement *te_iter, *te_sub; - for (te_iter = te->subtree.first; te_iter; te_iter = te_iter->next) { - te_sub = outliner_find_first_desired_element_at_y_recursive( + LISTBASE_FOREACH (TreeElement *, te_iter, &te->subtree) { + TreeElement *te_sub = outliner_find_first_desired_element_at_y_recursive( space_outliner, te_iter, limit, callback_test); if (te_sub != NULL) { return te_sub; @@ -1784,7 +1793,8 @@ static TreeElement *outliner_extract_children_from_subtree(TreeElement *element, if (outliner_element_is_collection_or_object(element)) { TreeElement *te_prev = NULL; - for (TreeElement *te = element->subtree.last; te; te = te_prev) { + for (TreeElement *te = reinterpret_cast<TreeElement *>(element->subtree.last); te; + te = te_prev) { te_prev = te->prev; if (!outliner_element_is_collection_or_object(te)) { @@ -1811,7 +1821,7 @@ static int outliner_filter_subtree(SpaceOutliner *space_outliner, TreeElement *te, *te_next; TreeStoreElem *tselem; - for (te = lb->first; te; te = te_next) { + for (te = reinterpret_cast<TreeElement *>(lb->first); te; te = te_next) { te_next = te->next; if ((outliner_element_visible_get(view_layer, te, exclude_filter) == false)) { /* Don't free the tree, but extract the children from the parent and add to this tree. */ @@ -1932,13 +1942,16 @@ void outliner_build_tree(Main *mainvar, outliner_storage_cleanup(space_outliner); outliner_tree_display_destroy(&space_outliner->runtime->tree_display); - space_outliner->runtime->tree_display = outliner_tree_display_create(space_outliner->outlinevis, - space_outliner); + space_outliner->runtime->tree_display = outliner_tree_display_create( + (eSpaceOutliner_Mode)space_outliner->outlinevis, space_outliner); /* All tree displays should be created as sub-classes of AbstractTreeDisplay. */ - BLI_assert(space_outliner->runtime->tree_display != NULL); + BLI_assert(space_outliner->runtime->tree_display != nullptr); - TreeSourceData source_data = {.bmain = mainvar, .scene = scene, .view_layer = view_layer}; + TreeSourceData source_data{}; + source_data.bmain = mainvar; + source_data.scene = scene; + source_data.view_layer = view_layer; space_outliner->tree = outliner_tree_display_build_tree(space_outliner->runtime->tree_display, &source_data); diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.cc index d370d508198..cf442074035 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.cc @@ -42,7 +42,7 @@ #include "UI_interface.h" #include "UI_view2d.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" /* -------------------------------------------------------------------- */ /** \name Tree View Context @@ -111,7 +111,7 @@ static TreeElement *outliner_find_item_at_x_in_row_recursive(const TreeElement * float view_co_x, bool *r_is_merged_icon) { - TreeElement *child_te = parent_te->subtree.first; + TreeElement *child_te = reinterpret_cast<TreeElement *>(parent_te->subtree.first); while (child_te) { const bool over_element = (view_co_x > child_te->xs) && (view_co_x < child_te->xend); @@ -295,7 +295,8 @@ bool outliner_tree_traverse(const SpaceOutliner *space_outliner, TreeTraversalFunc func, void *customdata) { - for (TreeElement *te = tree->first, *te_next; te; te = te_next) { + for (TreeElement *te = reinterpret_cast<TreeElement *>(tree->first), *te_next; te; + te = te_next) { TreeTraversalAction func_retval = TRAVERSE_CONTINUE; /* in case te is freed in callback */ TreeStoreElem *tselem = TREESTORE(te); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.cc index 6c45d39e0d8..4e51797b552 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -49,7 +49,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "outliner_intern.h" +#include "outliner_intern.hh" #include "tree/tree_display.h" static void outliner_main_region_init(wmWindowManager *wm, ARegion *region) @@ -104,7 +104,7 @@ static void outliner_main_region_listener(const wmRegionListenerParams *params) ScrArea *area = params->area; ARegion *region = params->region; wmNotifier *wmn = params->notifier; - SpaceOutliner *space_outliner = area->spacedata.first; + SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(area->spacedata.first); /* context changes */ switch (wmn->category) { @@ -267,13 +267,12 @@ static void outliner_main_region_message_subscribe(const wmRegionMessageSubscrib struct wmMsgBus *mbus = params->message_bus; ScrArea *area = params->area; ARegion *region = params->region; - SpaceOutliner *space_outliner = area->spacedata.first; + SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(area->spacedata.first); - 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; if (ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_OVERRIDES_LIBRARY)) { WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw); @@ -324,7 +323,7 @@ static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUS ARegion *region; SpaceOutliner *space_outliner; - space_outliner = MEM_callocN(sizeof(SpaceOutliner), "initoutliner"); + space_outliner = MEM_cnew<SpaceOutliner>("initoutliner"); space_outliner->spacetype = SPACE_OUTLINER; space_outliner->filter_id_type = ID_GR; space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE | SO_RESTRICT_RENDER; @@ -334,14 +333,14 @@ static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUS space_outliner->filter = SO_FILTER_NO_VIEW_LAYERS; /* header */ - region = MEM_callocN(sizeof(ARegion), "header for outliner"); + region = MEM_cnew<ARegion>("header for outliner"); BLI_addtail(&space_outliner->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* main region */ - region = MEM_callocN(sizeof(ARegion), "main region for outliner"); + region = MEM_cnew<ARegion>("main region for outliner"); BLI_addtail(&space_outliner->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; @@ -371,18 +370,17 @@ static void outliner_free(SpaceLink *sl) /* spacetype; init callback */ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *area) { - SpaceOutliner *space_outliner = area->spacedata.first; + SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(area->spacedata.first); if (space_outliner->runtime == NULL) { - space_outliner->runtime = MEM_callocN(sizeof(*space_outliner->runtime), - "SpaceOutliner_Runtime"); + space_outliner->runtime = MEM_cnew<SpaceOutliner_Runtime>("SpaceOutliner_Runtime"); } } static SpaceLink *outliner_duplicate(SpaceLink *sl) { SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - SpaceOutliner *space_outliner_new = MEM_dupallocN(space_outliner); + SpaceOutliner *space_outliner_new = MEM_new<SpaceOutliner>(__func__, *space_outliner); BLI_listbase_clear(&space_outliner_new->tree); space_outliner_new->treestore = NULL; @@ -390,7 +388,8 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) space_outliner_new->sync_select_dirty = WM_OUTLINER_SYNC_SELECT_FROM_ALL; if (space_outliner->runtime) { - space_outliner_new->runtime = MEM_dupallocN(space_outliner->runtime); + space_outliner_new->runtime = MEM_new<SpaceOutliner_Runtime>("SpaceOutliner_runtime dup", + *space_outliner->runtime); space_outliner_new->runtime->tree_display = NULL; space_outliner_new->runtime->treehash = NULL; } @@ -417,7 +416,7 @@ static void outliner_id_remap(ScrArea *area, SpaceLink *slink, ID *old_id, ID *n bool changed = false; BLI_mempool_iternew(space_outliner->treestore, &iter); - while ((tselem = BLI_mempool_iterstep(&iter))) { + while ((tselem = reinterpret_cast<TreeStoreElem *>(BLI_mempool_iterstep(&iter)))) { if (tselem->id == old_id) { tselem->id = new_id; changed = true; @@ -444,14 +443,14 @@ static void outliner_id_remap(ScrArea *area, SpaceLink *slink, ID *old_id, ID *n static void outliner_deactivate(struct ScrArea *area) { /* Remove hover highlights */ - SpaceOutliner *space_outliner = area->spacedata.first; + SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(area->spacedata.first); outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED_ANY, false); ED_region_tag_redraw_no_rebuild(BKE_area_find_region_type(area, RGN_TYPE_WINDOW)); } void ED_spacetype_outliner(void) { - SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_cnew<SpaceType>("spacetype time"); ARegionType *art; st->spaceid = SPACE_OUTLINER; @@ -469,7 +468,7 @@ void ED_spacetype_outliner(void) st->context = outliner_context; /* regions: main window */ - art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region"); + art = MEM_cnew<ARegionType>("spacetype outliner region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; @@ -481,7 +480,7 @@ void ED_spacetype_outliner(void) BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region"); + art = MEM_cnew<ARegionType>("spacetype outliner header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; diff --git a/source/blender/editors/space_outliner/tree/tree_display_data.cc b/source/blender/editors/space_outliner/tree/tree_display_data.cc index 8a5c2e7d9f3..f0c94257917 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_data.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_data.cc @@ -23,7 +23,7 @@ #include "RNA_access.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc index 461104e6bad..8b6096dea7f 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc @@ -28,7 +28,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc b/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc index eeb3ca6893a..3efdaa51921 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc @@ -26,7 +26,7 @@ #include "BKE_main.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_override_library.cc b/source/blender/editors/space_outliner/tree/tree_display_override_library.cc index bf9fba30c9f..b1aea801db4 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_override_library.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_override_library.cc @@ -28,7 +28,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_scenes.cc b/source/blender/editors/space_outliner/tree/tree_display_scenes.cc index 29442aace37..4b489479e28 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_scenes.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_scenes.cc @@ -24,7 +24,7 @@ #include "BKE_main.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc b/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc index aa28b164584..26afb720197 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc @@ -26,7 +26,7 @@ #include "SEQ_sequencer.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc index ebbc9baaa9f..7782abd7c11 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc @@ -32,7 +32,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc b/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc index c0fef7c98e2..8b0afb28588 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc @@ -25,7 +25,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_anim_data.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_collection.cc b/source/blender/editors/space_outliner/tree/tree_element_collection.cc index 1add61db7f1..c1894733c62 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_collection.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_collection.cc @@ -22,7 +22,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_collection.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_driver.cc b/source/blender/editors/space_outliner/tree/tree_element_driver.cc index 42f51908eaa..9fd1d18ba80 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_driver.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_driver.cc @@ -27,7 +27,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_driver.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc index 91e6fdcde4b..6f5db2b3f12 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc @@ -22,7 +22,7 @@ #include "DNA_gpencil_types.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_element_gpencil_layer.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc index 7ff5a3285f1..7b73c33f510 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -29,7 +29,7 @@ #include "RNA_access.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_id_library.hh" #include "tree_element_id_scene.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_library.cc b/source/blender/editors/space_outliner/tree/tree_element_id_library.cc index 36f536c9845..9261b2ca537 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id_library.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id_library.cc @@ -20,7 +20,7 @@ #include "DNA_listBase.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_element_id_library.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_scene.cc b/source/blender/editors/space_outliner/tree/tree_element_id_scene.cc index ae81b44a1e4..a92e3ba9089 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id_scene.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id_scene.cc @@ -20,7 +20,7 @@ #include "DNA_listBase.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_id_scene.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_nla.cc b/source/blender/editors/space_outliner/tree/tree_element_nla.cc index 65832e8f981..a4be8fa0fdc 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_nla.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_nla.cc @@ -25,7 +25,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_nla.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc index 731beb3956e..91f56d20a65 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc @@ -29,7 +29,7 @@ #include "RNA_access.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_overrides.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc b/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc index a46e8de1bdd..af058e9eea8 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc @@ -24,7 +24,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_scene_objects.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc index 7bb9405147e..86e680b20ad 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc @@ -24,7 +24,7 @@ #include "BLT_translation.h" -#include "../outliner_intern.h" +#include "../outliner_intern.hh" #include "tree_display.h" #include "tree_element_view_layer.hh" |