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:
@@ -251,13 +251,13 @@ DiskProbe::ReadyToRun()
|
|||||||
status_t
|
status_t
|
||||||
DiskProbe::Probe(BEntry &entry, const char *attribute)
|
DiskProbe::Probe(BEntry &entry, const char *attribute)
|
||||||
{
|
{
|
||||||
int32 probeWindows = 0;
|
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
status_t status = entry.GetRef(&ref);
|
status_t status = entry.GetRef(&ref);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
ProbeWindow *lastWindow(NULL);
|
||||||
|
|
||||||
// Do we already have that window open?
|
// Do we already have that window open?
|
||||||
for (int32 i = CountWindows(); i-- > 0; ) {
|
for (int32 i = CountWindows(); i-- > 0; ) {
|
||||||
ProbeWindow *window = dynamic_cast<ProbeWindow *>(WindowAt(i));
|
ProbeWindow *window = dynamic_cast<ProbeWindow *>(WindowAt(i));
|
||||||
@@ -268,7 +268,8 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
|
|||||||
window->Activate(true);
|
window->Activate(true);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
probeWindows++;
|
if (lastWindow == NULL)
|
||||||
|
lastWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does the file really exist?
|
// Does the file really exist?
|
||||||
@@ -278,8 +279,13 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
|
|||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
|
|
||||||
// cascade window
|
// cascade window
|
||||||
BRect rect = fWindowFrame;
|
BRect rect;
|
||||||
rect.OffsetBy(probeWindows * kCascadeOffset, probeWindows * kCascadeOffset);
|
if (lastWindow != NULL)
|
||||||
|
rect = lastWindow->Frame();
|
||||||
|
else
|
||||||
|
rect = fWindowFrame;
|
||||||
|
|
||||||
|
rect.OffsetBy(kCascadeOffset, kCascadeOffset);
|
||||||
|
|
||||||
BWindow *window;
|
BWindow *window;
|
||||||
if (attribute != NULL)
|
if (attribute != NULL)
|
||||||
@@ -288,6 +294,26 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
|
|||||||
window = new FileWindow(rect, &ref, &fSettings.Message());
|
window = new FileWindow(rect, &ref, &fSettings.Message());
|
||||||
|
|
||||||
window->Show();
|
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++;
|
fWindowCount++;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user