diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-01-26 13:42:15 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-01-26 13:45:20 +0300 |
commit | de079abfbd707247d8bb8318116d1429b3279703 (patch) | |
tree | abd947cb90366451da5353ec6a7c643d2716834c /source/blender/editors/space_outliner/outliner_ops.c | |
parent | 13238ee991ad9ec72330b7a23bfc1173f3a57e0f (diff) |
Outliner tooltips: Small refactor, future proof change
In the future we may have siblings to collections (like overrides) that are not
collections. This change make sure tooltips will keep working.
Note: This was originally wrongly committed together with a Collada fix,
re-committing separately now. See bd7060a87fd9.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_ops.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_ops.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 599096c0ee9..ff322b49a27 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -250,21 +250,36 @@ static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEv return retval; } +/** + * Check if the given TreeElement is a collection + * + * This test is mainly used to see if next/prev TreeElement is a collection. + * It will fail when there is no next/prev TreeElement, or when the + * element is an Override or something else in the future. + */ +static bool tree_element_is_collection_get(const TreeElement *te) { + if (te == NULL) { + return false; + } + + TreeStoreElem *tselem = TREESTORE(te); + return ELEM(tselem->type, TSE_LAYER_COLLECTION, TSE_SCENE_COLLECTION); +} + static const char *outliner_drag_drop_tooltip_get( const TreeElement *te_float) { const char *name = NULL; - TreeStoreElem *tselem = TREESTORE(te_float); const TreeElement *te_insert = te_float->drag_data->insert_handle; - if (ELEM(tselem->type, TSE_LAYER_COLLECTION, TSE_SCENE_COLLECTION)) { + if (tree_element_is_collection_get(te_float)) { if (te_insert == NULL) { name = TIP_("Move collection"); } else { switch (te_float->drag_data->insert_type) { case TE_INSERT_BEFORE: - if (te_insert->prev) { + if (tree_element_is_collection_get(te_insert->prev)) { name = TIP_("Move between collections"); } else { @@ -272,7 +287,7 @@ static const char *outliner_drag_drop_tooltip_get( } break; case TE_INSERT_AFTER: - if (te_insert->next) { + if (tree_element_is_collection_get(te_insert->next)) { name = TIP_("Move between collections"); } else { @@ -285,7 +300,7 @@ static const char *outliner_drag_drop_tooltip_get( } } } - else if ((tselem->type == 0) && (te_float->idcode == ID_OB)) { + else if ((TREESTORE(te_float)->type == 0) && (te_float->idcode == ID_OB)) { name = TIP_("Move to collection (Ctrl to add)"); } |