diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/editors/space_outliner/outliner_utils.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_utils.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_utils.c | 323 |
1 files changed, 167 insertions, 156 deletions
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index a44a6e605de..03d15088380 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -38,25 +38,27 @@ * Try to find an item under y-coordinate \a view_co_y (view-space). * \note Recursive */ -TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops, const ListBase *tree, float view_co_y) +TreeElement *outliner_find_item_at_y(const SpaceOutliner *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; + 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; } /** @@ -65,146 +67,150 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops, const ListBase * * \return a hovered child item or \a parent_te (if no hovered child found). */ -TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *soops, const TreeElement *parent_te, float view_co_x) +TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *soops, + const TreeElement *parent_te, + float view_co_x) { - /* if parent_te is opened, it doesn't show childs in row */ - if (!TSELEM_OPEN(TREESTORE(parent_te), soops)) { - /* no recursion, items can only display their direct children in the row */ - for (TreeElement *child_te = parent_te->subtree.first; - /* don't look further if co_x is smaller than child position*/ - child_te && view_co_x >= child_te->xs; - - 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; + /* if parent_te is opened, it doesn't show childs in row */ + if (!TSELEM_OPEN(TREESTORE(parent_te), soops)) { + /* no recursion, items can only display their direct children in the row */ + for (TreeElement *child_te = parent_te->subtree.first; + /* don't look further if co_x is smaller than child position*/ + child_te && view_co_x >= child_te->xs; + + 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; } /* Find specific item from the treestore */ TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem) { - TreeElement *te, *tes; - for (te = lb->first; te; te = te->next) { - if (te->store_elem == store_elem) { - return te; - } - tes = outliner_find_tree_element(&te->subtree, store_elem); - if (tes) { - return tes; - } - } - return NULL; + TreeElement *te, *tes; + for (te = lb->first; te; te = te->next) { + if (te->store_elem == store_elem) { + return te; + } + tes = outliner_find_tree_element(&te->subtree, store_elem); + if (tes) { + return tes; + } + } + return NULL; } /* Find parent element of te */ -TreeElement *outliner_find_parent_element(ListBase *lb, TreeElement *parent_te, const TreeElement *child_te) +TreeElement *outliner_find_parent_element(ListBase *lb, + TreeElement *parent_te, + const TreeElement *child_te) { - TreeElement *te; - for (te = lb->first; te; te = te->next) { - if (te == child_te) { - return parent_te; - } - - TreeElement *find_te = outliner_find_parent_element(&te->subtree, te, child_te); - if (find_te) { - return find_te; - } - } - return NULL; + TreeElement *te; + for (te = lb->first; te; te = te->next) { + if (te == child_te) { + return parent_te; + } + + TreeElement *find_te = outliner_find_parent_element(&te->subtree, te, child_te); + if (find_te) { + return find_te; + } + } + return NULL; } /* tse is not in the treestore, we use its contents to find a match */ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse) { - TreeStoreElem *tselem; + TreeStoreElem *tselem; - if (tse->id == NULL) { - return NULL; - } + if (tse->id == NULL) { + return NULL; + } - /* check if 'tse' is in treestore */ - tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); - if (tselem) { - return outliner_find_tree_element(&soops->tree, tselem); - } + /* check if 'tse' is in treestore */ + tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); + if (tselem) { + return outliner_find_tree_element(&soops->tree, tselem); + } - return NULL; + return NULL; } /* Find treestore that refers to given ID */ TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id) { - for (TreeElement *te = lb->first; te; te = te->next) { - TreeStoreElem *tselem = TREESTORE(te); - if (tselem->type == 0) { - if (tselem->id == id) { - return te; - } - } - - TreeElement *tes = outliner_find_id(soops, &te->subtree, id); - if (tes) { - return tes; - } - } - return NULL; + for (TreeElement *te = lb->first; te; te = te->next) { + TreeStoreElem *tselem = TREESTORE(te); + if (tselem->type == 0) { + if (tselem->id == id) { + return te; + } + } + + TreeElement *tes = outliner_find_id(soops, &te->subtree, id); + if (tes) { + return tes; + } + } + return NULL; } TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan) { - for (TreeElement *te = lb->first; te; te = te->next) { - if (te->directdata == pchan) { - return te; - } - - TreeStoreElem *tselem = TREESTORE(te); - if (ELEM(tselem->type, TSE_POSE_BASE, TSE_POSE_CHANNEL)) { - TreeElement *tes = outliner_find_posechannel(&te->subtree, pchan); - if (tes) { - return tes; - } - } - } - return NULL; + for (TreeElement *te = lb->first; te; te = te->next) { + if (te->directdata == pchan) { + return te; + } + + TreeStoreElem *tselem = TREESTORE(te); + if (ELEM(tselem->type, TSE_POSE_BASE, TSE_POSE_CHANNEL)) { + TreeElement *tes = outliner_find_posechannel(&te->subtree, pchan); + if (tes) { + return tes; + } + } + } + return NULL; } TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone) { - for (TreeElement *te = lb->first; te; te = te->next) { - if (te->directdata == ebone) { - return te; - } - - TreeStoreElem *tselem = TREESTORE(te); - if (ELEM(tselem->type, 0, TSE_EBONE)) { - TreeElement *tes = outliner_find_editbone(&te->subtree, ebone); - if (tes) { - return tes; - } - } - } - return NULL; + for (TreeElement *te = lb->first; te; te = te->next) { + if (te->directdata == ebone) { + return te; + } + + TreeStoreElem *tselem = TREESTORE(te); + if (ELEM(tselem->type, 0, TSE_EBONE)) { + TreeElement *tes = outliner_find_editbone(&te->subtree, ebone); + if (tes) { + return tes; + } + } + } + return NULL; } ID *outliner_search_back(SpaceOutliner *UNUSED(soops), TreeElement *te, short idcode) { - TreeStoreElem *tselem; - te = te->parent; - - while (te) { - tselem = TREESTORE(te); - if (tselem->type == 0 && te->idcode == idcode) { - return tselem->id; - } - te = te->parent; - } - return NULL; + TreeStoreElem *tselem; + te = te->parent; + + while (te) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == idcode) { + return tselem->id; + } + te = te->parent; + } + return NULL; } /** @@ -215,38 +221,43 @@ ID *outliner_search_back(SpaceOutliner *UNUSED(soops), TreeElement *te, short id * \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 SpaceOutliner *soops, ListBase *tree, int filter_te_flag, int filter_tselem_flag, - TreeTraversalFunc func, void *customdata) +bool outliner_tree_traverse(const SpaceOutliner *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) { - TreeTraversalAction 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; + for (TreeElement *te = tree->first, *te_next; te; te = te_next) { + TreeTraversalAction 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; } |