| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "views/controls/menu/native_menu_x.h" | 5 #include "views/controls/menu/native_menu_x.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "gfx/canvas_skia.h" | 9 #include "gfx/canvas_skia.h" |
| 10 #include "gfx/skia_util.h" | 10 #include "gfx/skia_util.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if (model->GetTypeAt(index) == menus::MenuModel::TYPE_SEPARATOR) { | 129 if (model->GetTypeAt(index) == menus::MenuModel::TYPE_SEPARATOR) { |
| 130 ++sep; | 130 ++sep; |
| 131 continue; | 131 continue; |
| 132 } | 132 } |
| 133 | 133 |
| 134 // The submenu excludes the separators when counting the menu-items | 134 // The submenu excludes the separators when counting the menu-items |
| 135 // in it. So exclude the number of separators to get the correct index. | 135 // in it. So exclude the number of separators to get the correct index. |
| 136 MenuItemView* mitem = menu->GetMenuItemAt(index - sep); | 136 MenuItemView* mitem = menu->GetMenuItemAt(index - sep); |
| 137 mitem->SetVisible(model->IsVisibleAt(index)); | 137 mitem->SetVisible(model->IsVisibleAt(index)); |
| 138 mitem->SetEnabled(model->IsEnabledAt(index)); | 138 mitem->SetEnabled(model->IsEnabledAt(index)); |
| 139 if (model->IsLabelDynamicAt(index)) { | 139 if (model->IsItemDynamicAt(index)) { |
| 140 mitem->SetTitle(UTF16ToWide(model->GetLabelAt(index))); | 140 mitem->SetTitle(UTF16ToWide(model->GetLabelAt(index))); |
| 141 } | 141 } |
| 142 | 142 |
| 143 SkBitmap icon; | 143 SkBitmap icon; |
| 144 if (model->GetIconAt(index, &icon)) { | 144 if (model->GetIconAt(index, &icon)) { |
| 145 // TODO(atwilson): Support removing the icon dynamically |
| 146 // (http://crbug.com/66508). |
| 145 mitem->SetIcon(icon); | 147 mitem->SetIcon(icon); |
| 146 } | 148 } |
| 147 | 149 |
| 148 if (model->GetTypeAt(index) == menus::MenuModel::TYPE_SUBMENU) { | 150 if (model->GetTypeAt(index) == menus::MenuModel::TYPE_SUBMENU) { |
| 149 DCHECK(mitem->HasSubmenu()); | 151 DCHECK(mitem->HasSubmenu()); |
| 150 UpdateMenuFromModel(mitem->GetSubmenu(), model->GetSubmenuModelAt(index)); | 152 UpdateMenuFromModel(mitem->GetSubmenu(), model->GetSubmenuModelAt(index)); |
| 151 } | 153 } |
| 152 } | 154 } |
| 153 } | 155 } |
| 154 | 156 |
| 155 // MenuWrapper, public: | 157 // MenuWrapper, public: |
| 156 | 158 |
| 157 #if !defined(OS_CHROMEOS) | 159 #if !defined(OS_CHROMEOS) |
| 158 // static | 160 // static |
| 159 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 161 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
| 160 return new NativeMenuX(menu); | 162 return new NativeMenuX(menu); |
| 161 } | 163 } |
| 162 #endif | 164 #endif |
| 163 | 165 |
| 164 } // namespace views | 166 } // namespace views |
| OLD | NEW |