From e0890a26f4d0ff7424358130b8e439bcbcd3229b Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 2 Nov 2011 16:25:29 +0000 Subject: [PATCH] Fix the layouting of notifications again. I'm not sure about the ApGroupView being (and looking like) a BBox. Thoughts about that ? git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43119 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/notification/AppGroupView.cpp | 2 +- src/servers/notification/NotificationView.cpp | 30 +++++++++++++------ .../notification/NotificationWindow.cpp | 3 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 5d931bf9db..756cb89d34 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -24,7 +24,7 @@ AppGroupView::AppGroupView(NotificationWindow* win, const char* label) : - BBox(B_FANCY_BORDER, (fView = new BGroupView(B_VERTICAL, 10))), + BBox(B_FANCY_BORDER, (fView = new BGroupView(B_VERTICAL, 0))), fLabel(label), fParent(win), fCollapsed(false) diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index 21307cad14..e7e74b70d2 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include #include #include #include @@ -59,6 +62,9 @@ NotificationView::NotificationView(NotificationWindow* win, if (fTimeout <= 0) fTimeout = fParent->Timeout() * 1000000; + BGroupLayout* layout = new BGroupLayout(B_VERTICAL); + SetLayout(layout); + SetText(); switch (fNotification->Type()) { @@ -72,9 +78,7 @@ NotificationView::NotificationView(NotificationWindow* win, break; case B_PROGRESS_NOTIFICATION: { - BRect frame(kIconStripeWidth + 9, Bounds().bottom - 36, - Bounds().right - 8, Bounds().bottom - 10); - BStatusBar* progress = new BStatusBar(frame, "progress"); + BStatusBar* progress = new BStatusBar("progress"); progress->SetBarHeight(12.0f); progress->SetMaxValue(1.0f); progress->Update(fNotification->Progress()); @@ -82,8 +86,10 @@ NotificationView::NotificationView(NotificationWindow* win, BString label = ""; label << (int)(fNotification->Progress() * 100) << " %"; progress->SetTrailingText(label); - - AddChild(progress); + + BGroupLayoutBuilder b(layout); + b.AddGlue() + .Add(progress); } // fall through default: @@ -410,8 +416,9 @@ NotificationView::GetSupportedSuites(BMessage* msg) void NotificationView::SetText(float newMaxWidth) { - if (newMaxWidth < 0) - newMaxWidth = Bounds().Width() - (kEdgePadding * 2); + if (newMaxWidth < 0) { + newMaxWidth = 200; + } // Delete old lines LineInfoList::iterator lIt; @@ -447,7 +454,7 @@ NotificationView::SetText(float newMaxWidth) + ceilf(fh.ascent); // Split text into chunks between certain characters and compose the lines. - const char kSeparatorCharacters[] = " \n-\\/"; + const char kSeparatorCharacters[] = " \n-\\"; BString textBuffer = fNotification->Content(); textBuffer.ReplaceAll("\t", " "); const char* chunkStart = textBuffer.String(); @@ -512,6 +519,11 @@ NotificationView::SetText(float newMaxWidth) if (fHeight < minHeight) fHeight = minHeight; } + + // Make sure the progress bar is below the text, and the window is big + // enough. + static_cast(GetLayout())->SetInsets(kIconStripeWidth + 8, + fHeight, 8, 8); } @@ -528,7 +540,7 @@ NotificationView::_CalculateSize() BSize size; // Parent width, minus the edge padding, minus the pensize - size.width = fParent->Width() - (kEdgePadding * 2) - (kPenSize * 2); + size.width = B_SIZE_UNLIMITED; size.height = fHeight; if (fNotification->Type() == B_PROGRESS_NOTIFICATION) { diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 059faa7a6c..c5954fba6f 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -62,7 +62,7 @@ NotificationWindow::NotificationWindow() | B_NOT_RESIZABLE | B_NOT_MOVABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES) { - SetLayout(new BGroupLayout(B_VERTICAL, 10)); + SetLayout(new BGroupLayout(B_VERTICAL, 0)); Hide(); Show(); @@ -359,7 +359,6 @@ NotificationWindow::SetPosition() float rightOffset = bounds.right - Frame().right; float bottomOffset = bounds.bottom - Frame().bottom; // Size of the borders around the window - printf("%f %f %f %f\n",leftOffset, topOffset, rightOffset, bottomOffset); float x = Frame().left, y = Frame().top; // If we can't guess, don't move...