[Bf-blender-cvs] [5dcbc320673] soc-2019-outliner: Outliner: Add scroll view util function

Nathan Craddock noreply at git.blender.org
Thu Aug 1 03:19:52 CEST 2019


Commit: 5dcbc320673b147fdac3dd541bd4f082d67a5a89
Author: Nathan Craddock
Date:   Wed Jul 31 19:00:40 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB5dcbc320673b147fdac3dd541bd4f082d67a5a89

Outliner: Add scroll view util function

Adds a scroll view utility function to be used for walk select
scrolling, pageup/pagedown scrolling, show active, and other
operators that scroll the outliner. The scroll view function
ensures the scroll amount does not go past the bounds of the
outliner, reducing redundant code in the operators.

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

M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_utils.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 387bfd18f68..56ecc4f20c3 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -481,6 +481,7 @@ bool outliner_tree_traverse(const SpaceOutliner *soops,
 float outliner_restrict_columns_width(const struct SpaceOutliner *soops);
 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 *ar, int delta_y);
 
 /* outliner_sync.c ---------------------------------------------- */
 
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 428a0f0f6dd..a27985939c3 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -24,6 +24,7 @@
 #include "BLI_utildefines.h"
 
 #include "DNA_action_types.h"
+#include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 
 #include "BKE_outliner_treehash.h"
@@ -361,4 +362,26 @@ bool outliner_is_element_visible(const TreeElement *te)
 bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x)
 {
   return (view_co_x > te->xs) && (view_co_x < te->xs + UI_UNIT_X);
-}
\ No newline at end of file
+}
+
+/* Scroll view vertically  while keeping within total bounds */
+void outliner_scroll_view(ARegion *ar, int delta_y)
+{
+  int y_min = MIN2(ar->v2d.cur.ymin, ar->v2d.tot.ymin);
+
+  ar->v2d.cur.ymax += delta_y;
+  ar->v2d.cur.ymin += delta_y;
+
+  /* Adjust view if delta placed view outside total area */
+  int offset;
+  if (ar->v2d.cur.ymax > -UI_UNIT_Y) {
+    offset = ar->v2d.cur.ymax;
+    ar->v2d.cur.ymax -= offset;
+    ar->v2d.cur.ymin -= offset;
+  }
+  else if (ar->v2d.cur.ymin < y_min) {
+    offset = y_min - ar->v2d.cur.ymin;
+    ar->v2d.cur.ymax += offset;
+    ar->v2d.cur.ymin += offset;
+  }
+}



More information about the Bf-blender-cvs mailing list