Adjust BAlert to position the alert using the revamped BWindow::CenterIn() method.
BAlert::AlertPosition() has been superceded by the new BWindow method and should be considered deprecated. Note that the alert position is not in the direct center of the screen, it is offset vertically like before.
This commit is contained in:
@@ -396,6 +396,7 @@ BAlert::QuitRequested()
|
||||
}
|
||||
|
||||
|
||||
// This method is deprecated, do not use
|
||||
BPoint
|
||||
BAlert::AlertPosition(float width, float height)
|
||||
{
|
||||
@@ -572,7 +573,16 @@ BAlert::_InitObject(const char* text, const char* button0, const char* button1,
|
||||
|
||||
AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
|
||||
|
||||
MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
|
||||
// Position the alert so that it is centered vertically but offset a bit
|
||||
// horizontally in the parent window's frame or, if unavailable, the
|
||||
// screen frame.
|
||||
BWindow* window =
|
||||
dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
|
||||
const BRect frame = window != NULL ? window->Frame()
|
||||
: (BScreen(this)).Frame();
|
||||
|
||||
CenterIn(frame.InsetByCopy(0, frame.Height() / 2)
|
||||
.OffsetBySelf(0, -frame.Height() / 4));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user