[Bf-blender-cvs] [bb795b2119b] soc-2019-outliner: Outliner: Use scroll view util function for walk scroll
Nathan Craddock
noreply at git.blender.org
Thu Aug 1 06:32:32 CEST 2019
Commit: bb795b2119be835c0c04ef46f5e400ecdd961733
Author: Nathan Craddock
Date: Wed Jul 31 19:19:06 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBbb795b2119be835c0c04ef46f5e400ecdd961733
Outliner: Use scroll view util function for walk scroll
Simplify the walk scrolling function by using the scrol view util
function
===================================================================
M source/blender/editors/space_outliner/outliner_select.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 09e39427ae6..88cedb68604 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1768,23 +1768,19 @@ static TreeElement *find_walk_select_start_element(SpaceOutliner *soops, bool *c
return walk_element;
}
-static void outliner_walk_scroll(ARegion *ar, TreeElement *te, short direction)
+/* Scroll the outliner when the walk element reaches the top or bottom boundary */
+static void outliner_walk_scroll(ARegion *ar, TreeElement *te)
{
- int y_max = ar->v2d.cur.ymax - (UI_UNIT_Y * 2);
- int y_min = ar->v2d.cur.ymin + UI_UNIT_Y;
- int offset = UI_HEADER_OFFSET;
- printf("ymax: %d, ymin: %d, te->ys: %d\n", y_max, y_min, te->ys);
-
- int delta_y;
- if (te->ys > y_max && direction == OUTLINER_SELECT_WALK_UP) {
- delta_y = MAX2(y_max - te->ys, UI_UNIT_Y);
- ar->v2d.cur.ymax += delta_y;
- ar->v2d.cur.ymin += delta_y;
- }
- else if (te->ys < y_min && direction == OUTLINER_SELECT_WALK_DOWN) {
- delta_y = MAX2((te->ys + UI_UNIT_Y), UI_UNIT_Y);
- ar->v2d.cur.ymax -= delta_y;
- ar->v2d.cur.ymin -= delta_y;
+ /* Account for the header height */
+ int y_max = ar->v2d.cur.ymax - UI_UNIT_Y;
+ int y_min = ar->v2d.cur.ymin;
+
+ /* Scroll if walked position is beyond the border */
+ if (te->ys > y_max) {
+ outliner_scroll_view(ar, te->ys - y_max);
+ }
+ else if (te->ys < y_min) {
+ outliner_scroll_view(ar, -(y_min - te->ys));
}
}
@@ -1809,7 +1805,7 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
}
/* Scroll outliner to focus on walk element */
- outliner_walk_scroll(ar, walk_element, direction);
+ outliner_walk_scroll(ar, walk_element);
if (soops->flag & SO_SYNC_SELECTION) {
outliner_select_sync(C, soops);
More information about the Bf-blender-cvs
mailing list