From cd28fb03310c256b75b9db9a9dd7e009c6dd1fa1 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 4 Jul 2013 13:11:00 -0400 Subject: [PATCH] Expander: Fix layout regression. - Adjust ExpanderWindow to use BLayoutBuilder. - Adjust content pane layout to explicitly use unlimited size, since it no longer implicitly gets it due to the recent checkbox changes. --- src/apps/expander/ExpanderWindow.cpp | 70 ++++++++++++++-------------- src/apps/expander/ExpanderWindow.h | 2 +- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/apps/expander/ExpanderWindow.cpp b/src/apps/expander/ExpanderWindow.cpp index 5d642717e8..aa2ed3ad6c 100644 --- a/src/apps/expander/ExpanderWindow.cpp +++ b/src/apps/expander/ExpanderWindow.cpp @@ -1,6 +1,7 @@ /* * Copyright 2004-2006, Jérôme DUVAL. All rights reserved. * Copyright 2010, Karsten Heimrich. All rights reserved. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -15,8 +16,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -64,10 +64,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref, fSettings(*settings), fPreferences(NULL) { - BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0); - SetLayout(layout); - - _AddMenuBar(layout); + _CreateMenuBar(); fDestButton = new BButton(B_TRANSLATE("Destination"), new BMessage(MSG_DEST)); @@ -100,34 +97,40 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref, BString statusPlaceholderString; statusPlaceholderString.SetTo(' ', MAX_STATUS_LENGTH * 2); - BView* topView = layout->View(); const float spacing = be_control_look->DefaultItemSpacing(); - topView->AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) - .AddGroup(B_HORIZONTAL, spacing) - .AddGroup(B_VERTICAL, 5.0) - .Add(fSourceButton) - .Add(fDestButton) - .Add(fExpandButton) - .End() - .AddGroup(B_VERTICAL, spacing) - .Add(fSourceText = new BTextControl(NULL, NULL, - new BMessage(MSG_SOURCETEXT))) - .Add(fDestText = new BTextControl(NULL, NULL, - new BMessage(MSG_DESTTEXT))) - .AddGroup(B_HORIZONTAL, spacing) - .Add(fShowContents = new BCheckBox( - B_TRANSLATE("Show contents"), - new BMessage(MSG_SHOWCONTENTS))) - .Add(fStatusView = new BStringView(NULL, - statusPlaceholderString)) + BGroupLayout* pathLayout; + BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0) + .SetInsets(0.0) + .Add(fBar) + .AddGroup(B_VERTICAL, spacing) + .AddGroup(B_HORIZONTAL, spacing) + .AddGroup(B_VERTICAL, 5.0) + .Add(fSourceButton) + .Add(fDestButton) + .Add(fExpandButton) + .End() + .AddGroup(B_VERTICAL, spacing) + .Add(fSourceText = new BTextControl(NULL, NULL, + new BMessage(MSG_SOURCETEXT))) + .Add(fDestText = new BTextControl(NULL, NULL, + new BMessage(MSG_DESTTEXT))) + .AddGroup(B_HORIZONTAL, spacing) + .GetLayout(&pathLayout) + .Add(fShowContents = new BCheckBox( + B_TRANSLATE("Show contents"), + new BMessage(MSG_SHOWCONTENTS))) + .Add(fStatusView = new BStringView(NULL, + statusPlaceholderString)) + .End() .End() .End() + .Add(scrollView) + .SetInsets(spacing, spacing, spacing, spacing) .End() - .Add(scrollView) - .SetInsets(spacing, spacing, spacing, spacing) - ); + .End(); - size = topView->PreferredSize(); + pathLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); + size = GetLayout()->View()->PreferredSize(); fSizeLimit = size.Height() - scrollView->PreferredSize().height - spacing; ResizeTo(Bounds().Width(), fSizeLimit); @@ -380,7 +383,7 @@ ExpanderWindow::MessageReceived(BMessage* msg) if (strstr(string.String(), "Enter password") != NULL) { fExpandingThread->SuspendExternalExpander(); BString password; - PasswordAlert* alert = + PasswordAlert* alert = new PasswordAlert("passwordAlert", string); alert->Go(password); fExpandingThread->ResumeExternalExpander(); @@ -389,8 +392,8 @@ ExpanderWindow::MessageReceived(BMessage* msg) } } break; - - case 'errp': + + case 'errp': { BString string; if (msg->FindString("error", &string) == B_OK @@ -550,7 +553,7 @@ ExpanderWindow::RefsReceived(BMessage* msg) #define B_TRANSLATION_CONTEXT "ExpanderMenu" void -ExpanderWindow::_AddMenuBar(BLayout* layout) +ExpanderWindow::_CreateMenuBar() { fBar = new BMenuBar("menu_bar", B_ITEMS_IN_ROW, B_INVALIDATE_AFTER_LAYOUT); BMenu* menu = new BMenu(B_TRANSLATE("File")); @@ -578,7 +581,6 @@ ExpanderWindow::_AddMenuBar(BLayout* layout) menu->AddItem(fPreferencesItem = new BMenuItem(B_TRANSLATE("Settings…"), new BMessage(MSG_PREFERENCES), 'S')); fBar->AddItem(menu); - layout->AddView(fBar); } diff --git a/src/apps/expander/ExpanderWindow.h b/src/apps/expander/ExpanderWindow.h index dcc56d0bb2..53f72f411b 100644 --- a/src/apps/expander/ExpanderWindow.h +++ b/src/apps/expander/ExpanderWindow.h @@ -41,7 +41,7 @@ public: void RefsReceived(BMessage* msg); private: - void _AddMenuBar(BLayout* layout); + void _CreateMenuBar(); bool CanQuit(); // returns true if the window can be closed safely, false if not void CloseWindowOrKeepOpen();