Installer: Rework status message view sizing logic.

* Make the status message view have a minimum height of the logo
   view's height.
 * Properly add the views to the BGroupView layout.
 * Instead of trying to set the explicit minimum size from the status
   view information, just invalidate the GroupLayout. This seems to fix
   a number of bugs relating to text overflowing the view, while it doesn't
   fix others (e.g. orphan words on their own lines are still not drawn
   in some cases, which appears to be a BTextView bug.)
 * Use BString::SetToFormat instead of snprintf in some places.

As far as I can make out, fixes #13608.
This commit is contained in:
Augustin Cavalier 2018-09-08 19:49:03 -04:00
parent 4a8634227e
commit bd949e1c02
2 changed files with 17 additions and 20 deletions

View File

@ -181,14 +181,14 @@ InstallerWindow::InstallerWindow()
BSize logoSize = logoView->MinSize();
logoView->SetExplicitMaxSize(logoSize);
fStatusView->SetExplicitMinSize(BSize(logoSize.width * 0.8,
B_SIZE_UNSET));
logoSize.height));
// Explicitly create group view to set the background white in case
// height resizing is needed for the status view
BGroupView* logoGroup = new BGroupView(B_HORIZONTAL, 0);
logoGroup->SetViewColor(255, 255, 255);
logoGroup->AddChild(logoView);
logoGroup->AddChild(fStatusView);
fLogoGroup = new BGroupView(B_HORIZONTAL, 0);
fLogoGroup->SetViewColor(255, 255, 255);
fLogoGroup->GroupLayout()->AddView(logoView);
fLogoGroup->GroupLayout()->AddView(fStatusView);
fDestMenu = new BPopUpMenu(B_TRANSLATE("scanning" B_UTF8_ELLIPSIS),
true, false);
@ -252,7 +252,7 @@ InstallerWindow::InstallerWindow()
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.Add(mainMenu)
.Add(logoGroup)
.Add(fLogoGroup)
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.AddGroup(B_VERTICAL, B_USE_ITEM_SPACING)
.SetInsets(B_USE_WINDOW_SPACING)
@ -500,10 +500,10 @@ InstallerWindow::MessageReceived(BMessage *msg)
PartitionMenuItem* dstItem
= (PartitionMenuItem*)fDestMenu->FindMarked();
char status[1024];
BString status;
if (be_roster->IsRunning(kDeskbarSignature)) {
fBeginButton->SetLabel(B_TRANSLATE("Quit"));
snprintf(status, sizeof(status), B_TRANSLATE("Installation "
status.SetToFormat(B_TRANSLATE("Installation "
"completed. Boot sector has been written to '%s'. Press "
"Quit to leave the Installer or choose a new target "
"volume to perform another installation."),
@ -511,7 +511,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
"Unknown partition name"));
} else {
fBeginButton->SetLabel(B_TRANSLATE("Restart"));
snprintf(status, sizeof(status), B_TRANSLATE("Installation "
status.SetToFormat(B_TRANSLATE("Installation "
"completed. Boot sector has been written to '%s'. Press "
"Restart to restart the computer or choose a new target "
"volume to perform another installation."),
@ -519,7 +519,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
"Unknown partition name"));
}
_SetStatusMessage(status);
_SetStatusMessage(status.String());
fInstallStatus = kFinished;
_DisableInterface(false);
fProgressLayoutItem->SetVisible(false);
@ -791,10 +791,10 @@ InstallerWindow::_UpdateControls()
fDestMenuField->MenuItem()->SetLabel(label.String());
if (srcItem != NULL && dstItem != NULL) {
char message[255];
sprintf(message, B_TRANSLATE("Press the Begin button to install from "
"'%1s' onto '%2s'."), srcItem->Name(), dstItem->Name());
_SetStatusMessage(message);
BString message;
message.SetToFormat(B_TRANSLATE("Press the Begin button to install "
"from '%1s' onto '%2s'."), srcItem->Name(), dstItem->Name());
_SetStatusMessage(message.String());
} else if (srcItem != NULL) {
_SetStatusMessage(B_TRANSLATE("Choose the disk you want to install "
"onto from the pop-up menu. Then click \"Begin\"."));
@ -876,12 +876,7 @@ void
InstallerWindow::_SetStatusMessage(const char *text)
{
fStatusView->SetText(text);
// Make the status view taller if needed
BSize size = fStatusView->ExplicitMinSize();
float heightNeeded = fStatusView->TextHeight(0, fStatusView->CountLines()) + 15.0;
if (heightNeeded > size.height)
fStatusView->SetExplicitMinSize(BSize(size.width, heightNeeded));
fLogoGroup->GroupLayout()->InvalidateLayout();
}

View File

@ -18,6 +18,7 @@ using namespace BPrivate;
class BButton;
class BLayoutItem;
class BGroupView;
class BMenu;
class BMenuField;
class BMenuItem;
@ -60,6 +61,7 @@ private:
static int _ComparePackages(const void* firstArg,
const void* secondArg);
BGroupView* fLogoGroup;
BTextView* fStatusView;
BMenu* fSrcMenu;
BMenu* fDestMenu;