diff options
author | rhashimoto@chromium.org <rhashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-03 15:45:00 +0000 |
---|---|---|
committer | rhashimoto@chromium.org <rhashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-03 15:45:00 +0000 |
commit | 295b5af6b58ab3a934467324908112ab6005cf29 (patch) | |
tree | fbc121a758704683374cee960d01533f2ec67d54 /views | |
parent | 923198a0940a0fcc6ddea249bb4769de2d7ad50a (diff) | |
download | chromium_src-295b5af6b58ab3a934467324908112ab6005cf29.zip chromium_src-295b5af6b58ab3a934467324908112ab6005cf29.tar.gz chromium_src-295b5af6b58ab3a934467324908112ab6005cf29.tar.bz2 |
Make NetworkMenuModel a ui::MenuModel again.
This is a necessary refactoring to a single menu model to define both views menu and WebUI menu.
BUG=chromium-os:17892
TEST=none
Review URL: http://codereview.chromium.org/7541002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 8 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 5 | ||||
-rw-r--r-- | views/controls/menu/menu_model_adapter.cc | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_model_adapter.h | 3 |
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(); |