From e894fbc0ac91379ca471b86399f4d7930a70e8d3 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 28 Apr 2013 20:27:44 -0400 Subject: [PATCH] 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. --- src/kits/interface/Alert.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/Alert.cpp b/src/kits/interface/Alert.cpp index fcd39f9c69..ce513cf457 100644 --- a/src/kits/interface/Alert.cpp +++ b/src/kits/interface/Alert.cpp @@ -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(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)); }