Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_utils.c
| Show All 17 Lines | |||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup spoutliner | * \ingroup spoutliner | ||||
| */ | */ | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "BLI_blenlib.h" | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "DNA_action_types.h" | #include "DNA_action_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| Show All 38 Lines | |||||
| /** | /** | ||||
| * Try to find an item under y-coordinate \a view_co_y (view-space). | * Try to find an item under y-coordinate \a view_co_y (view-space). | ||||
| * \note Recursive | * \note Recursive | ||||
| */ | */ | ||||
| TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops, | TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops, | ||||
| const ListBase *tree, | const ListBase *tree, | ||||
| float view_co_y) | float view_co_y) | ||||
| { | { | ||||
| for (TreeElement *te_iter = tree->first; te_iter; te_iter = te_iter->next) { | LISTBASE_FOREACH (TreeElement *, te_iter, tree) { | ||||
| if (view_co_y < (te_iter->ys + UI_UNIT_Y)) { | if (view_co_y < (te_iter->ys + UI_UNIT_Y)) { | ||||
| if (view_co_y >= te_iter->ys) { | if (view_co_y >= te_iter->ys) { | ||||
| /* co_y is inside this element */ | /* co_y is inside this element */ | ||||
| return te_iter; | return te_iter; | ||||
| } | } | ||||
| else if (TSELEM_OPEN(te_iter->store_elem, soops)) { | else if (TSELEM_OPEN(te_iter->store_elem, soops)) { | ||||
| /* co_y is lower than current element, possibly inside children */ | /* 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); | TreeElement *te_sub = outliner_find_item_at_y(soops, &te_iter->subtree, view_co_y); | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse) | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Find treestore that refers to given ID */ | /* Find treestore that refers to given ID */ | ||||
| TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id) | TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id) | ||||
| { | { | ||||
| for (TreeElement *te = lb->first; te; te = te->next) { | LISTBASE_FOREACH (TreeElement *, te, lb) { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (tselem->type == 0) { | if (tselem->type == 0) { | ||||
| if (tselem->id == id) { | if (tselem->id == id) { | ||||
| return te; | return te; | ||||
| } | } | ||||
| } | } | ||||
| TreeElement *tes = outliner_find_id(soops, &te->subtree, id); | TreeElement *tes = outliner_find_id(soops, &te->subtree, id); | ||||
| if (tes) { | if (tes) { | ||||
| return tes; | return tes; | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan) | TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan) | ||||
| { | { | ||||
| for (TreeElement *te = lb->first; te; te = te->next) { | LISTBASE_FOREACH (TreeElement *, te, lb) { | ||||
| if (te->directdata == pchan) { | if (te->directdata == pchan) { | ||||
| return te; | return te; | ||||
| } | } | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (ELEM(tselem->type, TSE_POSE_BASE, TSE_POSE_CHANNEL)) { | if (ELEM(tselem->type, TSE_POSE_BASE, TSE_POSE_CHANNEL)) { | ||||
| TreeElement *tes = outliner_find_posechannel(&te->subtree, pchan); | TreeElement *tes = outliner_find_posechannel(&te->subtree, pchan); | ||||
| if (tes) { | if (tes) { | ||||
| return tes; | return tes; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone) | TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone) | ||||
| { | { | ||||
| for (TreeElement *te = lb->first; te; te = te->next) { | LISTBASE_FOREACH (TreeElement *, te, lb) { | ||||
| if (te->directdata == ebone) { | if (te->directdata == ebone) { | ||||
| return te; | return te; | ||||
| } | } | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (ELEM(tselem->type, 0, TSE_EBONE)) { | if (ELEM(tselem->type, 0, TSE_EBONE)) { | ||||
| TreeElement *tes = outliner_find_editbone(&te->subtree, ebone); | TreeElement *tes = outliner_find_editbone(&te->subtree, ebone); | ||||
| if (tes) { | if (tes) { | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | case SO_SCENES: | ||||
| break; | break; | ||||
| } | } | ||||
| return (num_columns * UI_UNIT_X + V2D_SCROLL_WIDTH); | return (num_columns * UI_UNIT_X + V2D_SCROLL_WIDTH); | ||||
| } | } | ||||
| /* Find first tree element in tree with matching treestore flag */ | /* Find first tree element in tree with matching treestore flag */ | ||||
| TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag) | TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag) | ||||
| { | { | ||||
| for (TreeElement *te = lb->first; te; te = te->next) { | LISTBASE_FOREACH (TreeElement *, te, lb) { | ||||
| if ((TREESTORE(te)->flag & flag) == flag) { | if ((TREESTORE(te)->flag & flag) == flag) { | ||||
| return te; | return te; | ||||
| } | } | ||||
| TreeElement *active_element = outliner_find_element_with_flag(&te->subtree, flag); | TreeElement *active_element = outliner_find_element_with_flag(&te->subtree, flag); | ||||
| if (active_element) { | if (active_element) { | ||||
| return active_element; | return active_element; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||