[Bf-blender-cvs] [e9a43a3b606] master: Cleanup: Remove Outliner C-API headers/wrappers
Julian Eisel
noreply at git.blender.org
Fri Jan 14 19:28:30 CET 2022
Commit: e9a43a3b6060b57b75e42f27c288608352f000ea
Author: Julian Eisel
Date: Fri Jan 14 18:00:21 2022 +0100
Branches: master
https://developer.blender.org/rBe9a43a3b6060b57b75e42f27c288608352f000ea
Cleanup: Remove Outliner C-API headers/wrappers
Basically this removes any C <-> C++ glue code. C++ types are accessed
directly via the public C++ APIs.
Contains some related changes like, moving functions that were
previously declared in a now removed header to a different file, whose
header is the more appropriate place (and the source file as well).
But generally I tried to avoid other changes.
===================================================================
M source/blender/editors/space_outliner/CMakeLists.txt
M source/blender/editors/space_outliner/outliner_draw.cc
M source/blender/editors/space_outliner/outliner_intern.hh
M source/blender/editors/space_outliner/outliner_tree.cc
M source/blender/editors/space_outliner/space_outliner.cc
M source/blender/editors/space_outliner/tree/common.cc
A source/blender/editors/space_outliner/tree/common.hh
M source/blender/editors/space_outliner/tree/tree_display.cc
D source/blender/editors/space_outliner/tree/tree_display.h
M source/blender/editors/space_outliner/tree/tree_display.hh
M source/blender/editors/space_outliner/tree/tree_display_data.cc
M source/blender/editors/space_outliner/tree/tree_display_libraries.cc
M source/blender/editors/space_outliner/tree/tree_display_orphaned.cc
M source/blender/editors/space_outliner/tree/tree_display_override_library.cc
M source/blender/editors/space_outliner/tree/tree_display_scenes.cc
M source/blender/editors/space_outliner/tree/tree_display_sequencer.cc
M source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
M source/blender/editors/space_outliner/tree/tree_element.cc
D source/blender/editors/space_outliner/tree/tree_element.h
M source/blender/editors/space_outliner/tree/tree_element.hh
M source/blender/editors/space_outliner/tree/tree_element_anim_data.cc
M source/blender/editors/space_outliner/tree/tree_element_collection.cc
M source/blender/editors/space_outliner/tree/tree_element_driver.cc
M source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc
M source/blender/editors/space_outliner/tree/tree_element_id.cc
M source/blender/editors/space_outliner/tree/tree_element_id.hh
M source/blender/editors/space_outliner/tree/tree_element_id_library.cc
M source/blender/editors/space_outliner/tree/tree_element_id_library.hh
M source/blender/editors/space_outliner/tree/tree_element_id_scene.cc
M source/blender/editors/space_outliner/tree/tree_element_nla.cc
M source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc
M source/blender/editors/space_outliner/tree/tree_element_scene_objects.hh
M source/blender/editors/space_outliner/tree/tree_element_view_layer.cc
===================================================================
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index 5530a1e0416..cac9d4131f8 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -69,9 +69,8 @@ set(SRC
tree/tree_element_view_layer.cc
outliner_intern.hh
- tree/tree_display.h
+ tree/common.hh
tree/tree_display.hh
- tree/tree_element.h
tree/tree_element.hh
tree/tree_element_anim_data.hh
tree/tree_element_collection.hh
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index 07c25a57f08..bc4b4e4f3b8 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -79,7 +79,10 @@
#include "RNA_access.h"
#include "outliner_intern.hh"
-#include "tree/tree_display.h"
+#include "tree/tree_display.hh"
+#include "tree/tree_element.hh"
+
+using namespace blender::ed::outliner;
/* Disable - this is far too slow - campbell. */
/* #define USE_GROUP_SELECT */
@@ -3861,9 +3864,10 @@ void draw_outliner(const bContext *C)
const bool use_mode_column = (space_outliner->flag & SO_MODE_COLUMN) &&
(ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES));
- const bool use_warning_column =
- ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_OVERRIDES_LIBRARY) &&
- outliner_tree_display_warnings_poll(space_outliner->runtime->tree_display);
+ const bool use_warning_column = ELEM(space_outliner->outlinevis,
+ SO_LIBRARIES,
+ SO_OVERRIDES_LIBRARY) &&
+ space_outliner->runtime->tree_display->hasWarnings();
/* Draw outliner stuff (background, hierarchy lines and names). */
const float restrict_column_width = outliner_restrict_columns_width(space_outliner);
diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh
index a11f325ef05..880d0bd7fb1 100644
--- a/source/blender/editors/space_outliner/outliner_intern.hh
+++ b/source/blender/editors/space_outliner/outliner_intern.hh
@@ -47,15 +47,24 @@ struct bPoseChannel;
struct wmKeyConfig;
struct wmOperatorType;
-typedef struct SpaceOutliner_Runtime {
- /** Internal C++ object to create and manage the tree for a specific display type (View Layers,
- * Scenes, Blender File, etc.). */
- struct TreeDisplay *tree_display;
+namespace blender::ed::outliner {
+class AbstractTreeDisplay;
+class AbstractTreeElement;
+} // namespace blender::ed::outliner
+
+struct SpaceOutliner_Runtime {
+ /** Object to create and manage the tree for a specific display type (View Layers, Scenes,
+ * Blender File, etc.). */
+ blender::ed::outliner::AbstractTreeDisplay *tree_display;
/** Pointers to tree-store elements, grouped by `(id, type, nr)`
* in hash-table for faster searching. */
struct GHash *treehash;
-} SpaceOutliner_Runtime;
+
+ SpaceOutliner_Runtime() = default;
+ /** Used for copying runtime data to a duplicated space. */
+ SpaceOutliner_Runtime(const SpaceOutliner_Runtime &);
+};
typedef enum TreeElementInsertType {
TE_INSERT_BEFORE,
@@ -82,7 +91,7 @@ typedef struct TreeElement {
* #TreeElement. Step by step, data should be moved to it and operations based on the type should
* become virtual methods of the class hierarchy.
*/
- struct TreeElementType *type;
+ blender::ed::outliner::AbstractTreeElement *type;
ListBase subtree;
int xs, ys; /* Do selection. */
@@ -269,6 +278,10 @@ void outliner_build_tree(struct Main *mainvar,
struct SpaceOutliner *space_outliner,
struct ARegion *region);
+struct TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
+ struct Collection *collection,
+ TreeElement *ten);
+
bool outliner_requires_rebuild_on_select_or_active_change(
const struct SpaceOutliner *space_outliner);
/**
diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc
index 18ed849dd26..477ed88cb87 100644
--- a/source/blender/editors/space_outliner/outliner_tree.cc
+++ b/source/blender/editors/space_outliner/outliner_tree.cc
@@ -77,13 +77,16 @@
#include "UI_resources.h"
#include "outliner_intern.hh"
-#include "tree/tree_display.h"
-#include "tree/tree_element.h"
+#include "tree/common.hh"
+#include "tree/tree_display.hh"
+#include "tree/tree_element.hh"
#ifdef WIN32
# include "BLI_math_base.h" /* M_PI */
#endif
+using namespace blender::ed::outliner;
+
/* prototypes */
static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
@@ -254,14 +257,6 @@ static void outliner_add_bone(SpaceOutliner *space_outliner,
}
}
-bool outliner_animdata_test(const AnimData *adt)
-{
- if (adt) {
- return (adt->action || adt->drivers.first || adt->nla_tracks.first);
- }
- return false;
-}
-
#ifdef WITH_FREESTYLE
static void outliner_add_line_styles(SpaceOutliner *space_outliner,
ListBase *lb,
@@ -815,40 +810,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
}
}
-bool outliner_element_warnings_get(TreeElement *te, int *r_icon, const char **r_message)
-{
- TreeStoreElem *tselem = TREESTORE(te);
-
- if (tselem->type != TSE_SOME_ID) {
- return false;
- }
- if (te->idcode != ID_LI) {
- return false;
- }
-
- Library *library = (Library *)tselem->id;
- if (library->tag & LIBRARY_TAG_RESYNC_REQUIRED) {
- if (r_icon) {
- *r_icon = ICON_ERROR;
- }
- if (r_message) {
- *r_message = TIP_(
- "Contains linked library overrides that need to be resynced, updating the library is "
- "recommended");
- }
- return true;
- }
- if (library->id.tag & LIB_TAG_MISSING) {
- if (r_icon) {
- *r_icon = ICON_ERROR;
- }
- if (r_message) {
- *r_message = TIP_("Missing library");
- }
- return true;
- }
- return false;
-}
+namespace blender::ed::outliner {
TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
ListBase *lb,
@@ -883,7 +845,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
BLI_assert(TREESTORE_ID_TYPE(id));
}
- TreeElement *te = MEM_cnew<TreeElement>(__func__);
+ TreeElement *te = MEM_new<TreeElement>(__func__);
/* add to the visual tree */
BLI_addtail(lb, te);
/* add to the storage */
@@ -898,9 +860,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
te->parent = parent;
te->index = index; /* For data arrays. */
- /* New C++ based type handle (`TreeElementType` in C, `AbstractTreeElement` in C++). Only some
- * support this, eventually this should replace `TreeElement` entirely. */
- te->type = outliner_tree_element_type_create(type, te, idv);
+ /* New C++ based type handle. Only some support this, eventually this should replace
+ * `TreeElement` entirely. */
+ te->type = outliner_tree_element_type_create(type, *te, idv);
if (te->type) {
/* Element types ported to the new design are expected to have their name set at this point! */
BLI_assert(te->name != nullptr);
@@ -947,14 +909,14 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
te->idcode = GS(id->name);
}
- if (te->type && outliner_tree_element_type_is_expand_valid(te->type)) {
- outliner_tree_element_type_expand(te->type, space_outliner);
+ if (te->type && te->type->isExpandValid()) {
+ tree_element_expand(*te->type, *space_outliner);
}
else if (type == TSE_SOME_ID) {
/* ID types not (fully) ported to new design yet. */
- if (outliner_tree_element_type_expand_poll(te->type, space_outliner)) {
+ if (te->type->expandPoll(*space_outliner)) {
outliner_add_id_contents(space_outliner, te, tselem, id);
- outliner_tree_element_type_post_expand(te->type, space_outliner);
+ te->type->postExpand(*space_outliner);
}
}
else if (ELEM(type,
@@ -1161,6 +1123,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
return te;
}
+} // namespace blender::ed::outliner
+
/* ======================================================= */
BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collection)
@@ -1200,30 +1164,6 @@ TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
/* ======================================================= */
/* Generic Tree Building helpers - order these are called is top to bottom */
-/* Hierarchy --------------------------------------------- */
-
-void outliner_make_object_parent_hierarchy(ListBase *lb)
-{
- /* build hierarchy */
- /* XXX also, set extents here... */
- TreeElement *te = reinterpret_cast<TreeElement *>(lb->first);
- while (te) {
- TreeElement *ten = te->next;
- TreeStoreElem *tselem = TREESTORE(te);
-
- if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_OB) {
- Object *ob = (Object *)tselem->id;
- if (ob->parent && ob->parent->id.newid) {
- BLI_remlink(lb, te);
- TreeElement *tep = (TreeElement *)ob->parent->id.newid;
- BLI_addtail(&tep->subtree, te);
- te->parent = tep;
- }
- }
- te = ten;
- }
-}
-
/* Sorting ------------------------------------------------------ */
struct tTreeSort {
@@ -1942,8 +1882,8 @@ 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(
- (eSpaceOutliner_Mode)space_outliner->outlinevis, space_outliner);
+ space_outliner->runtime->tree_display = outliner_tree_display_create(space_outliner->outlinevis,
+ space_outliner);
/* All tree displays should be crea
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list