Expander: Smarter window resize

* Rather than enlarging the window on (potentially) every line, simply keep the largest delta and use it only once at the end of the listing.

Ref: r33073 and ticket #3797.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33075 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre 2009-09-12 03:09:52 +00:00
parent c0a72ca298
commit 8b93f21c22
2 changed files with 9 additions and 3 deletions

View File

@ -365,9 +365,8 @@ ExpanderWindow::MessageReceived(BMessage *msg)
// expand the window if we need...
float delta = fListingText->StringWidth(string.String())
- fListingText->Frame().Width();
if (delta > 0) {
ResizeTo(Frame().Width() + delta,
Frame().Height());
if (delta > fLargestDelta) {
fLargestDelta = delta;
}
fListingText->Insert(string.String());
}
@ -385,6 +384,9 @@ ExpanderWindow::MessageReceived(BMessage *msg)
} else if (fListingStarted){
fSourceChanged = false;
StopListing();
if (fLargestDelta > 0.0f)
ResizeBy(fLargestDelta, 0.0f);
fLargestDelta = 0.0f;
} else
fStatusView->SetText("");
break;
@ -597,6 +599,8 @@ ExpanderWindow::StartListing()
{
_UpdateWindowSize(true);
fLargestDelta = 0.0f;
if (fListingScroll->IsHidden())
fListingScroll->Show();

View File

@ -77,6 +77,8 @@ class ExpanderWindow : public BWindow {
BMessage fSettings;
ExpanderPreferences *fPreferences;
ExpanderRules fRules;
float fLargestDelta;
};
#endif /* EXPANDER_WINDOW_H */