From 7ba971d6d855034d5a8f0e8dab1bcd892b5aabd3 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 10 Nov 2020 12:23:48 +0100 Subject: Fix T82553: Outliner F2 renaming issue when item is out of view - scrolling would be restricted (usually, if the object to be renamed is in view, this prevents scrolling away without finishing the rename operation) - renaming by typing and confirming with Enter was not possible (you would have to escape, scroll to the object and use F2 again) - other shortcuts like A and H are still active instead of being handled as text input Avoid all these issue by forcing the item into view using outliner_show_active / outliner_scroll_view. Maniphest Tasks: T82553 Differential Revision: https://developer.blender.org/D9521 --- source/blender/editors/space_outliner/outliner_edit.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/blender/editors/space_outliner/outliner_edit.c') diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 165d7bb2aa2..c1add28b1e4 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -83,6 +83,11 @@ #include "outliner_intern.h" +static void outliner_show_active(SpaceOutliner *space_outliner, + ARegion *region, + TreeElement *te, + ID *id); + /** \} */ /* -------------------------------------------------------------------- */ @@ -394,6 +399,7 @@ static TreeElement *outliner_item_rename_find_hovered(const SpaceOutliner *space static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *region = CTX_wm_region(C); + View2D *v2d = ®ion->v2d; SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); const bool use_active = RNA_boolean_get(op->ptr, "use_active"); @@ -403,6 +409,13 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_CANCELLED; } + /* Force element into view. */ + outliner_show_active(space_outliner, region, te, TREESTORE(te)->id); + int size_y = BLI_rcti_size_y(&v2d->mask) + 1; + int ytop = (te->ys + (size_y / 2)); + int delta_y = ytop - v2d->cur.ymax; + outliner_scroll_view(space_outliner, region, delta_y); + do_item_rename(region, te, TREESTORE(te), op->reports); return OPERATOR_FINISHED; -- cgit v1.2.3