Commit: 9d28b8ae3f69284fcd57a449f8a589d779be7b81
Author: Nathan Craddock
Date:   Tue Jul 16 22:35:28 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB9d28b8ae3f69284fcd57a449f8a589d779be7b81

Outliner: Prevent scroll page from leaving view bounds

The page up/down operator to scroll the tree could go past the
bounds of the tree leading to jumpy redraws. This prevents the
operator to go outside the bounds of the area.

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

M       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 e6e15388e21..6f817a451e3 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1258,16 +1258,24 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
 static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
 {
   ARegion *ar = CTX_wm_region(C);
-  int dy = BLI_rcti_size_y(&ar->v2d.mask);
-  int up = 0;
+  int size_y = BLI_rcti_size_y(&ar->v2d.mask) + 1;
 
+  bool up = false;
   if (RNA_boolean_get(op->ptr, "up")) {
-    up = 1;
+    up = true;
   }
 
-  if (up == 0) {
-    dy = -dy;
+  /* Keep view within outliner tree bounds */
+  int y_min = MIN2(ar->v2d.tot.ymin, ar->v2d.cur.ymin);
+  int dy;
+
+  if (up) {
+    dy = MIN2(size_y, -ar->v2d.cur.ymax);
+  }
+  else {
+    dy = -MIN2(size_y, ar->v2d.cur.ymin - y_min);
   }
+
   ar->v2d.cur.ymin += dy;
   ar->v2d.cur.ymax += dy;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to