diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-11-11 12:27:44 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-11-11 12:27:44 +0300 |
commit | 251b7d77b3459aefbf31193a0edfee9d2423b94b (patch) | |
tree | 2c1497069d09c421873fc85758b4e44217456fb7 | |
parent | 9b3dabacbcb3e2e108a49309df647692dab320dc (diff) | |
parent | 7ba971d6d855034d5a8f0e8dab1bcd892b5aabd3 (diff) |
Merge branch 'blender-v2.91-release' into master
5 files changed, 28 insertions, 10 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index d961813d04a..22bb99530dc 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -109,7 +109,7 @@ static void outliner_tree_dimensions_impl(SpaceOutliner *space_outliner, } } -static void outliner_tree_dimensions(SpaceOutliner *space_outliner, int *r_width, int *r_height) +void outliner_tree_dimensions(SpaceOutliner *space_outliner, int *r_width, int *r_height) { *r_width = 0; *r_height = 0; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 0d7255b5558..8de7c233728 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; @@ -1343,7 +1356,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) int ytop = (active_element->ys + (size_y / 2)); int delta_y = ytop - v2d->cur.ymax; - outliner_scroll_view(region, delta_y); + outliner_scroll_view(space_outliner, region, delta_y); } else { return OPERATOR_CANCELLED; @@ -1375,6 +1388,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) static int outliner_scroll_page_exec(bContext *C, wmOperator *op) { + SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); ARegion *region = CTX_wm_region(C); int size_y = BLI_rcti_size_y(®ion->v2d.mask) + 1; @@ -1384,7 +1398,7 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op) size_y = -size_y; } - outliner_scroll_view(region, size_y); + outliner_scroll_view(space_outliner, region, size_y); ED_region_tag_redraw_no_rebuild(region); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 382078f006b..d65dec54a20 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -251,6 +251,8 @@ TreeTraversalAction outliner_find_selected_objects(struct TreeElement *te, void void draw_outliner(const struct bContext *C); +void outliner_tree_dimensions(struct SpaceOutliner *space_outliner, int *r_width, int *r_height); + TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te); void outliner_collection_isolate_flag(struct Scene *scene, @@ -525,7 +527,7 @@ bool outliner_tree_traverse(const SpaceOutliner *space_outliner, float outliner_restrict_columns_width(const struct SpaceOutliner *space_outliner); TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag); bool outliner_is_element_visible(const TreeElement *te); -void outliner_scroll_view(struct ARegion *region, int delta_y); +void outliner_scroll_view(struct SpaceOutliner *space_outliner, struct ARegion *region, int delta_y); void outliner_tag_redraw_avoid_rebuild_on_open_change(const struct SpaceOutliner *space_outliner, struct ARegion *region); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 999525deb3a..044d75b4722 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1891,7 +1891,7 @@ static TreeElement *find_walk_select_start_element(SpaceOutliner *space_outliner } /* Scroll the outliner when the walk element reaches the top or bottom boundary */ -static void outliner_walk_scroll(ARegion *region, TreeElement *te) +static void outliner_walk_scroll(SpaceOutliner *space_outliner, ARegion *region, TreeElement *te) { /* Account for the header height */ int y_max = region->v2d.cur.ymax - UI_UNIT_Y; @@ -1899,10 +1899,10 @@ static void outliner_walk_scroll(ARegion *region, TreeElement *te) /* Scroll if walked position is beyond the border */ if (te->ys > y_max) { - outliner_scroll_view(region, te->ys - y_max); + outliner_scroll_view(space_outliner, region, te->ys - y_max); } else if (te->ys < y_min) { - outliner_scroll_view(region, -(y_min - te->ys)); + outliner_scroll_view(space_outliner, region, -(y_min - te->ys)); } } @@ -1929,7 +1929,7 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven OL_ITEM_SELECT | OL_ITEM_ACTIVATE | (extend ? OL_ITEM_EXTEND : 0)); /* Scroll outliner to focus on walk element */ - outliner_walk_scroll(region, active_te); + outliner_walk_scroll(space_outliner, region, active_te); ED_outliner_select_sync_from_outliner(C, space_outliner); outliner_tag_redraw_avoid_rebuild_on_open_change(space_outliner, region); diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 86cc6672b0f..1a0ab3e00d0 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -442,9 +442,11 @@ bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_c } /* Scroll view vertically while keeping within total bounds */ -void outliner_scroll_view(ARegion *region, int delta_y) +void outliner_scroll_view(SpaceOutliner *space_outliner, ARegion *region, int delta_y) { - int y_min = MIN2(region->v2d.cur.ymin, region->v2d.tot.ymin); + int tree_width, tree_height; + outliner_tree_dimensions(space_outliner, &tree_width, &tree_height); + int y_min = MIN2(region->v2d.cur.ymin, -tree_height); region->v2d.cur.ymax += delta_y; region->v2d.cur.ymin += delta_y; |