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 47ba82bf03
commit a3e22cdaa7
2 changed files with 17 additions and 20 deletions
+15 -20
View File
@@ -181,14 +181,14 @@ InstallerWindow::InstallerWindow()
BSize logoSize = logoView->MinSize(); BSize logoSize = logoView->MinSize();
logoView->SetExplicitMaxSize(logoSize); logoView->SetExplicitMaxSize(logoSize);
fStatusView->SetExplicitMinSize(BSize(logoSize.width * 0.8, fStatusView->SetExplicitMinSize(BSize(logoSize.width * 0.8,
B_SIZE_UNSET)); logoSize.height));
// Explicitly create group view to set the background white in case // Explicitly create group view to set the background white in case
// height resizing is needed for the status view // height resizing is needed for the status view
BGroupView* logoGroup = new BGroupView(B_HORIZONTAL, 0); fLogoGroup = new BGroupView(B_HORIZONTAL, 0);
logoGroup->SetViewColor(255, 255, 255); fLogoGroup->SetViewColor(255, 255, 255);
logoGroup->AddChild(logoView); fLogoGroup->GroupLayout()->AddView(logoView);
logoGroup->AddChild(fStatusView); fLogoGroup->GroupLayout()->AddView(fStatusView);
fDestMenu = new BPopUpMenu(B_TRANSLATE("scanning" B_UTF8_ELLIPSIS), fDestMenu = new BPopUpMenu(B_TRANSLATE("scanning" B_UTF8_ELLIPSIS),
true, false); true, false);
@@ -252,7 +252,7 @@ InstallerWindow::InstallerWindow()
BLayoutBuilder::Group<>(this, B_VERTICAL, 0) BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.Add(mainMenu) .Add(mainMenu)
.Add(logoGroup) .Add(fLogoGroup)
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.AddGroup(B_VERTICAL, B_USE_ITEM_SPACING) .AddGroup(B_VERTICAL, B_USE_ITEM_SPACING)
.SetInsets(B_USE_WINDOW_SPACING) .SetInsets(B_USE_WINDOW_SPACING)
@@ -496,10 +496,10 @@ InstallerWindow::MessageReceived(BMessage *msg)
PartitionMenuItem* dstItem PartitionMenuItem* dstItem
= (PartitionMenuItem*)fDestMenu->FindMarked(); = (PartitionMenuItem*)fDestMenu->FindMarked();
char status[1024]; BString status;
if (be_roster->IsRunning(kDeskbarSignature)) { if (be_roster->IsRunning(kDeskbarSignature)) {
fBeginButton->SetLabel(B_TRANSLATE("Quit")); 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 " "completed. Boot sector has been written to '%s'. Press "
"Quit to leave the Installer or choose a new target " "Quit to leave the Installer or choose a new target "
"volume to perform another installation."), "volume to perform another installation."),
@@ -507,7 +507,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
"Unknown partition name")); "Unknown partition name"));
} else { } else {
fBeginButton->SetLabel(B_TRANSLATE("Restart")); 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 " "completed. Boot sector has been written to '%s'. Press "
"Restart to restart the computer or choose a new target " "Restart to restart the computer or choose a new target "
"volume to perform another installation."), "volume to perform another installation."),
@@ -515,7 +515,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
"Unknown partition name")); "Unknown partition name"));
} }
_SetStatusMessage(status); _SetStatusMessage(status.String());
fInstallStatus = kFinished; fInstallStatus = kFinished;
_DisableInterface(false); _DisableInterface(false);
fProgressLayoutItem->SetVisible(false); fProgressLayoutItem->SetVisible(false);
@@ -787,10 +787,10 @@ InstallerWindow::_UpdateControls()
fDestMenuField->MenuItem()->SetLabel(label.String()); fDestMenuField->MenuItem()->SetLabel(label.String());
if (srcItem != NULL && dstItem != NULL) { if (srcItem != NULL && dstItem != NULL) {
char message[255]; BString message;
sprintf(message, B_TRANSLATE("Press the Begin button to install from " message.SetToFormat(B_TRANSLATE("Press the Begin button to install "
"'%1s' onto '%2s'."), srcItem->Name(), dstItem->Name()); "from '%1s' onto '%2s'."), srcItem->Name(), dstItem->Name());
_SetStatusMessage(message); _SetStatusMessage(message.String());
} else if (srcItem != NULL) { } else if (srcItem != NULL) {
_SetStatusMessage(B_TRANSLATE("Choose the disk you want to install " _SetStatusMessage(B_TRANSLATE("Choose the disk you want to install "
"onto from the pop-up menu. Then click \"Begin\".")); "onto from the pop-up menu. Then click \"Begin\"."));
@@ -872,12 +872,7 @@ void
InstallerWindow::_SetStatusMessage(const char *text) InstallerWindow::_SetStatusMessage(const char *text)
{ {
fStatusView->SetText(text); fStatusView->SetText(text);
fLogoGroup->GroupLayout()->InvalidateLayout();
// 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));
} }
+2
View File
@@ -18,6 +18,7 @@ using namespace BPrivate;
class BButton; class BButton;
class BLayoutItem; class BLayoutItem;
class BGroupView;
class BMenu; class BMenu;
class BMenuField; class BMenuField;
class BMenuItem; class BMenuItem;
@@ -60,6 +61,7 @@ private:
static int _ComparePackages(const void* firstArg, static int _ComparePackages(const void* firstArg,
const void* secondArg); const void* secondArg);
BGroupView* fLogoGroup;
BTextView* fStatusView; BTextView* fStatusView;
BMenu* fSrcMenu; BMenu* fSrcMenu;
BMenu* fDestMenu; BMenu* fDestMenu;