From ed15f1b8fb8b635349829c655678177ad3032ccc Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 18 Jul 2012 23:00:53 -0400 Subject: [PATCH] Fix scrollbar handling when removing rows in BCLV. - If removing a row results in there no longer being any rows whatsoever visible, force a scroll back into the visible range. Fixes #8287. --- src/kits/interface/ColumnListView.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index baa05a2822..8123c690d3 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -4090,6 +4090,16 @@ OutlineView::RemoveRow(BRow* row) fItemsHeight -= subTreeHeight; FixScrollBar(false); + int32 indent = 0; + float top = 0.0; + if (FindRow(fVisibleRect.top, &indent, &top) == NULL && ScrollBar(B_VERTICAL) != NULL) { + // after removing this row, no rows are actually visible any more, + // force a scroll to make them visible again + if (fItemsHeight > fVisibleRect.Height()) + ScrollBy(0.0, fItemsHeight - fVisibleRect.Height() - Bounds().top); + else + ScrollBy(0.0, -Bounds().top); + } if (parentRow != NULL) { parentRow->fChildList->RemoveItem(row); if (parentRow->fChildList->CountItems() == 0) { @@ -4294,7 +4304,7 @@ OutlineView::FixScrollBar(bool scrollToFit) float maxScrollBarValue = fItemsHeight - fVisibleRect.Height(); vScrollBar->SetProportion(fVisibleRect.Height() / fItemsHeight); - // If the user is scrolled down too far when makes the range smaller, the list + // If the user is scrolled down too far when making the range smaller, the list // will jump suddenly, which is undesirable. In this case, don't fix the scroll // bar here. In ScrollTo, it checks to see if this has occured, and will // fix the scroll bars sneakily if the user has scrolled up far enough.