diff options
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_utils.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_utils.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index d39a9387a6a..5dfdf6f129b 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -327,12 +327,68 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops) return (num_columns * UI_UNIT_X + V2D_SCROLL_WIDTH); } +/* Find first tree element in tree with matching treestore flag */ +TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag) +{ + for (TreeElement *te = lb->first; te; te = te->next) { + if ((TREESTORE(te)->flag & flag) == flag) { + return te; + } + TreeElement *active_element = outliner_find_element_with_flag(&te->subtree, flag); + if (active_element) { + return active_element; + } + } + return NULL; +} + +/* Find if element is visible in the outliner tree */ +bool outliner_is_element_visible(const TreeElement *te) +{ + TreeStoreElem *tselem; + + while (te->parent) { + tselem = TREESTORE(te->parent); + + if (tselem->flag & TSE_CLOSED) { + return false; + } + else { + te = te->parent; + } + } + + return true; +} + /* Find if x coordinate is over element disclosure toggle */ bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x) { return (view_co_x > te->xs) && (view_co_x < te->xs + UI_UNIT_X); } +/* Scroll view vertically while keeping within total bounds */ +void outliner_scroll_view(ARegion *ar, int delta_y) +{ + int y_min = MIN2(ar->v2d.cur.ymin, ar->v2d.tot.ymin); + + ar->v2d.cur.ymax += delta_y; + ar->v2d.cur.ymin += delta_y; + + /* Adjust view if delta placed view outside total area */ + int offset; + if (ar->v2d.cur.ymax > -UI_UNIT_Y) { + offset = ar->v2d.cur.ymax; + ar->v2d.cur.ymax -= offset; + ar->v2d.cur.ymin -= offset; + } + else if (ar->v2d.cur.ymin < y_min) { + offset = y_min - ar->v2d.cur.ymin; + ar->v2d.cur.ymax += offset; + ar->v2d.cur.ymin += offset; + } +} + /* Get base of object under cursor. Used for eyedropper tool */ Base *ED_outliner_give_base_under_cursor(bContext *C, const int mval[2]) { |