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 <eiseljulian@gmail.com>2017-02-28 22:37:14 +0300
committerJulian Eisel <eiseljulian@gmail.com>2017-02-28 23:15:51 +0300
commitc0e055fa7e4b171b9a188bc2328c6c11d2af22ab (patch)
treec00febbae447a1a533af520ef8480d19ce38f4be /source/blender/editors/space_outliner/outliner_tree.c
parent5e889ebf19ae1bd3daf6930473dc1d19029bf837 (diff)
Outliner: Delete all selected collections, not just active one
There were some issues with how we store outliner tree elements: Apparently the only removable elements have been data-blocks so far. When recreating the TreeElements, their TreeStoreElem instances were mainly identified by their ID pointer. However non-data-blocks mostly depend on an index. For collections, such an index isn't a reliable measure though if we want to allow removing items. Depending on it for identifying the TreeStoreElem instance would cause some quite noticeable glitches (wrong highlights, two elements sharing highlight, etc). For now I've solved that by actually removing the TreeStoreElem that represents the removed element. A little limitation of this is that after undoing the removal, some information might get lost, like flags to store selection, or opened/closed state. A better solution that would also fix this issue would be having a real unique identifier for each non-data-block element, like an idname or even its data-pointer. Not sure if we can get those to work reliable with file read/write though, would have to investigate... Also added a general Outliner tree traversal utility.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tree.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index b0b99692405..7fb6eacb731 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1240,6 +1240,15 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
return te;
}
+/**
+ * \note Really only removes \a tselem, not it's TreeElement instance or any children.
+ */
+void outliner_remove_treestore_element(SpaceOops *soops, TreeStoreElem *tselem)
+{
+ BKE_outliner_treehash_remove_element(soops->treehash, tselem);
+ BLI_mempool_free(soops->treestore, tselem);
+}
+
/* ======================================================= */
/* Sequencer mode tree building */
@@ -1387,10 +1396,12 @@ static void outliner_collections_reorder(const Scene *scene, TreeElement *insert
}
static void outliner_add_layer_collections_recursive(SpaceOops *soops, ListBase *tree, Scene *scene,
- ListBase *layer_collections, TreeElement *parent_ten)
+ ListBase *layer_collections, TreeElement *parent_ten,
+ int *io_collection_counter)
{
for (LayerCollection *collection = layer_collections->first; collection; collection = collection->next) {
- TreeElement *ten = outliner_add_element(soops, tree, scene, parent_ten, TSE_LAYER_COLLECTION, 0);
+ TreeElement *ten = outliner_add_element(soops, tree, scene, parent_ten, TSE_LAYER_COLLECTION,
+ (*io_collection_counter)++);
ten->name = collection->scene_collection->name;
ten->directdata = collection;
@@ -1401,12 +1412,14 @@ static void outliner_add_layer_collections_recursive(SpaceOops *soops, ListBase
}
outliner_make_hierarchy(&ten->subtree);
- outliner_add_layer_collections_recursive(soops, &ten->subtree, scene, &collection->layer_collections, ten);
+ outliner_add_layer_collections_recursive(soops, &ten->subtree, scene, &collection->layer_collections, ten,
+ io_collection_counter);
}
}
static void outliner_add_collections_act_layer(SpaceOops *soops, SceneLayer *layer, Scene *scene)
{
- outliner_add_layer_collections_recursive(soops, &soops->tree, scene, &layer->layer_collections, NULL);
+ int collection_counter = 0;
+ outliner_add_layer_collections_recursive(soops, &soops->tree, scene, &layer->layer_collections, NULL, &collection_counter);
}
static void outliner_add_scene_collection_init(TreeElement *te, SceneCollection *collection)