diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-11-20 12:45:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-11-20 12:45:03 +0300 |
commit | a8777f905846f80385fc90135e000c3169bbefc6 (patch) | |
tree | 928a7db22a8553abd35f99a0afe2990be87d69ac /source/blender/editors/space_outliner | |
parent | c0c696b014e3c21b923a2c21fb33a18839a3faa3 (diff) | |
parent | 65af15ad887b30e678db9acab75efc7897c9197e (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/space_outliner')
3 files changed, 60 insertions, 25 deletions
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 8d93f6bca55..1edb3c88396 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -196,7 +196,13 @@ eOLDrawState tree_element_type_active( TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive); eOLDrawState tree_element_active(struct bContext *C, struct Scene *scene, struct SceneLayer *sl, SpaceOops *soops, TreeElement *te, const eOLSetState set, const bool handle_all_types); -int outliner_item_activate_or_toggle_closed(struct bContext *C, int x, int y, bool extend, bool recursive); + +void outliner_item_do_activate_from_tree_element( + struct bContext *C, TreeElement *te, TreeStoreElem *tselem, + bool extend, bool recursive); +int outliner_item_do_activate_from_cursor( + struct bContext *C, const int mval[2], + bool extend, bool recursive); /* outliner_edit.c ---------------------------------------------- */ typedef void (*outliner_operation_cb)( diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 606cc2fd14a..670be7611e4 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -876,21 +876,25 @@ eOLDrawState tree_element_type_active( /* ================================================ */ -static void outliner_item_activate( - bContext *C, SpaceOops *soops, TreeElement *te, +/** + * Action when clicking to activate an item (typically under the mouse cursor), + * but don't do any cursor intersection checks. + * + * Needed to run from operators accessed from a menu. + */ +static void do_outliner_item_activate_tree_element( + bContext *C, Scene *scene, SceneLayer *sl, SpaceOops *soops, + TreeElement *te, TreeStoreElem *tselem, const bool extend, const bool recursive) { - Scene *scene = CTX_data_scene(C); - SceneLayer *sl = CTX_data_scene_layer(C); - TreeStoreElem *tselem = TREESTORE(te); - /* always makes active object, except for some specific types. * Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, we do not want * to switch out of edit mode (see T48328 for details). */ if (!ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, TSE_EBONE, TSE_LAYER_COLLECTION)) { - tree_element_set_active_object(C, scene, sl, soops, te, - (extend && tselem->type == 0) ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL, - recursive && tselem->type == 0); + tree_element_set_active_object( + C, scene, sl, soops, te, + (extend && tselem->type == 0) ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL, + recursive && tselem->type == 0); } if (tselem->type == 0) { // the lib blocks @@ -903,7 +907,7 @@ static void outliner_item_activate( else if (te->idcode == ID_GR) { Group *gr = (Group *)tselem->id; GroupObject *gob; - + if (extend) { int sel = BA_SELECT; for (gob = gr->gobject.first; gob; gob = gob->next) { @@ -989,7 +993,34 @@ static bool outliner_is_co_within_restrict_columns(const SpaceOops *soops, const (view_co_x > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)); } -int outliner_item_activate_or_toggle_closed(bContext *C, int x, int y, bool extend, bool recursive) +/** + * A version of #outliner_item_do_acticate_from_cursor that takes the tree element directly. + * and doesn't depend on the pointer position. + * + * This allows us to simulate clicking on an item without dealing with the mouse cursor. + */ +void outliner_item_do_activate_from_tree_element( + bContext *C, TreeElement *te, TreeStoreElem *tselem, + bool extend, bool recursive) +{ + Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + + do_outliner_item_activate_tree_element( + C, scene, sl, soops, + te, tselem, + extend, recursive); +} + +/** + * Action to run when clicking in the outliner, + * + * May expend/collapse branches or activate items. + * */ +int outliner_item_do_activate_from_cursor( + bContext *C, const int mval[2], + bool extend, bool recursive) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -997,7 +1028,7 @@ int outliner_item_activate_or_toggle_closed(bContext *C, int x, int y, bool exte float view_mval[2]; bool changed = false, rebuild_tree = false; - UI_view2d_region_to_view(&ar->v2d, x, y, &view_mval[0], &view_mval[1]); + UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]); if (outliner_is_co_within_restrict_columns(soops, ar, view_mval[0])) { return OPERATOR_CANCELLED; @@ -1012,11 +1043,14 @@ int outliner_item_activate_or_toggle_closed(bContext *C, int x, int y, bool exte rebuild_tree = true; } else { + Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); /* the row may also contain children, if one is hovered we want this instead of current te */ TreeElement *activate_te = outliner_find_item_at_x_in_row(soops, te, view_mval[0]); + TreeStoreElem *activate_tselem = TREESTORE(activate_te); outliner_item_select(soops, activate_te, extend, extend); - outliner_item_activate(C, soops, activate_te, extend, recursive); + do_outliner_item_activate_tree_element(C, scene, sl, soops, activate_te, activate_tselem, extend, recursive); changed = true; } @@ -1037,9 +1071,7 @@ static int outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEv { bool extend = RNA_boolean_get(op->ptr, "extend"); bool recursive = RNA_boolean_get(op->ptr, "recursive"); - int x = event->mval[0]; - int y = event->mval[1]; - return outliner_item_activate_or_toggle_closed(C, x, y, extend, recursive); + return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive); } void OUTLINER_OT_item_activate(wmOperatorType *ot) diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index ca168094ae2..79122de70dd 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -376,17 +376,14 @@ static void object_select_cb( } static void object_select_hierarchy_cb( - bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te), - TreeStoreElem *UNUSED(tsep), TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data)) + bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *te, + TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { - /* From where do i get the x,y coordinate of the mouse event ? */ - wmWindow *win = CTX_wm_window(C); - int x = win->eventstate->mval[0]; - int y = win->eventstate->mval[1]; - outliner_item_activate_or_toggle_closed(C, x, y, true, true); + /* Don't extend because this toggles, which is nice for Ctrl-Click but not for a menu item. + * it's especially confusing when multiple items are selected since some toggle on/off. */ + outliner_item_do_activate_from_tree_element(C, te, tselem, false, true); } - static void object_deselect_cb( bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) |