Commit 27a7b364 authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Cleanup: Remove Menu Subtitles/Sublabels

No one seems to use subtitles or sublabels.

BUG=865318

Change-Id: Ia850adabeab5aa280b2730e2a4177ac7a9f8d0cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764883
Auto-Submit: Robert Liao <robliao@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689998}
parent 323a3571
...@@ -157,7 +157,7 @@ void MockRenderViewContextMenu::AppendSubMenuItems(ui::MenuModel* model) { ...@@ -157,7 +157,7 @@ void MockRenderViewContextMenu::AppendSubMenuItems(ui::MenuModel* model) {
sub_item.enabled = model->IsEnabledAt(i); sub_item.enabled = model->IsEnabledAt(i);
sub_item.checked = model->IsItemCheckedAt(i); sub_item.checked = model->IsItemCheckedAt(i);
sub_item.hidden = false; sub_item.hidden = false;
sub_item.title = model->GetSublabelAt(i); sub_item.title = model->GetLabelAt(i);
items_.push_back(sub_item); items_.push_back(sub_item);
} }
} }
......
...@@ -20,7 +20,6 @@ struct StatusIconMenuModel::ItemState { ...@@ -20,7 +20,6 @@ struct StatusIconMenuModel::ItemState {
bool is_dynamic; bool is_dynamic;
ui::Accelerator accelerator; ui::Accelerator accelerator;
base::string16 label; base::string16 label;
base::string16 sublabel;
gfx::Image icon; gfx::Image icon;
}; };
...@@ -62,13 +61,6 @@ void StatusIconMenuModel::ChangeLabelForCommandId(int command_id, ...@@ -62,13 +61,6 @@ void StatusIconMenuModel::ChangeLabelForCommandId(int command_id,
NotifyMenuStateChanged(); NotifyMenuStateChanged();
} }
void StatusIconMenuModel::ChangeSublabelForCommandId(
int command_id, const base::string16& sublabel) {
item_states_[command_id].is_dynamic = true;
item_states_[command_id].sublabel = sublabel;
NotifyMenuStateChanged();
}
void StatusIconMenuModel::ChangeIconForCommandId( void StatusIconMenuModel::ChangeIconForCommandId(
int command_id, const gfx::Image& icon) { int command_id, const gfx::Image& icon) {
item_states_[command_id].is_dynamic = true; item_states_[command_id].is_dynamic = true;
...@@ -130,14 +122,6 @@ base::string16 StatusIconMenuModel::GetLabelForCommandId(int command_id) const { ...@@ -130,14 +122,6 @@ base::string16 StatusIconMenuModel::GetLabelForCommandId(int command_id) const {
return base::string16(); return base::string16();
} }
base::string16 StatusIconMenuModel::GetSublabelForCommandId(
int command_id) const {
auto iter = item_states_.find(command_id);
if (iter != item_states_.end())
return iter->second.sublabel;
return base::string16();
}
bool StatusIconMenuModel::GetIconForCommandId(int command_id, bool StatusIconMenuModel::GetIconForCommandId(int command_id,
gfx::Image* image_skia) const { gfx::Image* image_skia) const {
auto iter = item_states_.find(command_id); auto iter = item_states_.find(command_id);
......
...@@ -61,11 +61,9 @@ class StatusIconMenuModel ...@@ -61,11 +61,9 @@ class StatusIconMenuModel
// Calling any of these "change" methods will mark the menu item as "dynamic" // Calling any of these "change" methods will mark the menu item as "dynamic"
// (see menu_model.h:IsItemDynamicAt) which many platforms take as a cue to // (see menu_model.h:IsItemDynamicAt) which many platforms take as a cue to
// refresh the label, sublabel and icon of the menu item each time the menu is // refresh the label and icon of the menu item each time the menu is
// shown. // shown.
void ChangeLabelForCommandId(int command_id, const base::string16& label); void ChangeLabelForCommandId(int command_id, const base::string16& label);
void ChangeSublabelForCommandId(
int command_id, const base::string16& sublabel);
void ChangeIconForCommandId(int command_id, const gfx::Image& icon); void ChangeIconForCommandId(int command_id, const gfx::Image& icon);
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
...@@ -79,7 +77,6 @@ class StatusIconMenuModel ...@@ -79,7 +77,6 @@ class StatusIconMenuModel
ui::Accelerator* accelerator) const override; ui::Accelerator* accelerator) const override;
bool IsItemForCommandIdDynamic(int command_id) const override; bool IsItemForCommandIdDynamic(int command_id) const override;
base::string16 GetLabelForCommandId(int command_id) const override; base::string16 GetLabelForCommandId(int command_id) const override;
base::string16 GetSublabelForCommandId(int command_id) const override;
bool GetIconForCommandId(int command_id, gfx::Image* icon) const override; bool GetIconForCommandId(int command_id, gfx::Image* icon) const override;
protected: protected:
......
...@@ -90,10 +90,6 @@ TEST_F(StatusIconMenuModelTest, SetProperties) { ...@@ -90,10 +90,6 @@ TEST_F(StatusIconMenuModelTest, SetProperties) {
menu_model()->ChangeLabelForCommandId(0, ASCIIToUTF16("label2")); menu_model()->ChangeLabelForCommandId(0, ASCIIToUTF16("label2"));
EXPECT_EQ(ASCIIToUTF16("label2"), menu_model()->GetLabelForCommandId(0)); EXPECT_EQ(ASCIIToUTF16("label2"), menu_model()->GetLabelForCommandId(0));
// Set the sublabel and icon image for the second menu item.
menu_model()->ChangeSublabelForCommandId(1, ASCIIToUTF16("sublabel"));
EXPECT_EQ(ASCIIToUTF16("sublabel"), menu_model()->GetSublabelForCommandId(1));
// Try setting icon image and changing it. // Try setting icon image and changing it.
menu_model()->ChangeIconForCommandId(1, test_image1); menu_model()->ChangeIconForCommandId(1, test_image1);
EXPECT_TRUE(menu_model()->GetIconForCommandId(1, &image_arg)); EXPECT_TRUE(menu_model()->GetIconForCommandId(1, &image_arg));
...@@ -102,9 +98,8 @@ TEST_F(StatusIconMenuModelTest, SetProperties) { ...@@ -102,9 +98,8 @@ TEST_F(StatusIconMenuModelTest, SetProperties) {
// Ensure changes to one menu item does not affect the other menu item. // Ensure changes to one menu item does not affect the other menu item.
EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg)); EXPECT_FALSE(menu_model()->GetAcceleratorForCommandId(1, &accel_arg));
EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1)); EXPECT_EQ(base::string16(), menu_model()->GetLabelForCommandId(1));
EXPECT_EQ(base::string16(), menu_model()->GetSublabelForCommandId(0));
EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg)); EXPECT_FALSE(menu_model()->GetIconForCommandId(0, &image_arg));
// Menu state should have changed 7 times in this test. // Menu state should have changed 6 times in this test.
EXPECT_EQ(7, changed_count()); EXPECT_EQ(6, changed_count());
} }
...@@ -91,8 +91,8 @@ class MenuItemViewTestInsert : public MenuTestBase { ...@@ -91,8 +91,8 @@ class MenuItemViewTestInsert : public MenuTestBase {
inserted_item_ = menu()->AddMenuItemAt( inserted_item_ = menu()->AddMenuItemAt(
INSERT_INDEX, 1000, ASCIIToUTF16("inserted item"), base::string16(), INSERT_INDEX, 1000, ASCIIToUTF16("inserted item"), base::string16(),
base::string16(), nullptr, gfx::ImageSkia(), nullptr, nullptr, gfx::ImageSkia(), nullptr, views::MenuItemView::NORMAL,
views::MenuItemView::NORMAL, ui::NORMAL_SEPARATOR); ui::NORMAL_SEPARATOR);
ASSERT_TRUE(inserted_item_); ASSERT_TRUE(inserted_item_);
menu()->ChildrenChanged(); menu()->ChildrenChanged();
...@@ -186,8 +186,8 @@ class MenuItemViewTestInsertWithSubmenu : public MenuTestBase { ...@@ -186,8 +186,8 @@ class MenuItemViewTestInsertWithSubmenu : public MenuTestBase {
void Step2() { void Step2() {
inserted_item_ = menu()->AddMenuItemAt( inserted_item_ = menu()->AddMenuItemAt(
INSERT_INDEX, 1000, ASCIIToUTF16("inserted item"), base::string16(), INSERT_INDEX, 1000, ASCIIToUTF16("inserted item"), base::string16(),
base::string16(), nullptr, gfx::ImageSkia(), nullptr, nullptr, gfx::ImageSkia(), nullptr, views::MenuItemView::NORMAL,
views::MenuItemView::NORMAL, ui::NORMAL_SEPARATOR); ui::NORMAL_SEPARATOR);
ASSERT_TRUE(inserted_item_); ASSERT_TRUE(inserted_item_);
menu()->ChildrenChanged(); menu()->ChildrenChanged();
......
...@@ -33,10 +33,6 @@ base::string16 ConcatMenuModel::GetLabelAt(int index) const { ...@@ -33,10 +33,6 @@ base::string16 ConcatMenuModel::GetLabelAt(int index) const {
return GetterImpl(&ui::MenuModel::GetLabelAt, index); return GetterImpl(&ui::MenuModel::GetLabelAt, index);
} }
base::string16 ConcatMenuModel::GetSublabelAt(int index) const {
return GetterImpl(&ui::MenuModel::GetSublabelAt, index);
}
base::string16 ConcatMenuModel::GetMinorTextAt(int index) const { base::string16 ConcatMenuModel::GetMinorTextAt(int index) const {
return GetterImpl(&ui::MenuModel::GetMinorTextAt, index); return GetterImpl(&ui::MenuModel::GetMinorTextAt, index);
} }
......
...@@ -23,7 +23,6 @@ class ConcatMenuModel : public ui::MenuModel { ...@@ -23,7 +23,6 @@ class ConcatMenuModel : public ui::MenuModel {
ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override;
int GetCommandIdAt(int index) const override; int GetCommandIdAt(int index) const override;
base::string16 GetLabelAt(int index) const override; base::string16 GetLabelAt(int index) const override;
base::string16 GetSublabelAt(int index) const override;
base::string16 GetMinorTextAt(int index) const override; base::string16 GetMinorTextAt(int index) const override;
const gfx::VectorIcon* GetMinorIconAt(int index) const override; const gfx::VectorIcon* GetMinorIconAt(int index) const override;
bool IsItemDynamicAt(int index) const override; bool IsItemDynamicAt(int index) const override;
......
...@@ -46,10 +46,6 @@ bool MenuModel::GetModelAndIndexForCommandId(int command_id, ...@@ -46,10 +46,6 @@ bool MenuModel::GetModelAndIndexForCommandId(int command_id,
return false; return false;
} }
base::string16 MenuModel::GetSublabelAt(int index) const {
return base::string16();
}
base::string16 MenuModel::GetMinorTextAt(int index) const { base::string16 MenuModel::GetMinorTextAt(int index) const {
return base::string16(); return base::string16();
} }
......
...@@ -64,10 +64,6 @@ class UI_BASE_EXPORT MenuModel { ...@@ -64,10 +64,6 @@ class UI_BASE_EXPORT MenuModel {
// Returns the label of the item at the specified index. // Returns the label of the item at the specified index.
virtual base::string16 GetLabelAt(int index) const = 0; virtual base::string16 GetLabelAt(int index) const = 0;
// Returns the sublabel of the item at the specified index. The sublabel
// is rendered beneath the label and using the font GetLabelFontAt().
virtual base::string16 GetSublabelAt(int index) const;
// Returns the minor text of the item at the specified index. The minor text // Returns the minor text of the item at the specified index. The minor text
// is rendered to the right of the label and using the font GetLabelFontAt(). // is rendered to the right of the label and using the font GetLabelFontAt().
virtual base::string16 GetMinorTextAt(int index) const; virtual base::string16 GetMinorTextAt(int index) const;
......
...@@ -42,11 +42,6 @@ base::string16 SimpleMenuModel::Delegate::GetLabelForCommandId( ...@@ -42,11 +42,6 @@ base::string16 SimpleMenuModel::Delegate::GetLabelForCommandId(
return base::string16(); return base::string16();
} }
base::string16 SimpleMenuModel::Delegate::GetSublabelForCommandId(
int command_id) const {
return base::string16();
}
base::string16 SimpleMenuModel::Delegate::GetMinorTextForCommandId( base::string16 SimpleMenuModel::Delegate::GetMinorTextForCommandId(
int command_id) const { int command_id) const {
return base::string16(); return base::string16();
...@@ -329,11 +324,6 @@ void SimpleMenuModel::SetLabel(int index, const base::string16& label) { ...@@ -329,11 +324,6 @@ void SimpleMenuModel::SetLabel(int index, const base::string16& label) {
MenuItemsChanged(); MenuItemsChanged();
} }
void SimpleMenuModel::SetSublabel(int index, const base::string16& sublabel) {
items_[ValidateItemIndex(index)].sublabel = sublabel;
MenuItemsChanged();
}
void SimpleMenuModel::SetMinorText(int index, void SimpleMenuModel::SetMinorText(int index,
const base::string16& minor_text) { const base::string16& minor_text) {
items_[ValidateItemIndex(index)].minor_text = minor_text; items_[ValidateItemIndex(index)].minor_text = minor_text;
...@@ -408,12 +398,6 @@ base::string16 SimpleMenuModel::GetLabelAt(int index) const { ...@@ -408,12 +398,6 @@ base::string16 SimpleMenuModel::GetLabelAt(int index) const {
return items_[ValidateItemIndex(index)].label; return items_[ValidateItemIndex(index)].label;
} }
base::string16 SimpleMenuModel::GetSublabelAt(int index) const {
if (IsItemDynamicAt(index))
return delegate_->GetSublabelForCommandId(GetCommandIdAt(index));
return items_[ValidateItemIndex(index)].sublabel;
}
base::string16 SimpleMenuModel::GetMinorTextAt(int index) const { base::string16 SimpleMenuModel::GetMinorTextAt(int index) const {
if (IsItemDynamicAt(index)) if (IsItemDynamicAt(index))
return delegate_->GetMinorTextForCommandId(GetCommandIdAt(index)); return delegate_->GetMinorTextForCommandId(GetCommandIdAt(index));
......
...@@ -44,11 +44,10 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel { ...@@ -44,11 +44,10 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
// Delegate should return true if |command_id| should be visible. // Delegate should return true if |command_id| should be visible.
virtual bool IsCommandIdVisible(int command_id) const; virtual bool IsCommandIdVisible(int command_id) const;
// Some command ids have labels, sublabels, minor text and icons that change // Some command ids have labels, minor text and icons that change over
// over time. // time.
virtual bool IsItemForCommandIdDynamic(int command_id) const; virtual bool IsItemForCommandIdDynamic(int command_id) const;
virtual base::string16 GetLabelForCommandId(int command_id) const; virtual base::string16 GetLabelForCommandId(int command_id) const;
virtual base::string16 GetSublabelForCommandId(int command_id) const;
virtual base::string16 GetMinorTextForCommandId(int command_id) const; virtual base::string16 GetMinorTextForCommandId(int command_id) const;
// Gets the icon for the item with the specified id, returning true if there // Gets the icon for the item with the specified id, returning true if there
// is an icon, false otherwise. // is an icon, false otherwise.
...@@ -176,9 +175,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel { ...@@ -176,9 +175,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
// Sets the label for the item at |index|. // Sets the label for the item at |index|.
void SetLabel(int index, const base::string16& label); void SetLabel(int index, const base::string16& label);
// Sets the sublabel for the item at |index|.
void SetSublabel(int index, const base::string16& sublabel);
// Sets the minor text for the item at |index|. // Sets the minor text for the item at |index|.
void SetMinorText(int index, const base::string16& minor_text); void SetMinorText(int index, const base::string16& minor_text);
...@@ -205,7 +201,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel { ...@@ -205,7 +201,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override;
int GetCommandIdAt(int index) const override; int GetCommandIdAt(int index) const override;
base::string16 GetLabelAt(int index) const override; base::string16 GetLabelAt(int index) const override;
base::string16 GetSublabelAt(int index) const override;
base::string16 GetMinorTextAt(int index) const override; base::string16 GetMinorTextAt(int index) const override;
const gfx::VectorIcon* GetMinorIconAt(int index) const override; const gfx::VectorIcon* GetMinorIconAt(int index) const override;
bool IsItemDynamicAt(int index) const override; bool IsItemDynamicAt(int index) const override;
...@@ -241,7 +236,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel { ...@@ -241,7 +236,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
int command_id = 0; int command_id = 0;
ItemType type = TYPE_COMMAND; ItemType type = TYPE_COMMAND;
base::string16 label; base::string16 label;
base::string16 sublabel;
base::string16 minor_text; base::string16 minor_text;
const gfx::VectorIcon* minor_icon = nullptr; const gfx::VectorIcon* minor_icon = nullptr;
gfx::Image icon; gfx::Image icon;
......
...@@ -275,7 +275,6 @@ MenuItemView* MenuItemView::AddMenuItemAt( ...@@ -275,7 +275,6 @@ MenuItemView* MenuItemView::AddMenuItemAt(
int index, int index,
int item_id, int item_id,
const base::string16& label, const base::string16& label,
const base::string16& sublabel,
const base::string16& minor_text, const base::string16& minor_text,
const gfx::VectorIcon* minor_icon, const gfx::VectorIcon* minor_icon,
const gfx::ImageSkia& icon, const gfx::ImageSkia& icon,
...@@ -296,7 +295,6 @@ MenuItemView* MenuItemView::AddMenuItemAt( ...@@ -296,7 +295,6 @@ MenuItemView* MenuItemView::AddMenuItemAt(
item->SetTitle(GetDelegate()->GetLabel(item_id)); item->SetTitle(GetDelegate()->GetLabel(item_id));
else else
item->SetTitle(label); item->SetTitle(label);
item->SetSubtitle(sublabel);
item->SetMinorText(minor_text); item->SetMinorText(minor_text);
item->SetMinorIcon(minor_icon); item->SetMinorIcon(minor_icon);
if (vector_icon) { if (vector_icon) {
...@@ -338,23 +336,21 @@ void MenuItemView::RemoveAllMenuItems() { ...@@ -338,23 +336,21 @@ void MenuItemView::RemoveAllMenuItems() {
MenuItemView* MenuItemView::AppendMenuItem(int item_id, MenuItemView* MenuItemView::AppendMenuItem(int item_id,
const base::string16& label, const base::string16& label,
Type type) { Type type) {
return AppendMenuItemImpl(item_id, label, base::string16(), base::string16(), return AppendMenuItemImpl(item_id, label, base::string16(), nullptr,
nullptr, gfx::ImageSkia(), type, gfx::ImageSkia(), type, ui::NORMAL_SEPARATOR);
ui::NORMAL_SEPARATOR);
} }
MenuItemView* MenuItemView::AppendSubMenu(int item_id, MenuItemView* MenuItemView::AppendSubMenu(int item_id,
const base::string16& label) { const base::string16& label) {
return AppendMenuItemImpl(item_id, label, base::string16(), base::string16(), return AppendMenuItemImpl(item_id, label, base::string16(), nullptr,
nullptr, gfx::ImageSkia(), SUBMENU, gfx::ImageSkia(), SUBMENU, ui::NORMAL_SEPARATOR);
ui::NORMAL_SEPARATOR);
} }
MenuItemView* MenuItemView::AppendSubMenuWithIcon(int item_id, MenuItemView* MenuItemView::AppendSubMenuWithIcon(int item_id,
const base::string16& label, const base::string16& label,
const gfx::ImageSkia& icon) { const gfx::ImageSkia& icon) {
return AppendMenuItemImpl(item_id, label, base::string16(), base::string16(), return AppendMenuItemImpl(item_id, label, base::string16(), nullptr, icon,
nullptr, icon, SUBMENU, ui::NORMAL_SEPARATOR); SUBMENU, ui::NORMAL_SEPARATOR);
} }
MenuItemView* MenuItemView::AppendMenuItemWithLabel( MenuItemView* MenuItemView::AppendMenuItemWithLabel(
...@@ -368,14 +364,12 @@ MenuItemView* MenuItemView::AppendDelegateMenuItem(int item_id) { ...@@ -368,14 +364,12 @@ MenuItemView* MenuItemView::AppendDelegateMenuItem(int item_id) {
} }
void MenuItemView::AppendSeparator() { void MenuItemView::AppendSeparator() {
AppendMenuItemImpl(0, base::string16(), base::string16(), base::string16(), AppendMenuItemImpl(0, base::string16(), base::string16(), nullptr,
nullptr, gfx::ImageSkia(), SEPARATOR, gfx::ImageSkia(), SEPARATOR, ui::NORMAL_SEPARATOR);
ui::NORMAL_SEPARATOR);
} }
void MenuItemView::AddSeparatorAt(int index) { void MenuItemView::AddSeparatorAt(int index) {
AddMenuItemAt(index, /*item_id=*/0, /*label=*/base::string16(), AddMenuItemAt(index, /*item_id=*/0, /*label=*/base::string16(),
/*sub_label=*/base::string16(),
/*minor_text=*/base::string16(), /*minor_icon=*/nullptr, /*minor_text=*/base::string16(), /*minor_icon=*/nullptr,
/*icon=*/gfx::ImageSkia(), /*vector_icon=*/nullptr, /*icon=*/gfx::ImageSkia(), /*vector_icon=*/nullptr,
/*type=*/SEPARATOR, /*type=*/SEPARATOR,
...@@ -385,22 +379,21 @@ void MenuItemView::AddSeparatorAt(int index) { ...@@ -385,22 +379,21 @@ void MenuItemView::AddSeparatorAt(int index) {
MenuItemView* MenuItemView::AppendMenuItemWithIcon(int item_id, MenuItemView* MenuItemView::AppendMenuItemWithIcon(int item_id,
const base::string16& label, const base::string16& label,
const gfx::ImageSkia& icon) { const gfx::ImageSkia& icon) {
return AppendMenuItemImpl(item_id, label, base::string16(), base::string16(), return AppendMenuItemImpl(item_id, label, base::string16(), nullptr, icon,
nullptr, icon, NORMAL, ui::NORMAL_SEPARATOR); NORMAL, ui::NORMAL_SEPARATOR);
} }
MenuItemView* MenuItemView::AppendMenuItemImpl( MenuItemView* MenuItemView::AppendMenuItemImpl(
int item_id, int item_id,
const base::string16& label, const base::string16& label,
const base::string16& sublabel,
const base::string16& minor_text, const base::string16& minor_text,
const gfx::VectorIcon* minor_icon, const gfx::VectorIcon* minor_icon,
const gfx::ImageSkia& icon, const gfx::ImageSkia& icon,
Type type, Type type,
ui::MenuSeparatorType separator_style) { ui::MenuSeparatorType separator_style) {
const int index = submenu_ ? int{submenu_->children().size()} : 0; const int index = submenu_ ? int{submenu_->children().size()} : 0;
return AddMenuItemAt(index, item_id, label, sublabel, minor_text, minor_icon, return AddMenuItemAt(index, item_id, label, minor_text, minor_icon, icon,
icon, nullptr, type, separator_style); nullptr, type, separator_style);
} }
SubmenuView* MenuItemView::CreateSubmenu() { SubmenuView* MenuItemView::CreateSubmenu() {
...@@ -432,11 +425,6 @@ void MenuItemView::SetTitle(const base::string16& title) { ...@@ -432,11 +425,6 @@ void MenuItemView::SetTitle(const base::string16& title) {
invalidate_dimensions(); // Triggers preferred size recalculation. invalidate_dimensions(); // Triggers preferred size recalculation.
} }
void MenuItemView::SetSubtitle(const base::string16& subtitle) {
subtitle_ = subtitle;
invalidate_dimensions(); // Triggers preferred size recalculation.
}
void MenuItemView::SetMinorText(const base::string16& minor_text) { void MenuItemView::SetMinorText(const base::string16& minor_text) {
minor_text_ = minor_text; minor_text_ = minor_text;
invalidate_dimensions(); // Triggers preferred size recalculation. invalidate_dimensions(); // Triggers preferred size recalculation.
...@@ -1026,23 +1014,13 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { ...@@ -1026,23 +1014,13 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
(!delegate || (!delegate ||
delegate->ShouldReserveSpaceForSubmenuIndicator() ? delegate->ShouldReserveSpaceForSubmenuIndicator() ?
item_right_margin_ : config.arrow_to_edge_padding); item_right_margin_ : config.arrow_to_edge_padding);
gfx::Rect text_bounds(label_start, top_margin, width, gfx::Rect text_bounds(label_start, top_margin, width, available_height);
subtitle_.empty() ? available_height
: available_height / 2);
text_bounds.set_x(GetMirroredXForRect(text_bounds)); text_bounds.set_x(GetMirroredXForRect(text_bounds));
int flags = GetDrawStringFlags(); int flags = GetDrawStringFlags();
if (mode == PB_FOR_DRAG) if (mode == PB_FOR_DRAG)
flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
canvas->DrawStringRectWithFlags(title(), style.font_list, style.foreground, canvas->DrawStringRectWithFlags(title(), style.font_list, style.foreground,
text_bounds, flags); text_bounds, flags);
if (!subtitle_.empty()) {
canvas->DrawStringRectWithFlags(
subtitle_, style.font_list,
GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_MenuItemMinorTextColor),
text_bounds + gfx::Vector2d(0, style.font_list.GetHeight()), flags);
}
PaintMinorIconAndText(canvas, style); PaintMinorIconAndText(canvas, style);
// Set the submenu indicator (arrow) image and color. // Set the submenu indicator (arrow) image and color.
...@@ -1295,11 +1273,6 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() const { ...@@ -1295,11 +1273,6 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() const {
// Determine the length of the label text. // Determine the length of the label text.
int string_width = gfx::GetStringWidth(title_, style.font_list); int string_width = gfx::GetStringWidth(title_, style.font_list);
if (!subtitle_.empty()) {
string_width =
std::max(string_width, gfx::GetStringWidth(subtitle_, style.font_list));
}
dimensions.standard_width = string_width + label_start + dimensions.standard_width = string_width + label_start +
item_right_margin_; item_right_margin_;
// Determine the length of the right-side text. // Determine the length of the right-side text.
...@@ -1307,10 +1280,9 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() const { ...@@ -1307,10 +1280,9 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() const {
minor_text.empty() ? 0 : gfx::GetStringWidth(minor_text, style.font_list); minor_text.empty() ? 0 : gfx::GetStringWidth(minor_text, style.font_list);
// Determine the height to use. // Determine the height to use.
dimensions.height = std::max( dimensions.height =
dimensions.height, (subtitle_.empty() ? 0 : style.font_list.GetHeight()) + std::max(dimensions.height, style.font_list.GetHeight() +
style.font_list.GetHeight() + GetBottomMargin() + GetBottomMargin() + GetTopMargin());
GetTopMargin());
dimensions.height = dimensions.height =
std::max(dimensions.height, MenuConfig::instance().item_min_height); std::max(dimensions.height, MenuConfig::instance().item_min_height);
......
...@@ -151,7 +151,6 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -151,7 +151,6 @@ class VIEWS_EXPORT MenuItemView : public View {
MenuItemView* AddMenuItemAt(int index, MenuItemView* AddMenuItemAt(int index,
int item_id, int item_id,
const base::string16& label, const base::string16& label,
const base::string16& sublabel,
const base::string16& minor_text, const base::string16& minor_text,
const gfx::VectorIcon* minor_icon, const gfx::VectorIcon* minor_icon,
const gfx::ImageSkia& icon, const gfx::ImageSkia& icon,
...@@ -215,7 +214,6 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -215,7 +214,6 @@ class VIEWS_EXPORT MenuItemView : public View {
// All the AppendXXX methods funnel into this. // All the AppendXXX methods funnel into this.
MenuItemView* AppendMenuItemImpl(int item_id, MenuItemView* AppendMenuItemImpl(int item_id,
const base::string16& label, const base::string16& label,
const base::string16& sublabel,
const base::string16& minor_text, const base::string16& minor_text,
const gfx::VectorIcon* minor_icon, const gfx::VectorIcon* minor_icon,
const gfx::ImageSkia& icon, const gfx::ImageSkia& icon,
...@@ -243,9 +241,6 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -243,9 +241,6 @@ class VIEWS_EXPORT MenuItemView : public View {
void SetTitle(const base::string16& title); void SetTitle(const base::string16& title);
const base::string16& title() const { return title_; } const base::string16& title() const { return title_; }
// Sets the subtitle.
void SetSubtitle(const base::string16& subtitle);
// Sets the minor text. // Sets the minor text.
void SetMinorText(const base::string16& minor_text); void SetMinorText(const base::string16& minor_text);
...@@ -456,7 +451,7 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -456,7 +451,7 @@ class VIEWS_EXPORT MenuItemView : public View {
void DestroyAllMenuHosts(); void DestroyAllMenuHosts();
// Returns the text that should be displayed on the end (right) of the menu // Returns the text that should be displayed on the end (right) of the menu
// item. This will be the accelerator (if one exists), otherwise |subtitle_|. // item. This will be the accelerator (if one exists).
base::string16 GetMinorText() const; base::string16 GetMinorText() const;
// Returns the icon that should be displayed to the left of the minor text. // Returns the icon that should be displayed to the left of the minor text.
...@@ -547,9 +542,6 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -547,9 +542,6 @@ class VIEWS_EXPORT MenuItemView : public View {
// Title. // Title.
base::string16 title_; base::string16 title_;
// Subtitle/sublabel.
base::string16 subtitle_;
// Minor text. // Minor text.
base::string16 minor_text_; base::string16 minor_text_;
......
...@@ -322,10 +322,10 @@ class MenuItemViewPaintUnitTest : public ViewsTestBase { ...@@ -322,10 +322,10 @@ class MenuItemViewPaintUnitTest : public ViewsTestBase {
// Provides assertion coverage for painting minor text and icons. // Provides assertion coverage for painting minor text and icons.
TEST_F(MenuItemViewPaintUnitTest, MinorTextAndIconAssertionCoverage) { TEST_F(MenuItemViewPaintUnitTest, MinorTextAndIconAssertionCoverage) {
auto AddItem = [this](auto label, auto minor_label, auto minor_icon) { auto AddItem = [this](auto label, auto minor_label, auto minor_icon) {
menu_item_view()->AddMenuItemAt( menu_item_view()->AddMenuItemAt(0, 1000, base::ASCIIToUTF16(label),
0, 1000, base::ASCIIToUTF16(label), base::string16(), minor_label, minor_label, minor_icon, gfx::ImageSkia(),
minor_icon, gfx::ImageSkia(), nullptr, views::MenuItemView::NORMAL, nullptr, views::MenuItemView::NORMAL,
ui::NORMAL_SEPARATOR); ui::NORMAL_SEPARATOR);
}; };
AddItem("No minor content", base::string16(), nullptr); AddItem("No minor content", base::string16(), nullptr);
AddItem("Minor text only", base::ASCIIToUTF16("minor text"), nullptr); AddItem("Minor text only", base::ASCIIToUTF16("minor text"), nullptr);
......
...@@ -96,8 +96,8 @@ MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model, ...@@ -96,8 +96,8 @@ MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model,
if (*type == MenuItemView::SEPARATOR) { if (*type == MenuItemView::SEPARATOR) {
return menu->AddMenuItemAt(menu_index, item_id, base::string16(), return menu->AddMenuItemAt(menu_index, item_id, base::string16(),
base::string16(), base::string16(), nullptr, base::string16(), nullptr, gfx::ImageSkia(),
gfx::ImageSkia(), nullptr, *type, nullptr, *type,
model->GetSeparatorTypeAt(model_index)); model->GetSeparatorTypeAt(model_index));
} }
...@@ -105,8 +105,7 @@ MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model, ...@@ -105,8 +105,7 @@ MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model,
model->GetIconAt(model_index, &icon); model->GetIconAt(model_index, &icon);
return menu->AddMenuItemAt( return menu->AddMenuItemAt(
menu_index, item_id, model->GetLabelAt(model_index), menu_index, item_id, model->GetLabelAt(model_index),
model->GetSublabelAt(model_index), model->GetMinorTextAt(model_index), model->GetMinorTextAt(model_index), model->GetMinorIconAt(model_index),
model->GetMinorIconAt(model_index),
icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(), icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(),
icon.IsEmpty() ? model->GetVectorIconAt(model_index) : nullptr, *type, icon.IsEmpty() ? model->GetVectorIconAt(model_index) : nullptr, *type,
ui::NORMAL_SEPARATOR); ui::NORMAL_SEPARATOR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment