diff --git a/src/preferences/fonts/FontSelectionView.cpp b/src/preferences/fonts/FontSelectionView.cpp index 94272db352..0fcbf87562 100644 --- a/src/preferences/fonts/FontSelectionView.cpp +++ b/src/preferences/fonts/FontSelectionView.cpp @@ -88,10 +88,10 @@ FontSelectionView::FontSelectionView(BRect _rect, const char* name, AddChild(fFontsMenuField); // size menu - rect.right = rect.left + StringWidth("99") + 40; + rect.right = rect.left + StringWidth("Size: 99") + 30.0f; fSizesMenuField = new BMenuField(rect, "sizes", "Size:", fSizesMenu, true, - B_FOLLOW_RIGHT | B_FOLLOW_TOP); - fSizesMenuField->SetDivider(StringWidth(fSizesMenuField->Label()) + 5.0); + B_FOLLOW_TOP); + fSizesMenuField->SetDivider(StringWidth(fSizesMenuField->Label()) + 5.0f); fSizesMenuField->SetAlignment(B_ALIGN_RIGHT); fSizesMenuField->ResizeToPreferred(); rect = Bounds(); @@ -165,6 +165,20 @@ FontSelectionView::SetDivider(float divider) } +void +FontSelectionView::RelayoutIfNeeded() +{ + float width, height; + GetPreferredSize(&width, &height); + + if (width > Bounds().Width()) { + fSizesMenuField->MoveTo(fMaxFontNameWidth + fDivider + 40.0f, + fFontsMenuField->Bounds().top); + ResizeTo(width, height); + } +} + + void FontSelectionView::AttachedToWindow() { diff --git a/src/preferences/fonts/FontSelectionView.h b/src/preferences/fonts/FontSelectionView.h index a492957ac4..e656d14979 100644 --- a/src/preferences/fonts/FontSelectionView.h +++ b/src/preferences/fonts/FontSelectionView.h @@ -30,6 +30,7 @@ class FontSelectionView : public BView { virtual void MessageReceived(BMessage *msg); void SetDivider(float divider); + void RelayoutIfNeeded(); void SetDefaults(); void Revert(); diff --git a/src/preferences/fonts/FontView.cpp b/src/preferences/fonts/FontView.cpp index 5f63a16f5a..7faf7891bc 100644 --- a/src/preferences/fonts/FontView.cpp +++ b/src/preferences/fonts/FontView.cpp @@ -85,6 +85,15 @@ FontView::UpdateFonts() } +void +FontView::RelayoutIfNeeded() +{ + fPlainView->RelayoutIfNeeded(); + fBoldView->RelayoutIfNeeded(); + fFixedView->RelayoutIfNeeded(); +} + + bool FontView::IsRevertable() { diff --git a/src/preferences/fonts/FontView.h b/src/preferences/fonts/FontView.h index 6ce256cc6c..bf9b462a76 100644 --- a/src/preferences/fonts/FontView.h +++ b/src/preferences/fonts/FontView.h @@ -23,6 +23,7 @@ class FontView : public BView { void SetDefaults(); void Revert(); void UpdateFonts(); + void RelayoutIfNeeded(); bool IsRevertable(); diff --git a/src/preferences/fonts/MainWindow.cpp b/src/preferences/fonts/MainWindow.cpp index c9b52ed041..6e335a8900 100644 --- a/src/preferences/fonts/MainWindow.cpp +++ b/src/preferences/fonts/MainWindow.cpp @@ -61,6 +61,8 @@ MainWindow::MainWindow() tabView->AddTab(fFontsView); + fFontsView->UpdateFonts(); + fFontsView->RelayoutIfNeeded(); float width, height; fFontsView->GetPreferredSize(&width, &height);