diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-02-28 23:35:29 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-02-28 23:37:15 +0300 |
commit | f35907444eb433a41f586a7efe4090a954c305a0 (patch) | |
tree | 532ae169a03a0895a61ffbdbf3971215db4d36bb /source/blender/editors/space_outliner/outliner_edit.c | |
parent | 3176bb83469df9dcba1f8243763bf182daeea6bb (diff) |
Cleanup: Add outliner_utils.c, move functions into it
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_edit.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_edit.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 2ab506ea746..fe31a796e4d 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -149,99 +149,6 @@ TreeElement *outliner_dropzone_find(const SpaceOops *soops, const float fmval[2] return NULL; } -/** - * Try to find an item under y-coordinate \a view_co_y (view-space). - * \note Recursive - */ -TreeElement *outliner_find_item_at_y(const SpaceOops *soops, const ListBase *tree, float view_co_y) -{ - for (TreeElement *te_iter = tree->first; te_iter; te_iter = te_iter->next) { - if (view_co_y < (te_iter->ys + UI_UNIT_Y)) { - if (view_co_y > te_iter->ys) { - /* co_y is inside this element */ - return te_iter; - } - else if (TSELEM_OPEN(te_iter->store_elem, soops)) { - /* co_y is lower than current element, possibly inside children */ - TreeElement *te_sub = outliner_find_item_at_y(soops, &te_iter->subtree, view_co_y); - if (te_sub) { - return te_sub; - } - } - } - } - - return NULL; -} - -/** - * Collapsed items can show their children as click-able icons. This function tries to find - * such an icon that represents the child item at x-coordinate \a view_co_x (view-space). - * - * \return a hovered child item or \a parent_te (if no hovered child found). - */ -TreeElement *outliner_find_item_at_x_in_row(const SpaceOops *soops, const TreeElement *parent_te, float view_co_x) -{ - if (!TSELEM_OPEN(TREESTORE(parent_te), soops)) { /* if parent_te is opened, it doesn't show childs in row */ - /* no recursion, items can only display their direct children in the row */ - for (TreeElement *child_te = parent_te->subtree.first; - child_te && view_co_x >= child_te->xs; /* don't look further if co_x is smaller than child position*/ - child_te = child_te->next) - { - if ((child_te->flag & TE_ICONROW) && (view_co_x > child_te->xs) && (view_co_x < child_te->xend)) { - return child_te; - } - } - } - - /* return parent if no child is hovered */ - return (TreeElement *)parent_te; -} - -/** - * Iterate over all tree elements (pre-order traversal), executing \a func callback for - * each tree element matching the optional filters. - * - * \param filter_te_flag: If not 0, only TreeElements with this flag will be visited. - * \param filter_tselem_flag: Same as \a filter_te_flag, but for the TreeStoreElem. - * \param func: Custom callback to execute for each visited item. - */ -bool outliner_tree_traverse(const SpaceOops *soops, ListBase *tree, int filter_te_flag, int filter_tselem_flag, - TreeTraversalFunc func, void *customdata) -{ - for (TreeElement *te = tree->first, *te_next; te; te = te_next) { - TreeTraversalReturn func_retval = TRAVERSE_CONTINUE; - /* in case te is freed in callback */ - TreeStoreElem *tselem = TREESTORE(te); - ListBase subtree = te->subtree; - te_next = te->next; - - if (filter_te_flag && (te->flag & filter_te_flag) == 0) { - /* skip */ - } - else if (filter_tselem_flag && (tselem->flag & filter_tselem_flag) == 0) { - /* skip */ - } - else { - func_retval = func(te, customdata); - } - /* Don't access te or tselem from now on! Might've been freed... */ - - if (func_retval == TRAVERSE_BREAK) { - return false; - } - - if (func_retval == TRAVERSE_SKIP_CHILDS) { - /* skip */ - } - else if (!outliner_tree_traverse(soops, &subtree, filter_te_flag, filter_tselem_flag, func, customdata)) { - return false; - } - } - - return true; -} - /* ************************************************************** */ |