Author: pulkomandy Date: 2011-11-02 17:25:29 +0100 (Wed, 02 Nov 2011) New Revision: 43119 Changeset: https://dev.haiku-os.org/changeset/43119 Modified: haiku/trunk/src/servers/notification/AppGroupView.cpp haiku/trunk/src/servers/notification/NotificationView.cpp haiku/trunk/src/servers/notification/NotificationWindow.cpp Log: Fix the layouting of notifications again. I'm not sure about the ApGroupView being (and looking like) a BBox. Thoughts about that ? Modified: haiku/trunk/src/servers/notification/AppGroupView.cpp =================================================================== --- haiku/trunk/src/servers/notification/AppGroupView.cpp 2011-11-02 16:12:48 UTC (rev 43118) +++ haiku/trunk/src/servers/notification/AppGroupView.cpp 2011-11-02 16:25:29 UTC (rev 43119) @@ -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) Modified: haiku/trunk/src/servers/notification/NotificationView.cpp =================================================================== --- haiku/trunk/src/servers/notification/NotificationView.cpp 2011-11-02 16:12:48 UTC (rev 43118) +++ haiku/trunk/src/servers/notification/NotificationView.cpp 2011-11-02 16:25:29 UTC (rev 43119) @@ -14,6 +14,9 @@ */ #include <ControlLook.h> +#include <GroupLayout.h> +#include <GroupLayoutBuilder.h> +#include <Layout.h> #include <LayoutUtils.h> #include <Messenger.h> #include <Path.h> @@ -59,6 +62,9 @@ if (fTimeout <= 0) fTimeout = fParent->Timeout() * 1000000; + BGroupLayout* layout = new BGroupLayout(B_VERTICAL); + SetLayout(layout); + SetText(); switch (fNotification->Type()) { @@ -72,9 +78,7 @@ 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 @@ 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 @@ 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 @@ + 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 @@ if (fHeight < minHeight) fHeight = minHeight; } + + // Make sure the progress bar is below the text, and the window is big + // enough. + static_cast<BGroupLayout*>(GetLayout())->SetInsets(kIconStripeWidth + 8, + fHeight, 8, 8); } @@ -528,7 +540,7 @@ 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) { Modified: haiku/trunk/src/servers/notification/NotificationWindow.cpp =================================================================== --- haiku/trunk/src/servers/notification/NotificationWindow.cpp 2011-11-02 16:12:48 UTC (rev 43118) +++ haiku/trunk/src/servers/notification/NotificationWindow.cpp 2011-11-02 16:25:29 UTC (rev 43119) @@ -62,7 +62,7 @@ | 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 @@ 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...