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:
authorJulian Eisel <julian@blender.org>2020-11-06 22:54:20 +0300
committerJulian Eisel <julian@blender.org>2020-11-11 20:51:57 +0300
commit249e4df110e0a5ca7ebb24a7503f922b28d10405 (patch)
tree28eef9acc37ad29a0c2fc8beb73532d5eb0638bb /source/blender/editors/space_outliner/space_outliner.c
parent5b5ec0a2e910a42d7c02774a47fd9c70b6f16f06 (diff)
UI Code Quality: Start refactoring Outliner tree building (using C++)
This introduces a new C++ abstraction "tree-display" (in this commit named tree-view, renamed in a followup) to help constructing and managing the tree for the different display types (View Layer, Scene, Blender file, etc.). See https://developer.blender.org/D9499 for more context. Other developers approved this rather significantly different design approach there. ---- Motivation General problems with current design: * The Outliner tree building code is messy and hard to follow. * Hard-coded display mode checks are scattered over many places. * Data is passed around in rather unsafe ways (e.g. lots of `void *`). * There are no individually testable units. * Data-structure use is inefficient. The current Outliner code needs quite some untangling, the tree building seems like a good place to start. This and the followup commits tackle that. ---- Design Idea Idea is to have an abstract base class (`AbstractTreeDisplay`), and then sub-classes with the implementation for each display type (e.g. `TreeDisplayViewLayer`, `TreeDisplayDataAPI`, etc). The tree-display is kept alive until tree-rebuild as runtime data of the space, so that further queries based on the display type can be executed (e.g. "does the display support selection syncing?", "does it support restriction toggle columns?", etc.). New files are in a new `space_outliner/tree` sub-directory. With the new design, display modes become proper units, making them more maintainable, safer and testable. It should also be easier now to add new display modes.
Diffstat (limited to 'source/blender/editors/space_outliner/space_outliner.c')
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 8be7f4d1bad..ce772043e3b 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -351,11 +351,21 @@ static void outliner_free(SpaceLink *sl)
if (space_outliner->treehash) {
BKE_outliner_treehash_free(space_outliner->treehash);
}
+
+ if (space_outliner->runtime) {
+ MEM_freeN(space_outliner->runtime);
+ }
}
/* spacetype; init callback */
-static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
+static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *area)
{
+ SpaceOutliner *space_outliner = area->spacedata.first;
+
+ if (space_outliner->runtime == NULL) {
+ space_outliner->runtime = MEM_callocN(sizeof(*space_outliner->runtime),
+ "SpaceOutliner_Runtime");
+ }
}
static SpaceLink *outliner_duplicate(SpaceLink *sl)
@@ -369,6 +379,10 @@ 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);
+ }
+
return (SpaceLink *)space_outliner_new;
}