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.
This commit is contained in:
@@ -286,38 +286,38 @@ ControlView::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
if (currentFamilyItem) {
|
if (currentFamilyItem) {
|
||||||
familyindex = fFontFamilyMenu->IndexOf(currentFamilyItem);
|
familyindex = fFontFamilyMenu->IndexOf(currentFamilyItem);
|
||||||
const int32 installedStyles = count_font_styles(
|
const int32 installedStyles = count_font_styles(
|
||||||
const_cast<char*>(currentFamilyItem->Label()));
|
const_cast<char*>(currentFamilyItem->Label()));
|
||||||
|
|
||||||
BMenu* submenu = currentFamilyItem->Submenu();
|
BMenu* submenu = currentFamilyItem->Submenu();
|
||||||
if (submenu) {
|
if (submenu) {
|
||||||
BMenuItem* markedStyle = submenu->FindMarked();
|
BMenuItem* markedStyle = submenu->FindMarked();
|
||||||
fFontStyleindex = submenu->IndexOf(markedStyle);
|
fFontStyleindex = submenu->IndexOf(markedStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fFontStyleindex < installedStyles - 1)
|
if (fFontStyleindex < installedStyles - 1)
|
||||||
fFontStyleindex++;
|
fFontStyleindex++;
|
||||||
else {
|
else {
|
||||||
fFontStyleindex = 0;
|
fFontStyleindex = 0;
|
||||||
|
|
||||||
if (familyindex < count_font_families() - 1)
|
if (familyindex < count_font_families() - 1)
|
||||||
familyindex++;
|
familyindex++;
|
||||||
else
|
else
|
||||||
familyindex = 0;
|
familyindex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BMenuItem* newFontFamilyItem = fFontFamilyMenu->ItemAt(familyindex);
|
BMenuItem* newFontFamilyItem = fFontFamilyMenu->ItemAt(familyindex);
|
||||||
BMenuItem* newstyleitem = submenu->ItemAt(fFontStyleindex);
|
BMenuItem* newstyleitem = submenu->ItemAt(fFontStyleindex);
|
||||||
|
|
||||||
if (newFontFamilyItem && newstyleitem) {
|
if (newFontFamilyItem && newstyleitem) {
|
||||||
if (msg->AddString("_style", newstyleitem->Label()) != B_OK
|
if (msg->AddString("_style", newstyleitem->Label()) != B_OK
|
||||||
|| msg->AddString("_family", newFontFamilyItem->Label()) != B_OK) {
|
|| msg->AddString("_family", newFontFamilyItem->Label()) != B_OK) {
|
||||||
printf("Failed to add style or family to the message\n");
|
printf("Failed to add style or family to the message\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("InstalledStyles(%" B_PRId32 "), Font(%s), Style(%s)\n",
|
printf("InstalledStyles(%" B_PRId32 "), Font(%s), Style(%s)\n",
|
||||||
installedStyles, newFontFamilyItem->Label(),
|
installedStyles, newFontFamilyItem->Label(),
|
||||||
newstyleitem->Label());
|
newstyleitem->Label());
|
||||||
_UpdateAndSendStyle(msg);
|
_UpdateAndSendStyle(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,6 +358,7 @@ ControlView::_UpdateFontmenus(bool setInitialfont)
|
|||||||
for (int32 i = 0; i < fontfamilies; i++) {
|
for (int32 i = 0; i < fontfamilies; i++) {
|
||||||
if (get_font_family(i, &fontFamilyName) == B_OK) {
|
if (get_font_family(i, &fontFamilyName) == B_OK) {
|
||||||
stylemenu = new BPopUpMenu(fontFamilyName);
|
stylemenu = new BPopUpMenu(fontFamilyName);
|
||||||
|
stylemenu->SetLabelFromMarked(false);
|
||||||
const int32 styles = count_font_styles(fontFamilyName);
|
const int32 styles = count_font_styles(fontFamilyName);
|
||||||
|
|
||||||
BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG);
|
BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG);
|
||||||
@@ -390,12 +391,13 @@ ControlView::_UpdateFontmenus(bool setInitialfont)
|
|||||||
stylemenu->AddItem(styleItem);
|
stylemenu->AddItem(styleItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stylemenu->SetRadioMode(true);
|
||||||
|
stylemenu->SetTargetForItems(this);
|
||||||
}
|
}
|
||||||
stylemenu->SetRadioMode(true);
|
|
||||||
stylemenu->SetTargetForItems(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fFontFamilyMenu->SetLabelFromMarked(true);
|
fFontFamilyMenu->SetLabelFromMarked(false);
|
||||||
fFontFamilyMenu->SetTargetForItems(this);
|
fFontFamilyMenu->SetTargetForItems(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,11 +407,11 @@ ControlView::_AddFontMenu()
|
|||||||
{
|
{
|
||||||
fFontFamilyMenu = new BPopUpMenu("fontfamlilymenu");
|
fFontFamilyMenu = new BPopUpMenu("fontfamlilymenu");
|
||||||
|
|
||||||
_UpdateFontmenus(true);
|
|
||||||
|
|
||||||
fFontMenuField = new BMenuField("FontMenuField",
|
fFontMenuField = new BMenuField("FontMenuField",
|
||||||
B_TRANSLATE("Font:"), fFontFamilyMenu);
|
B_TRANSLATE("Font:"), fFontFamilyMenu);
|
||||||
AddChild(fFontMenuField);
|
AddChild(fFontMenuField);
|
||||||
|
|
||||||
|
_UpdateFontmenus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user