summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/menu/menu_item_view.cc8
-rw-r--r--views/controls/menu/menu_item_view.h5
-rw-r--r--views/controls/menu/menu_model_adapter.cc6
-rw-r--r--views/controls/menu/menu_model_adapter.h3
4 files changed, 15 insertions, 7 deletions
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc
index 55e45bb..e6a2d4f 100644
--- a/views/controls/menu/menu_item_view.cc
+++ b/views/controls/menu/menu_item_view.cc
@@ -516,6 +516,14 @@ int MenuItemView::GetAcceleratorTextWidth() {
return text.empty() ? 0 : GetFont().GetStringWidth(text);
}
+void MenuItemView::SetMargins(int top_margin, int bottom_margin) {
+ top_margin_ = top_margin;
+ bottom_margin_ = bottom_margin;
+
+ // invalidate GetPreferredSize() cache
+ pref_size_.SetSize(0,0);
+}
+
MenuItemView::MenuItemView(MenuItemView* parent,
int command,
MenuItemView::Type type)
diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h
index cc0a91f..ae04cc6 100644
--- a/views/controls/menu/menu_item_view.h
+++ b/views/controls/menu/menu_item_view.h
@@ -322,10 +322,7 @@ class VIEWS_API MenuItemView : public View {
// Set top and bottom margins in pixels. If no margin is set or a
// negative margin is specified then MenuConfig values are used.
- void set_margins(int top_margin, int bottom_margin) {
- top_margin_ = top_margin;
- bottom_margin_ = bottom_margin;
- }
+ void SetMargins(int top_margin, int bottom_margin);
// Set the position of the menu with respect to the bounds (top
// level only).
diff --git a/views/controls/menu/menu_model_adapter.cc b/views/controls/menu/menu_model_adapter.cc
index 90a99db..e2c895d 100644
--- a/views/controls/menu/menu_model_adapter.cc
+++ b/views/controls/menu/menu_model_adapter.cc
@@ -32,7 +32,11 @@ void MenuModelAdapter::BuildMenu(MenuItemView* menu) {
menu->RemoveMenuItemAt(0);
}
- menu_map_.clear();
+ // Leave entries in the map if the menu is being shown. This
+ // allows the map to find the menu model of submenus being closed
+ // so ui::MenuModel::MenuClosed() can be called.
+ if (!menu->GetMenuController())
+ menu_map_.clear();
menu_map_[menu] = menu_model_;
// Repopulate the menu.
diff --git a/views/controls/menu/menu_model_adapter.h b/views/controls/menu/menu_model_adapter.h
index 18a61a5..f1c5a7d 100644
--- a/views/controls/menu/menu_model_adapter.h
+++ b/views/controls/menu/menu_model_adapter.h
@@ -22,8 +22,7 @@ class MenuItemView;
class VIEWS_API MenuModelAdapter : public MenuDelegate {
public:
// The caller retains ownership of the ui::MenuModel instance and
- // must ensure it exists for the lifetime of the adapter. The
- // base_id argument is the command id for the first menu item.
+ // must ensure it exists for the lifetime of the adapter.
explicit MenuModelAdapter(ui::MenuModel* menu_model);
virtual ~MenuModelAdapter();