Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/models/simple_menu_model.h" | 5 #include "ui/base/models/simple_menu_model.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 } | 173 } |
| 174 | 174 |
| 175 void SimpleMenuModel::SetIcon(int index, const SkBitmap& icon) { | 175 void SimpleMenuModel::SetIcon(int index, const SkBitmap& icon) { |
| 176 items_[index].icon = icon; | 176 items_[index].icon = icon; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void SimpleMenuModel::Clear() { | 179 void SimpleMenuModel::Clear() { |
| 180 items_.clear(); | 180 items_.clear(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SimpleMenuModel::RemoveItemAt(int index) { | |
|
sail
2011/06/10 06:57:31
This change isn't ready yet but I'm stuck on this
Nico
2011/06/10 14:34:23
Several SimpleMenuModel clients create a new ui me
sail
2011/06/10 14:52:59
I'm seeing this on mac.
So do I change wrench menu
sky
2011/06/10 16:24:14
The windows side does this. Of course you would ha
Robert Sesek
2011/06/10 16:46:26
In general, MenuModel is immutable after creation.
| |
| 184 items_.erase(items_.begin() + FlipIndex(index)); | |
| 185 } | |
| 186 | |
| 183 int SimpleMenuModel::GetIndexOfCommandId(int command_id) { | 187 int SimpleMenuModel::GetIndexOfCommandId(int command_id) { |
| 184 std::vector<Item>::iterator itr; | 188 std::vector<Item>::iterator itr; |
| 185 for (itr = items_.begin(); itr != items_.end(); itr++) { | 189 for (itr = items_.begin(); itr != items_.end(); itr++) { |
| 186 if ((*itr).command_id == command_id) { | 190 if ((*itr).command_id == command_id) { |
| 187 return FlipIndex(static_cast<int>(std::distance(items_.begin(), itr))); | 191 return FlipIndex(static_cast<int>(std::distance(items_.begin(), itr))); |
| 188 } | 192 } |
| 189 } | 193 } |
| 190 return -1; | 194 return -1; |
| 191 } | 195 } |
| 192 | 196 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 #ifndef NDEBUG | 343 #ifndef NDEBUG |
| 340 if (item.type == TYPE_SEPARATOR) { | 344 if (item.type == TYPE_SEPARATOR) { |
| 341 DCHECK_EQ(item.command_id, kSeparatorId); | 345 DCHECK_EQ(item.command_id, kSeparatorId); |
| 342 } else { | 346 } else { |
| 343 DCHECK_GE(item.command_id, 0); | 347 DCHECK_GE(item.command_id, 0); |
| 344 } | 348 } |
| 345 #endif // NDEBUG | 349 #endif // NDEBUG |
| 346 } | 350 } |
| 347 | 351 |
| 348 } // namespace ui | 352 } // namespace ui |
| OLD | NEW |