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.
This commit is contained in:
Rene Gollent
2013-07-04 13:15:21 -04:00
parent 575f2f598a
commit cd28fb0331
2 changed files with 37 additions and 35 deletions
+33 -31
View File
@@ -1,6 +1,7 @@
/* /*
* Copyright 2004-2006, Jérôme DUVAL. All rights reserved. * Copyright 2004-2006, Jérôme DUVAL. All rights reserved.
* Copyright 2010, Karsten Heimrich. All rights reserved. * Copyright 2010, Karsten Heimrich. All rights reserved.
* Copyright 2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -15,8 +16,7 @@
#include <ControlLook.h> #include <ControlLook.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
#include <GroupLayout.h> #include <LayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
@@ -64,10 +64,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
fSettings(*settings), fSettings(*settings),
fPreferences(NULL) fPreferences(NULL)
{ {
BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0); _CreateMenuBar();
SetLayout(layout);
_AddMenuBar(layout);
fDestButton = new BButton(B_TRANSLATE("Destination"), fDestButton = new BButton(B_TRANSLATE("Destination"),
new BMessage(MSG_DEST)); new BMessage(MSG_DEST));
@@ -100,34 +97,40 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
BString statusPlaceholderString; BString statusPlaceholderString;
statusPlaceholderString.SetTo(' ', MAX_STATUS_LENGTH * 2); statusPlaceholderString.SetTo(' ', MAX_STATUS_LENGTH * 2);
BView* topView = layout->View();
const float spacing = be_control_look->DefaultItemSpacing(); const float spacing = be_control_look->DefaultItemSpacing();
topView->AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) BGroupLayout* pathLayout;
.AddGroup(B_HORIZONTAL, spacing) BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0)
.AddGroup(B_VERTICAL, 5.0) .SetInsets(0.0)
.Add(fSourceButton) .Add(fBar)
.Add(fDestButton) .AddGroup(B_VERTICAL, spacing)
.Add(fExpandButton) .AddGroup(B_HORIZONTAL, spacing)
.End() .AddGroup(B_VERTICAL, 5.0)
.AddGroup(B_VERTICAL, spacing) .Add(fSourceButton)
.Add(fSourceText = new BTextControl(NULL, NULL, .Add(fDestButton)
new BMessage(MSG_SOURCETEXT))) .Add(fExpandButton)
.Add(fDestText = new BTextControl(NULL, NULL, .End()
new BMessage(MSG_DESTTEXT))) .AddGroup(B_VERTICAL, spacing)
.AddGroup(B_HORIZONTAL, spacing) .Add(fSourceText = new BTextControl(NULL, NULL,
.Add(fShowContents = new BCheckBox( new BMessage(MSG_SOURCETEXT)))
B_TRANSLATE("Show contents"), .Add(fDestText = new BTextControl(NULL, NULL,
new BMessage(MSG_SHOWCONTENTS))) new BMessage(MSG_DESTTEXT)))
.Add(fStatusView = new BStringView(NULL, .AddGroup(B_HORIZONTAL, spacing)
statusPlaceholderString)) .GetLayout(&pathLayout)
.Add(fShowContents = new BCheckBox(
B_TRANSLATE("Show contents"),
new BMessage(MSG_SHOWCONTENTS)))
.Add(fStatusView = new BStringView(NULL,
statusPlaceholderString))
.End()
.End() .End()
.End() .End()
.Add(scrollView)
.SetInsets(spacing, spacing, spacing, spacing)
.End() .End()
.Add(scrollView) .End();
.SetInsets(spacing, spacing, spacing, spacing)
);
size = topView->PreferredSize(); pathLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
size = GetLayout()->View()->PreferredSize();
fSizeLimit = size.Height() - scrollView->PreferredSize().height - spacing; fSizeLimit = size.Height() - scrollView->PreferredSize().height - spacing;
ResizeTo(Bounds().Width(), fSizeLimit); ResizeTo(Bounds().Width(), fSizeLimit);
@@ -550,7 +553,7 @@ ExpanderWindow::RefsReceived(BMessage* msg)
#define B_TRANSLATION_CONTEXT "ExpanderMenu" #define B_TRANSLATION_CONTEXT "ExpanderMenu"
void void
ExpanderWindow::_AddMenuBar(BLayout* layout) ExpanderWindow::_CreateMenuBar()
{ {
fBar = new BMenuBar("menu_bar", B_ITEMS_IN_ROW, B_INVALIDATE_AFTER_LAYOUT); fBar = new BMenuBar("menu_bar", B_ITEMS_IN_ROW, B_INVALIDATE_AFTER_LAYOUT);
BMenu* menu = new BMenu(B_TRANSLATE("File")); BMenu* menu = new BMenu(B_TRANSLATE("File"));
@@ -578,7 +581,6 @@ ExpanderWindow::_AddMenuBar(BLayout* layout)
menu->AddItem(fPreferencesItem = new BMenuItem(B_TRANSLATE("Settings…"), menu->AddItem(fPreferencesItem = new BMenuItem(B_TRANSLATE("Settings…"),
new BMessage(MSG_PREFERENCES), 'S')); new BMessage(MSG_PREFERENCES), 'S'));
fBar->AddItem(menu); fBar->AddItem(menu);
layout->AddView(fBar);
} }
+1 -1
View File
@@ -41,7 +41,7 @@ public:
void RefsReceived(BMessage* msg); void RefsReceived(BMessage* msg);
private: private:
void _AddMenuBar(BLayout* layout); void _CreateMenuBar();
bool CanQuit(); bool CanQuit();
// returns true if the window can be closed safely, false if not // returns true if the window can be closed safely, false if not
void CloseWindowOrKeepOpen(); void CloseWindowOrKeepOpen();