From 122fdeece7169a2a55fdb4ea5aabaa2de1ba6bdb Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 28 Nov 2014 10:45:36 +0100 Subject: [PATCH] FontDemo: fix overwriting of family with style. Menus were wrongly set to SetLabelFromMarked (probably from a previous version of the UI without the nested font menu). Fixes #11517. --- src/apps/fontdemo/ControlView.cpp | 58 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/apps/fontdemo/ControlView.cpp b/src/apps/fontdemo/ControlView.cpp index ab7da39429..7c15aae8ec 100644 --- a/src/apps/fontdemo/ControlView.cpp +++ b/src/apps/fontdemo/ControlView.cpp @@ -286,38 +286,38 @@ ControlView::MessageReceived(BMessage* msg) if (currentFamilyItem) { familyindex = fFontFamilyMenu->IndexOf(currentFamilyItem); - const int32 installedStyles = count_font_styles( - const_cast(currentFamilyItem->Label())); + const int32 installedStyles = count_font_styles( + const_cast(currentFamilyItem->Label())); - BMenu* submenu = currentFamilyItem->Submenu(); - if (submenu) { - BMenuItem* markedStyle = submenu->FindMarked(); - fFontStyleindex = submenu->IndexOf(markedStyle); + BMenu* submenu = currentFamilyItem->Submenu(); + if (submenu) { + BMenuItem* markedStyle = submenu->FindMarked(); + fFontStyleindex = submenu->IndexOf(markedStyle); } - if (fFontStyleindex < installedStyles - 1) - fFontStyleindex++; - else { - fFontStyleindex = 0; + if (fFontStyleindex < installedStyles - 1) + fFontStyleindex++; + else { + fFontStyleindex = 0; - if (familyindex < count_font_families() - 1) - familyindex++; - else - familyindex = 0; + if (familyindex < count_font_families() - 1) + familyindex++; + else + familyindex = 0; } BMenuItem* newFontFamilyItem = fFontFamilyMenu->ItemAt(familyindex); - BMenuItem* newstyleitem = submenu->ItemAt(fFontStyleindex); + BMenuItem* newstyleitem = submenu->ItemAt(fFontStyleindex); - if (newFontFamilyItem && newstyleitem) { - if (msg->AddString("_style", newstyleitem->Label()) != B_OK - || msg->AddString("_family", newFontFamilyItem->Label()) != B_OK) { - printf("Failed to add style or family to the message\n"); - return; - } + if (newFontFamilyItem && newstyleitem) { + if (msg->AddString("_style", newstyleitem->Label()) != B_OK + || msg->AddString("_family", newFontFamilyItem->Label()) != B_OK) { + printf("Failed to add style or family to the message\n"); + return; + } printf("InstalledStyles(%" B_PRId32 "), Font(%s), Style(%s)\n", - installedStyles, newFontFamilyItem->Label(), - newstyleitem->Label()); + installedStyles, newFontFamilyItem->Label(), + newstyleitem->Label()); _UpdateAndSendStyle(msg); } } @@ -358,6 +358,7 @@ ControlView::_UpdateFontmenus(bool setInitialfont) for (int32 i = 0; i < fontfamilies; i++) { if (get_font_family(i, &fontFamilyName) == B_OK) { stylemenu = new BPopUpMenu(fontFamilyName); + stylemenu->SetLabelFromMarked(false); const int32 styles = count_font_styles(fontFamilyName); BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG); @@ -390,12 +391,13 @@ ControlView::_UpdateFontmenus(bool setInitialfont) stylemenu->AddItem(styleItem); } } + + stylemenu->SetRadioMode(true); + stylemenu->SetTargetForItems(this); } - stylemenu->SetRadioMode(true); - stylemenu->SetTargetForItems(this); } - fFontFamilyMenu->SetLabelFromMarked(true); + fFontFamilyMenu->SetLabelFromMarked(false); fFontFamilyMenu->SetTargetForItems(this); } @@ -405,11 +407,11 @@ ControlView::_AddFontMenu() { fFontFamilyMenu = new BPopUpMenu("fontfamlilymenu"); - _UpdateFontmenus(true); - fFontMenuField = new BMenuField("FontMenuField", B_TRANSLATE("Font:"), fFontFamilyMenu); AddChild(fFontMenuField); + + _UpdateFontmenus(true); }