diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-06-26 03:04:07 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-06-28 14:38:04 +0300 |
commit | 40a1c671655c7583bc6d6e0d339e5033c156028f (patch) | |
tree | 2f9800937c5b0209a6870af5229398f2ac010643 /source/blender/editors/space_outliner/outliner_tree.c | |
parent | 782813e4633eaeddb9067949ed68d6a377f8a8b3 (diff) |
Fix T65263: Outliner doesn't display selected object if parent not selected
This works for most situations, however if you have:
```
A
|-> B
|--> C
```
And only A and C are selected, C will be shown nested under A, instead
being by its side.
I still have to think on how to address these cases since they are
slightly misleading.
Related: T65263.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5134
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tree.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 2a0bc470bcb..d428a190549 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -2126,6 +2126,45 @@ static bool outliner_filter_has_name(TreeElement *te, const char *name, int flag return fnmatch(name, te->name, fn_flag) == 0; } +static bool outliner_element_is_collection_or_object(TreeElement *te) +{ + TreeStoreElem *tselem = TREESTORE(te); + + if ((tselem->type == 0) && (te->idcode == ID_OB)) { + return true; + } + else if (outliner_is_collection_tree_element(te)) { + return true; + } + + return false; +} + +static TreeElement *outliner_extract_children_from_subtree(TreeElement *element, + ListBase *parent_subtree) +{ + TreeElement *te_next = element->next; + + if (outliner_element_is_collection_or_object(element)) { + TreeElement *te_prev = NULL; + for (TreeElement *te = element->subtree.last; te; te = te_prev) { + te_prev = te->prev; + + if (!outliner_element_is_collection_or_object(te)) { + continue; + } + + te_next = te; + BLI_remlink(&element->subtree, te); + BLI_insertlinkafter(parent_subtree, element->prev, te); + te->parent = element->parent; + } + } + + outliner_free_tree_element(element, parent_subtree); + return te_next; +} + static int outliner_filter_subtree(SpaceOutliner *soops, ViewLayer *view_layer, ListBase *lb, @@ -2137,9 +2176,9 @@ static int outliner_filter_subtree(SpaceOutliner *soops, for (te = lb->first; te; te = te_next) { te_next = te->next; - if ((outliner_element_visible_get(view_layer, te, exclude_filter) == false)) { - outliner_free_tree_element(te, lb); + /* Don't free the tree, but extract the children from the parent and add to this tree. */ + te_next = outliner_extract_children_from_subtree(te, lb); continue; } else if ((exclude_filter & SO_FILTER_SEARCH) == 0) { |