Improve layouting of Expander

Especially actually hide the content's scroll view, which
otherwise would peak out if the B_USE_WINDOW_SPACING would
ever be increased.
This commit is contained in:
Humdinger
2015-11-07 17:40:20 +01:00
parent 744a39273b
commit c8325bb7d7
2 changed files with 54 additions and 61 deletions
+26 -36
View File
@@ -21,6 +21,7 @@
#include <Path.h> #include <Path.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <Screen.h> #include <Screen.h>
#include <SeparatorView.h>
#include <StringView.h> #include <StringView.h>
#include <TextControl.h> #include <TextControl.h>
@@ -51,13 +52,6 @@ ExpanderPreferences::ExpanderPreferences(BMessage* settings)
{ {
const float kSpacing = be_control_look->DefaultItemSpacing(); const float kSpacing = be_control_look->DefaultItemSpacing();
BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 2);
settingsBox->SetLayout(settingsLayout);
BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 2);
buttonBox->SetLayout(buttonLayout);
BStringView* expansionLabel = new BStringView("stringViewExpansion", BStringView* expansionLabel = new BStringView("stringViewExpansion",
B_TRANSLATE("Expansion")); B_TRANSLATE("Expansion"));
expansionLabel->SetFont(be_bold_font); expansionLabel->SetFont(be_bold_font);
@@ -103,54 +97,50 @@ ExpanderPreferences::ExpanderPreferences(BMessage* settings)
// Build the layout // Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL, 0) BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.AddGroup(settingsLayout) .AddGroup(B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL) .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
.Add(expansionLabel) B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
.AddGlue() .Add(expansionLabel)
.End()
.AddGroup(B_VERTICAL, 0) .AddGroup(B_VERTICAL, 0)
.Add(fAutoExpand) .Add(fAutoExpand)
.Add(fCloseWindow) .Add(fCloseWindow)
.SetInsets(kSpacing, 0, 0, 0)
.End()
.AddGroup(B_HORIZONTAL, 0)
.Add(destinationLabel)
.AddGlue() .AddGlue()
.SetInsets(0, kSpacing, 0, 0) .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, 0,
.End() B_USE_ITEM_SPACING)
.End()
.Add(destinationLabel)
.AddGroup(B_VERTICAL, 0) .AddGroup(B_VERTICAL, 0)
.Add(fLeaveDest) .Add(fLeaveDest)
.Add(fSameDest) .Add(fSameDest)
.Add(fDestUse) .Add(fDestUse)
.AddGroup(B_HORIZONTAL, 0) .AddGroup(B_HORIZONTAL, 0)
.Add(fDestText, 0.8) .Add(fDestText, 0.8)
.AddStrut(be_control_look->DefaultLabelSpacing()) .AddStrut(B_USE_ITEM_SPACING)
.Add(fSelect, 0.2) .Add(fSelect, 0.2)
.SetInsets(kSpacing * 2, 0, kSpacing / 2, 0) .SetInsets(kSpacing * 2, 0, 0, 0)
.End() .End()
.SetInsets(kSpacing, 0, 0, 0)
.End()
.AddGroup(B_HORIZONTAL, 0)
.Add(otherLabel)
.AddGlue() .AddGlue()
.SetInsets(0, kSpacing / 2, 0, 0) .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, 0,
.End() B_USE_ITEM_SPACING)
.End()
.Add(otherLabel)
.AddGroup(B_VERTICAL, 0) .AddGroup(B_VERTICAL, 0)
.Add(fOpenDest) .Add(fOpenDest)
.Add(fAutoShow) .Add(fAutoShow)
.SetInsets(kSpacing, 0, 0, 0)
.End()
.SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
.End()
.AddGroup(buttonLayout)
.AddGroup(B_HORIZONTAL, kSpacing)
.AddGlue() .AddGlue()
.Add(cancel) .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, 0, 0)
.Add(okbutton) .End()
.End() .End()
.SetInsets(kSpacing, kSpacing, kSpacing, kSpacing) .Add(new BSeparatorView(B_HORIZONTAL))
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.SetInsets(0, B_USE_DEFAULT_SPACING,
B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
.AddGlue()
.Add(cancel)
.Add(okbutton)
.End(); .End();
fDestText->SetExplicitAlignment( fDestText->SetExplicitAlignment(
BAlignment(B_ALIGN_HORIZONTAL_UNSET, B_ALIGN_VERTICAL_CENTER)); BAlignment(B_ALIGN_HORIZONTAL_UNSET, B_ALIGN_VERTICAL_CENTER));
+28 -25
View File
@@ -102,35 +102,33 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
const float spacing = be_control_look->DefaultItemSpacing(); const float spacing = be_control_look->DefaultItemSpacing();
BGroupLayout* pathLayout; BGroupLayout* pathLayout;
BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0) BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(0.0)
.Add(fBar) .Add(fBar)
.AddGroup(B_VERTICAL, spacing) .AddGroup(B_VERTICAL, B_USE_ITEM_SPACING)
.AddGroup(B_HORIZONTAL, spacing) .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
.AddGroup(B_VERTICAL, 5.0) .Add(fSourceButton)
.Add(fSourceButton) .Add(fSourceText = new BTextControl(NULL, NULL,
.Add(fDestButton) new BMessage(MSG_SOURCETEXT)))
.Add(fExpandButton)
.End() .End()
.AddGroup(B_VERTICAL, spacing) .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
.Add(fSourceText = new BTextControl(NULL, NULL, .Add(fDestButton)
new BMessage(MSG_SOURCETEXT))) .Add(fDestText = new BTextControl(NULL, NULL,
.Add(fDestText = new BTextControl(NULL, NULL, new BMessage(MSG_DESTTEXT)))
new BMessage(MSG_DESTTEXT))) .End()
.AddGroup(B_HORIZONTAL, spacing) .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
.GetLayout(&pathLayout) .Add(fExpandButton)
.Add(fShowContents = new BCheckBox( .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
B_TRANSLATE("Show contents"), .GetLayout(&pathLayout)
new BMessage(MSG_SHOWCONTENTS))) .Add(fShowContents = new BCheckBox(
.Add(fStatusView = new BStringView(NULL, B_TRANSLATE("Show contents"),
statusPlaceholderString)) new BMessage(MSG_SHOWCONTENTS)))
.Add(fStatusView = new BStringView(NULL,
statusPlaceholderString))
.End() .End()
.End() .End()
.End()
.Add(fScrollView) .Add(fScrollView)
.SetInsets(spacing, spacing, spacing, spacing) .SetInsets(B_USE_WINDOW_SPACING)
.End() .End();
.End();
pathLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); pathLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
size = GetLayout()->View()->PreferredSize(); size = GetLayout()->View()->PreferredSize();
@@ -141,6 +139,8 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
SetZoomLimits(Bounds().Width(), fSizeLimit); SetZoomLimits(Bounds().Width(), fSizeLimit);
fPreviousHeight = -1; fPreviousHeight = -1;
fScrollView->Hide();
Show(); Show();
} }
@@ -309,9 +309,12 @@ ExpanderWindow::MessageReceived(BMessage* message)
if (fListingStarted) if (fListingStarted)
StopListing(); StopListing();
fScrollView->Hide();
_UpdateWindowSize(false); _UpdateWindowSize(false);
} else } else {
fScrollView->Show();
StartListing(); StartListing();
}
break; break;
case MSG_SOURCETEXT: case MSG_SOURCETEXT: