Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_intern.hh')
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.hh39
1 files changed, 30 insertions, 9 deletions
diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh
index 9065f7f9cc1..efbd8a32716 100644
--- a/source/blender/editors/space_outliner/outliner_intern.hh
+++ b/source/blender/editors/space_outliner/outliner_intern.hh
@@ -27,6 +27,9 @@
#include "RNA_types.h"
+/* Needed for `tree_element_cast()`. */
+#include "tree/tree_element.hh"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -54,10 +57,12 @@ class AbstractTreeDisplay;
class AbstractTreeElement;
} // namespace blender::ed::outliner
+namespace outliner = blender::ed::outliner;
+
struct SpaceOutliner_Runtime {
/** Object to create and manage the tree for a specific display type (View Layers, Scenes,
* Blender File, etc.). */
- std::unique_ptr<blender::ed::outliner::AbstractTreeDisplay> tree_display;
+ std::unique_ptr<outliner::AbstractTreeDisplay> tree_display;
/** Pointers to tree-store elements, grouped by `(id, type, nr)`
* in hash-table for faster searching. */
@@ -90,11 +95,12 @@ typedef struct TreeElement {
struct TreeElement *next, *prev, *parent;
/**
- * Handle to the new C++ object (a derived type of base #AbstractTreeElement) that should replace
- * #TreeElement. Step by step, data should be moved to it and operations based on the type should
- * become virtual methods of the class hierarchy.
+ * The new inheritance based representation of the element (a derived type of base
+ * #AbstractTreeElement) that should eventually replace #TreeElement. Step by step, data should
+ * be moved to it and operations based on the type should become virtual methods of the class
+ * hierarchy.
*/
- std::unique_ptr<blender::ed::outliner::AbstractTreeElement> type;
+ std::unique_ptr<outliner::AbstractTreeElement> abstract_element;
ListBase subtree;
int xs, ys; /* Do selection. */
@@ -104,8 +110,7 @@ typedef struct TreeElement {
short idcode; /* From TreeStore id. */
short xend; /* Width of item display, for select. */
const char *name;
- void *directdata; /* Armature Bones, Base, Sequence, Strip... */
- PointerRNA rnaptr; /* RNA Pointer. */
+ void *directdata; /* Armature Bones, Base, ... */
} TreeElement;
typedef struct TreeElementIcon {
@@ -140,7 +145,7 @@ typedef struct TreeElementIcon {
ID_GD, \
ID_LS, \
ID_LP, \
- ID_HA, \
+ ID_CV, \
ID_PT, \
ID_VO, \
ID_SIM) || /* Only in 'blendfile' mode ... :/ */ \
@@ -225,7 +230,7 @@ typedef enum {
* - not searching into RNA items helps but isn't the complete solution
*/
-#define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE)
+#define SEARCHING_OUTLINER(sov) ((sov)->search_flags & SO_SEARCH_RECURSIVE)
/* is the current element open? if so we also show children */
#define TSELEM_OPEN(telm, sv) \
@@ -686,3 +691,19 @@ int outliner_context(const struct bContext *C,
#ifdef __cplusplus
}
#endif
+
+namespace blender::ed::outliner {
+
+/**
+ * Helper to safely "cast" a #TreeElement to its new C++ #AbstractTreeElement, if possible.
+ * \return nullptr if the tree-element doesn't match the requested type \a TreeElementT or the
+ * element doesn't hold a C++ #AbstractTreeElement pendant yet.
+ */
+template<typename TreeElementT> TreeElementT *tree_element_cast(const TreeElement *te)
+{
+ static_assert(std::is_base_of_v<AbstractTreeElement, TreeElementT>,
+ "Requested tree-element type must be an AbstractTreeElement");
+ return dynamic_cast<TreeElementT *>(te->abstract_element.get());
+}
+
+} // namespace blender::ed::outliner