Expander: don't scroll to the end if the user modifies the scrollbar position.
Fixes #11027. This preserves the functionality of scroll-to-end while allowing the user to interrupt it (and resume it, in the case of extremely long archives).
This commit is contained in:
parent
1a5860e2d2
commit
9fb72ec18e
@ -91,8 +91,8 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
|
|||||||
fListingText->SetWordWrap(false);
|
fListingText->SetWordWrap(false);
|
||||||
BFont font = be_fixed_font;
|
BFont font = be_fixed_font;
|
||||||
fListingText->SetFontAndColor(&font);
|
fListingText->SetFontAndColor(&font);
|
||||||
BScrollView* scrollView = new BScrollView("", fListingText,
|
fScrollView = new BScrollView("", fListingText, B_INVALIDATE_AFTER_LAYOUT,
|
||||||
B_INVALIDATE_AFTER_LAYOUT, true, true);
|
true, true);
|
||||||
|
|
||||||
// workaround to let the layout manager estimate
|
// workaround to let the layout manager estimate
|
||||||
// the width of status view and fix the #5289
|
// the width of status view and fix the #5289
|
||||||
@ -127,14 +127,14 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
|
|||||||
.End()
|
.End()
|
||||||
.End()
|
.End()
|
||||||
.End()
|
.End()
|
||||||
.Add(scrollView)
|
.Add(fScrollView)
|
||||||
.SetInsets(spacing, spacing, spacing, spacing)
|
.SetInsets(spacing, spacing, spacing, spacing)
|
||||||
.End()
|
.End()
|
||||||
.End();
|
.End();
|
||||||
|
|
||||||
pathLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
pathLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
size = GetLayout()->View()->PreferredSize();
|
size = GetLayout()->View()->PreferredSize();
|
||||||
fSizeLimit = size.Height() - scrollView->PreferredSize().height - spacing;
|
fSizeLimit = size.Height() - fScrollView->PreferredSize().height - spacing;
|
||||||
|
|
||||||
ResizeTo(Bounds().Width(), fSizeLimit);
|
ResizeTo(Bounds().Width(), fSizeLimit);
|
||||||
SetSizeLimits(size.Width(), 32767.0f, fSizeLimit, fSizeLimit);
|
SetSizeLimits(size.Width(), 32767.0f, fSizeLimit, fSizeLimit);
|
||||||
@ -369,6 +369,12 @@ ExpanderWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case 'outp':
|
case 'outp':
|
||||||
if (!fExpandingStarted && fListingStarted) {
|
if (!fExpandingStarted && fListingStarted) {
|
||||||
|
// Check if the vertical scroll bar is at the end
|
||||||
|
float max, pos;
|
||||||
|
fScrollView->ScrollBar(B_VERTICAL)->GetRange(NULL, &max);
|
||||||
|
pos = fScrollView->ScrollBar(B_VERTICAL)->Value();
|
||||||
|
bool atEnd = (pos == max);
|
||||||
|
|
||||||
BString string;
|
BString string;
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
while (message->FindString("output", i++, &string) == B_OK) {
|
while (message->FindString("output", i++, &string) == B_OK) {
|
||||||
@ -379,7 +385,11 @@ ExpanderWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
fListingText->Insert(string.String());
|
fListingText->Insert(string.String());
|
||||||
}
|
}
|
||||||
fListingText->ScrollToSelection();
|
|
||||||
|
if (atEnd && fScrollView->ScrollBar(B_VERTICAL)->Value() == pos) {
|
||||||
|
fScrollView->ScrollBar(B_VERTICAL)->GetRange(NULL, &max);
|
||||||
|
fScrollView->ScrollBar(B_VERTICAL)->SetValue(max);
|
||||||
|
}
|
||||||
} else if (fExpandingStarted) {
|
} else if (fExpandingStarted) {
|
||||||
BString string;
|
BString string;
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
class BLayout;
|
class BLayout;
|
||||||
|
class BScrollView;
|
||||||
class BStringView;
|
class BStringView;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class BTextView;
|
class BTextView;
|
||||||
@ -80,6 +81,7 @@ private:
|
|||||||
BTextControl* fDestText;
|
BTextControl* fDestText;
|
||||||
BStringView* fStatusView;
|
BStringView* fStatusView;
|
||||||
BTextView* fListingText;
|
BTextView* fListingText;
|
||||||
|
BScrollView* fScrollView;
|
||||||
|
|
||||||
ExpanderThread* fListingThread;
|
ExpanderThread* fListingThread;
|
||||||
bool fListingStarted;
|
bool fListingStarted;
|
||||||
|
Loading…
Reference in New Issue
Block a user