[Bf-blender-cvs] [2d48f3e445a] blender-v2.91-release: Fix 'outliner_scroll_view()' not reaching wanted element

Philipp Oeser noreply at git.blender.org
Wed Nov 11 10:26:44 CET 2020


Commit: 2d48f3e445ad4294cfe1a354629bf335117ba40d
Author: Philipp Oeser
Date:   Tue Nov 10 13:53:05 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rB2d48f3e445ad4294cfe1a354629bf335117ba40d

Fix 'outliner_scroll_view()' not reaching wanted element

Scrolling to an item after opening relevant parents can go wrong if said
parent e.g. the last in the list [as in: then the Outliner does not
scroll down all the way]
It stems from the fact that 'region->v2d.tot.ymin' is not up-to-date in
outliner_scroll_view after outliner_show_active opens up parents, 'tot'
will only update on a redraw.

Now calculate the trees height on the fly using
'outliner_tree_dimensions()'.

ref D9521
ref T82553

Maniphest Tasks: T82553

Differential Revision: https://developer.blender.org/D9523

===================================================================

M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_utils.c

===================================================================

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 779efc3cacb..165d7bb2aa2 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1343,7 +1343,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 +1375,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(&region->v2d.mask) + 1;
 
@@ -1384,7 +1385,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 aebb574578f..0a0b099eb5b 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1709,7 +1709,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;
@@ -1717,10 +1717,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));
   }
 }
 
@@ -1747,7 +1747,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;



More information about the Bf-blender-cvs mailing list