Fix: Outliner walk navigation in Data API mode

Because the subtrees in Data API mode are empty for performance reasons,
it was impossible to move through the tree with walk navigation. This
adds an exception to allow walk navigation to expand subtrees in that
mode.
This commit is contained in:
Nathan Craddock 2020-08-27 09:41:05 -06:00
parent 2a0e996d77
commit e726ed3c6b
3 changed files with 19 additions and 11 deletions

View File

@ -150,10 +150,18 @@ void OUTLINER_OT_highlight_update(wmOperatorType *ot)
* \{ */
/* Open or close a tree element, optionally toggling all children recursively */
void outliner_item_openclose(TreeElement *te, bool open, bool toggle_all)
void outliner_item_openclose(SpaceOutliner *space_outliner,
TreeElement *te,
bool open,
bool toggle_all)
{
TreeStoreElem *tselem = TREESTORE(te);
/* Prevent opening leaf elements in the tree unless in the Data API display mode because in that
* mode subtrees are empty unless expanded. */
if (space_outliner->outlinevis != SO_DATA_API && BLI_listbase_is_empty(&te->subtree)) {
return;
}
TreeStoreElem *tselem = TREESTORE(te);
if (open) {
tselem->flag &= ~TSE_CLOSED;
}
@ -191,7 +199,7 @@ static int outliner_item_openclose_modal(bContext *C, wmOperator *op, const wmEv
/* Only toggle openclose on the same level as the first clicked element */
if (te->xs == data->x_location) {
outliner_item_openclose(te, data->open, false);
outliner_item_openclose(space_outliner, te, data->open, false);
outliner_tag_redraw_avoid_rebuild_on_open_change(space_outliner, region);
}
@ -232,7 +240,7 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE
const bool open = (tselem->flag & TSE_CLOSED) ||
(toggle_all && (outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1)));
outliner_item_openclose(te, open, toggle_all);
outliner_item_openclose(space_outliner, te, open, toggle_all);
outliner_tag_redraw_avoid_rebuild_on_open_change(space_outliner, region);
/* Only toggle once for single click toggling */

View File

@ -374,7 +374,10 @@ void item_object_mode_exit_fn(struct bContext *C,
void outliner_set_coordinates(struct ARegion *region, struct SpaceOutliner *space_outliner);
void outliner_item_openclose(TreeElement *te, bool open, bool toggle_all);
void outliner_item_openclose(struct SpaceOutliner *space_outliner,
TreeElement *te,
bool open,
bool toggle_all);
/* outliner_dragdrop.c */
void outliner_dropboxes(void);

View File

@ -1647,7 +1647,7 @@ static TreeElement *outliner_walk_left(SpaceOutliner *space_outliner,
TreeStoreElem *tselem = TREESTORE(te);
if (TSELEM_OPEN(tselem, space_outliner)) {
outliner_item_openclose(te, false, toggle_all);
outliner_item_openclose(space_outliner, te, false, toggle_all);
}
/* Only walk up a level if the element is closed and not toggling expand */
else if (!toggle_all && te->parent) {
@ -1667,11 +1667,8 @@ static TreeElement *outliner_walk_right(SpaceOutliner *space_outliner,
if (!toggle_all && TSELEM_OPEN(tselem, space_outliner) && !BLI_listbase_is_empty(&te->subtree)) {
te = te->subtree.first;
}
/* Prevent opening leaf elements in the tree.
* This cannot be done in `outliner_item_openclose` because the Data API display mode subtrees
* are empty unless expanded. */
else if (!BLI_listbase_is_empty(&te->subtree)) {
outliner_item_openclose(te, true, toggle_all);
else {
outliner_item_openclose(space_outliner, te, true, toggle_all);
}
return te;