Enhance/fix the cascading of windows in DiskProbe. Re-uses basically the same algorithm as StyledEdit.

Should fix ticket #3911.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32382 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre 2009-08-14 18:11:49 +00:00
parent b044ca6a19
commit 718b394111

View File

@ -251,13 +251,13 @@ DiskProbe::ReadyToRun()
status_t
DiskProbe::Probe(BEntry &entry, const char *attribute)
{
int32 probeWindows = 0;
entry_ref ref;
status_t status = entry.GetRef(&ref);
if (status < B_OK)
return status;
ProbeWindow *lastWindow(NULL);
// Do we already have that window open?
for (int32 i = CountWindows(); i-- > 0; ) {
ProbeWindow *window = dynamic_cast<ProbeWindow *>(WindowAt(i));
@ -268,7 +268,8 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
window->Activate(true);
return B_OK;
}
probeWindows++;
if (lastWindow == NULL)
lastWindow = window;
}
// Does the file really exist?
@ -278,8 +279,13 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
entry.GetRef(&ref);
// cascade window
BRect rect = fWindowFrame;
rect.OffsetBy(probeWindows * kCascadeOffset, probeWindows * kCascadeOffset);
BRect rect;
if (lastWindow != NULL)
rect = lastWindow->Frame();
else
rect = fWindowFrame;
rect.OffsetBy(kCascadeOffset, kCascadeOffset);
BWindow *window;
if (attribute != NULL)
@ -288,6 +294,26 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
window = new FileWindow(rect, &ref, &fSettings.Message());
window->Show();
/* adjust the cascading... we can only do this after the window was created
* to adjust to the real size */
rect.right = window->Frame().right;
rect.bottom = window->Frame().bottom;
BScreen screen;
BRect screenBorder = screen.Frame();
float left = rect.left;
if (left + rect.Width() > screenBorder.right)
left = 7;
float top = rect.top;
if (top + rect.Height() > screenBorder.bottom)
top = 26;
rect.OffsetTo(BPoint(left, top));
window->MoveTo(BPoint(left, top));
fWindowCount++;
return B_OK;